1(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ExcelJS = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2"use strict";
3
4function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
5
6function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
7
8function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
9
10function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
12function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13
14function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15
16var fs = require('fs');
17
18var fastCsv = require('fast-csv');
19
20var customParseFormat = require('dayjs/plugin/customParseFormat');
21
22var utc = require('dayjs/plugin/utc');
23
24var dayjs = require('dayjs').extend(customParseFormat).extend(utc);
25
26var StreamBuf = require('../utils/stream-buf');
27
28var _require = require('../utils/utils'),
29    exists = _require.fs.exists;
30/* eslint-disable quote-props */
31
32
33var SpecialValues = {
34  true: true,
35  false: false,
36  '#N/A': {
37    error: '#N/A'
38  },
39  '#REF!': {
40    error: '#REF!'
41  },
42  '#NAME?': {
43    error: '#NAME?'
44  },
45  '#DIV/0!': {
46    error: '#DIV/0!'
47  },
48  '#NULL!': {
49    error: '#NULL!'
50  },
51  '#VALUE!': {
52    error: '#VALUE!'
53  },
54  '#NUM!': {
55    error: '#NUM!'
56  }
57};
58/* eslint-ensable quote-props */
59
60var CSV = /*#__PURE__*/function () {
61  function CSV(workbook) {
62    _classCallCheck(this, CSV);
63
64    this.workbook = workbook;
65    this.worksheet = null;
66  }
67
68  _createClass(CSV, [{
69    key: "readFile",
70    value: function () {
71      var _readFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(filename, options) {
72        var stream, worksheet;
73        return regeneratorRuntime.wrap(function _callee$(_context) {
74          while (1) {
75            switch (_context.prev = _context.next) {
76              case 0:
77                options = options || {};
78                _context.next = 3;
79                return exists(filename);
80
81              case 3:
82                if (_context.sent) {
83                  _context.next = 5;
84                  break;
85                }
86
87                throw new Error("File not found: ".concat(filename));
88
89              case 5:
90                stream = fs.createReadStream(filename);
91                _context.next = 8;
92                return this.read(stream, options);
93
94              case 8:
95                worksheet = _context.sent;
96                stream.close();
97                return _context.abrupt("return", worksheet);
98
99              case 11:
100              case "end":
101                return _context.stop();
102            }
103          }
104        }, _callee, this);
105      }));
106
107      function readFile(_x, _x2) {
108        return _readFile.apply(this, arguments);
109      }
110
111      return readFile;
112    }()
113  }, {
114    key: "read",
115    value: function read(stream, options) {
116      var _this = this;
117
118      options = options || {};
119      return new Promise(function (resolve, reject) {
120        var worksheet = _this.workbook.addWorksheet(options.sheetName);
121
122        var dateFormats = options.dateFormats || ['YYYY-MM-DD[T]HH:mm:ssZ', 'YYYY-MM-DD[T]HH:mm:ss', 'MM-DD-YYYY', 'YYYY-MM-DD'];
123
124        var map = options.map || function (datum) {
125          if (datum === '') {
126            return null;
127          }
128
129          var datumNumber = Number(datum);
130
131          if (!Number.isNaN(datumNumber) && datumNumber !== Infinity) {
132            return datumNumber;
133          }
134
135          var dt = dateFormats.reduce(function (matchingDate, currentDateFormat) {
136            if (matchingDate) {
137              return matchingDate;
138            }
139
140            var dayjsObj = dayjs(datum, currentDateFormat, true);
141
142            if (dayjsObj.isValid()) {
143              return dayjsObj;
144            }
145
146            return null;
147          }, null);
148
149          if (dt) {
150            return new Date(dt.valueOf());
151          }
152
153          var special = SpecialValues[datum];
154
155          if (special !== undefined) {
156            return special;
157          }
158
159          return datum;
160        };
161
162        var csvStream = fastCsv.parse(options.parserOptions).on('data', function (data) {
163          worksheet.addRow(data.map(map));
164        }).on('end', function () {
165          csvStream.emit('worksheet', worksheet);
166        });
167        csvStream.on('worksheet', resolve).on('error', reject);
168        stream.pipe(csvStream);
169      });
170    }
171    /**
172     * @deprecated since version 4.0. You should use `CSV#read` instead. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md
173     */
174
175  }, {
176    key: "createInputStream",
177    value: function createInputStream() {
178      throw new Error('`CSV#createInputStream` is deprecated. You should use `CSV#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md');
179    }
180  }, {
181    key: "write",
182    value: function write(stream, options) {
183      var _this2 = this;
184
185      return new Promise(function (resolve, reject) {
186        options = options || {}; // const encoding = options.encoding || 'utf8';
187        // const separator = options.separator || ',';
188        // const quoteChar = options.quoteChar || '\'';
189
190        var worksheet = _this2.workbook.getWorksheet(options.sheetName || options.sheetId);
191
192        var csvStream = fastCsv.format(options.formatterOptions);
193        stream.on('finish', function () {
194          resolve();
195        });
196        csvStream.on('error', reject);
197        csvStream.pipe(stream);
198        var _options = options,
199            dateFormat = _options.dateFormat,
200            dateUTC = _options.dateUTC;
201
202        var map = options.map || function (value) {
203          if (value) {
204            if (value.text || value.hyperlink) {
205              return value.hyperlink || value.text || '';
206            }
207
208            if (value.formula || value.result) {
209              return value.result || '';
210            }
211
212            if (value instanceof Date) {
213              if (dateFormat) {
214                return dateUTC ? dayjs.utc(value).format(dateFormat) : dayjs(value).format(dateFormat);
215              }
216
217              return dateUTC ? dayjs.utc(value).format() : dayjs(value).format();
218            }
219
220            if (value.error) {
221              return value.error;
222            }
223
224            if (_typeof(value) === 'object') {
225              return JSON.stringify(value);
226            }
227          }
228
229          return value;
230        };
231
232        var includeEmptyRows = options.includeEmptyRows === undefined || options.includeEmptyRows;
233        var lastRow = 1;
234
235        if (worksheet) {
236          worksheet.eachRow(function (row, rowNumber) {
237            if (includeEmptyRows) {
238              while (lastRow++ < rowNumber - 1) {
239                csvStream.write([]);
240              }
241            }
242
243            var values = row.values;
244            values.shift();
245            csvStream.write(values.map(map));
246            lastRow = rowNumber;
247          });
248        }
249
250        csvStream.end();
251      });
252    }
253  }, {
254    key: "writeFile",
255    value: function writeFile(filename, options) {
256      options = options || {};
257      var streamOptions = {
258        encoding: options.encoding || 'utf8'
259      };
260      var stream = fs.createWriteStream(filename, streamOptions);
261      return this.write(stream, options);
262    }
263  }, {
264    key: "writeBuffer",
265    value: function () {
266      var _writeBuffer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(options) {
267        var stream;
268        return regeneratorRuntime.wrap(function _callee2$(_context2) {
269          while (1) {
270            switch (_context2.prev = _context2.next) {
271              case 0:
272                stream = new StreamBuf();
273                _context2.next = 3;
274                return this.write(stream, options);
275
276              case 3:
277                return _context2.abrupt("return", stream.read());
278
279              case 4:
280              case "end":
281                return _context2.stop();
282            }
283          }
284        }, _callee2, this);
285      }));
286
287      function writeBuffer(_x3) {
288        return _writeBuffer.apply(this, arguments);
289      }
290
291      return writeBuffer;
292    }()
293  }]);
294
295  return CSV;
296}();
297
298module.exports = CSV;
299
300},{"../utils/stream-buf":23,"../utils/utils":26,"dayjs":336,"dayjs/plugin/customParseFormat":337,"dayjs/plugin/utc":338,"fast-csv":369,"fs":215}],2:[function(require,module,exports){
301'use strict';
302
303function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
304
305function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
306
307function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
308
309var colCache = require('../utils/col-cache');
310
311var Anchor = /*#__PURE__*/function () {
312  function Anchor(worksheet, address) {
313    var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
314
315    _classCallCheck(this, Anchor);
316
317    if (!address) {
318      this.nativeCol = 0;
319      this.nativeColOff = 0;
320      this.nativeRow = 0;
321      this.nativeRowOff = 0;
322    } else if (typeof address === 'string') {
323      var decoded = colCache.decodeAddress(address);
324      this.nativeCol = decoded.col + offset;
325      this.nativeColOff = 0;
326      this.nativeRow = decoded.row + offset;
327      this.nativeRowOff = 0;
328    } else if (address.nativeCol !== undefined) {
329      this.nativeCol = address.nativeCol || 0;
330      this.nativeColOff = address.nativeColOff || 0;
331      this.nativeRow = address.nativeRow || 0;
332      this.nativeRowOff = address.nativeRowOff || 0;
333    } else if (address.col !== undefined) {
334      this.col = address.col + offset;
335      this.row = address.row + offset;
336    } else {
337      this.nativeCol = 0;
338      this.nativeColOff = 0;
339      this.nativeRow = 0;
340      this.nativeRowOff = 0;
341    }
342
343    this.worksheet = worksheet;
344  }
345
346  _createClass(Anchor, [{
347    key: "col",
348    get: function get() {
349      return this.nativeCol + Math.min(this.colWidth - 1, this.nativeColOff) / this.colWidth;
350    },
351    set: function set(v) {
352      this.nativeCol = Math.floor(v);
353      this.nativeColOff = Math.floor((v - this.nativeCol) * this.colWidth);
354    }
355  }, {
356    key: "row",
357    get: function get() {
358      return this.nativeRow + Math.min(this.rowHeight - 1, this.nativeRowOff) / this.rowHeight;
359    },
360    set: function set(v) {
361      this.nativeRow = Math.floor(v);
362      this.nativeRowOff = Math.floor((v - this.nativeRow) * this.rowHeight);
363    }
364  }, {
365    key: "colWidth",
366    get: function get() {
367      return this.worksheet && this.worksheet.getColumn(this.nativeCol + 1) && this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth ? Math.floor(this.worksheet.getColumn(this.nativeCol + 1).width * 10000) : 640000;
368    }
369  }, {
370    key: "rowHeight",
371    get: function get() {
372      return this.worksheet && this.worksheet.getRow(this.nativeRow + 1) && this.worksheet.getRow(this.nativeRow + 1).height ? Math.floor(this.worksheet.getRow(this.nativeRow + 1).height * 10000) : 180000;
373    }
374  }, {
375    key: "model",
376    get: function get() {
377      return {
378        nativeCol: this.nativeCol,
379        nativeColOff: this.nativeColOff,
380        nativeRow: this.nativeRow,
381        nativeRowOff: this.nativeRowOff
382      };
383    },
384    set: function set(value) {
385      this.nativeCol = value.nativeCol;
386      this.nativeColOff = value.nativeColOff;
387      this.nativeRow = value.nativeRow;
388      this.nativeRowOff = value.nativeRowOff;
389    }
390  }], [{
391    key: "asInstance",
392    value: function asInstance(model) {
393      return model instanceof Anchor || model == null ? model : new Anchor(model);
394    }
395  }]);
396
397  return Anchor;
398}();
399
400module.exports = Anchor;
401
402},{"../utils/col-cache":19}],3:[function(require,module,exports){
403"use strict";
404
405function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
406
407function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
408
409function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
410
411/* eslint-disable max-classes-per-file */
412var colCache = require('../utils/col-cache');
413
414var _ = require('../utils/under-dash');
415
416var Enums = require('./enums');
417
418var _require = require('../utils/shared-formula'),
419    slideFormula = _require.slideFormula;
420
421var Note = require('./note'); // Cell requirements
422//  Operate inside a worksheet
423//  Store and retrieve a value with a range of types: text, number, date, hyperlink, reference, formula, etc.
424//  Manage/use and manipulate cell format either as local to cell or inherited from column or row.
425
426
427var Cell = /*#__PURE__*/function () {
428  function Cell(row, column, address) {
429    _classCallCheck(this, Cell);
430
431    if (!row || !column) {
432      throw new Error('A Cell needs a Row');
433    }
434
435    this._row = row;
436    this._column = column;
437    colCache.validateAddress(address);
438    this._address = address; // TODO: lazy evaluation of this._value
439
440    this._value = Value.create(Cell.Types.Null, this);
441    this.style = this._mergeStyle(row.style, column.style, {});
442    this._mergeCount = 0;
443  }
444
445  _createClass(Cell, [{
446    key: "destroy",
447    // help GC by removing cyclic (and other) references
448    value: function destroy() {
449      delete this.style;
450      delete this._value;
451      delete this._row;
452      delete this._column;
453      delete this._address;
454    } // =========================================================================
455    // Styles stuff
456
457  }, {
458    key: "_mergeStyle",
459    value: function _mergeStyle(rowStyle, colStyle, style) {
460      var numFmt = rowStyle && rowStyle.numFmt || colStyle && colStyle.numFmt;
461      if (numFmt) style.numFmt = numFmt;
462      var font = rowStyle && rowStyle.font || colStyle && colStyle.font;
463      if (font) style.font = font;
464      var alignment = rowStyle && rowStyle.alignment || colStyle && colStyle.alignment;
465      if (alignment) style.alignment = alignment;
466      var border = rowStyle && rowStyle.border || colStyle && colStyle.border;
467      if (border) style.border = border;
468      var fill = rowStyle && rowStyle.fill || colStyle && colStyle.fill;
469      if (fill) style.fill = fill;
470      var protection = rowStyle && rowStyle.protection || colStyle && colStyle.protection;
471      if (protection) style.protection = protection;
472      return style;
473    } // =========================================================================
474    // return the address for this cell
475
476  }, {
477    key: "toCsvString",
478    value: function toCsvString() {
479      return this._value.toCsvString();
480    } // =========================================================================
481    // Merge stuff
482
483  }, {
484    key: "addMergeRef",
485    value: function addMergeRef() {
486      this._mergeCount++;
487    }
488  }, {
489    key: "releaseMergeRef",
490    value: function releaseMergeRef() {
491      this._mergeCount--;
492    }
493  }, {
494    key: "merge",
495    value: function merge(master, ignoreStyle) {
496      this._value.release();
497
498      this._value = Value.create(Cell.Types.Merge, this, master);
499
500      if (!ignoreStyle) {
501        this.style = master.style;
502      }
503    }
504  }, {
505    key: "unmerge",
506    value: function unmerge() {
507      if (this.type === Cell.Types.Merge) {
508        this._value.release();
509
510        this._value = Value.create(Cell.Types.Null, this);
511        this.style = this._mergeStyle(this._row.style, this._column.style, {});
512      }
513    }
514  }, {
515    key: "isMergedTo",
516    value: function isMergedTo(master) {
517      if (this._value.type !== Cell.Types.Merge) return false;
518      return this._value.isMergedTo(master);
519    }
520  }, {
521    key: "toString",
522    value: function toString() {
523      return this.text;
524    }
525  }, {
526    key: "_upgradeToHyperlink",
527    value: function _upgradeToHyperlink(hyperlink) {
528      // if this cell is a string, turn it into a Hyperlink
529      if (this.type === Cell.Types.String) {
530        this._value = Value.create(Cell.Types.Hyperlink, this, {
531          text: this._value.value,
532          hyperlink: hyperlink
533        });
534      }
535    } // =========================================================================
536    // Formula stuff
537
538  }, {
539    key: "addName",
540    value: function addName(name) {
541      this.workbook.definedNames.addEx(this.fullAddress, name);
542    }
543  }, {
544    key: "removeName",
545    value: function removeName(name) {
546      this.workbook.definedNames.removeEx(this.fullAddress, name);
547    }
548  }, {
549    key: "removeAllNames",
550    value: function removeAllNames() {
551      this.workbook.definedNames.removeAllNames(this.fullAddress);
552    } // =========================================================================
553    // Data Validation stuff
554
555  }, {
556    key: "worksheet",
557    get: function get() {
558      return this._row.worksheet;
559    }
560  }, {
561    key: "workbook",
562    get: function get() {
563      return this._row.worksheet.workbook;
564    }
565  }, {
566    key: "numFmt",
567    get: function get() {
568      return this.style.numFmt;
569    },
570    set: function set(value) {
571      this.style.numFmt = value;
572    }
573  }, {
574    key: "font",
575    get: function get() {
576      return this.style.font;
577    },
578    set: function set(value) {
579      this.style.font = value;
580    }
581  }, {
582    key: "alignment",
583    get: function get() {
584      return this.style.alignment;
585    },
586    set: function set(value) {
587      this.style.alignment = value;
588    }
589  }, {
590    key: "border",
591    get: function get() {
592      return this.style.border;
593    },
594    set: function set(value) {
595      this.style.border = value;
596    }
597  }, {
598    key: "fill",
599    get: function get() {
600      return this.style.fill;
601    },
602    set: function set(value) {
603      this.style.fill = value;
604    }
605  }, {
606    key: "protection",
607    get: function get() {
608      return this.style.protection;
609    },
610    set: function set(value) {
611      this.style.protection = value;
612    }
613  }, {
614    key: "address",
615    get: function get() {
616      return this._address;
617    }
618  }, {
619    key: "row",
620    get: function get() {
621      return this._row.number;
622    }
623  }, {
624    key: "col",
625    get: function get() {
626      return this._column.number;
627    }
628  }, {
629    key: "$col$row",
630    get: function get() {
631      return "$".concat(this._column.letter, "$").concat(this.row);
632    } // =========================================================================
633    // Value stuff
634
635  }, {
636    key: "type",
637    get: function get() {
638      return this._value.type;
639    }
640  }, {
641    key: "effectiveType",
642    get: function get() {
643      return this._value.effectiveType;
644    }
645  }, {
646    key: "isMerged",
647    get: function get() {
648      return this._mergeCount > 0 || this.type === Cell.Types.Merge;
649    }
650  }, {
651    key: "master",
652    get: function get() {
653      if (this.type === Cell.Types.Merge) {
654        return this._value.master;
655      }
656
657      return this; // an unmerged cell is its own master
658    }
659  }, {
660    key: "isHyperlink",
661    get: function get() {
662      return this._value.type === Cell.Types.Hyperlink;
663    }
664  }, {
665    key: "hyperlink",
666    get: function get() {
667      return this._value.hyperlink;
668    } // return the value
669
670  }, {
671    key: "value",
672    get: function get() {
673      return this._value.value;
674    } // set the value - can be number, string or raw
675    ,
676    set: function set(v) {
677      // special case - merge cells set their master's value
678      if (this.type === Cell.Types.Merge) {
679        this._value.master.value = v;
680        return;
681      }
682
683      this._value.release(); // assign value
684
685
686      this._value = Value.create(Value.getType(v), this, v);
687    }
688  }, {
689    key: "note",
690    get: function get() {
691      return this._comment && this._comment.note;
692    },
693    set: function set(note) {
694      this._comment = new Note(note);
695    }
696  }, {
697    key: "text",
698    get: function get() {
699      return this._value.toString();
700    }
701  }, {
702    key: "html",
703    get: function get() {
704      return _.escapeHtml(this.text);
705    }
706  }, {
707    key: "formula",
708    get: function get() {
709      return this._value.formula;
710    }
711  }, {
712    key: "result",
713    get: function get() {
714      return this._value.result;
715    }
716  }, {
717    key: "formulaType",
718    get: function get() {
719      return this._value.formulaType;
720    } // =========================================================================
721    // Name stuff
722
723  }, {
724    key: "fullAddress",
725    get: function get() {
726      var worksheet = this._row.worksheet;
727      return {
728        sheetName: worksheet.name,
729        address: this.address,
730        row: this.row,
731        col: this.col
732      };
733    }
734  }, {
735    key: "name",
736    get: function get() {
737      return this.names[0];
738    },
739    set: function set(value) {
740      this.names = [value];
741    }
742  }, {
743    key: "names",
744    get: function get() {
745      return this.workbook.definedNames.getNamesEx(this.fullAddress);
746    },
747    set: function set(value) {
748      var _this = this;
749
750      var definedNames = this.workbook.definedNames;
751      definedNames.removeAllNames(this.fullAddress);
752      value.forEach(function (name) {
753        definedNames.addEx(_this.fullAddress, name);
754      });
755    }
756  }, {
757    key: "_dataValidations",
758    get: function get() {
759      return this.worksheet.dataValidations;
760    }
761  }, {
762    key: "dataValidation",
763    get: function get() {
764      return this._dataValidations.find(this.address);
765    },
766    set: function set(value) {
767      this._dataValidations.add(this.address, value);
768    } // =========================================================================
769    // Model stuff
770
771  }, {
772    key: "model",
773    get: function get() {
774      var model = this._value.model;
775      model.style = this.style;
776
777      if (this._comment) {
778        model.comment = this._comment.model;
779      }
780
781      return model;
782    },
783    set: function set(value) {
784      this._value.release();
785
786      this._value = Value.create(value.type, this);
787      this._value.model = value;
788
789      if (value.comment) {
790        switch (value.comment.type) {
791          case 'note':
792            this._comment = Note.fromModel(value.comment);
793            break;
794        }
795      }
796
797      if (value.style) {
798        this.style = value.style;
799      } else {
800        this.style = {};
801      }
802    }
803  }]);
804
805  return Cell;
806}();
807
808Cell.Types = Enums.ValueType; // =============================================================================
809// Internal Value Types
810
811var NullValue = /*#__PURE__*/function () {
812  function NullValue(cell) {
813    _classCallCheck(this, NullValue);
814
815    this.model = {
816      address: cell.address,
817      type: Cell.Types.Null
818    };
819  }
820
821  _createClass(NullValue, [{
822    key: "toCsvString",
823    value: function toCsvString() {
824      return '';
825    }
826  }, {
827    key: "release",
828    value: function release() {}
829  }, {
830    key: "toString",
831    value: function toString() {
832      return '';
833    }
834  }, {
835    key: "value",
836    get: function get() {
837      return null;
838    },
839    set: function set(value) {// nothing to do
840    }
841  }, {
842    key: "type",
843    get: function get() {
844      return Cell.Types.Null;
845    }
846  }, {
847    key: "effectiveType",
848    get: function get() {
849      return Cell.Types.Null;
850    }
851  }, {
852    key: "address",
853    get: function get() {
854      return this.model.address;
855    },
856    set: function set(value) {
857      this.model.address = value;
858    }
859  }]);
860
861  return NullValue;
862}();
863
864var NumberValue = /*#__PURE__*/function () {
865  function NumberValue(cell, value) {
866    _classCallCheck(this, NumberValue);
867
868    this.model = {
869      address: cell.address,
870      type: Cell.Types.Number,
871      value: value
872    };
873  }
874
875  _createClass(NumberValue, [{
876    key: "toCsvString",
877    value: function toCsvString() {
878      return this.model.value.toString();
879    }
880  }, {
881    key: "release",
882    value: function release() {}
883  }, {
884    key: "toString",
885    value: function toString() {
886      return this.model.value.toString();
887    }
888  }, {
889    key: "value",
890    get: function get() {
891      return this.model.value;
892    },
893    set: function set(value) {
894      this.model.value = value;
895    }
896  }, {
897    key: "type",
898    get: function get() {
899      return Cell.Types.Number;
900    }
901  }, {
902    key: "effectiveType",
903    get: function get() {
904      return Cell.Types.Number;
905    }
906  }, {
907    key: "address",
908    get: function get() {
909      return this.model.address;
910    },
911    set: function set(value) {
912      this.model.address = value;
913    }
914  }]);
915
916  return NumberValue;
917}();
918
919var StringValue = /*#__PURE__*/function () {
920  function StringValue(cell, value) {
921    _classCallCheck(this, StringValue);
922
923    this.model = {
924      address: cell.address,
925      type: Cell.Types.String,
926      value: value
927    };
928  }
929
930  _createClass(StringValue, [{
931    key: "toCsvString",
932    value: function toCsvString() {
933      return "\"".concat(this.model.value.replace(/"/g, '""'), "\"");
934    }
935  }, {
936    key: "release",
937    value: function release() {}
938  }, {
939    key: "toString",
940    value: function toString() {
941      return this.model.value;
942    }
943  }, {
944    key: "value",
945    get: function get() {
946      return this.model.value;
947    },
948    set: function set(value) {
949      this.model.value = value;
950    }
951  }, {
952    key: "type",
953    get: function get() {
954      return Cell.Types.String;
955    }
956  }, {
957    key: "effectiveType",
958    get: function get() {
959      return Cell.Types.String;
960    }
961  }, {
962    key: "address",
963    get: function get() {
964      return this.model.address;
965    },
966    set: function set(value) {
967      this.model.address = value;
968    }
969  }]);
970
971  return StringValue;
972}();
973
974var RichTextValue = /*#__PURE__*/function () {
975  function RichTextValue(cell, value) {
976    _classCallCheck(this, RichTextValue);
977
978    this.model = {
979      address: cell.address,
980      type: Cell.Types.String,
981      value: value
982    };
983  }
984
985  _createClass(RichTextValue, [{
986    key: "toString",
987    value: function toString() {
988      return this.model.value.richText.map(function (t) {
989        return t.text;
990      }).join('');
991    }
992  }, {
993    key: "toCsvString",
994    value: function toCsvString() {
995      return "\"".concat(this.text.replace(/"/g, '""'), "\"");
996    }
997  }, {
998    key: "release",
999    value: function release() {}
1000  }, {
1001    key: "value",
1002    get: function get() {
1003      return this.model.value;
1004    },
1005    set: function set(value) {
1006      this.model.value = value;
1007    }
1008  }, {
1009    key: "type",
1010    get: function get() {
1011      return Cell.Types.RichText;
1012    }
1013  }, {
1014    key: "effectiveType",
1015    get: function get() {
1016      return Cell.Types.RichText;
1017    }
1018  }, {
1019    key: "address",
1020    get: function get() {
1021      return this.model.address;
1022    },
1023    set: function set(value) {
1024      this.model.address = value;
1025    }
1026  }]);
1027
1028  return RichTextValue;
1029}();
1030
1031var DateValue = /*#__PURE__*/function () {
1032  function DateValue(cell, value) {
1033    _classCallCheck(this, DateValue);
1034
1035    this.model = {
1036      address: cell.address,
1037      type: Cell.Types.Date,
1038      value: value
1039    };
1040  }
1041
1042  _createClass(DateValue, [{
1043    key: "toCsvString",
1044    value: function toCsvString() {
1045      return this.model.value.toISOString();
1046    }
1047  }, {
1048    key: "release",
1049    value: function release() {}
1050  }, {
1051    key: "toString",
1052    value: function toString() {
1053      return this.model.value.toString();
1054    }
1055  }, {
1056    key: "value",
1057    get: function get() {
1058      return this.model.value;
1059    },
1060    set: function set(value) {
1061      this.model.value = value;
1062    }
1063  }, {
1064    key: "type",
1065    get: function get() {
1066      return Cell.Types.Date;
1067    }
1068  }, {
1069    key: "effectiveType",
1070    get: function get() {
1071      return Cell.Types.Date;
1072    }
1073  }, {
1074    key: "address",
1075    get: function get() {
1076      return this.model.address;
1077    },
1078    set: function set(value) {
1079      this.model.address = value;
1080    }
1081  }]);
1082
1083  return DateValue;
1084}();
1085
1086var HyperlinkValue = /*#__PURE__*/function () {
1087  function HyperlinkValue(cell, value) {
1088    _classCallCheck(this, HyperlinkValue);
1089
1090    this.model = {
1091      address: cell.address,
1092      type: Cell.Types.Hyperlink,
1093      text: value ? value.text : undefined,
1094      hyperlink: value ? value.hyperlink : undefined
1095    };
1096
1097    if (value && value.tooltip) {
1098      this.model.tooltip = value.tooltip;
1099    }
1100  }
1101
1102  _createClass(HyperlinkValue, [{
1103    key: "toCsvString",
1104    value: function toCsvString() {
1105      return this.model.hyperlink;
1106    }
1107  }, {
1108    key: "release",
1109    value: function release() {}
1110  }, {
1111    key: "toString",
1112    value: function toString() {
1113      return this.model.text;
1114    }
1115  }, {
1116    key: "value",
1117    get: function get() {
1118      var v = {
1119        text: this.model.text,
1120        hyperlink: this.model.hyperlink
1121      };
1122
1123      if (this.model.tooltip) {
1124        v.tooltip = this.model.tooltip;
1125      }
1126
1127      return v;
1128    },
1129    set: function set(value) {
1130      this.model = {
1131        text: value.text,
1132        hyperlink: value.hyperlink
1133      };
1134
1135      if (value.tooltip) {
1136        this.model.tooltip = value.tooltip;
1137      }
1138    }
1139  }, {
1140    key: "text",
1141    get: function get() {
1142      return this.model.text;
1143    },
1144    set: function set(value) {
1145      this.model.text = value;
1146    }
1147    /*
1148    get tooltip() {
1149      return this.model.tooltip;
1150    }
1151      set tooltip(value) {
1152      this.model.tooltip = value;
1153    } */
1154
1155  }, {
1156    key: "hyperlink",
1157    get: function get() {
1158      return this.model.hyperlink;
1159    },
1160    set: function set(value) {
1161      this.model.hyperlink = value;
1162    }
1163  }, {
1164    key: "type",
1165    get: function get() {
1166      return Cell.Types.Hyperlink;
1167    }
1168  }, {
1169    key: "effectiveType",
1170    get: function get() {
1171      return Cell.Types.Hyperlink;
1172    }
1173  }, {
1174    key: "address",
1175    get: function get() {
1176      return this.model.address;
1177    },
1178    set: function set(value) {
1179      this.model.address = value;
1180    }
1181  }]);
1182
1183  return HyperlinkValue;
1184}();
1185
1186var MergeValue = /*#__PURE__*/function () {
1187  function MergeValue(cell, master) {
1188    _classCallCheck(this, MergeValue);
1189
1190    this.model = {
1191      address: cell.address,
1192      type: Cell.Types.Merge,
1193      master: master ? master.address : undefined
1194    };
1195    this._master = master;
1196
1197    if (master) {
1198      master.addMergeRef();
1199    }
1200  }
1201
1202  _createClass(MergeValue, [{
1203    key: "isMergedTo",
1204    value: function isMergedTo(master) {
1205      return master === this._master;
1206    }
1207  }, {
1208    key: "toCsvString",
1209    value: function toCsvString() {
1210      return '';
1211    }
1212  }, {
1213    key: "release",
1214    value: function release() {
1215      this._master.releaseMergeRef();
1216    }
1217  }, {
1218    key: "toString",
1219    value: function toString() {
1220      return this.value.toString();
1221    }
1222  }, {
1223    key: "value",
1224    get: function get() {
1225      return this._master.value;
1226    },
1227    set: function set(value) {
1228      if (value instanceof Cell) {
1229        if (this._master) {
1230          this._master.releaseMergeRef();
1231        }
1232
1233        value.addMergeRef();
1234        this._master = value;
1235      } else {
1236        this._master.value = value;
1237      }
1238    }
1239  }, {
1240    key: "master",
1241    get: function get() {
1242      return this._master;
1243    }
1244  }, {
1245    key: "type",
1246    get: function get() {
1247      return Cell.Types.Merge;
1248    }
1249  }, {
1250    key: "effectiveType",
1251    get: function get() {
1252      return this._master.effectiveType;
1253    }
1254  }, {
1255    key: "address",
1256    get: function get() {
1257      return this.model.address;
1258    },
1259    set: function set(value) {
1260      this.model.address = value;
1261    }
1262  }]);
1263
1264  return MergeValue;
1265}();
1266
1267var FormulaValue = /*#__PURE__*/function () {
1268  function FormulaValue(cell, value) {
1269    _classCallCheck(this, FormulaValue);
1270
1271    this.cell = cell;
1272    this.model = {
1273      address: cell.address,
1274      type: Cell.Types.Formula,
1275      shareType: value ? value.shareType : undefined,
1276      ref: value ? value.ref : undefined,
1277      formula: value ? value.formula : undefined,
1278      sharedFormula: value ? value.sharedFormula : undefined,
1279      result: value ? value.result : undefined
1280    };
1281  }
1282
1283  _createClass(FormulaValue, [{
1284    key: "_copyModel",
1285    value: function _copyModel(model) {
1286      var copy = {};
1287
1288      var cp = function cp(name) {
1289        var value = model[name];
1290
1291        if (value) {
1292          copy[name] = value;
1293        }
1294      };
1295
1296      cp('formula');
1297      cp('result');
1298      cp('ref');
1299      cp('shareType');
1300      cp('sharedFormula');
1301      return copy;
1302    }
1303  }, {
1304    key: "validate",
1305    value: function validate(value) {
1306      switch (Value.getType(value)) {
1307        case Cell.Types.Null:
1308        case Cell.Types.String:
1309        case Cell.Types.Number:
1310        case Cell.Types.Date:
1311          break;
1312
1313        case Cell.Types.Hyperlink:
1314        case Cell.Types.Formula:
1315        default:
1316          throw new Error('Cannot process that type of result value');
1317      }
1318    }
1319  }, {
1320    key: "_getTranslatedFormula",
1321    value: function _getTranslatedFormula() {
1322      if (!this._translatedFormula && this.model.sharedFormula) {
1323        var worksheet = this.cell.worksheet;
1324        var master = worksheet.findCell(this.model.sharedFormula);
1325        this._translatedFormula = master && slideFormula(master.formula, master.address, this.model.address);
1326      }
1327
1328      return this._translatedFormula;
1329    }
1330  }, {
1331    key: "toCsvString",
1332    value: function toCsvString() {
1333      return "".concat(this.model.result || '');
1334    }
1335  }, {
1336    key: "release",
1337    value: function release() {}
1338  }, {
1339    key: "toString",
1340    value: function toString() {
1341      return this.model.result ? this.model.result.toString() : '';
1342    }
1343  }, {
1344    key: "value",
1345    get: function get() {
1346      return this._copyModel(this.model);
1347    },
1348    set: function set(value) {
1349      this.model = this._copyModel(value);
1350    }
1351  }, {
1352    key: "dependencies",
1353    get: function get() {
1354      // find all the ranges and cells mentioned in the formula
1355      var ranges = this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g);
1356      var cells = this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g, '').match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g);
1357      return {
1358        ranges: ranges,
1359        cells: cells
1360      };
1361    }
1362  }, {
1363    key: "formula",
1364    get: function get() {
1365      return this.model.formula || this._getTranslatedFormula();
1366    },
1367    set: function set(value) {
1368      this.model.formula = value;
1369    }
1370  }, {
1371    key: "formulaType",
1372    get: function get() {
1373      if (this.model.formula) {
1374        return Enums.FormulaType.Master;
1375      }
1376
1377      if (this.model.sharedFormula) {
1378        return Enums.FormulaType.Shared;
1379      }
1380
1381      return Enums.FormulaType.None;
1382    }
1383  }, {
1384    key: "result",
1385    get: function get() {
1386      return this.model.result;
1387    },
1388    set: function set(value) {
1389      this.model.result = value;
1390    }
1391  }, {
1392    key: "type",
1393    get: function get() {
1394      return Cell.Types.Formula;
1395    }
1396  }, {
1397    key: "effectiveType",
1398    get: function get() {
1399      var v = this.model.result;
1400
1401      if (v === null || v === undefined) {
1402        return Enums.ValueType.Null;
1403      }
1404
1405      if (v instanceof String || typeof v === 'string') {
1406        return Enums.ValueType.String;
1407      }
1408
1409      if (typeof v === 'number') {
1410        return Enums.ValueType.Number;
1411      }
1412
1413      if (v instanceof Date) {
1414        return Enums.ValueType.Date;
1415      }
1416
1417      if (v.text && v.hyperlink) {
1418        return Enums.ValueType.Hyperlink;
1419      }
1420
1421      if (v.formula) {
1422        return Enums.ValueType.Formula;
1423      }
1424
1425      return Enums.ValueType.Null;
1426    }
1427  }, {
1428    key: "address",
1429    get: function get() {
1430      return this.model.address;
1431    },
1432    set: function set(value) {
1433      this.model.address = value;
1434    }
1435  }]);
1436
1437  return FormulaValue;
1438}();
1439
1440var SharedStringValue = /*#__PURE__*/function () {
1441  function SharedStringValue(cell, value) {
1442    _classCallCheck(this, SharedStringValue);
1443
1444    this.model = {
1445      address: cell.address,
1446      type: Cell.Types.SharedString,
1447      value: value
1448    };
1449  }
1450
1451  _createClass(SharedStringValue, [{
1452    key: "toCsvString",
1453    value: function toCsvString() {
1454      return this.model.value.toString();
1455    }
1456  }, {
1457    key: "release",
1458    value: function release() {}
1459  }, {
1460    key: "toString",
1461    value: function toString() {
1462      return this.model.value.toString();
1463    }
1464  }, {
1465    key: "value",
1466    get: function get() {
1467      return this.model.value;
1468    },
1469    set: function set(value) {
1470      this.model.value = value;
1471    }
1472  }, {
1473    key: "type",
1474    get: function get() {
1475      return Cell.Types.SharedString;
1476    }
1477  }, {
1478    key: "effectiveType",
1479    get: function get() {
1480      return Cell.Types.SharedString;
1481    }
1482  }, {
1483    key: "address",
1484    get: function get() {
1485      return this.model.address;
1486    },
1487    set: function set(value) {
1488      this.model.address = value;
1489    }
1490  }]);
1491
1492  return SharedStringValue;
1493}();
1494
1495var BooleanValue = /*#__PURE__*/function () {
1496  function BooleanValue(cell, value) {
1497    _classCallCheck(this, BooleanValue);
1498
1499    this.model = {
1500      address: cell.address,
1501      type: Cell.Types.Boolean,
1502      value: value
1503    };
1504  }
1505
1506  _createClass(BooleanValue, [{
1507    key: "toCsvString",
1508    value: function toCsvString() {
1509      return this.model.value ? 1 : 0;
1510    }
1511  }, {
1512    key: "release",
1513    value: function release() {}
1514  }, {
1515    key: "toString",
1516    value: function toString() {
1517      return this.model.value.toString();
1518    }
1519  }, {
1520    key: "value",
1521    get: function get() {
1522      return this.model.value;
1523    },
1524    set: function set(value) {
1525      this.model.value = value;
1526    }
1527  }, {
1528    key: "type",
1529    get: function get() {
1530      return Cell.Types.Boolean;
1531    }
1532  }, {
1533    key: "effectiveType",
1534    get: function get() {
1535      return Cell.Types.Boolean;
1536    }
1537  }, {
1538    key: "address",
1539    get: function get() {
1540      return this.model.address;
1541    },
1542    set: function set(value) {
1543      this.model.address = value;
1544    }
1545  }]);
1546
1547  return BooleanValue;
1548}();
1549
1550var ErrorValue = /*#__PURE__*/function () {
1551  function ErrorValue(cell, value) {
1552    _classCallCheck(this, ErrorValue);
1553
1554    this.model = {
1555      address: cell.address,
1556      type: Cell.Types.Error,
1557      value: value
1558    };
1559  }
1560
1561  _createClass(ErrorValue, [{
1562    key: "toCsvString",
1563    value: function toCsvString() {
1564      return this.toString();
1565    }
1566  }, {
1567    key: "release",
1568    value: function release() {}
1569  }, {
1570    key: "toString",
1571    value: function toString() {
1572      return this.model.value.error.toString();
1573    }
1574  }, {
1575    key: "value",
1576    get: function get() {
1577      return this.model.value;
1578    },
1579    set: function set(value) {
1580      this.model.value = value;
1581    }
1582  }, {
1583    key: "type",
1584    get: function get() {
1585      return Cell.Types.Error;
1586    }
1587  }, {
1588    key: "effectiveType",
1589    get: function get() {
1590      return Cell.Types.Error;
1591    }
1592  }, {
1593    key: "address",
1594    get: function get() {
1595      return this.model.address;
1596    },
1597    set: function set(value) {
1598      this.model.address = value;
1599    }
1600  }]);
1601
1602  return ErrorValue;
1603}();
1604
1605var JSONValue = /*#__PURE__*/function () {
1606  function JSONValue(cell, value) {
1607    _classCallCheck(this, JSONValue);
1608
1609    this.model = {
1610      address: cell.address,
1611      type: Cell.Types.String,
1612      value: JSON.stringify(value),
1613      rawValue: value
1614    };
1615  }
1616
1617  _createClass(JSONValue, [{
1618    key: "toCsvString",
1619    value: function toCsvString() {
1620      return this.model.value;
1621    }
1622  }, {
1623    key: "release",
1624    value: function release() {}
1625  }, {
1626    key: "toString",
1627    value: function toString() {
1628      return this.model.value;
1629    }
1630  }, {
1631    key: "value",
1632    get: function get() {
1633      return this.model.rawValue;
1634    },
1635    set: function set(value) {
1636      this.model.rawValue = value;
1637      this.model.value = JSON.stringify(value);
1638    }
1639  }, {
1640    key: "type",
1641    get: function get() {
1642      return Cell.Types.String;
1643    }
1644  }, {
1645    key: "effectiveType",
1646    get: function get() {
1647      return Cell.Types.String;
1648    }
1649  }, {
1650    key: "address",
1651    get: function get() {
1652      return this.model.address;
1653    },
1654    set: function set(value) {
1655      this.model.address = value;
1656    }
1657  }]);
1658
1659  return JSONValue;
1660}(); // Value is a place to hold common static Value type functions
1661
1662
1663var Value = {
1664  getType: function getType(value) {
1665    if (value === null || value === undefined) {
1666      return Cell.Types.Null;
1667    }
1668
1669    if (value instanceof String || typeof value === 'string') {
1670      return Cell.Types.String;
1671    }
1672
1673    if (typeof value === 'number') {
1674      return Cell.Types.Number;
1675    }
1676
1677    if (typeof value === 'boolean') {
1678      return Cell.Types.Boolean;
1679    }
1680
1681    if (value instanceof Date) {
1682      return Cell.Types.Date;
1683    }
1684
1685    if (value.text && value.hyperlink) {
1686      return Cell.Types.Hyperlink;
1687    }
1688
1689    if (value.formula || value.sharedFormula) {
1690      return Cell.Types.Formula;
1691    }
1692
1693    if (value.richText) {
1694      return Cell.Types.RichText;
1695    }
1696
1697    if (value.sharedString) {
1698      return Cell.Types.SharedString;
1699    }
1700
1701    if (value.error) {
1702      return Cell.Types.Error;
1703    }
1704
1705    return Cell.Types.JSON;
1706  },
1707  // map valueType to constructor
1708  types: [{
1709    t: Cell.Types.Null,
1710    f: NullValue
1711  }, {
1712    t: Cell.Types.Number,
1713    f: NumberValue
1714  }, {
1715    t: Cell.Types.String,
1716    f: StringValue
1717  }, {
1718    t: Cell.Types.Date,
1719    f: DateValue
1720  }, {
1721    t: Cell.Types.Hyperlink,
1722    f: HyperlinkValue
1723  }, {
1724    t: Cell.Types.Formula,
1725    f: FormulaValue
1726  }, {
1727    t: Cell.Types.Merge,
1728    f: MergeValue
1729  }, {
1730    t: Cell.Types.JSON,
1731    f: JSONValue
1732  }, {
1733    t: Cell.Types.SharedString,
1734    f: SharedStringValue
1735  }, {
1736    t: Cell.Types.RichText,
1737    f: RichTextValue
1738  }, {
1739    t: Cell.Types.Boolean,
1740    f: BooleanValue
1741  }, {
1742    t: Cell.Types.Error,
1743    f: ErrorValue
1744  }].reduce(function (p, t) {
1745    p[t.t] = t.f;
1746    return p;
1747  }, []),
1748  create: function create(type, cell, value) {
1749    var T = this.types[type];
1750
1751    if (!T) {
1752      throw new Error("Could not create Value of type ".concat(type));
1753    }
1754
1755    return new T(cell, value);
1756  }
1757};
1758module.exports = Cell;
1759
1760},{"../utils/col-cache":19,"../utils/shared-formula":22,"../utils/under-dash":25,"./enums":7,"./note":9}],4:[function(require,module,exports){
1761'use strict';
1762
1763function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1764
1765function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1766
1767function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
1768
1769var _ = require('../utils/under-dash');
1770
1771var Enums = require('./enums');
1772
1773var colCache = require('../utils/col-cache');
1774
1775var DEFAULT_COLUMN_WIDTH = 9; // Column defines the column properties for 1 column.
1776// This includes header rows, widths, key, (style), etc.
1777// Worksheet will condense the columns as appropriate during serialization
1778
1779var Column = /*#__PURE__*/function () {
1780  function Column(worksheet, number, defn) {
1781    _classCallCheck(this, Column);
1782
1783    this._worksheet = worksheet;
1784    this._number = number;
1785
1786    if (defn !== false) {
1787      // sometimes defn will follow
1788      this.defn = defn;
1789    }
1790  }
1791
1792  _createClass(Column, [{
1793    key: "toString",
1794    value: function toString() {
1795      return JSON.stringify({
1796        key: this.key,
1797        width: this.width,
1798        headers: this.headers.length ? this.headers : undefined
1799      });
1800    }
1801  }, {
1802    key: "equivalentTo",
1803    value: function equivalentTo(other) {
1804      return this.width === other.width && this.hidden === other.hidden && this.outlineLevel === other.outlineLevel && _.isEqual(this.style, other.style);
1805    }
1806  }, {
1807    key: "eachCell",
1808    value: function eachCell(options, iteratee) {
1809      var colNumber = this.number;
1810
1811      if (!iteratee) {
1812        iteratee = options;
1813        options = null;
1814      }
1815
1816      this._worksheet.eachRow(options, function (row, rowNumber) {
1817        iteratee(row.getCell(colNumber), rowNumber);
1818      });
1819    }
1820  }, {
1821    key: "_applyStyle",
1822    // =========================================================================
1823    // styles
1824    value: function _applyStyle(name, value) {
1825      this.style[name] = value;
1826      this.eachCell(function (cell) {
1827        cell[name] = value;
1828      });
1829      return value;
1830    }
1831  }, {
1832    key: "number",
1833    get: function get() {
1834      return this._number;
1835    }
1836  }, {
1837    key: "worksheet",
1838    get: function get() {
1839      return this._worksheet;
1840    }
1841  }, {
1842    key: "letter",
1843    get: function get() {
1844      return colCache.n2l(this._number);
1845    }
1846  }, {
1847    key: "isCustomWidth",
1848    get: function get() {
1849      return this.width !== undefined && this.width !== DEFAULT_COLUMN_WIDTH;
1850    }
1851  }, {
1852    key: "defn",
1853    get: function get() {
1854      return {
1855        header: this._header,
1856        key: this.key,
1857        width: this.width,
1858        style: this.style,
1859        hidden: this.hidden,
1860        outlineLevel: this.outlineLevel
1861      };
1862    },
1863    set: function set(value) {
1864      if (value) {
1865        this.key = value.key;
1866        this.width = value.width !== undefined ? value.width : DEFAULT_COLUMN_WIDTH;
1867        this.outlineLevel = value.outlineLevel;
1868
1869        if (value.style) {
1870          this.style = value.style;
1871        } else {
1872          this.style = {};
1873        } // headers must be set after style
1874
1875
1876        this.header = value.header;
1877        this._hidden = !!value.hidden;
1878      } else {
1879        delete this._header;
1880        delete this._key;
1881        delete this.width;
1882        this.style = {};
1883        this.outlineLevel = 0;
1884      }
1885    }
1886  }, {
1887    key: "headers",
1888    get: function get() {
1889      return this._header && this._header instanceof Array ? this._header : [this._header];
1890    }
1891  }, {
1892    key: "header",
1893    get: function get() {
1894      return this._header;
1895    },
1896    set: function set(value) {
1897      var _this = this;
1898
1899      if (value !== undefined) {
1900        this._header = value;
1901        this.headers.forEach(function (text, index) {
1902          _this._worksheet.getCell(index + 1, _this.number).value = text;
1903        });
1904      } else {
1905        this._header = undefined;
1906      }
1907    }
1908  }, {
1909    key: "key",
1910    get: function get() {
1911      return this._key;
1912    },
1913    set: function set(value) {
1914      var column = this._key && this._worksheet.getColumnKey(this._key);
1915
1916      if (column === this) {
1917        this._worksheet.deleteColumnKey(this._key);
1918      }
1919
1920      this._key = value;
1921
1922      if (value) {
1923        this._worksheet.setColumnKey(this._key, this);
1924      }
1925    }
1926  }, {
1927    key: "hidden",
1928    get: function get() {
1929      return !!this._hidden;
1930    },
1931    set: function set(value) {
1932      this._hidden = value;
1933    }
1934  }, {
1935    key: "outlineLevel",
1936    get: function get() {
1937      return this._outlineLevel || 0;
1938    },
1939    set: function set(value) {
1940      this._outlineLevel = value;
1941    }
1942  }, {
1943    key: "collapsed",
1944    get: function get() {
1945      return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol);
1946    }
1947  }, {
1948    key: "isDefault",
1949    get: function get() {
1950      if (this.isCustomWidth) {
1951        return false;
1952      }
1953
1954      if (this.hidden) {
1955        return false;
1956      }
1957
1958      if (this.outlineLevel) {
1959        return false;
1960      }
1961
1962      var s = this.style;
1963
1964      if (s && (s.font || s.numFmt || s.alignment || s.border || s.fill || s.protection)) {
1965        return false;
1966      }
1967
1968      return true;
1969    }
1970  }, {
1971    key: "headerCount",
1972    get: function get() {
1973      return this.headers.length;
1974    }
1975  }, {
1976    key: "values",
1977    get: function get() {
1978      var v = [];
1979      this.eachCell(function (cell, rowNumber) {
1980        if (cell && cell.type !== Enums.ValueType.Null) {
1981          v[rowNumber] = cell.value;
1982        }
1983      });
1984      return v;
1985    },
1986    set: function set(v) {
1987      var _this2 = this;
1988
1989      if (!v) {
1990        return;
1991      }
1992
1993      var colNumber = this.number;
1994      var offset = 0;
1995
1996      if (v.hasOwnProperty('0')) {
1997        // assume contiguous array, start at row 1
1998        offset = 1;
1999      }
2000
2001      v.forEach(function (value, index) {
2002        _this2._worksheet.getCell(index + offset, colNumber).value = value;
2003      });
2004    }
2005  }, {
2006    key: "numFmt",
2007    get: function get() {
2008      return this.style.numFmt;
2009    },
2010    set: function set(value) {
2011      this._applyStyle('numFmt', value);
2012    }
2013  }, {
2014    key: "font",
2015    get: function get() {
2016      return this.style.font;
2017    },
2018    set: function set(value) {
2019      this._applyStyle('font', value);
2020    }
2021  }, {
2022    key: "alignment",
2023    get: function get() {
2024      return this.style.alignment;
2025    },
2026    set: function set(value) {
2027      this._applyStyle('alignment', value);
2028    }
2029  }, {
2030    key: "protection",
2031    get: function get() {
2032      return this.style.protection;
2033    },
2034    set: function set(value) {
2035      this._applyStyle('protection', value);
2036    }
2037  }, {
2038    key: "border",
2039    get: function get() {
2040      return this.style.border;
2041    },
2042    set: function set(value) {
2043      this._applyStyle('border', value);
2044    }
2045  }, {
2046    key: "fill",
2047    get: function get() {
2048      return this.style.fill;
2049    },
2050    set: function set(value) {
2051      this._applyStyle('fill', value);
2052    } // =============================================================================
2053    // static functions
2054
2055  }], [{
2056    key: "toModel",
2057    value: function toModel(columns) {
2058      // Convert array of Column into compressed list cols
2059      var cols = [];
2060      var col = null;
2061
2062      if (columns) {
2063        columns.forEach(function (column, index) {
2064          if (column.isDefault) {
2065            if (col) {
2066              col = null;
2067            }
2068          } else if (!col || !column.equivalentTo(col)) {
2069            col = {
2070              min: index + 1,
2071              max: index + 1,
2072              width: column.width !== undefined ? column.width : DEFAULT_COLUMN_WIDTH,
2073              style: column.style,
2074              isCustomWidth: column.isCustomWidth,
2075              hidden: column.hidden,
2076              outlineLevel: column.outlineLevel,
2077              collapsed: column.collapsed
2078            };
2079            cols.push(col);
2080          } else {
2081            col.max = index + 1;
2082          }
2083        });
2084      }
2085
2086      return cols.length ? cols : undefined;
2087    }
2088  }, {
2089    key: "fromModel",
2090    value: function fromModel(worksheet, cols) {
2091      cols = cols || [];
2092      var columns = [];
2093      var count = 1;
2094      var index = 0;
2095
2096      while (index < cols.length) {
2097        var col = cols[index++];
2098
2099        while (count < col.min) {
2100          columns.push(new Column(worksheet, count++));
2101        }
2102
2103        while (count <= col.max) {
2104          columns.push(new Column(worksheet, count++, col));
2105        }
2106      }
2107
2108      return columns.length ? columns : null;
2109    }
2110  }]);
2111
2112  return Column;
2113}();
2114
2115module.exports = Column;
2116
2117},{"../utils/col-cache":19,"../utils/under-dash":25,"./enums":7}],5:[function(require,module,exports){
2118"use strict";
2119
2120function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2121
2122function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2123
2124function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2125
2126var DataValidations = /*#__PURE__*/function () {
2127  function DataValidations(model) {
2128    _classCallCheck(this, DataValidations);
2129
2130    this.model = model || {};
2131  }
2132
2133  _createClass(DataValidations, [{
2134    key: "add",
2135    value: function add(address, validation) {
2136      return this.model[address] = validation;
2137    }
2138  }, {
2139    key: "find",
2140    value: function find(address) {
2141      return this.model[address];
2142    }
2143  }, {
2144    key: "remove",
2145    value: function remove(address) {
2146      this.model[address] = undefined;
2147    }
2148  }]);
2149
2150  return DataValidations;
2151}();
2152
2153module.exports = DataValidations;
2154
2155},{}],6:[function(require,module,exports){
2156'use strict';
2157
2158function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2159
2160function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2161
2162function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2163
2164var _ = require('../utils/under-dash');
2165
2166var colCache = require('../utils/col-cache');
2167
2168var CellMatrix = require('../utils/cell-matrix');
2169
2170var Range = require('./range');
2171
2172var rangeRegexp = /[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;
2173
2174var DefinedNames = /*#__PURE__*/function () {
2175  function DefinedNames() {
2176    _classCallCheck(this, DefinedNames);
2177
2178    this.matrixMap = {};
2179  }
2180
2181  _createClass(DefinedNames, [{
2182    key: "getMatrix",
2183    value: function getMatrix(name) {
2184      var matrix = this.matrixMap[name] || (this.matrixMap[name] = new CellMatrix());
2185      return matrix;
2186    } // add a name to a cell. locStr in the form SheetName!$col$row or SheetName!$c1$r1:$c2:$r2
2187
2188  }, {
2189    key: "add",
2190    value: function add(locStr, name) {
2191      var location = colCache.decodeEx(locStr);
2192      this.addEx(location, name);
2193    }
2194  }, {
2195    key: "addEx",
2196    value: function addEx(location, name) {
2197      var matrix = this.getMatrix(name);
2198
2199      if (location.top) {
2200        for (var col = location.left; col <= location.right; col++) {
2201          for (var row = location.top; row <= location.bottom; row++) {
2202            var address = {
2203              sheetName: location.sheetName,
2204              address: colCache.n2l(col) + row,
2205              row: row,
2206              col: col
2207            };
2208            matrix.addCellEx(address);
2209          }
2210        }
2211      } else {
2212        matrix.addCellEx(location);
2213      }
2214    }
2215  }, {
2216    key: "remove",
2217    value: function remove(locStr, name) {
2218      var location = colCache.decodeEx(locStr);
2219      this.removeEx(location, name);
2220    }
2221  }, {
2222    key: "removeEx",
2223    value: function removeEx(location, name) {
2224      var matrix = this.getMatrix(name);
2225      matrix.removeCellEx(location);
2226    }
2227  }, {
2228    key: "removeAllNames",
2229    value: function removeAllNames(location) {
2230      _.each(this.matrixMap, function (matrix) {
2231        matrix.removeCellEx(location);
2232      });
2233    }
2234  }, {
2235    key: "forEach",
2236    value: function forEach(callback) {
2237      _.each(this.matrixMap, function (matrix, name) {
2238        matrix.forEach(function (cell) {
2239          callback(name, cell);
2240        });
2241      });
2242    } // get all the names of a cell
2243
2244  }, {
2245    key: "getNames",
2246    value: function getNames(addressStr) {
2247      return this.getNamesEx(colCache.decodeEx(addressStr));
2248    }
2249  }, {
2250    key: "getNamesEx",
2251    value: function getNamesEx(address) {
2252      return _.map(this.matrixMap, function (matrix, name) {
2253        return matrix.findCellEx(address) && name;
2254      }).filter(Boolean);
2255    }
2256  }, {
2257    key: "_explore",
2258    value: function _explore(matrix, cell) {
2259      cell.mark = false;
2260      var sheetName = cell.sheetName;
2261      var range = new Range(cell.row, cell.col, cell.row, cell.col, sheetName);
2262      var x;
2263      var y; // grow vertical - only one col to worry about
2264
2265      function vGrow(yy, edge) {
2266        var c = matrix.findCellAt(sheetName, yy, cell.col);
2267
2268        if (!c || !c.mark) {
2269          return false;
2270        }
2271
2272        range[edge] = yy;
2273        c.mark = false;
2274        return true;
2275      }
2276
2277      for (y = cell.row - 1; vGrow(y, 'top'); y--) {
2278        ;
2279      }
2280
2281      for (y = cell.row + 1; vGrow(y, 'bottom'); y++) {
2282        ;
2283      } // grow horizontal - ensure all rows can grow
2284
2285
2286      function hGrow(xx, edge) {
2287        var cells = [];
2288
2289        for (y = range.top; y <= range.bottom; y++) {
2290          var c = matrix.findCellAt(sheetName, y, xx);
2291
2292          if (c && c.mark) {
2293            cells.push(c);
2294          } else {
2295            return false;
2296          }
2297        }
2298
2299        range[edge] = xx;
2300
2301        for (var i = 0; i < cells.length; i++) {
2302          cells[i].mark = false;
2303        }
2304
2305        return true;
2306      }
2307
2308      for (x = cell.col - 1; hGrow(x, 'left'); x--) {
2309        ;
2310      }
2311
2312      for (x = cell.col + 1; hGrow(x, 'right'); x++) {
2313        ;
2314      }
2315
2316      return range;
2317    }
2318  }, {
2319    key: "getRanges",
2320    value: function getRanges(name, matrix) {
2321      var _this = this;
2322
2323      matrix = matrix || this.matrixMap[name];
2324
2325      if (!matrix) {
2326        return {
2327          name: name,
2328          ranges: []
2329        };
2330      } // mark and sweep!
2331
2332
2333      matrix.forEach(function (cell) {
2334        cell.mark = true;
2335      });
2336      var ranges = matrix.map(function (cell) {
2337        return cell.mark && _this._explore(matrix, cell);
2338      }).filter(Boolean).map(function (range) {
2339        return range.$shortRange;
2340      });
2341      return {
2342        name: name,
2343        ranges: ranges
2344      };
2345    }
2346  }, {
2347    key: "normaliseMatrix",
2348    value: function normaliseMatrix(matrix, sheetName) {
2349      // some of the cells might have shifted on specified sheet
2350      // need to reassign rows, cols
2351      matrix.forEachInSheet(sheetName, function (cell, row, col) {
2352        if (cell) {
2353          if (cell.row !== row || cell.col !== col) {
2354            cell.row = row;
2355            cell.col = col;
2356            cell.address = colCache.n2l(col) + row;
2357          }
2358        }
2359      });
2360    }
2361  }, {
2362    key: "spliceRows",
2363    value: function spliceRows(sheetName, start, numDelete, numInsert) {
2364      var _this2 = this;
2365
2366      _.each(this.matrixMap, function (matrix) {
2367        matrix.spliceRows(sheetName, start, numDelete, numInsert);
2368
2369        _this2.normaliseMatrix(matrix, sheetName);
2370      });
2371    }
2372  }, {
2373    key: "spliceColumns",
2374    value: function spliceColumns(sheetName, start, numDelete, numInsert) {
2375      var _this3 = this;
2376
2377      _.each(this.matrixMap, function (matrix) {
2378        matrix.spliceColumns(sheetName, start, numDelete, numInsert);
2379
2380        _this3.normaliseMatrix(matrix, sheetName);
2381      });
2382    }
2383  }, {
2384    key: "model",
2385    get: function get() {
2386      var _this4 = this;
2387
2388      // To get names per cell - just iterate over all names finding cells if they exist
2389      return _.map(this.matrixMap, function (matrix, name) {
2390        return _this4.getRanges(name, matrix);
2391      }).filter(function (definedName) {
2392        return definedName.ranges.length;
2393      });
2394    },
2395    set: function set(value) {
2396      // value is [ { name, ranges }, ... ]
2397      var matrixMap = this.matrixMap = {};
2398      value.forEach(function (definedName) {
2399        var matrix = matrixMap[definedName.name] = new CellMatrix();
2400        definedName.ranges.forEach(function (rangeStr) {
2401          if (rangeRegexp.test(rangeStr.split('!').pop() || '')) {
2402            matrix.addCell(rangeStr);
2403          }
2404        });
2405      });
2406    }
2407  }]);
2408
2409  return DefinedNames;
2410}();
2411
2412module.exports = DefinedNames;
2413
2414},{"../utils/cell-matrix":18,"../utils/col-cache":19,"../utils/under-dash":25,"./range":10}],7:[function(require,module,exports){
2415'use strict';
2416
2417module.exports = {
2418  ValueType: {
2419    Null: 0,
2420    Merge: 1,
2421    Number: 2,
2422    String: 3,
2423    Date: 4,
2424    Hyperlink: 5,
2425    Formula: 6,
2426    SharedString: 7,
2427    RichText: 8,
2428    Boolean: 9,
2429    Error: 10
2430  },
2431  FormulaType: {
2432    None: 0,
2433    Master: 1,
2434    Shared: 2
2435  },
2436  RelationshipType: {
2437    None: 0,
2438    OfficeDocument: 1,
2439    Worksheet: 2,
2440    CalcChain: 3,
2441    SharedStrings: 4,
2442    Styles: 5,
2443    Theme: 6,
2444    Hyperlink: 7
2445  },
2446  DocumentType: {
2447    Xlsx: 1
2448  },
2449  ReadingOrder: {
2450    LeftToRight: 1,
2451    RightToLeft: 2
2452  },
2453  ErrorValue: {
2454    NotApplicable: '#N/A',
2455    Ref: '#REF!',
2456    Name: '#NAME?',
2457    DivZero: '#DIV/0!',
2458    Null: '#NULL!',
2459    Value: '#VALUE!',
2460    Num: '#NUM!'
2461  }
2462};
2463
2464},{}],8:[function(require,module,exports){
2465"use strict";
2466
2467function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2468
2469function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2470
2471function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2472
2473var colCache = require('../utils/col-cache');
2474
2475var Anchor = require('./anchor');
2476
2477var Image = /*#__PURE__*/function () {
2478  function Image(worksheet, model) {
2479    _classCallCheck(this, Image);
2480
2481    this.worksheet = worksheet;
2482    this.model = model;
2483  }
2484
2485  _createClass(Image, [{
2486    key: "model",
2487    get: function get() {
2488      switch (this.type) {
2489        case 'background':
2490          return {
2491            type: this.type,
2492            imageId: this.imageId
2493          };
2494
2495        case 'image':
2496          return {
2497            type: this.type,
2498            imageId: this.imageId,
2499            hyperlinks: this.range.hyperlinks,
2500            range: {
2501              tl: this.range.tl.model,
2502              br: this.range.br && this.range.br.model,
2503              ext: this.range.ext,
2504              editAs: this.range.editAs
2505            }
2506          };
2507
2508        default:
2509          throw new Error('Invalid Image Type');
2510      }
2511    },
2512    set: function set(_ref) {
2513      var type = _ref.type,
2514          imageId = _ref.imageId,
2515          range = _ref.range,
2516          hyperlinks = _ref.hyperlinks;
2517      this.type = type;
2518      this.imageId = imageId;
2519
2520      if (type === 'image') {
2521        if (typeof range === 'string') {
2522          var decoded = colCache.decode(range);
2523          this.range = {
2524            tl: new Anchor(this.worksheet, {
2525              col: decoded.left,
2526              row: decoded.top
2527            }, -1),
2528            br: new Anchor(this.worksheet, {
2529              col: decoded.right,
2530              row: decoded.bottom
2531            }, 0),
2532            editAs: 'oneCell'
2533          };
2534        } else {
2535          this.range = {
2536            tl: new Anchor(this.worksheet, range.tl, 0),
2537            br: range.br && new Anchor(this.worksheet, range.br, 0),
2538            ext: range.ext,
2539            editAs: range.editAs,
2540            hyperlinks: hyperlinks || range.hyperlinks
2541          };
2542        }
2543      }
2544    }
2545  }]);
2546
2547  return Image;
2548}();
2549
2550module.exports = Image;
2551
2552},{"../utils/col-cache":19,"./anchor":2}],9:[function(require,module,exports){
2553"use strict";
2554
2555function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2556
2557function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2558
2559function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2560
2561function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2562
2563var _ = require('../utils/under-dash');
2564
2565var Note = /*#__PURE__*/function () {
2566  function Note(note) {
2567    _classCallCheck(this, Note);
2568
2569    this.note = note;
2570  }
2571
2572  _createClass(Note, [{
2573    key: "model",
2574    get: function get() {
2575      var value = null;
2576
2577      switch (_typeof(this.note)) {
2578        case 'string':
2579          value = {
2580            type: 'note',
2581            note: {
2582              texts: [{
2583                text: this.note
2584              }]
2585            }
2586          };
2587          break;
2588
2589        default:
2590          value = {
2591            type: 'note',
2592            note: this.note
2593          };
2594          break;
2595      } // Suitable for all cell comments
2596
2597
2598      return _.deepMerge({}, Note.DEFAULT_CONFIGS, value);
2599    },
2600    set: function set(value) {
2601      var note = value.note;
2602      var texts = note.texts;
2603
2604      if (texts.length === 1 && Object.keys(texts[0]).length === 1) {
2605        this.note = texts[0].text;
2606      } else {
2607        this.note = note;
2608      }
2609    }
2610  }], [{
2611    key: "fromModel",
2612    value: function fromModel(model) {
2613      var note = new Note();
2614      note.model = model;
2615      return note;
2616    }
2617  }]);
2618
2619  return Note;
2620}();
2621
2622Note.DEFAULT_CONFIGS = {
2623  note: {
2624    margins: {
2625      insetmode: 'auto',
2626      inset: [0.13, 0.13, 0.25, 0.25]
2627    },
2628    protection: {
2629      locked: 'True',
2630      lockText: 'True'
2631    },
2632    editAs: 'absolute'
2633  }
2634};
2635module.exports = Note;
2636
2637},{"../utils/under-dash":25}],10:[function(require,module,exports){
2638"use strict";
2639
2640function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2641
2642function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2643
2644function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2645
2646var colCache = require('../utils/col-cache'); // used by worksheet to calculate sheet dimensions
2647
2648
2649var Range = /*#__PURE__*/function () {
2650  function Range() {
2651    _classCallCheck(this, Range);
2652
2653    this.decode(arguments);
2654  }
2655
2656  _createClass(Range, [{
2657    key: "setTLBR",
2658    value: function setTLBR(t, l, b, r, s) {
2659      if (arguments.length < 4) {
2660        // setTLBR(tl, br, s)
2661        var tl = colCache.decodeAddress(t);
2662        var br = colCache.decodeAddress(l);
2663        this.model = {
2664          top: Math.min(tl.row, br.row),
2665          left: Math.min(tl.col, br.col),
2666          bottom: Math.max(tl.row, br.row),
2667          right: Math.max(tl.col, br.col),
2668          sheetName: b
2669        };
2670        this.setTLBR(tl.row, tl.col, br.row, br.col, s);
2671      } else {
2672        // setTLBR(t, l, b, r, s)
2673        this.model = {
2674          top: Math.min(t, b),
2675          left: Math.min(l, r),
2676          bottom: Math.max(t, b),
2677          right: Math.max(l, r),
2678          sheetName: s
2679        };
2680      }
2681    }
2682  }, {
2683    key: "decode",
2684    value: function decode(argv) {
2685      switch (argv.length) {
2686        case 5:
2687          // [t,l,b,r,s]
2688          this.setTLBR(argv[0], argv[1], argv[2], argv[3], argv[4]);
2689          break;
2690
2691        case 4:
2692          // [t,l,b,r]
2693          this.setTLBR(argv[0], argv[1], argv[2], argv[3]);
2694          break;
2695
2696        case 3:
2697          // [tl,br,s]
2698          this.setTLBR(argv[0], argv[1], argv[2]);
2699          break;
2700
2701        case 2:
2702          // [tl,br]
2703          this.setTLBR(argv[0], argv[1]);
2704          break;
2705
2706        case 1:
2707          {
2708            var value = argv[0];
2709
2710            if (value instanceof Range) {
2711              // copy constructor
2712              this.model = {
2713                top: value.model.top,
2714                left: value.model.left,
2715                bottom: value.model.bottom,
2716                right: value.model.right,
2717                sheetName: value.sheetName
2718              };
2719            } else if (value instanceof Array) {
2720              // an arguments array
2721              this.decode(value);
2722            } else if (value.top && value.left && value.bottom && value.right) {
2723              // a model
2724              this.model = {
2725                top: value.top,
2726                left: value.left,
2727                bottom: value.bottom,
2728                right: value.right,
2729                sheetName: value.sheetName
2730              };
2731            } else {
2732              // [sheetName!]tl:br
2733              var tlbr = colCache.decodeEx(value);
2734
2735              if (tlbr.top) {
2736                this.model = {
2737                  top: tlbr.top,
2738                  left: tlbr.left,
2739                  bottom: tlbr.bottom,
2740                  right: tlbr.right,
2741                  sheetName: tlbr.sheetName
2742                };
2743              } else {
2744                this.model = {
2745                  top: tlbr.row,
2746                  left: tlbr.col,
2747                  bottom: tlbr.row,
2748                  right: tlbr.col,
2749                  sheetName: tlbr.sheetName
2750                };
2751              }
2752            }
2753
2754            break;
2755          }
2756
2757        case 0:
2758          this.model = {
2759            top: 0,
2760            left: 0,
2761            bottom: 0,
2762            right: 0
2763          };
2764          break;
2765
2766        default:
2767          throw new Error("Invalid number of arguments to _getDimensions() - ".concat(argv.length));
2768      }
2769    }
2770  }, {
2771    key: "expand",
2772    value: function expand(top, left, bottom, right) {
2773      if (!this.model.top || top < this.top) this.top = top;
2774      if (!this.model.left || left < this.left) this.left = left;
2775      if (!this.model.bottom || bottom > this.bottom) this.bottom = bottom;
2776      if (!this.model.right || right > this.right) this.right = right;
2777    }
2778  }, {
2779    key: "expandRow",
2780    value: function expandRow(row) {
2781      if (row) {
2782        var dimensions = row.dimensions,
2783            number = row.number;
2784
2785        if (dimensions) {
2786          this.expand(number, dimensions.min, number, dimensions.max);
2787        }
2788      }
2789    }
2790  }, {
2791    key: "expandToAddress",
2792    value: function expandToAddress(addressStr) {
2793      var address = colCache.decodeEx(addressStr);
2794      this.expand(address.row, address.col, address.row, address.col);
2795    }
2796  }, {
2797    key: "toString",
2798    value: function toString() {
2799      return this.range;
2800    }
2801  }, {
2802    key: "intersects",
2803    value: function intersects(other) {
2804      if (other.sheetName && this.sheetName && other.sheetName !== this.sheetName) return false;
2805      if (other.bottom < this.top) return false;
2806      if (other.top > this.bottom) return false;
2807      if (other.right < this.left) return false;
2808      if (other.left > this.right) return false;
2809      return true;
2810    }
2811  }, {
2812    key: "contains",
2813    value: function contains(addressStr) {
2814      var address = colCache.decodeEx(addressStr);
2815      return this.containsEx(address);
2816    }
2817  }, {
2818    key: "containsEx",
2819    value: function containsEx(address) {
2820      if (address.sheetName && this.sheetName && address.sheetName !== this.sheetName) return false;
2821      return address.row >= this.top && address.row <= this.bottom && address.col >= this.left && address.col <= this.right;
2822    }
2823  }, {
2824    key: "forEachAddress",
2825    value: function forEachAddress(cb) {
2826      for (var col = this.left; col <= this.right; col++) {
2827        for (var row = this.top; row <= this.bottom; row++) {
2828          cb(colCache.encodeAddress(row, col), row, col);
2829        }
2830      }
2831    }
2832  }, {
2833    key: "top",
2834    get: function get() {
2835      return this.model.top || 1;
2836    },
2837    set: function set(value) {
2838      this.model.top = value;
2839    }
2840  }, {
2841    key: "left",
2842    get: function get() {
2843      return this.model.left || 1;
2844    },
2845    set: function set(value) {
2846      this.model.left = value;
2847    }
2848  }, {
2849    key: "bottom",
2850    get: function get() {
2851      return this.model.bottom || 1;
2852    },
2853    set: function set(value) {
2854      this.model.bottom = value;
2855    }
2856  }, {
2857    key: "right",
2858    get: function get() {
2859      return this.model.right || 1;
2860    },
2861    set: function set(value) {
2862      this.model.right = value;
2863    }
2864  }, {
2865    key: "sheetName",
2866    get: function get() {
2867      return this.model.sheetName;
2868    },
2869    set: function set(value) {
2870      this.model.sheetName = value;
2871    }
2872  }, {
2873    key: "_serialisedSheetName",
2874    get: function get() {
2875      var sheetName = this.model.sheetName;
2876
2877      if (sheetName) {
2878        if (/^[a-zA-Z0-9]*$/.test(sheetName)) {
2879          return "".concat(sheetName, "!");
2880        }
2881
2882        return "'".concat(sheetName, "'!");
2883      }
2884
2885      return '';
2886    }
2887  }, {
2888    key: "tl",
2889    get: function get() {
2890      return colCache.n2l(this.left) + this.top;
2891    }
2892  }, {
2893    key: "$t$l",
2894    get: function get() {
2895      return "$".concat(colCache.n2l(this.left), "$").concat(this.top);
2896    }
2897  }, {
2898    key: "br",
2899    get: function get() {
2900      return colCache.n2l(this.right) + this.bottom;
2901    }
2902  }, {
2903    key: "$b$r",
2904    get: function get() {
2905      return "$".concat(colCache.n2l(this.right), "$").concat(this.bottom);
2906    }
2907  }, {
2908    key: "range",
2909    get: function get() {
2910      return "".concat(this._serialisedSheetName + this.tl, ":").concat(this.br);
2911    }
2912  }, {
2913    key: "$range",
2914    get: function get() {
2915      return "".concat(this._serialisedSheetName + this.$t$l, ":").concat(this.$b$r);
2916    }
2917  }, {
2918    key: "shortRange",
2919    get: function get() {
2920      return this.count > 1 ? this.range : this._serialisedSheetName + this.tl;
2921    }
2922  }, {
2923    key: "$shortRange",
2924    get: function get() {
2925      return this.count > 1 ? this.$range : this._serialisedSheetName + this.$t$l;
2926    }
2927  }, {
2928    key: "count",
2929    get: function get() {
2930      return (1 + this.bottom - this.top) * (1 + this.right - this.left);
2931    }
2932  }]);
2933
2934  return Range;
2935}();
2936
2937module.exports = Range;
2938
2939},{"../utils/col-cache":19}],11:[function(require,module,exports){
2940'use strict';
2941
2942function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2943
2944function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2945
2946function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2947
2948var _ = require('../utils/under-dash');
2949
2950var Enums = require('./enums');
2951
2952var colCache = require('../utils/col-cache');
2953
2954var Cell = require('./cell');
2955
2956var Row = /*#__PURE__*/function () {
2957  function Row(worksheet, number) {
2958    _classCallCheck(this, Row);
2959
2960    this._worksheet = worksheet;
2961    this._number = number;
2962    this._cells = [];
2963    this.style = {};
2964    this.outlineLevel = 0;
2965  } // return the row number
2966
2967
2968  _createClass(Row, [{
2969    key: "commit",
2970    // Inform Streaming Writer that this row (and all rows before it) are complete
2971    // and ready to write. Has no effect on Worksheet document
2972    value: function commit() {
2973      this._worksheet._commitRow(this); // eslint-disable-line no-underscore-dangle
2974
2975    } // helps GC by breaking cyclic references
2976
2977  }, {
2978    key: "destroy",
2979    value: function destroy() {
2980      delete this._worksheet;
2981      delete this._cells;
2982      delete this.style;
2983    }
2984  }, {
2985    key: "findCell",
2986    value: function findCell(colNumber) {
2987      return this._cells[colNumber - 1];
2988    } // given {address, row, col}, find or create new cell
2989
2990  }, {
2991    key: "getCellEx",
2992    value: function getCellEx(address) {
2993      var cell = this._cells[address.col - 1];
2994
2995      if (!cell) {
2996        var column = this._worksheet.getColumn(address.col);
2997
2998        cell = new Cell(this, column, address.address);
2999        this._cells[address.col - 1] = cell;
3000      }
3001
3002      return cell;
3003    } // get cell by key, letter or column number
3004
3005  }, {
3006    key: "getCell",
3007    value: function getCell(col) {
3008      if (typeof col === 'string') {
3009        // is it a key?
3010        var column = this._worksheet.getColumnKey(col);
3011
3012        if (column) {
3013          col = column.number;
3014        } else {
3015          col = colCache.l2n(col);
3016        }
3017      }
3018
3019      return this._cells[col - 1] || this.getCellEx({
3020        address: colCache.encodeAddress(this._number, col),
3021        row: this._number,
3022        col: col
3023      });
3024    } // remove cell(s) and shift all higher cells down by count
3025
3026  }, {
3027    key: "splice",
3028    value: function splice(start, count) {
3029      var nKeep = start + count;
3030
3031      for (var _len = arguments.length, inserts = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
3032        inserts[_key - 2] = arguments[_key];
3033      }
3034
3035      var nExpand = inserts.length - count;
3036      var nEnd = this._cells.length;
3037      var i;
3038      var cSrc;
3039      var cDst;
3040
3041      if (nExpand < 0) {
3042        // remove cells
3043        for (i = start + inserts.length; i <= nEnd; i++) {
3044          cDst = this._cells[i - 1];
3045          cSrc = this._cells[i - nExpand - 1];
3046
3047          if (cSrc) {
3048            cDst = this.getCell(i);
3049            cDst.value = cSrc.value;
3050            cDst.style = cSrc.style; // eslint-disable-next-line no-underscore-dangle
3051
3052            cDst._comment = cSrc._comment;
3053          } else if (cDst) {
3054            cDst.value = null;
3055            cDst.style = {}; // eslint-disable-next-line no-underscore-dangle
3056
3057            cDst._comment = undefined;
3058          }
3059        }
3060      } else if (nExpand > 0) {
3061        // insert new cells
3062        for (i = nEnd; i >= nKeep; i--) {
3063          cSrc = this._cells[i - 1];
3064
3065          if (cSrc) {
3066            cDst = this.getCell(i + nExpand);
3067            cDst.value = cSrc.value;
3068            cDst.style = cSrc.style; // eslint-disable-next-line no-underscore-dangle
3069
3070            cDst._comment = cSrc._comment;
3071          } else {
3072            this._cells[i + nExpand - 1] = undefined;
3073          }
3074        }
3075      } // now add the new values
3076
3077
3078      for (i = 0; i < inserts.length; i++) {
3079        cDst = this.getCell(start + i);
3080        cDst.value = inserts[i];
3081        cDst.style = {}; // eslint-disable-next-line no-underscore-dangle
3082
3083        cDst._comment = undefined;
3084      }
3085    } // Iterate over all non-null cells in this row
3086
3087  }, {
3088    key: "eachCell",
3089    value: function eachCell(options, iteratee) {
3090      if (!iteratee) {
3091        iteratee = options;
3092        options = null;
3093      }
3094
3095      if (options && options.includeEmpty) {
3096        var n = this._cells.length;
3097
3098        for (var i = 1; i <= n; i++) {
3099          iteratee(this.getCell(i), i);
3100        }
3101      } else {
3102        this._cells.forEach(function (cell, index) {
3103          if (cell && cell.type !== Enums.ValueType.Null) {
3104            iteratee(cell, index + 1);
3105          }
3106        });
3107      }
3108    } // ===========================================================================
3109    // Page Breaks
3110
3111  }, {
3112    key: "addPageBreak",
3113    value: function addPageBreak(lft, rght) {
3114      var ws = this._worksheet;
3115      var left = Math.max(0, lft - 1) || 0;
3116      var right = Math.max(0, rght - 1) || 16838;
3117      var pb = {
3118        id: this._number,
3119        max: right,
3120        man: 1
3121      };
3122      if (left) pb.min = left;
3123      ws.rowBreaks.push(pb);
3124    } // return a sparse array of cell values
3125
3126  }, {
3127    key: "_applyStyle",
3128    // =========================================================================
3129    // styles
3130    value: function _applyStyle(name, value) {
3131      this.style[name] = value;
3132
3133      this._cells.forEach(function (cell) {
3134        if (cell) {
3135          cell[name] = value;
3136        }
3137      });
3138
3139      return value;
3140    }
3141  }, {
3142    key: "number",
3143    get: function get() {
3144      return this._number;
3145    }
3146  }, {
3147    key: "worksheet",
3148    get: function get() {
3149      return this._worksheet;
3150    }
3151  }, {
3152    key: "values",
3153    get: function get() {
3154      var values = [];
3155
3156      this._cells.forEach(function (cell) {
3157        if (cell && cell.type !== Enums.ValueType.Null) {
3158          values[cell.col] = cell.value;
3159        }
3160      });
3161
3162      return values;
3163    } // set the values by contiguous or sparse array, or by key'd object literal
3164    ,
3165    set: function set(value) {
3166      var _this = this;
3167
3168      // this operation is not additive - any prior cells are removed
3169      this._cells = [];
3170
3171      if (!value) {// empty row
3172      } else if (value instanceof Array) {
3173        var offset = 0;
3174
3175        if (value.hasOwnProperty('0')) {
3176          // contiguous array - start at column 1
3177          offset = 1;
3178        }
3179
3180        value.forEach(function (item, index) {
3181          if (item !== undefined) {
3182            _this.getCellEx({
3183              address: colCache.encodeAddress(_this._number, index + offset),
3184              row: _this._number,
3185              col: index + offset
3186            }).value = item;
3187          }
3188        });
3189      } else {
3190        // assume object with column keys
3191        this._worksheet.eachColumnKey(function (column, key) {
3192          if (value[key] !== undefined) {
3193            _this.getCellEx({
3194              address: colCache.encodeAddress(_this._number, column.number),
3195              row: _this._number,
3196              col: column.number
3197            }).value = value[key];
3198          }
3199        });
3200      }
3201    } // returns true if the row includes at least one cell with a value
3202
3203  }, {
3204    key: "hasValues",
3205    get: function get() {
3206      return _.some(this._cells, function (cell) {
3207        return cell && cell.type !== Enums.ValueType.Null;
3208      });
3209    }
3210  }, {
3211    key: "cellCount",
3212    get: function get() {
3213      return this._cells.length;
3214    }
3215  }, {
3216    key: "actualCellCount",
3217    get: function get() {
3218      var count = 0;
3219      this.eachCell(function () {
3220        count++;
3221      });
3222      return count;
3223    } // get the min and max column number for the non-null cells in this row or null
3224
3225  }, {
3226    key: "dimensions",
3227    get: function get() {
3228      var min = 0;
3229      var max = 0;
3230
3231      this._cells.forEach(function (cell) {
3232        if (cell && cell.type !== Enums.ValueType.Null) {
3233          if (!min || min > cell.col) {
3234            min = cell.col;
3235          }
3236
3237          if (max < cell.col) {
3238            max = cell.col;
3239          }
3240        }
3241      });
3242
3243      return min > 0 ? {
3244        min: min,
3245        max: max
3246      } : null;
3247    }
3248  }, {
3249    key: "numFmt",
3250    get: function get() {
3251      return this.style.numFmt;
3252    },
3253    set: function set(value) {
3254      this._applyStyle('numFmt', value);
3255    }
3256  }, {
3257    key: "font",
3258    get: function get() {
3259      return this.style.font;
3260    },
3261    set: function set(value) {
3262      this._applyStyle('font', value);
3263    }
3264  }, {
3265    key: "alignment",
3266    get: function get() {
3267      return this.style.alignment;
3268    },
3269    set: function set(value) {
3270      this._applyStyle('alignment', value);
3271    }
3272  }, {
3273    key: "protection",
3274    get: function get() {
3275      return this.style.protection;
3276    },
3277    set: function set(value) {
3278      this._applyStyle('protection', value);
3279    }
3280  }, {
3281    key: "border",
3282    get: function get() {
3283      return this.style.border;
3284    },
3285    set: function set(value) {
3286      this._applyStyle('border', value);
3287    }
3288  }, {
3289    key: "fill",
3290    get: function get() {
3291      return this.style.fill;
3292    },
3293    set: function set(value) {
3294      this._applyStyle('fill', value);
3295    }
3296  }, {
3297    key: "hidden",
3298    get: function get() {
3299      return !!this._hidden;
3300    },
3301    set: function set(value) {
3302      this._hidden = value;
3303    }
3304  }, {
3305    key: "outlineLevel",
3306    get: function get() {
3307      return this._outlineLevel || 0;
3308    },
3309    set: function set(value) {
3310      this._outlineLevel = value;
3311    }
3312  }, {
3313    key: "collapsed",
3314    get: function get() {
3315      return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow);
3316    } // =========================================================================
3317
3318  }, {
3319    key: "model",
3320    get: function get() {
3321      var cells = [];
3322      var min = 0;
3323      var max = 0;
3324
3325      this._cells.forEach(function (cell) {
3326        if (cell) {
3327          var cellModel = cell.model;
3328
3329          if (cellModel) {
3330            if (!min || min > cell.col) {
3331              min = cell.col;
3332            }
3333
3334            if (max < cell.col) {
3335              max = cell.col;
3336            }
3337
3338            cells.push(cellModel);
3339          }
3340        }
3341      });
3342
3343      return this.height || cells.length ? {
3344        cells: cells,
3345        number: this.number,
3346        min: min,
3347        max: max,
3348        height: this.height,
3349        style: this.style,
3350        hidden: this.hidden,
3351        outlineLevel: this.outlineLevel,
3352        collapsed: this.collapsed
3353      } : null;
3354    },
3355    set: function set(value) {
3356      var _this2 = this;
3357
3358      if (value.number !== this._number) {
3359        throw new Error('Invalid row number in model');
3360      }
3361
3362      this._cells = [];
3363      var previousAddress;
3364      value.cells.forEach(function (cellModel) {
3365        switch (cellModel.type) {
3366          case Cell.Types.Merge:
3367            // special case - don't add this types
3368            break;
3369
3370          default:
3371            {
3372              var address;
3373
3374              if (cellModel.address) {
3375                address = colCache.decodeAddress(cellModel.address);
3376              } else if (previousAddress) {
3377                // This is a <c> element without an r attribute
3378                // Assume that it's the cell for the next column
3379                var _previousAddress = previousAddress,
3380                    row = _previousAddress.row;
3381                var col = previousAddress.col + 1;
3382                address = {
3383                  row: row,
3384                  col: col,
3385                  address: colCache.encodeAddress(row, col),
3386                  $col$row: "$".concat(colCache.n2l(col), "$").concat(row)
3387                };
3388              }
3389
3390              previousAddress = address;
3391
3392              var cell = _this2.getCellEx(address);
3393
3394              cell.model = cellModel;
3395              break;
3396            }
3397        }
3398      });
3399
3400      if (value.height) {
3401        this.height = value.height;
3402      } else {
3403        delete this.height;
3404      }
3405
3406      this.hidden = value.hidden;
3407      this.outlineLevel = value.outlineLevel || 0;
3408      this.style = value.style && JSON.parse(JSON.stringify(value.style)) || {};
3409    }
3410  }]);
3411
3412  return Row;
3413}();
3414
3415module.exports = Row;
3416
3417},{"../utils/col-cache":19,"../utils/under-dash":25,"./cell":3,"./enums":7}],12:[function(require,module,exports){
3418"use strict";
3419
3420function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3421
3422function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3423
3424function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
3425
3426/* eslint-disable max-classes-per-file */
3427var colCache = require('../utils/col-cache');
3428
3429var Column = /*#__PURE__*/function () {
3430  // wrapper around column model, allowing access and manipulation
3431  function Column(table, column, index) {
3432    _classCallCheck(this, Column);
3433
3434    this.table = table;
3435    this.column = column;
3436    this.index = index;
3437  }
3438
3439  _createClass(Column, [{
3440    key: "_set",
3441    value: function _set(name, value) {
3442      this.table.cacheState();
3443      this.column[name] = value;
3444    }
3445    /* eslint-disable lines-between-class-members */
3446
3447  }, {
3448    key: "name",
3449    get: function get() {
3450      return this.column.name;
3451    },
3452    set: function set(value) {
3453      this._set('name', value);
3454    }
3455  }, {
3456    key: "filterButton",
3457    get: function get() {
3458      return this.column.filterButton;
3459    },
3460    set: function set(value) {
3461      this.column.filterButton = value;
3462    }
3463  }, {
3464    key: "style",
3465    get: function get() {
3466      return this.column.style;
3467    },
3468    set: function set(value) {
3469      this.column.style = value;
3470    }
3471  }, {
3472    key: "totalsRowLabel",
3473    get: function get() {
3474      return this.column.totalsRowLabel;
3475    },
3476    set: function set(value) {
3477      this._set('totalsRowLabel', value);
3478    }
3479  }, {
3480    key: "totalsRowFunction",
3481    get: function get() {
3482      return this.column.totalsRowFunction;
3483    },
3484    set: function set(value) {
3485      this._set('totalsRowFunction', value);
3486    }
3487  }, {
3488    key: "totalsRowResult",
3489    get: function get() {
3490      return this.column.totalsRowResult;
3491    },
3492    set: function set(value) {
3493      this._set('totalsRowResult', value);
3494    }
3495  }, {
3496    key: "totalsRowFormula",
3497    get: function get() {
3498      return this.column.totalsRowFormula;
3499    },
3500    set: function set(value) {
3501      this._set('totalsRowFormula', value);
3502    }
3503    /* eslint-enable lines-between-class-members */
3504
3505  }]);
3506
3507  return Column;
3508}();
3509
3510var Table = /*#__PURE__*/function () {
3511  function Table(worksheet, table) {
3512    _classCallCheck(this, Table);
3513
3514    this.worksheet = worksheet;
3515
3516    if (table) {
3517      this.table = table; // check things are ok first
3518
3519      this.validate();
3520      this.store();
3521    }
3522  }
3523
3524  _createClass(Table, [{
3525    key: "getFormula",
3526    value: function getFormula(column) {
3527      // get the correct formula to apply to the totals row
3528      switch (column.totalsRowFunction) {
3529        case 'none':
3530          return null;
3531
3532        case 'average':
3533          return "SUBTOTAL(101,".concat(this.table.name, "[").concat(column.name, "])");
3534
3535        case 'countNums':
3536          return "SUBTOTAL(102,".concat(this.table.name, "[").concat(column.name, "])");
3537
3538        case 'count':
3539          return "SUBTOTAL(103,".concat(this.table.name, "[").concat(column.name, "])");
3540
3541        case 'max':
3542          return "SUBTOTAL(104,".concat(this.table.name, "[").concat(column.name, "])");
3543
3544        case 'min':
3545          return "SUBTOTAL(105,".concat(this.table.name, "[").concat(column.name, "])");
3546
3547        case 'stdDev':
3548          return "SUBTOTAL(106,".concat(this.table.name, "[").concat(column.name, "])");
3549
3550        case 'var':
3551          return "SUBTOTAL(107,".concat(this.table.name, "[").concat(column.name, "])");
3552
3553        case 'sum':
3554          return "SUBTOTAL(109,".concat(this.table.name, "[").concat(column.name, "])");
3555
3556        case 'custom':
3557          return column.totalsRowFormula;
3558
3559        default:
3560          throw new Error("Invalid Totals Row Function: ".concat(column.totalsRowFunction));
3561      }
3562    }
3563  }, {
3564    key: "validate",
3565    value: function validate() {
3566      var _this = this;
3567
3568      var table = this.table; // set defaults and check is valid
3569
3570      var assign = function assign(o, name, dflt) {
3571        if (o[name] === undefined) {
3572          o[name] = dflt;
3573        }
3574      };
3575
3576      assign(table, 'headerRow', true);
3577      assign(table, 'totalsRow', false);
3578      assign(table, 'style', {});
3579      assign(table.style, 'theme', 'TableStyleMedium2');
3580      assign(table.style, 'showFirstColumn', false);
3581      assign(table.style, 'showLastColumn', false);
3582      assign(table.style, 'showRowStripes', false);
3583      assign(table.style, 'showColumnStripes', false);
3584
3585      var assert = function assert(test, message) {
3586        if (!test) {
3587          throw new Error(message);
3588        }
3589      };
3590
3591      assert(table.ref, 'Table must have ref');
3592      assert(table.columns, 'Table must have column definitions');
3593      assert(table.rows, 'Table must have row definitions');
3594      table.tl = colCache.decodeAddress(table.ref);
3595      var _table$tl = table.tl,
3596          row = _table$tl.row,
3597          col = _table$tl.col;
3598      assert(row > 0, 'Table must be on valid row');
3599      assert(col > 0, 'Table must be on valid col');
3600      var width = this.width,
3601          filterHeight = this.filterHeight,
3602          tableHeight = this.tableHeight; // autoFilterRef is a range that includes optional headers only
3603
3604      table.autoFilterRef = colCache.encode(row, col, row + filterHeight - 1, col + width - 1); // tableRef is a range that includes optional headers and totals
3605
3606      table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);
3607      table.columns.forEach(function (column, i) {
3608        assert(column.name, "Column ".concat(i, " must have a name"));
3609
3610        if (i === 0) {
3611          assign(column, 'totalsRowLabel', 'Total');
3612        } else {
3613          assign(column, 'totalsRowFunction', 'none');
3614          column.totalsRowFormula = _this.getFormula(column);
3615        }
3616      });
3617    }
3618  }, {
3619    key: "store",
3620    value: function store() {
3621      var _this2 = this;
3622
3623      // where the table needs to store table data, headers, footers in
3624      // the sheet...
3625      var assignStyle = function assignStyle(cell, style) {
3626        if (style) {
3627          Object.keys(style).forEach(function (key) {
3628            cell[key] = style[key];
3629          });
3630        }
3631      };
3632
3633      var worksheet = this.worksheet,
3634          table = this.table;
3635      var _table$tl2 = table.tl,
3636          row = _table$tl2.row,
3637          col = _table$tl2.col;
3638      var count = 0;
3639
3640      if (table.headerRow) {
3641        var r = worksheet.getRow(row + count++);
3642        table.columns.forEach(function (column, j) {
3643          var style = column.style,
3644              name = column.name;
3645          var cell = r.getCell(col + j);
3646          cell.value = name;
3647          assignStyle(cell, style);
3648        });
3649      }
3650
3651      table.rows.forEach(function (data) {
3652        var r = worksheet.getRow(row + count++);
3653        data.forEach(function (value, j) {
3654          var cell = r.getCell(col + j);
3655          cell.value = value;
3656          assignStyle(cell, table.columns[j].style);
3657        });
3658      });
3659
3660      if (table.totalsRow) {
3661        var _r = worksheet.getRow(row + count++);
3662
3663        table.columns.forEach(function (column, j) {
3664          var cell = _r.getCell(col + j);
3665
3666          if (j === 0) {
3667            cell.value = column.totalsRowLabel;
3668          } else {
3669            var formula = _this2.getFormula(column);
3670
3671            if (formula) {
3672              cell.value = {
3673                formula: column.totalsRowFormula,
3674                result: column.totalsRowResult
3675              };
3676            } else {
3677              cell.value = null;
3678            }
3679          }
3680
3681          assignStyle(cell, column.style);
3682        });
3683      }
3684    }
3685  }, {
3686    key: "load",
3687    value: function load(worksheet) {
3688      var _this3 = this;
3689
3690      // where the table will read necessary features from a loaded sheet
3691      var table = this.table;
3692      var _table$tl3 = table.tl,
3693          row = _table$tl3.row,
3694          col = _table$tl3.col;
3695      var count = 0;
3696
3697      if (table.headerRow) {
3698        var r = worksheet.getRow(row + count++);
3699        table.columns.forEach(function (column, j) {
3700          var cell = r.getCell(col + j);
3701          cell.value = column.name;
3702        });
3703      }
3704
3705      table.rows.forEach(function (data) {
3706        var r = worksheet.getRow(row + count++);
3707        data.forEach(function (value, j) {
3708          var cell = r.getCell(col + j);
3709          cell.value = value;
3710        });
3711      });
3712
3713      if (table.totalsRow) {
3714        var _r2 = worksheet.getRow(row + count++);
3715
3716        table.columns.forEach(function (column, j) {
3717          var cell = _r2.getCell(col + j);
3718
3719          if (j === 0) {
3720            cell.value = column.totalsRowLabel;
3721          } else {
3722            var formula = _this3.getFormula(column);
3723
3724            if (formula) {
3725              cell.value = {
3726                formula: column.totalsRowFormula,
3727                result: column.totalsRowResult
3728              };
3729            }
3730          }
3731        });
3732      }
3733    }
3734  }, {
3735    key: "cacheState",
3736    // ================================================================
3737    // TODO: Mutating methods
3738    value: function cacheState() {
3739      if (!this._cache) {
3740        this._cache = {
3741          ref: this.ref,
3742          width: this.width,
3743          tableHeight: this.tableHeight
3744        };
3745      }
3746    }
3747  }, {
3748    key: "commit",
3749    value: function commit() {
3750      // changes may have been made that might have on-sheet effects
3751      if (!this._cache) {
3752        return;
3753      } // check things are ok first
3754
3755
3756      this.validate();
3757      var ref = colCache.decodeAddress(this._cache.ref);
3758
3759      if (this.ref !== this._cache.ref) {
3760        // wipe out whole table footprint at previous location
3761        for (var i = 0; i < this._cache.tableHeight; i++) {
3762          var row = this.worksheet.getRow(ref.row + i);
3763
3764          for (var j = 0; j < this._cache.width; j++) {
3765            var cell = row.getCell(ref.col + j);
3766            cell.value = null;
3767          }
3768        }
3769      } else {
3770        // clear out below table if it has shrunk
3771        for (var _i = this.tableHeight; _i < this._cache.tableHeight; _i++) {
3772          var _row = this.worksheet.getRow(ref.row + _i);
3773
3774          for (var _j = 0; _j < this._cache.width; _j++) {
3775            var _cell = _row.getCell(ref.col + _j);
3776
3777            _cell.value = null;
3778          }
3779        } // clear out to right of table if it has lost columns
3780
3781
3782        for (var _i2 = 0; _i2 < this.tableHeight; _i2++) {
3783          var _row2 = this.worksheet.getRow(ref.row + _i2);
3784
3785          for (var _j2 = this.width; _j2 < this._cache.width; _j2++) {
3786            var _cell2 = _row2.getCell(ref.col + _j2);
3787
3788            _cell2.value = null;
3789          }
3790        }
3791      }
3792
3793      this.store();
3794    }
3795  }, {
3796    key: "addRow",
3797    value: function addRow(values, rowNumber) {
3798      // Add a row of data, either insert at rowNumber or append
3799      this.cacheState();
3800
3801      if (rowNumber === undefined) {
3802        this.table.rows.push(values);
3803      } else {
3804        this.table.rows.splice(rowNumber, 0, values);
3805      }
3806    }
3807  }, {
3808    key: "removeRows",
3809    value: function removeRows(rowIndex) {
3810      var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
3811      // Remove a rows of data
3812      this.cacheState();
3813      this.table.rows.splice(rowIndex, count);
3814    }
3815  }, {
3816    key: "getColumn",
3817    value: function getColumn(colIndex) {
3818      var column = this.table.columns[colIndex];
3819      return new Column(this, column, colIndex);
3820    }
3821  }, {
3822    key: "addColumn",
3823    value: function addColumn(column, values, colIndex) {
3824      // Add a new column, including column defn and values
3825      // Inserts at colNumber or adds to the right
3826      this.cacheState();
3827
3828      if (colIndex === undefined) {
3829        this.table.columns.push(column);
3830        this.table.rows.forEach(function (row, i) {
3831          row.push(values[i]);
3832        });
3833      } else {
3834        this.table.columns.splice(colIndex, 0, column);
3835        this.table.rows.forEach(function (row, i) {
3836          row.splice(colIndex, 0, values[i]);
3837        });
3838      }
3839    }
3840  }, {
3841    key: "removeColumns",
3842    value: function removeColumns(colIndex) {
3843      var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
3844      // Remove a column with data
3845      this.cacheState();
3846      this.table.columns.splice(colIndex, count);
3847      this.table.rows.forEach(function (row) {
3848        row.splice(colIndex, count);
3849      });
3850    }
3851  }, {
3852    key: "_assign",
3853    value: function _assign(target, prop, value) {
3854      this.cacheState();
3855      target[prop] = value;
3856    }
3857    /* eslint-disable lines-between-class-members */
3858
3859  }, {
3860    key: "width",
3861    get: function get() {
3862      // width of the table
3863      return this.table.columns.length;
3864    }
3865  }, {
3866    key: "height",
3867    get: function get() {
3868      // height of the table data
3869      return this.table.rows.length;
3870    }
3871  }, {
3872    key: "filterHeight",
3873    get: function get() {
3874      // height of the table data plus optional header row
3875      return this.height + (this.table.headerRow ? 1 : 0);
3876    }
3877  }, {
3878    key: "tableHeight",
3879    get: function get() {
3880      // full height of the table on the sheet
3881      return this.filterHeight + (this.table.totalsRow ? 1 : 0);
3882    }
3883  }, {
3884    key: "model",
3885    get: function get() {
3886      return this.table;
3887    },
3888    set: function set(value) {
3889      this.table = value;
3890    }
3891  }, {
3892    key: "ref",
3893    get: function get() {
3894      return this.table.ref;
3895    },
3896    set: function set(value) {
3897      this._assign(this.table, 'ref', value);
3898    }
3899  }, {
3900    key: "name",
3901    get: function get() {
3902      return this.table.name;
3903    },
3904    set: function set(value) {
3905      this.table.name = value;
3906    }
3907  }, {
3908    key: "displayName",
3909    get: function get() {
3910      return this.table.displyName || this.table.name;
3911    }
3912  }, {
3913    key: "displayNamename",
3914    set: function set(value) {
3915      this.table.displayName = value;
3916    }
3917  }, {
3918    key: "headerRow",
3919    get: function get() {
3920      return this.table.headerRow;
3921    },
3922    set: function set(value) {
3923      this._assign(this.table, 'headerRow', value);
3924    }
3925  }, {
3926    key: "totalsRow",
3927    get: function get() {
3928      return this.table.totalsRow;
3929    },
3930    set: function set(value) {
3931      this._assign(this.table, 'totalsRow', value);
3932    }
3933  }, {
3934    key: "theme",
3935    get: function get() {
3936      return this.table.style.name;
3937    },
3938    set: function set(value) {
3939      this.table.style.name = value;
3940    }
3941  }, {
3942    key: "showFirstColumn",
3943    get: function get() {
3944      return this.table.style.showFirstColumn;
3945    },
3946    set: function set(value) {
3947      this.table.style.showFirstColumn = value;
3948    }
3949  }, {
3950    key: "showLastColumn",
3951    get: function get() {
3952      return this.table.style.showLastColumn;
3953    },
3954    set: function set(value) {
3955      this.table.style.showLastColumn = value;
3956    }
3957  }, {
3958    key: "showRowStripes",
3959    get: function get() {
3960      return this.table.style.showRowStripes;
3961    },
3962    set: function set(value) {
3963      this.table.style.showRowStripes = value;
3964    }
3965  }, {
3966    key: "showColumnStripes",
3967    get: function get() {
3968      return this.table.style.showColumnStripes;
3969    },
3970    set: function set(value) {
3971      this.table.style.showColumnStripes = value;
3972    }
3973    /* eslint-enable lines-between-class-members */
3974
3975  }]);
3976
3977  return Table;
3978}();
3979
3980module.exports = Table;
3981
3982},{"../utils/col-cache":19}],13:[function(require,module,exports){
3983'use strict';
3984
3985function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3986
3987function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3988
3989function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
3990
3991var Worksheet = require('./worksheet');
3992
3993var DefinedNames = require('./defined-names');
3994
3995var XLSX = require('../xlsx/xlsx');
3996
3997var CSV = require('../csv/csv'); // Workbook requirements
3998//  Load and Save from file and stream
3999//  Access/Add/Delete individual worksheets
4000//  Manage String table, Hyperlink table, etc.
4001//  Manage scaffolding for contained objects to write to/read from
4002
4003
4004var Workbook = /*#__PURE__*/function () {
4005  function Workbook() {
4006    _classCallCheck(this, Workbook);
4007
4008    this.category = '';
4009    this.company = '';
4010    this.created = new Date();
4011    this.description = '';
4012    this.keywords = '';
4013    this.manager = '';
4014    this.modified = this.created;
4015    this.properties = {};
4016    this.calcProperties = {};
4017    this._worksheets = [];
4018    this.subject = '';
4019    this.title = '';
4020    this.views = [];
4021    this.media = [];
4022    this._definedNames = new DefinedNames();
4023  }
4024
4025  _createClass(Workbook, [{
4026    key: "addWorksheet",
4027    value: function addWorksheet(name, options) {
4028      var id = this.nextId;
4029
4030      if (name && name.length > 31) {
4031        // eslint-disable-next-line no-console
4032        console.warn("Worksheet name ".concat(name, " exceeds 31 chars. This will be truncated"));
4033      } // Illegal character in worksheet name: asterisk (*), question mark (?),
4034      // colon (:), forward slash (/ \), or bracket ([])
4035
4036
4037      if (/[*?:/\\[\]]/.test(name)) {
4038        throw new Error("Worksheet name ".concat(name, " cannot include any of the following characters: * ? : \\ / [ ]"));
4039      }
4040
4041      if (/(^')|('$)/.test(name)) {
4042        throw new Error("The first or last character of worksheet name cannot be a single quotation mark: ".concat(name));
4043      }
4044
4045      name = (name || "sheet".concat(id)).substring(0, 31);
4046
4047      if (this._worksheets.find(function (ws) {
4048        return ws && ws.name.toLowerCase() === name.toLowerCase();
4049      })) {
4050        throw new Error("Worksheet name already exists: ".concat(name));
4051      } // if options is a color, call it tabColor (and signal deprecated message)
4052
4053
4054      if (options) {
4055        if (typeof options === 'string') {
4056          // eslint-disable-next-line no-console
4057          console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }');
4058          options = {
4059            properties: {
4060              tabColor: {
4061                argb: options
4062              }
4063            }
4064          };
4065        } else if (options.argb || options.theme || options.indexed) {
4066          // eslint-disable-next-line no-console
4067          console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }');
4068          options = {
4069            properties: {
4070              tabColor: options
4071            }
4072          };
4073        }
4074      }
4075
4076      var lastOrderNo = this._worksheets.reduce(function (acc, ws) {
4077        return (ws && ws.orderNo) > acc ? ws.orderNo : acc;
4078      }, 0);
4079
4080      var worksheetOptions = Object.assign({}, options, {
4081        id: id,
4082        name: name,
4083        orderNo: lastOrderNo + 1,
4084        workbook: this
4085      });
4086      var worksheet = new Worksheet(worksheetOptions);
4087      this._worksheets[id] = worksheet;
4088      return worksheet;
4089    }
4090  }, {
4091    key: "removeWorksheetEx",
4092    value: function removeWorksheetEx(worksheet) {
4093      delete this._worksheets[worksheet.id];
4094    }
4095  }, {
4096    key: "removeWorksheet",
4097    value: function removeWorksheet(id) {
4098      var worksheet = this.getWorksheet(id);
4099
4100      if (worksheet) {
4101        worksheet.destroy();
4102      }
4103    }
4104  }, {
4105    key: "getWorksheet",
4106    value: function getWorksheet(id) {
4107      if (id === undefined) {
4108        return this._worksheets.find(Boolean);
4109      }
4110
4111      if (typeof id === 'number') {
4112        return this._worksheets[id];
4113      }
4114
4115      if (typeof id === 'string') {
4116        return this._worksheets.find(function (worksheet) {
4117          return worksheet && worksheet.name === id;
4118        });
4119      }
4120
4121      return undefined;
4122    }
4123  }, {
4124    key: "eachSheet",
4125    value: function eachSheet(iteratee) {
4126      this.worksheets.forEach(function (sheet) {
4127        iteratee(sheet, sheet.id);
4128      });
4129    }
4130  }, {
4131    key: "clearThemes",
4132    value: function clearThemes() {
4133      // Note: themes are not an exposed feature, meddle at your peril!
4134      this._themes = undefined;
4135    }
4136  }, {
4137    key: "addImage",
4138    value: function addImage(image) {
4139      // TODO:  validation?
4140      var id = this.media.length;
4141      this.media.push(Object.assign({}, image, {
4142        type: 'image'
4143      }));
4144      return id;
4145    }
4146  }, {
4147    key: "getImage",
4148    value: function getImage(id) {
4149      return this.media[id];
4150    }
4151  }, {
4152    key: "xlsx",
4153    get: function get() {
4154      if (!this._xlsx) this._xlsx = new XLSX(this);
4155      return this._xlsx;
4156    }
4157  }, {
4158    key: "csv",
4159    get: function get() {
4160      if (!this._csv) this._csv = new CSV(this);
4161      return this._csv;
4162    }
4163  }, {
4164    key: "nextId",
4165    get: function get() {
4166      // find the next unique spot to add worksheet
4167      for (var i = 1; i < this._worksheets.length; i++) {
4168        if (!this._worksheets[i]) {
4169          return i;
4170        }
4171      }
4172
4173      return this._worksheets.length || 1;
4174    }
4175  }, {
4176    key: "worksheets",
4177    get: function get() {
4178      // return a clone of _worksheets
4179      return this._worksheets.slice(1).sort(function (a, b) {
4180        return a.orderNo - b.orderNo;
4181      }).filter(Boolean);
4182    }
4183  }, {
4184    key: "definedNames",
4185    get: function get() {
4186      return this._definedNames;
4187    }
4188  }, {
4189    key: "model",
4190    get: function get() {
4191      return {
4192        creator: this.creator || 'Unknown',
4193        lastModifiedBy: this.lastModifiedBy || 'Unknown',
4194        lastPrinted: this.lastPrinted,
4195        created: this.created,
4196        modified: this.modified,
4197        properties: this.properties,
4198        worksheets: this.worksheets.map(function (worksheet) {
4199          return worksheet.model;
4200        }),
4201        sheets: this.worksheets.map(function (ws) {
4202          return ws.model;
4203        }).filter(Boolean),
4204        definedNames: this._definedNames.model,
4205        views: this.views,
4206        company: this.company,
4207        manager: this.manager,
4208        title: this.title,
4209        subject: this.subject,
4210        keywords: this.keywords,
4211        category: this.category,
4212        description: this.description,
4213        language: this.language,
4214        revision: this.revision,
4215        contentStatus: this.contentStatus,
4216        themes: this._themes,
4217        media: this.media,
4218        calcProperties: this.calcProperties
4219      };
4220    },
4221    set: function set(value) {
4222      var _this = this;
4223
4224      this.creator = value.creator;
4225      this.lastModifiedBy = value.lastModifiedBy;
4226      this.lastPrinted = value.lastPrinted;
4227      this.created = value.created;
4228      this.modified = value.modified;
4229      this.company = value.company;
4230      this.manager = value.manager;
4231      this.title = value.title;
4232      this.subject = value.subject;
4233      this.keywords = value.keywords;
4234      this.category = value.category;
4235      this.description = value.description;
4236      this.language = value.language;
4237      this.revision = value.revision;
4238      this.contentStatus = value.contentStatus;
4239      this.properties = value.properties;
4240      this.calcProperties = value.calcProperties;
4241      this._worksheets = [];
4242      value.worksheets.forEach(function (worksheetModel) {
4243        var id = worksheetModel.id,
4244            name = worksheetModel.name,
4245            state = worksheetModel.state;
4246        var orderNo = value.sheets && value.sheets.findIndex(function (ws) {
4247          return ws.id === id;
4248        });
4249        var worksheet = _this._worksheets[id] = new Worksheet({
4250          id: id,
4251          name: name,
4252          orderNo: orderNo,
4253          state: state,
4254          workbook: _this
4255        });
4256        worksheet.model = worksheetModel;
4257      });
4258      this._definedNames.model = value.definedNames;
4259      this.views = value.views;
4260      this._themes = value.themes;
4261      this.media = value.media || [];
4262    }
4263  }]);
4264
4265  return Workbook;
4266}();
4267
4268module.exports = Workbook;
4269
4270},{"../csv/csv":1,"../xlsx/xlsx":141,"./defined-names":6,"./worksheet":14}],14:[function(require,module,exports){
4271"use strict";
4272
4273function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4274
4275function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4276
4277function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4278
4279function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4280
4281function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4282
4283function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4284
4285function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
4286
4287function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
4288
4289function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
4290
4291function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4292
4293function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4294
4295function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
4296
4297var _ = require('../utils/under-dash');
4298
4299var colCache = require('../utils/col-cache');
4300
4301var Range = require('./range');
4302
4303var Row = require('./row');
4304
4305var Column = require('./column');
4306
4307var Enums = require('./enums');
4308
4309var Image = require('./image');
4310
4311var Table = require('./table');
4312
4313var DataValidations = require('./data-validations');
4314
4315var Encryptor = require('../utils/encryptor'); // Worksheet requirements
4316//  Operate as sheet inside workbook or standalone
4317//  Load and Save from file and stream
4318//  Access/Add/Delete individual cells
4319//  Manage column widths and row heights
4320
4321
4322var Worksheet = /*#__PURE__*/function () {
4323  function Worksheet(options) {
4324    _classCallCheck(this, Worksheet);
4325
4326    options = options || {}; // in a workbook, each sheet will have a number
4327
4328    this.id = options.id;
4329    this.orderNo = options.orderNo; // and a name
4330
4331    this.name = options.name || "Sheet".concat(this.id); // add a state
4332
4333    this.state = options.state || 'visible'; // rows allows access organised by row. Sparse array of arrays indexed by row-1, col
4334    // Note: _rows is zero based. Must subtract 1 to go from cell.row to index
4335
4336    this._rows = []; // column definitions
4337
4338    this._columns = null; // column keys (addRow convenience): key ==> this._collumns index
4339
4340    this._keys = {}; // keep record of all merges
4341
4342    this._merges = {}; // record of all row and column pageBreaks
4343
4344    this.rowBreaks = [];
4345    this._workbook = options.workbook; // for tabColor, default row height, outline levels, etc
4346
4347    this.properties = Object.assign({}, {
4348      defaultRowHeight: 15,
4349      dyDescent: 55,
4350      outlineLevelCol: 0,
4351      outlineLevelRow: 0
4352    }, options.properties); // for all things printing
4353
4354    this.pageSetup = Object.assign({}, {
4355      margins: {
4356        left: 0.7,
4357        right: 0.7,
4358        top: 0.75,
4359        bottom: 0.75,
4360        header: 0.3,
4361        footer: 0.3
4362      },
4363      orientation: 'portrait',
4364      horizontalDpi: 4294967295,
4365      verticalDpi: 4294967295,
4366      fitToPage: !!(options.pageSetup && (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && !options.pageSetup.scale),
4367      pageOrder: 'downThenOver',
4368      blackAndWhite: false,
4369      draft: false,
4370      cellComments: 'None',
4371      errors: 'displayed',
4372      scale: 100,
4373      fitToWidth: 1,
4374      fitToHeight: 1,
4375      paperSize: undefined,
4376      showRowColHeaders: false,
4377      showGridLines: false,
4378      firstPageNumber: undefined,
4379      horizontalCentered: false,
4380      verticalCentered: false,
4381      rowBreaks: null,
4382      colBreaks: null
4383    }, options.pageSetup);
4384    this.headerFooter = Object.assign({}, {
4385      differentFirst: false,
4386      differentOddEven: false,
4387      oddHeader: null,
4388      oddFooter: null,
4389      evenHeader: null,
4390      evenFooter: null,
4391      firstHeader: null,
4392      firstFooter: null
4393    }, options.headerFooter);
4394    this.dataValidations = new DataValidations(); // for freezepanes, split, zoom, gridlines, etc
4395
4396    this.views = options.views || [];
4397    this.autoFilter = options.autoFilter || null; // for images, etc
4398
4399    this._media = []; // worksheet protection
4400
4401    this.sheetProtection = null; // for tables
4402
4403    this.tables = {};
4404    this.conditionalFormattings = [];
4405  }
4406
4407  _createClass(Worksheet, [{
4408    key: "destroy",
4409    // when you're done with this worksheet, call this to remove from workbook
4410    value: function destroy() {
4411      this._workbook.removeWorksheetEx(this);
4412    } // Get the bounding range of the cells in this worksheet
4413
4414  }, {
4415    key: "getColumnKey",
4416    value: function getColumnKey(key) {
4417      return this._keys[key];
4418    }
4419  }, {
4420    key: "setColumnKey",
4421    value: function setColumnKey(key, value) {
4422      this._keys[key] = value;
4423    }
4424  }, {
4425    key: "deleteColumnKey",
4426    value: function deleteColumnKey(key) {
4427      delete this._keys[key];
4428    }
4429  }, {
4430    key: "eachColumnKey",
4431    value: function eachColumnKey(f) {
4432      _.each(this._keys, f);
4433    } // get a single column by col number. If it doesn't exist, create it and any gaps before it
4434
4435  }, {
4436    key: "getColumn",
4437    value: function getColumn(c) {
4438      if (typeof c === 'string') {
4439        // if it matches a key'd column, return that
4440        var col = this._keys[c];
4441        if (col) return col; // otherwise, assume letter
4442
4443        c = colCache.l2n(c);
4444      }
4445
4446      if (!this._columns) {
4447        this._columns = [];
4448      }
4449
4450      if (c > this._columns.length) {
4451        var n = this._columns.length + 1;
4452
4453        while (n <= c) {
4454          this._columns.push(new Column(this, n++));
4455        }
4456      }
4457
4458      return this._columns[c - 1];
4459    }
4460  }, {
4461    key: "spliceColumns",
4462    value: function spliceColumns(start, count) {
4463      var _this = this;
4464
4465      var rows = this._rows;
4466      var nRows = rows.length;
4467
4468      for (var _len = arguments.length, inserts = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
4469        inserts[_key - 2] = arguments[_key];
4470      }
4471
4472      if (inserts.length > 0) {
4473        var _loop = function _loop(i) {
4474          var rowArguments = [start, count]; // eslint-disable-next-line no-loop-func
4475
4476          inserts.forEach(function (insert) {
4477            rowArguments.push(insert[i] || null);
4478          });
4479
4480          var row = _this.getRow(i + 1); // eslint-disable-next-line prefer-spread
4481
4482
4483          row.splice.apply(row, rowArguments);
4484        };
4485
4486        // must iterate over all rows whether they exist yet or not
4487        for (var i = 0; i < nRows; i++) {
4488          _loop(i);
4489        }
4490      } else {
4491        // nothing to insert, so just splice all rows
4492        this._rows.forEach(function (r) {
4493          if (r) {
4494            r.splice(start, count);
4495          }
4496        });
4497      } // splice column definitions
4498
4499
4500      var nExpand = inserts.length - count;
4501      var nKeep = start + count;
4502      var nEnd = this._columns.length;
4503
4504      if (nExpand < 0) {
4505        for (var _i = start + inserts.length; _i <= nEnd; _i++) {
4506          this.getColumn(_i).defn = this.getColumn(_i - nExpand).defn;
4507        }
4508      } else if (nExpand > 0) {
4509        for (var _i2 = nEnd; _i2 >= nKeep; _i2--) {
4510          this.getColumn(_i2 + nExpand).defn = this.getColumn(_i2).defn;
4511        }
4512      }
4513
4514      for (var _i3 = start; _i3 < start + inserts.length; _i3++) {
4515        this.getColumn(_i3).defn = null;
4516      } // account for defined names
4517
4518
4519      this.workbook.definedNames.spliceColumns(this.name, start, count, inserts.length);
4520    }
4521  }, {
4522    key: "_commitRow",
4523    // =========================================================================
4524    // Rows
4525    value: function _commitRow() {// nop - allows streaming reader to fill a document
4526    }
4527  }, {
4528    key: "findRow",
4529    // find a row (if exists) by row number
4530    value: function findRow(r) {
4531      return this._rows[r - 1];
4532    } // find multiple rows (if exists) by row number
4533
4534  }, {
4535    key: "findRows",
4536    value: function findRows(start, length) {
4537      return this._rows.slice(start - 1, start - 1 + length);
4538    }
4539  }, {
4540    key: "getRow",
4541    // get a row by row number.
4542    value: function getRow(r) {
4543      var row = this._rows[r - 1];
4544
4545      if (!row) {
4546        row = this._rows[r - 1] = new Row(this, r);
4547      }
4548
4549      return row;
4550    } // get multiple rows by row number.
4551
4552  }, {
4553    key: "getRows",
4554    value: function getRows(start, length) {
4555      if (length < 1) return undefined;
4556      var rows = [];
4557
4558      for (var i = start; i < start + length; i++) {
4559        rows.push(this.getRow(i));
4560      }
4561
4562      return rows;
4563    }
4564  }, {
4565    key: "addRow",
4566    value: function addRow(value) {
4567      var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n';
4568      var rowNo = this._nextRow;
4569      var row = this.getRow(rowNo);
4570      row.values = value;
4571
4572      this._setStyleOption(rowNo, style[0] === 'i' ? style : 'n');
4573
4574      return row;
4575    }
4576  }, {
4577    key: "addRows",
4578    value: function addRows(value) {
4579      var _this2 = this;
4580
4581      var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n';
4582      var rows = [];
4583      value.forEach(function (row) {
4584        rows.push(_this2.addRow(row, style));
4585      });
4586      return rows;
4587    }
4588  }, {
4589    key: "insertRow",
4590    value: function insertRow(pos, value) {
4591      var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n';
4592      this.spliceRows(pos, 0, value);
4593
4594      this._setStyleOption(pos, style);
4595
4596      return this.getRow(pos);
4597    }
4598  }, {
4599    key: "insertRows",
4600    value: function insertRows(pos, values) {
4601      var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n';
4602      this.spliceRows.apply(this, [pos, 0].concat(_toConsumableArray(values)));
4603
4604      if (style !== 'n') {
4605        // copy over the styles
4606        for (var i = 0; i < values.length; i++) {
4607          if (style[0] === 'o' && this.findRow(values.length + pos + i) !== undefined) {
4608            this._copyStyle(values.length + pos + i, pos + i, style[1] === '+');
4609          } else if (style[0] === 'i' && this.findRow(pos - 1) !== undefined) {
4610            this._copyStyle(pos - 1, pos + i, style[1] === '+');
4611          }
4612        }
4613      }
4614
4615      return this.getRows(pos, values.length);
4616    } // set row at position to same style as of either pervious row (option 'i') or next row (option 'o')
4617
4618  }, {
4619    key: "_setStyleOption",
4620    value: function _setStyleOption(pos) {
4621      var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n';
4622
4623      if (style[0] === 'o' && this.findRow(pos + 1) !== undefined) {
4624        this._copyStyle(pos + 1, pos, style[1] === '+');
4625      } else if (style[0] === 'i' && this.findRow(pos - 1) !== undefined) {
4626        this._copyStyle(pos - 1, pos, style[1] === '+');
4627      }
4628    }
4629  }, {
4630    key: "_copyStyle",
4631    value: function _copyStyle(src, dest) {
4632      var styleEmpty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4633      var rSrc = this.getRow(src);
4634      var rDst = this.getRow(dest);
4635      rDst.style = Object.freeze(_objectSpread({}, rSrc.style)); // eslint-disable-next-line no-loop-func
4636
4637      rSrc.eachCell({
4638        includeEmpty: styleEmpty
4639      }, function (cell, colNumber) {
4640        rDst.getCell(colNumber).style = Object.freeze(_objectSpread({}, cell.style));
4641      });
4642      rDst.height = rSrc.height;
4643    }
4644  }, {
4645    key: "duplicateRow",
4646    value: function duplicateRow(rowNum, count) {
4647      var _this3 = this;
4648
4649      var insert = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4650      // create count duplicates of rowNum
4651      // either inserting new or overwriting existing rows
4652      var rSrc = this._rows[rowNum - 1];
4653      var inserts = new Array(count).fill(rSrc.values);
4654      this.spliceRows.apply(this, [rowNum + 1, insert ? 0 : count].concat(_toConsumableArray(inserts))); // now copy styles...
4655
4656      var _loop2 = function _loop2(i) {
4657        var rDst = _this3._rows[rowNum + i];
4658        rDst.style = rSrc.style;
4659        rDst.height = rSrc.height; // eslint-disable-next-line no-loop-func
4660
4661        rSrc.eachCell({
4662          includeEmpty: true
4663        }, function (cell, colNumber) {
4664          rDst.getCell(colNumber).style = cell.style;
4665        });
4666      };
4667
4668      for (var i = 0; i < count; i++) {
4669        _loop2(i);
4670      }
4671    }
4672  }, {
4673    key: "spliceRows",
4674    value: function spliceRows(start, count) {
4675      var _this4 = this;
4676
4677      // same problem as row.splice, except worse.
4678      var nKeep = start + count;
4679
4680      for (var _len2 = arguments.length, inserts = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
4681        inserts[_key2 - 2] = arguments[_key2];
4682      }
4683
4684      var nInserts = inserts.length;
4685      var nExpand = nInserts - count;
4686      var nEnd = this._rows.length;
4687      var i;
4688      var rSrc;
4689
4690      if (nExpand < 0) {
4691        // remove rows
4692        for (i = nKeep; i <= nEnd; i++) {
4693          rSrc = this._rows[i - 1];
4694
4695          if (rSrc) {
4696            (function () {
4697              var rDst = _this4.getRow(i + nExpand);
4698
4699              rDst.values = rSrc.values;
4700              rDst.style = rSrc.style;
4701              rDst.height = rSrc.height; // eslint-disable-next-line no-loop-func
4702
4703              rSrc.eachCell({
4704                includeEmpty: true
4705              }, function (cell, colNumber) {
4706                rDst.getCell(colNumber).style = cell.style;
4707              });
4708              _this4._rows[i - 1] = undefined;
4709            })();
4710          } else {
4711            this._rows[i + nExpand - 1] = undefined;
4712          }
4713        }
4714      } else if (nExpand > 0) {
4715        // insert new cells
4716        for (i = nEnd; i >= nKeep; i--) {
4717          rSrc = this._rows[i - 1];
4718
4719          if (rSrc) {
4720            (function () {
4721              var rDst = _this4.getRow(i + nExpand);
4722
4723              rDst.values = rSrc.values;
4724              rDst.style = rSrc.style;
4725              rDst.height = rSrc.height; // eslint-disable-next-line no-loop-func
4726
4727              rSrc.eachCell({
4728                includeEmpty: true
4729              }, function (cell, colNumber) {
4730                rDst.getCell(colNumber).style = cell.style; // remerge cells accounting for insert offset
4731
4732                if (cell._value.constructor.name === 'MergeValue') {
4733                  var cellToBeMerged = _this4.getRow(cell._row._number + nInserts).getCell(colNumber);
4734
4735                  var prevMaster = cell._value._master;
4736
4737                  var newMaster = _this4.getRow(prevMaster._row._number + nInserts).getCell(prevMaster._column._number);
4738
4739                  cellToBeMerged.merge(newMaster);
4740                }
4741              });
4742            })();
4743          } else {
4744            this._rows[i + nExpand - 1] = undefined;
4745          }
4746        }
4747      } // now copy over the new values
4748
4749
4750      for (i = 0; i < nInserts; i++) {
4751        var rDst = this.getRow(start + i);
4752        rDst.style = {};
4753        rDst.values = inserts[i];
4754      } // account for defined names
4755
4756
4757      this.workbook.definedNames.spliceRows(this.name, start, count, nInserts);
4758    } // iterate over every row in the worksheet, including maybe empty rows
4759
4760  }, {
4761    key: "eachRow",
4762    value: function eachRow(options, iteratee) {
4763      if (!iteratee) {
4764        iteratee = options;
4765        options = undefined;
4766      }
4767
4768      if (options && options.includeEmpty) {
4769        var n = this._rows.length;
4770
4771        for (var i = 1; i <= n; i++) {
4772          iteratee(this.getRow(i), i);
4773        }
4774      } else {
4775        this._rows.forEach(function (row) {
4776          if (row && row.hasValues) {
4777            iteratee(row, row.number);
4778          }
4779        });
4780      }
4781    } // return all rows as sparse array
4782
4783  }, {
4784    key: "getSheetValues",
4785    value: function getSheetValues() {
4786      var rows = [];
4787
4788      this._rows.forEach(function (row) {
4789        if (row) {
4790          rows[row.number] = row.values;
4791        }
4792      });
4793
4794      return rows;
4795    } // =========================================================================
4796    // Cells
4797    // returns the cell at [r,c] or address given by r. If not found, return undefined
4798
4799  }, {
4800    key: "findCell",
4801    value: function findCell(r, c) {
4802      var address = colCache.getAddress(r, c);
4803      var row = this._rows[address.row - 1];
4804      return row ? row.findCell(address.col) : undefined;
4805    } // return the cell at [r,c] or address given by r. If not found, create a new one.
4806
4807  }, {
4808    key: "getCell",
4809    value: function getCell(r, c) {
4810      var address = colCache.getAddress(r, c);
4811      var row = this.getRow(address.row);
4812      return row.getCellEx(address);
4813    } // =========================================================================
4814    // Merge
4815    // convert the range defined by ['tl:br'], [tl,br] or [t,l,b,r] into a single 'merged' cell
4816
4817  }, {
4818    key: "mergeCells",
4819    value: function mergeCells() {
4820      for (var _len3 = arguments.length, cells = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
4821        cells[_key3] = arguments[_key3];
4822      }
4823
4824      var dimensions = new Range(cells);
4825
4826      this._mergeCellsInternal(dimensions);
4827    }
4828  }, {
4829    key: "mergeCellsWithoutStyle",
4830    value: function mergeCellsWithoutStyle() {
4831      for (var _len4 = arguments.length, cells = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
4832        cells[_key4] = arguments[_key4];
4833      }
4834
4835      var dimensions = new Range(cells);
4836
4837      this._mergeCellsInternal(dimensions, true);
4838    }
4839  }, {
4840    key: "_mergeCellsInternal",
4841    value: function _mergeCellsInternal(dimensions, ignoreStyle) {
4842      // check cells aren't already merged
4843      _.each(this._merges, function (merge) {
4844        if (merge.intersects(dimensions)) {
4845          throw new Error('Cannot merge already merged cells');
4846        }
4847      }); // apply merge
4848
4849
4850      var master = this.getCell(dimensions.top, dimensions.left);
4851
4852      for (var i = dimensions.top; i <= dimensions.bottom; i++) {
4853        for (var j = dimensions.left; j <= dimensions.right; j++) {
4854          // merge all but the master cell
4855          if (i > dimensions.top || j > dimensions.left) {
4856            this.getCell(i, j).merge(master, ignoreStyle);
4857          }
4858        }
4859      } // index merge
4860
4861
4862      this._merges[master.address] = dimensions;
4863    }
4864  }, {
4865    key: "_unMergeMaster",
4866    value: function _unMergeMaster(master) {
4867      // master is always top left of a rectangle
4868      var merge = this._merges[master.address];
4869
4870      if (merge) {
4871        for (var i = merge.top; i <= merge.bottom; i++) {
4872          for (var j = merge.left; j <= merge.right; j++) {
4873            this.getCell(i, j).unmerge();
4874          }
4875        }
4876
4877        delete this._merges[master.address];
4878      }
4879    }
4880  }, {
4881    key: "unMergeCells",
4882    // scan the range defined by ['tl:br'], [tl,br] or [t,l,b,r] and if any cell is part of a merge,
4883    // un-merge the group. Note this function can affect multiple merges and merge-blocks are
4884    // atomic - either they're all merged or all un-merged.
4885    value: function unMergeCells() {
4886      for (var _len5 = arguments.length, cells = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
4887        cells[_key5] = arguments[_key5];
4888      }
4889
4890      var dimensions = new Range(cells); // find any cells in that range and unmerge them
4891
4892      for (var i = dimensions.top; i <= dimensions.bottom; i++) {
4893        for (var j = dimensions.left; j <= dimensions.right; j++) {
4894          var cell = this.findCell(i, j);
4895
4896          if (cell) {
4897            if (cell.type === Enums.ValueType.Merge) {
4898              // this cell merges to another master
4899              this._unMergeMaster(cell.master);
4900            } else if (this._merges[cell.address]) {
4901              // this cell is a master
4902              this._unMergeMaster(cell);
4903            }
4904          }
4905        }
4906      }
4907    } // ===========================================================================
4908    // Shared/Array Formula
4909
4910  }, {
4911    key: "fillFormula",
4912    value: function fillFormula(range, formula, results) {
4913      var shareType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'shared';
4914      // Define formula for top-left cell and share to rest
4915      var decoded = colCache.decode(range);
4916      var top = decoded.top,
4917          left = decoded.left,
4918          bottom = decoded.bottom,
4919          right = decoded.right;
4920      var width = right - left + 1;
4921      var masterAddress = colCache.encodeAddress(top, left);
4922      var isShared = shareType === 'shared'; // work out result accessor
4923
4924      var getResult;
4925
4926      if (typeof results === 'function') {
4927        getResult = results;
4928      } else if (Array.isArray(results)) {
4929        if (Array.isArray(results[0])) {
4930          getResult = function getResult(row, col) {
4931            return results[row - top][col - left];
4932          };
4933        } else {
4934          // eslint-disable-next-line no-mixed-operators
4935          getResult = function getResult(row, col) {
4936            return results[(row - top) * width + (col - left)];
4937          };
4938        }
4939      } else {
4940        getResult = function getResult() {
4941          return undefined;
4942        };
4943      }
4944
4945      var first = true;
4946
4947      for (var r = top; r <= bottom; r++) {
4948        for (var c = left; c <= right; c++) {
4949          if (first) {
4950            this.getCell(r, c).value = {
4951              shareType: shareType,
4952              formula: formula,
4953              ref: range,
4954              result: getResult(r, c)
4955            };
4956            first = false;
4957          } else {
4958            this.getCell(r, c).value = isShared ? {
4959              sharedFormula: masterAddress,
4960              result: getResult(r, c)
4961            } : getResult(r, c);
4962          }
4963        }
4964      }
4965    } // =========================================================================
4966    // Images
4967
4968  }, {
4969    key: "addImage",
4970    value: function addImage(imageId, range) {
4971      var model = {
4972        type: 'image',
4973        imageId: imageId,
4974        range: range
4975      };
4976
4977      this._media.push(new Image(this, model));
4978    }
4979  }, {
4980    key: "getImages",
4981    value: function getImages() {
4982      return this._media.filter(function (m) {
4983        return m.type === 'image';
4984      });
4985    }
4986  }, {
4987    key: "addBackgroundImage",
4988    value: function addBackgroundImage(imageId) {
4989      var model = {
4990        type: 'background',
4991        imageId: imageId
4992      };
4993
4994      this._media.push(new Image(this, model));
4995    }
4996  }, {
4997    key: "getBackgroundImageId",
4998    value: function getBackgroundImageId() {
4999      var image = this._media.find(function (m) {
5000        return m.type === 'background';
5001      });
5002
5003      return image && image.imageId;
5004    } // =========================================================================
5005    // Worksheet Protection
5006
5007  }, {
5008    key: "protect",
5009    value: function protect(password, options) {
5010      var _this5 = this;
5011
5012      // TODO: make this function truly async
5013      // perhaps marshal to worker thread or something
5014      return new Promise(function (resolve) {
5015        _this5.sheetProtection = {
5016          sheet: true
5017        };
5018
5019        if (options && 'spinCount' in options) {
5020          // force spinCount to be integer >= 0
5021          options.spinCount = Number.isFinite(options.spinCount) ? Math.round(Math.max(0, options.spinCount)) : 100000;
5022        }
5023
5024        if (password) {
5025          _this5.sheetProtection.algorithmName = 'SHA-512';
5026          _this5.sheetProtection.saltValue = Encryptor.randomBytes(16).toString('base64');
5027          _this5.sheetProtection.spinCount = options && 'spinCount' in options ? options.spinCount : 100000; // allow user specified spinCount
5028
5029          _this5.sheetProtection.hashValue = Encryptor.convertPasswordToHash(password, 'SHA512', _this5.sheetProtection.saltValue, _this5.sheetProtection.spinCount);
5030        }
5031
5032        if (options) {
5033          _this5.sheetProtection = Object.assign(_this5.sheetProtection, options);
5034
5035          if (!password && 'spinCount' in options) {
5036            delete _this5.sheetProtection.spinCount;
5037          }
5038        }
5039
5040        resolve();
5041      });
5042    }
5043  }, {
5044    key: "unprotect",
5045    value: function unprotect() {
5046      this.sheetProtection = null;
5047    } // =========================================================================
5048    // Tables
5049
5050  }, {
5051    key: "addTable",
5052    value: function addTable(model) {
5053      var table = new Table(this, model);
5054      this.tables[model.name] = table;
5055      return table;
5056    }
5057  }, {
5058    key: "getTable",
5059    value: function getTable(name) {
5060      return this.tables[name];
5061    }
5062  }, {
5063    key: "removeTable",
5064    value: function removeTable(name) {
5065      delete this.tables[name];
5066    }
5067  }, {
5068    key: "getTables",
5069    value: function getTables() {
5070      return Object.values(this.tables);
5071    } // ===========================================================================
5072    // Conditional Formatting
5073
5074  }, {
5075    key: "addConditionalFormatting",
5076    value: function addConditionalFormatting(cf) {
5077      this.conditionalFormattings.push(cf);
5078    }
5079  }, {
5080    key: "removeConditionalFormatting",
5081    value: function removeConditionalFormatting(filter) {
5082      if (typeof filter === 'number') {
5083        this.conditionalFormattings.splice(filter, 1);
5084      } else if (filter instanceof Function) {
5085        this.conditionalFormattings = this.conditionalFormattings.filter(filter);
5086      } else {
5087        this.conditionalFormattings = [];
5088      }
5089    } // ===========================================================================
5090    // Deprecated
5091
5092  }, {
5093    key: "_parseRows",
5094    value: function _parseRows(model) {
5095      var _this6 = this;
5096
5097      this._rows = [];
5098      model.rows.forEach(function (rowModel) {
5099        var row = new Row(_this6, rowModel.number);
5100        _this6._rows[row.number - 1] = row;
5101        row.model = rowModel;
5102      });
5103    }
5104  }, {
5105    key: "_parseMergeCells",
5106    value: function _parseMergeCells(model) {
5107      var _this7 = this;
5108
5109      _.each(model.mergeCells, function (merge) {
5110        // Do not merge styles when importing an Excel file
5111        // since each cell may have different styles intentionally.
5112        _this7.mergeCellsWithoutStyle(merge);
5113      });
5114    }
5115  }, {
5116    key: "workbook",
5117    get: function get() {
5118      return this._workbook;
5119    }
5120  }, {
5121    key: "dimensions",
5122    get: function get() {
5123      var dimensions = new Range();
5124
5125      this._rows.forEach(function (row) {
5126        if (row) {
5127          var rowDims = row.dimensions;
5128
5129          if (rowDims) {
5130            dimensions.expand(row.number, rowDims.min, row.number, rowDims.max);
5131          }
5132        }
5133      });
5134
5135      return dimensions;
5136    } // =========================================================================
5137    // Columns
5138    // get the current columns array.
5139
5140  }, {
5141    key: "columns",
5142    get: function get() {
5143      return this._columns;
5144    } // set the columns from an array of column definitions.
5145    // Note: any headers defined will overwrite existing values.
5146    ,
5147    set: function set(value) {
5148      var _this8 = this;
5149
5150      // calculate max header row count
5151      this._headerRowCount = value.reduce(function (pv, cv) {
5152        var headerCount = cv.header && 1 || cv.headers && cv.headers.length || 0;
5153        return Math.max(pv, headerCount);
5154      }, 0); // construct Column objects
5155
5156      var count = 1;
5157      var columns = this._columns = [];
5158      value.forEach(function (defn) {
5159        var column = new Column(_this8, count++, false);
5160        columns.push(column);
5161        column.defn = defn;
5162      });
5163    }
5164  }, {
5165    key: "lastColumn",
5166    get: function get() {
5167      return this.getColumn(this.columnCount);
5168    }
5169  }, {
5170    key: "columnCount",
5171    get: function get() {
5172      var maxCount = 0;
5173      this.eachRow(function (row) {
5174        maxCount = Math.max(maxCount, row.cellCount);
5175      });
5176      return maxCount;
5177    }
5178  }, {
5179    key: "actualColumnCount",
5180    get: function get() {
5181      // performance nightmare - for each row, counts all the columns used
5182      var counts = [];
5183      var count = 0;
5184      this.eachRow(function (row) {
5185        row.eachCell(function (_ref) {
5186          var col = _ref.col;
5187
5188          if (!counts[col]) {
5189            counts[col] = true;
5190            count++;
5191          }
5192        });
5193      });
5194      return count;
5195    }
5196  }, {
5197    key: "_lastRowNumber",
5198    get: function get() {
5199      // need to cope with results of splice
5200      var rows = this._rows;
5201      var n = rows.length;
5202
5203      while (n > 0 && rows[n - 1] === undefined) {
5204        n--;
5205      }
5206
5207      return n;
5208    }
5209  }, {
5210    key: "_nextRow",
5211    get: function get() {
5212      return this._lastRowNumber + 1;
5213    }
5214  }, {
5215    key: "lastRow",
5216    get: function get() {
5217      if (this._rows.length) {
5218        return this._rows[this._rows.length - 1];
5219      }
5220
5221      return undefined;
5222    }
5223  }, {
5224    key: "rowCount",
5225    get: function get() {
5226      return this._lastRowNumber;
5227    }
5228  }, {
5229    key: "actualRowCount",
5230    get: function get() {
5231      // counts actual rows that have actual data
5232      var count = 0;
5233      this.eachRow(function () {
5234        count++;
5235      });
5236      return count;
5237    }
5238  }, {
5239    key: "hasMerges",
5240    get: function get() {
5241      // return true if this._merges has a merge object
5242      return _.some(this._merges, Boolean);
5243    }
5244  }, {
5245    key: "tabColor",
5246    get: function get() {
5247      // eslint-disable-next-line no-console
5248      console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor');
5249      return this.properties.tabColor;
5250    },
5251    set: function set(value) {
5252      // eslint-disable-next-line no-console
5253      console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor');
5254      this.properties.tabColor = value;
5255    } // ===========================================================================
5256    // Model
5257
5258  }, {
5259    key: "model",
5260    get: function get() {
5261      var model = {
5262        id: this.id,
5263        name: this.name,
5264        dataValidations: this.dataValidations.model,
5265        properties: this.properties,
5266        state: this.state,
5267        pageSetup: this.pageSetup,
5268        headerFooter: this.headerFooter,
5269        rowBreaks: this.rowBreaks,
5270        views: this.views,
5271        autoFilter: this.autoFilter,
5272        media: this._media.map(function (medium) {
5273          return medium.model;
5274        }),
5275        sheetProtection: this.sheetProtection,
5276        tables: Object.values(this.tables).map(function (table) {
5277          return table.model;
5278        }),
5279        conditionalFormattings: this.conditionalFormattings
5280      }; // =================================================
5281      // columns
5282
5283      model.cols = Column.toModel(this.columns); // ==========================================================
5284      // Rows
5285
5286      var rows = model.rows = [];
5287      var dimensions = model.dimensions = new Range();
5288
5289      this._rows.forEach(function (row) {
5290        var rowModel = row && row.model;
5291
5292        if (rowModel) {
5293          dimensions.expand(rowModel.number, rowModel.min, rowModel.number, rowModel.max);
5294          rows.push(rowModel);
5295        }
5296      }); // ==========================================================
5297      // Merges
5298
5299
5300      model.merges = [];
5301
5302      _.each(this._merges, function (merge) {
5303        model.merges.push(merge.range);
5304      });
5305
5306      return model;
5307    },
5308    set: function set(value) {
5309      var _this9 = this;
5310
5311      this.name = value.name;
5312      this._columns = Column.fromModel(this, value.cols);
5313
5314      this._parseRows(value);
5315
5316      this._parseMergeCells(value);
5317
5318      this.dataValidations = new DataValidations(value.dataValidations);
5319      this.properties = value.properties;
5320      this.pageSetup = value.pageSetup;
5321      this.headerFooter = value.headerFooter;
5322      this.views = value.views;
5323      this.autoFilter = value.autoFilter;
5324      this._media = value.media.map(function (medium) {
5325        return new Image(_this9, medium);
5326      });
5327      this.sheetProtection = value.sheetProtection;
5328      this.tables = value.tables.reduce(function (tables, table) {
5329        var t = new Table();
5330        t.model = table;
5331        tables[table.name] = t;
5332        return tables;
5333      }, {});
5334      this.conditionalFormattings = value.conditionalFormattings;
5335    }
5336  }]);
5337
5338  return Worksheet;
5339}();
5340
5341module.exports = Worksheet;
5342
5343},{"../utils/col-cache":19,"../utils/encryptor":20,"../utils/under-dash":25,"./column":4,"./data-validations":5,"./enums":7,"./image":8,"./range":10,"./row":11,"./table":12}],15:[function(require,module,exports){
5344"use strict";
5345
5346/* eslint-disable import/no-extraneous-dependencies,node/no-unpublished-require */
5347require('core-js/modules/es.promise');
5348
5349require('core-js/modules/es.object.assign');
5350
5351require('core-js/modules/es.object.keys');
5352
5353require('core-js/modules/es.object.values');
5354
5355require('core-js/modules/es.symbol');
5356
5357require('core-js/modules/es.symbol.async-iterator'); // required by core-js/modules/es.promise Promise.all
5358
5359
5360require('core-js/modules/es.array.iterator'); // required by node_modules/saxes/saxes.js SaxesParser.captureTo
5361
5362
5363require('core-js/modules/es.array.includes'); // required by lib/doc/workbook.js Workbook.model
5364
5365
5366require('core-js/modules/es.array.find-index'); // required by lib/doc/workbook.js Workbook.addWorksheet and Workbook.getWorksheet
5367
5368
5369require('core-js/modules/es.array.find'); // required by node_modules/saxes/saxes.js SaxesParser.getCode10
5370
5371
5372require('core-js/modules/es.string.from-code-point'); // required by lib/xlsx/xform/sheet/data-validations-xform.js DataValidationsXform.parseClose
5373
5374
5375require('core-js/modules/es.string.includes'); // required by lib/utils/utils.js utils.validInt and lib/csv/csv.js CSV.read
5376
5377
5378require('core-js/modules/es.number.is-nan');
5379
5380require('regenerator-runtime/runtime');
5381
5382var ExcelJS = {
5383  Workbook: require('./doc/workbook')
5384}; // Object.assign mono-fill
5385
5386var Enums = require('./doc/enums');
5387
5388Object.keys(Enums).forEach(function (key) {
5389  ExcelJS[key] = Enums[key];
5390});
5391module.exports = ExcelJS;
5392
5393},{"./doc/enums":7,"./doc/workbook":13,"core-js/modules/es.array.find":316,"core-js/modules/es.array.find-index":315,"core-js/modules/es.array.includes":317,"core-js/modules/es.array.iterator":318,"core-js/modules/es.number.is-nan":319,"core-js/modules/es.object.assign":320,"core-js/modules/es.object.keys":321,"core-js/modules/es.object.values":322,"core-js/modules/es.promise":323,"core-js/modules/es.string.from-code-point":324,"core-js/modules/es.string.includes":325,"core-js/modules/es.symbol":327,"core-js/modules/es.symbol.async-iterator":326,"regenerator-runtime/runtime":492}],16:[function(require,module,exports){
5394"use strict";
5395
5396// eslint-disable-next-line node/no-unsupported-features/node-builtins
5397var textDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf-8');
5398
5399function bufferToString(chunk) {
5400  if (typeof chunk === 'string') {
5401    return chunk;
5402  }
5403
5404  if (textDecoder) {
5405    return textDecoder.decode(chunk);
5406  }
5407
5408  return chunk.toString();
5409}
5410
5411exports.bufferToString = bufferToString;
5412
5413},{}],17:[function(require,module,exports){
5414"use strict";
5415
5416// eslint-disable-next-line node/no-unsupported-features/node-builtins
5417var textEncoder = typeof TextEncoder === 'undefined' ? null : new TextEncoder('utf-8');
5418
5419var _require = require('buffer'),
5420    Buffer = _require.Buffer;
5421
5422function stringToBuffer(str) {
5423  if (typeof str !== 'string') {
5424    return str;
5425  }
5426
5427  if (textEncoder) {
5428    return Buffer.from(textEncoder.encode(str).buffer);
5429  }
5430
5431  return Buffer.from(str);
5432}
5433
5434exports.stringToBuffer = stringToBuffer;
5435
5436},{"buffer":216}],18:[function(require,module,exports){
5437"use strict";
5438
5439function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5440
5441function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
5442
5443function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5444
5445var _ = require('./under-dash');
5446
5447var colCache = require('./col-cache');
5448
5449var CellMatrix = /*#__PURE__*/function () {
5450  function CellMatrix(template) {
5451    _classCallCheck(this, CellMatrix);
5452
5453    this.template = template;
5454    this.sheets = {};
5455  }
5456
5457  _createClass(CellMatrix, [{
5458    key: "addCell",
5459    value: function addCell(addressStr) {
5460      this.addCellEx(colCache.decodeEx(addressStr));
5461    }
5462  }, {
5463    key: "getCell",
5464    value: function getCell(addressStr) {
5465      return this.findCellEx(colCache.decodeEx(addressStr), true);
5466    }
5467  }, {
5468    key: "findCell",
5469    value: function findCell(addressStr) {
5470      return this.findCellEx(colCache.decodeEx(addressStr), false);
5471    }
5472  }, {
5473    key: "findCellAt",
5474    value: function findCellAt(sheetName, rowNumber, colNumber) {
5475      var sheet = this.sheets[sheetName];
5476      var row = sheet && sheet[rowNumber];
5477      return row && row[colNumber];
5478    }
5479  }, {
5480    key: "addCellEx",
5481    value: function addCellEx(address) {
5482      if (address.top) {
5483        for (var row = address.top; row <= address.bottom; row++) {
5484          for (var col = address.left; col <= address.right; col++) {
5485            this.getCellAt(address.sheetName, row, col);
5486          }
5487        }
5488      } else {
5489        this.findCellEx(address, true);
5490      }
5491    }
5492  }, {
5493    key: "getCellEx",
5494    value: function getCellEx(address) {
5495      return this.findCellEx(address, true);
5496    }
5497  }, {
5498    key: "findCellEx",
5499    value: function findCellEx(address, create) {
5500      var sheet = this.findSheet(address, create);
5501      var row = this.findSheetRow(sheet, address, create);
5502      return this.findRowCell(row, address, create);
5503    }
5504  }, {
5505    key: "getCellAt",
5506    value: function getCellAt(sheetName, rowNumber, colNumber) {
5507      var sheet = this.sheets[sheetName] || (this.sheets[sheetName] = []);
5508      var row = sheet[rowNumber] || (sheet[rowNumber] = []);
5509      var cell = row[colNumber] || (row[colNumber] = {
5510        sheetName: sheetName,
5511        address: colCache.n2l(colNumber) + rowNumber,
5512        row: rowNumber,
5513        col: colNumber
5514      });
5515      return cell;
5516    }
5517  }, {
5518    key: "removeCellEx",
5519    value: function removeCellEx(address) {
5520      var sheet = this.findSheet(address);
5521
5522      if (!sheet) {
5523        return;
5524      }
5525
5526      var row = this.findSheetRow(sheet, address);
5527
5528      if (!row) {
5529        return;
5530      }
5531
5532      delete row[address.col];
5533    }
5534  }, {
5535    key: "forEachInSheet",
5536    value: function forEachInSheet(sheetName, callback) {
5537      var sheet = this.sheets[sheetName];
5538
5539      if (sheet) {
5540        sheet.forEach(function (row, rowNumber) {
5541          if (row) {
5542            row.forEach(function (cell, colNumber) {
5543              if (cell) {
5544                callback(cell, rowNumber, colNumber);
5545              }
5546            });
5547          }
5548        });
5549      }
5550    }
5551  }, {
5552    key: "forEach",
5553    value: function forEach(callback) {
5554      var _this = this;
5555
5556      _.each(this.sheets, function (sheet, sheetName) {
5557        _this.forEachInSheet(sheetName, callback);
5558      });
5559    }
5560  }, {
5561    key: "map",
5562    value: function map(callback) {
5563      var results = [];
5564      this.forEach(function (cell) {
5565        results.push(callback(cell));
5566      });
5567      return results;
5568    }
5569  }, {
5570    key: "findSheet",
5571    value: function findSheet(address, create) {
5572      var name = address.sheetName;
5573
5574      if (this.sheets[name]) {
5575        return this.sheets[name];
5576      }
5577
5578      if (create) {
5579        return this.sheets[name] = [];
5580      }
5581
5582      return undefined;
5583    }
5584  }, {
5585    key: "findSheetRow",
5586    value: function findSheetRow(sheet, address, create) {
5587      var row = address.row;
5588
5589      if (sheet && sheet[row]) {
5590        return sheet[row];
5591      }
5592
5593      if (create) {
5594        return sheet[row] = [];
5595      }
5596
5597      return undefined;
5598    }
5599  }, {
5600    key: "findRowCell",
5601    value: function findRowCell(row, address, create) {
5602      var col = address.col;
5603
5604      if (row && row[col]) {
5605        return row[col];
5606      }
5607
5608      if (create) {
5609        return row[col] = this.template ? Object.assign(address, JSON.parse(JSON.stringify(this.template))) : address;
5610      }
5611
5612      return undefined;
5613    }
5614  }, {
5615    key: "spliceRows",
5616    value: function spliceRows(sheetName, start, numDelete, numInsert) {
5617      var sheet = this.sheets[sheetName];
5618
5619      if (sheet) {
5620        var inserts = [];
5621
5622        for (var i = 0; i < numInsert; i++) {
5623          inserts.push([]);
5624        }
5625
5626        sheet.splice.apply(sheet, [start, numDelete].concat(inserts));
5627      }
5628    }
5629  }, {
5630    key: "spliceColumns",
5631    value: function spliceColumns(sheetName, start, numDelete, numInsert) {
5632      var sheet = this.sheets[sheetName];
5633
5634      if (sheet) {
5635        var inserts = [];
5636
5637        for (var i = 0; i < numInsert; i++) {
5638          inserts.push(null);
5639        }
5640
5641        _.each(sheet, function (row) {
5642          row.splice.apply(row, [start, numDelete].concat(inserts));
5643        });
5644      }
5645    }
5646  }]);
5647
5648  return CellMatrix;
5649}();
5650
5651module.exports = CellMatrix;
5652
5653},{"./col-cache":19,"./under-dash":25}],19:[function(require,module,exports){
5654"use strict";
5655
5656function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5657
5658function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5659
5660function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5661
5662function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
5663
5664function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
5665
5666function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5667
5668function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
5669
5670function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5671
5672function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5673
5674var addressRegex = /^[A-Z]+\d+$/; // =========================================================================
5675// Column Letter to Number conversion
5676
5677var colCache = {
5678  _dictionary: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
5679  _l2nFill: 0,
5680  _l2n: {},
5681  _n2l: [],
5682  _level: function _level(n) {
5683    if (n <= 26) {
5684      return 1;
5685    }
5686
5687    if (n <= 26 * 26) {
5688      return 2;
5689    }
5690
5691    return 3;
5692  },
5693  _fill: function _fill(level) {
5694    var c;
5695    var v;
5696    var l1;
5697    var l2;
5698    var l3;
5699    var n = 1;
5700
5701    if (level >= 4) {
5702      throw new Error('Out of bounds. Excel supports columns from 1 to 16384');
5703    }
5704
5705    if (this._l2nFill < 1 && level >= 1) {
5706      while (n <= 26) {
5707        c = this._dictionary[n - 1];
5708        this._n2l[n] = c;
5709        this._l2n[c] = n;
5710        n++;
5711      }
5712
5713      this._l2nFill = 1;
5714    }
5715
5716    if (this._l2nFill < 2 && level >= 2) {
5717      n = 27;
5718
5719      while (n <= 26 + 26 * 26) {
5720        v = n - (26 + 1);
5721        l1 = v % 26;
5722        l2 = Math.floor(v / 26);
5723        c = this._dictionary[l2] + this._dictionary[l1];
5724        this._n2l[n] = c;
5725        this._l2n[c] = n;
5726        n++;
5727      }
5728
5729      this._l2nFill = 2;
5730    }
5731
5732    if (this._l2nFill < 3 && level >= 3) {
5733      n = 26 + 26 * 26 + 1;
5734
5735      while (n <= 16384) {
5736        v = n - (26 * 26 + 26 + 1);
5737        l1 = v % 26;
5738        l2 = Math.floor(v / 26) % 26;
5739        l3 = Math.floor(v / (26 * 26));
5740        c = this._dictionary[l3] + this._dictionary[l2] + this._dictionary[l1];
5741        this._n2l[n] = c;
5742        this._l2n[c] = n;
5743        n++;
5744      }
5745
5746      this._l2nFill = 3;
5747    }
5748  },
5749  l2n: function l2n(l) {
5750    if (!this._l2n[l]) {
5751      this._fill(l.length);
5752    }
5753
5754    if (!this._l2n[l]) {
5755      throw new Error("Out of bounds. Invalid column letter: ".concat(l));
5756    }
5757
5758    return this._l2n[l];
5759  },
5760  n2l: function n2l(n) {
5761    if (n < 1 || n > 16384) {
5762      throw new Error("".concat(n, " is out of bounds. Excel supports columns from 1 to 16384"));
5763    }
5764
5765    if (!this._n2l[n]) {
5766      this._fill(this._level(n));
5767    }
5768
5769    return this._n2l[n];
5770  },
5771  // =========================================================================
5772  // Address processing
5773  _hash: {},
5774  // check if value looks like an address
5775  validateAddress: function validateAddress(value) {
5776    if (!addressRegex.test(value)) {
5777      throw new Error("Invalid Address: ".concat(value));
5778    }
5779
5780    return true;
5781  },
5782  // convert address string into structure
5783  decodeAddress: function decodeAddress(value) {
5784    var addr = value.length < 5 && this._hash[value];
5785
5786    if (addr) {
5787      return addr;
5788    }
5789
5790    var hasCol = false;
5791    var col = '';
5792    var colNumber = 0;
5793    var hasRow = false;
5794    var row = '';
5795    var rowNumber = 0;
5796
5797    for (var i = 0, char; i < value.length; i++) {
5798      char = value.charCodeAt(i); // col should before row
5799
5800      if (!hasRow && char >= 65 && char <= 90) {
5801        // 65 = 'A'.charCodeAt(0)
5802        // 90 = 'Z'.charCodeAt(0)
5803        hasCol = true;
5804        col += value[i]; // colNumber starts from 1
5805
5806        colNumber = colNumber * 26 + char - 64;
5807      } else if (char >= 48 && char <= 57) {
5808        // 48 = '0'.charCodeAt(0)
5809        // 57 = '9'.charCodeAt(0)
5810        hasRow = true;
5811        row += value[i]; // rowNumber starts from 0
5812
5813        rowNumber = rowNumber * 10 + char - 48;
5814      } else if (hasRow && hasCol && char !== 36) {
5815        // 36 = '$'.charCodeAt(0)
5816        break;
5817      }
5818    }
5819
5820    if (!hasCol) {
5821      colNumber = undefined;
5822    } else if (colNumber > 16384) {
5823      throw new Error("Out of bounds. Invalid column letter: ".concat(col));
5824    }
5825
5826    if (!hasRow) {
5827      rowNumber = undefined;
5828    } // in case $row$col
5829
5830
5831    value = col + row;
5832    var address = {
5833      address: value,
5834      col: colNumber,
5835      row: rowNumber,
5836      $col$row: "$".concat(col, "$").concat(row)
5837    }; // mem fix - cache only the tl 100x100 square
5838
5839    if (colNumber <= 100 && rowNumber <= 100) {
5840      this._hash[value] = address;
5841      this._hash[address.$col$row] = address;
5842    }
5843
5844    return address;
5845  },
5846  // convert r,c into structure (if only 1 arg, assume r is address string)
5847  getAddress: function getAddress(r, c) {
5848    if (c) {
5849      var address = this.n2l(c) + r;
5850      return this.decodeAddress(address);
5851    }
5852
5853    return this.decodeAddress(r);
5854  },
5855  // convert [address], [tl:br] into address structures
5856  decode: function decode(value) {
5857    var parts = value.split(':');
5858
5859    if (parts.length === 2) {
5860      var tl = this.decodeAddress(parts[0]);
5861      var br = this.decodeAddress(parts[1]);
5862      var result = {
5863        top: Math.min(tl.row, br.row),
5864        left: Math.min(tl.col, br.col),
5865        bottom: Math.max(tl.row, br.row),
5866        right: Math.max(tl.col, br.col)
5867      }; // reconstruct tl, br and dimensions
5868
5869      result.tl = this.n2l(result.left) + result.top;
5870      result.br = this.n2l(result.right) + result.bottom;
5871      result.dimensions = "".concat(result.tl, ":").concat(result.br);
5872      return result;
5873    }
5874
5875    return this.decodeAddress(value);
5876  },
5877  // convert [sheetName!][$]col[$]row[[$]col[$]row] into address or range structures
5878  decodeEx: function decodeEx(value) {
5879    var groups = value.match(/(?:(?:(?:'((?:[^']|'')*)')|([^'^ !]*))!)?(.*)/);
5880    var sheetName = groups[1] || groups[2]; // Qouted and unqouted groups
5881
5882    var reference = groups[3]; // Remaining address
5883
5884    var parts = reference.split(':');
5885
5886    if (parts.length > 1) {
5887      var tl = this.decodeAddress(parts[0]);
5888      var br = this.decodeAddress(parts[1]);
5889      var top = Math.min(tl.row, br.row);
5890      var left = Math.min(tl.col, br.col);
5891      var bottom = Math.max(tl.row, br.row);
5892      var right = Math.max(tl.col, br.col);
5893      tl = this.n2l(left) + top;
5894      br = this.n2l(right) + bottom;
5895      return {
5896        top: top,
5897        left: left,
5898        bottom: bottom,
5899        right: right,
5900        sheetName: sheetName,
5901        tl: {
5902          address: tl,
5903          col: left,
5904          row: top,
5905          $col$row: "$".concat(this.n2l(left), "$").concat(top),
5906          sheetName: sheetName
5907        },
5908        br: {
5909          address: br,
5910          col: right,
5911          row: bottom,
5912          $col$row: "$".concat(this.n2l(right), "$").concat(bottom),
5913          sheetName: sheetName
5914        },
5915        dimensions: "".concat(tl, ":").concat(br)
5916      };
5917    }
5918
5919    if (reference.startsWith('#')) {
5920      return sheetName ? {
5921        sheetName: sheetName,
5922        error: reference
5923      } : {
5924        error: reference
5925      };
5926    }
5927
5928    var address = this.decodeAddress(reference);
5929    return sheetName ? _objectSpread({
5930      sheetName: sheetName
5931    }, address) : address;
5932  },
5933  // convert row,col into address string
5934  encodeAddress: function encodeAddress(row, col) {
5935    return colCache.n2l(col) + row;
5936  },
5937  // convert row,col into string address or t,l,b,r into range
5938  encode: function encode() {
5939    switch (arguments.length) {
5940      case 2:
5941        return colCache.encodeAddress(arguments[0], arguments[1]);
5942
5943      case 4:
5944        return "".concat(colCache.encodeAddress(arguments[0], arguments[1]), ":").concat(colCache.encodeAddress(arguments[2], arguments[3]));
5945
5946      default:
5947        throw new Error('Can only encode with 2 or 4 arguments');
5948    }
5949  },
5950  // return true if address is contained within range
5951  inRange: function inRange(range, address) {
5952    var _range = _slicedToArray(range, 5),
5953        left = _range[0],
5954        top = _range[1],
5955        right = _range[3],
5956        bottom = _range[4];
5957
5958    var _address = _slicedToArray(address, 2),
5959        col = _address[0],
5960        row = _address[1];
5961
5962    return col >= left && col <= right && row >= top && row <= bottom;
5963  }
5964};
5965module.exports = colCache;
5966
5967},{}],20:[function(require,module,exports){
5968(function (Buffer){
5969'use strict';
5970
5971var crypto = require('crypto');
5972
5973var Encryptor = {
5974  /**
5975   * Calculate a hash of the concatenated buffers with the given algorithm.
5976   * @param {string} algorithm - The hash algorithm.
5977   * @returns {Buffer} The hash
5978   */
5979  hash: function hash(algorithm) {
5980    var hash = crypto.createHash(algorithm);
5981
5982    for (var _len = arguments.length, buffers = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
5983      buffers[_key - 1] = arguments[_key];
5984    }
5985
5986    hash.update(Buffer.concat(buffers));
5987    return hash.digest();
5988  },
5989
5990  /**
5991   * Convert a password into an encryption key
5992   * @param {string} password - The password
5993   * @param {string} hashAlgorithm - The hash algoritm
5994   * @param {string} saltValue - The salt value
5995   * @param {number} spinCount - The spin count
5996   * @param {number} keyBits - The length of the key in bits
5997   * @param {Buffer} blockKey - The block key
5998   * @returns {Buffer} The encryption key
5999   */
6000  convertPasswordToHash: function convertPasswordToHash(password, hashAlgorithm, saltValue, spinCount) {
6001    hashAlgorithm = hashAlgorithm.toLowerCase();
6002    var hashes = crypto.getHashes();
6003
6004    if (hashes.indexOf(hashAlgorithm) < 0) {
6005      throw new Error("Hash algorithm '".concat(hashAlgorithm, "' not supported!"));
6006    } // Password must be in unicode buffer
6007
6008
6009    var passwordBuffer = Buffer.from(password, 'utf16le'); // Generate the initial hash
6010
6011    var key = this.hash(hashAlgorithm, Buffer.from(saltValue, 'base64'), passwordBuffer); // Now regenerate until spin count
6012
6013    for (var i = 0; i < spinCount; i++) {
6014      var iterator = Buffer.alloc(4); // this is the 'special' element of Excel password hashing
6015      // that stops us from using crypto.pbkdf2()
6016
6017      iterator.writeUInt32LE(i, 0);
6018      key = this.hash(hashAlgorithm, key, iterator);
6019    }
6020
6021    return key.toString('base64');
6022  },
6023
6024  /**
6025   * Generates cryptographically strong pseudo-random data.
6026   * @param size The size argument is a number indicating the number of bytes to generate.
6027   */
6028  randomBytes: function randomBytes(size) {
6029    return crypto.randomBytes(size);
6030  }
6031};
6032module.exports = Encryptor;
6033
6034}).call(this,require("buffer").Buffer)
6035
6036},{"buffer":216,"crypto":335}],21:[function(require,module,exports){
6037"use strict";
6038
6039function _awaitAsyncGenerator(value) { return new _AwaitValue(value); }
6040
6041function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; }
6042
6043function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen.return !== "function") { this.return = undefined; } }
6044
6045if (typeof Symbol === "function" && Symbol.asyncIterator) { _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; }; }
6046
6047_AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
6048
6049_AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };
6050
6051_AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); };
6052
6053function _AwaitValue(value) { this.wrapped = value; }
6054
6055function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); }
6056
6057var _require = require('saxes'),
6058    SaxesParser = _require.SaxesParser;
6059
6060var _require2 = require('readable-stream'),
6061    PassThrough = _require2.PassThrough;
6062
6063var _require3 = require('./browser-buffer-decode'),
6064    bufferToString = _require3.bufferToString;
6065
6066module.exports = /*#__PURE__*/function () {
6067  var _ref = _wrapAsyncGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(iterable) {
6068    var saxesParser, error, events, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk;
6069
6070    return regeneratorRuntime.wrap(function _callee$(_context) {
6071      while (1) {
6072        switch (_context.prev = _context.next) {
6073          case 0:
6074            // TODO: Remove once node v8 is deprecated
6075            // Detect and upgrade old streams
6076            if (iterable.pipe && !iterable[Symbol.asyncIterator]) {
6077              iterable = iterable.pipe(new PassThrough());
6078            }
6079
6080            saxesParser = new SaxesParser();
6081            saxesParser.on('error', function (err) {
6082              error = err;
6083            });
6084            events = [];
6085            saxesParser.on('opentag', function (value) {
6086              return events.push({
6087                eventType: 'opentag',
6088                value: value
6089              });
6090            });
6091            saxesParser.on('text', function (value) {
6092              return events.push({
6093                eventType: 'text',
6094                value: value
6095              });
6096            });
6097            saxesParser.on('closetag', function (value) {
6098              return events.push({
6099                eventType: 'closetag',
6100                value: value
6101              });
6102            });
6103            _iteratorNormalCompletion = true;
6104            _didIteratorError = false;
6105            _context.prev = 9;
6106            _iterator = _asyncIterator(iterable);
6107
6108          case 11:
6109            _context.next = 13;
6110            return _awaitAsyncGenerator(_iterator.next());
6111
6112          case 13:
6113            _step = _context.sent;
6114            _iteratorNormalCompletion = _step.done;
6115            _context.next = 17;
6116            return _awaitAsyncGenerator(_step.value);
6117
6118          case 17:
6119            _value = _context.sent;
6120
6121            if (_iteratorNormalCompletion) {
6122              _context.next = 29;
6123              break;
6124            }
6125
6126            chunk = _value;
6127            saxesParser.write(bufferToString(chunk)); // saxesParser.write and saxesParser.on() are synchronous,
6128            // so we can only reach the below line once all events have been emitted
6129
6130            if (!error) {
6131              _context.next = 23;
6132              break;
6133            }
6134
6135            throw error;
6136
6137          case 23:
6138            _context.next = 25;
6139            return events;
6140
6141          case 25:
6142            events = [];
6143
6144          case 26:
6145            _iteratorNormalCompletion = true;
6146            _context.next = 11;
6147            break;
6148
6149          case 29:
6150            _context.next = 35;
6151            break;
6152
6153          case 31:
6154            _context.prev = 31;
6155            _context.t0 = _context["catch"](9);
6156            _didIteratorError = true;
6157            _iteratorError = _context.t0;
6158
6159          case 35:
6160            _context.prev = 35;
6161            _context.prev = 36;
6162
6163            if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
6164              _context.next = 40;
6165              break;
6166            }
6167
6168            _context.next = 40;
6169            return _awaitAsyncGenerator(_iterator.return());
6170
6171          case 40:
6172            _context.prev = 40;
6173
6174            if (!_didIteratorError) {
6175              _context.next = 43;
6176              break;
6177            }
6178
6179            throw _iteratorError;
6180
6181          case 43:
6182            return _context.finish(40);
6183
6184          case 44:
6185            return _context.finish(35);
6186
6187          case 45:
6188          case "end":
6189            return _context.stop();
6190        }
6191      }
6192    }, _callee, null, [[9, 31, 35, 45], [36,, 40, 44]]);
6193  }));
6194
6195  return function (_x) {
6196    return _ref.apply(this, arguments);
6197  };
6198}();
6199
6200},{"./browser-buffer-decode":16,"readable-stream":491,"saxes":496}],22:[function(require,module,exports){
6201"use strict";
6202
6203var colCache = require('./col-cache'); // const cellRefRegex = /(([a-z_\-0-9]*)!)?[$]?([a-z]+)[$]?([1-9][0-9]*)/i;
6204
6205
6206var replacementCandidateRx = /(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi;
6207var CRrx = /^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;
6208
6209function slideFormula(formula, fromCell, toCell) {
6210  var offset = colCache.decode(fromCell);
6211  var to = colCache.decode(toCell);
6212  return formula.replace(replacementCandidateRx, function (refMatch, sheet, sheetMaybe, addrPart, trailingParen) {
6213    if (trailingParen) {
6214      return refMatch;
6215    }
6216
6217    var match = CRrx.exec(addrPart);
6218
6219    if (match) {
6220      var colDollar = match[1];
6221      var colStr = match[2].toUpperCase();
6222      var rowDollar = match[3];
6223      var rowStr = match[4];
6224
6225      if (colStr.length > 3 || colStr.length === 3 && colStr > 'XFD') {
6226        // > XFD is the highest col number in excel 2007 and beyond, so this is a named range
6227        return refMatch;
6228      }
6229
6230      var col = colCache.l2n(colStr);
6231      var row = parseInt(rowStr, 10);
6232
6233      if (!colDollar) {
6234        col += to.col - offset.col;
6235      }
6236
6237      if (!rowDollar) {
6238        row += to.row - offset.row;
6239      }
6240
6241      var res = (sheet || '') + (colDollar || '') + colCache.n2l(col) + (rowDollar || '') + row;
6242      return res;
6243    }
6244
6245    return refMatch;
6246  });
6247}
6248
6249module.exports = {
6250  slideFormula: slideFormula
6251};
6252
6253},{"./col-cache":19}],23:[function(require,module,exports){
6254(function (process,Buffer){
6255"use strict";
6256
6257function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6258
6259function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6260
6261function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6262
6263function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6264
6265function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6266
6267/* eslint-disable max-classes-per-file */
6268var Stream = require('readable-stream');
6269
6270var utils = require('./utils');
6271
6272var StringBuf = require('./string-buf'); // =============================================================================
6273// data chunks - encapsulating incoming data
6274
6275
6276var StringChunk = /*#__PURE__*/function () {
6277  function StringChunk(data, encoding) {
6278    _classCallCheck(this, StringChunk);
6279
6280    this._data = data;
6281    this._encoding = encoding;
6282  }
6283
6284  _createClass(StringChunk, [{
6285    key: "copy",
6286    // copy to target buffer
6287    value: function copy(target, targetOffset, offset, length) {
6288      return this.toBuffer().copy(target, targetOffset, offset, length);
6289    }
6290  }, {
6291    key: "toBuffer",
6292    value: function toBuffer() {
6293      if (!this._buffer) {
6294        this._buffer = Buffer.from(this._data, this._encoding);
6295      }
6296
6297      return this._buffer;
6298    }
6299  }, {
6300    key: "length",
6301    get: function get() {
6302      return this.toBuffer().length;
6303    }
6304  }]);
6305
6306  return StringChunk;
6307}();
6308
6309var StringBufChunk = /*#__PURE__*/function () {
6310  function StringBufChunk(data) {
6311    _classCallCheck(this, StringBufChunk);
6312
6313    this._data = data;
6314  }
6315
6316  _createClass(StringBufChunk, [{
6317    key: "copy",
6318    // copy to target buffer
6319    value: function copy(target, targetOffset, offset, length) {
6320      // eslint-disable-next-line no-underscore-dangle
6321      return this._data._buf.copy(target, targetOffset, offset, length);
6322    }
6323  }, {
6324    key: "toBuffer",
6325    value: function toBuffer() {
6326      return this._data.toBuffer();
6327    }
6328  }, {
6329    key: "length",
6330    get: function get() {
6331      return this._data.length;
6332    }
6333  }]);
6334
6335  return StringBufChunk;
6336}();
6337
6338var BufferChunk = /*#__PURE__*/function () {
6339  function BufferChunk(data) {
6340    _classCallCheck(this, BufferChunk);
6341
6342    this._data = data;
6343  }
6344
6345  _createClass(BufferChunk, [{
6346    key: "copy",
6347    // copy to target buffer
6348    value: function copy(target, targetOffset, offset, length) {
6349      this._data.copy(target, targetOffset, offset, length);
6350    }
6351  }, {
6352    key: "toBuffer",
6353    value: function toBuffer() {
6354      return this._data;
6355    }
6356  }, {
6357    key: "length",
6358    get: function get() {
6359      return this._data.length;
6360    }
6361  }]);
6362
6363  return BufferChunk;
6364}(); // =============================================================================
6365// ReadWriteBuf - a single buffer supporting simple read-write
6366
6367
6368var ReadWriteBuf = /*#__PURE__*/function () {
6369  function ReadWriteBuf(size) {
6370    _classCallCheck(this, ReadWriteBuf);
6371
6372    this.size = size; // the buffer
6373
6374    this.buffer = Buffer.alloc(size); // read index
6375
6376    this.iRead = 0; // write index
6377
6378    this.iWrite = 0;
6379  }
6380
6381  _createClass(ReadWriteBuf, [{
6382    key: "toBuffer",
6383    value: function toBuffer() {
6384      if (this.iRead === 0 && this.iWrite === this.size) {
6385        return this.buffer;
6386      }
6387
6388      var buf = Buffer.alloc(this.iWrite - this.iRead);
6389      this.buffer.copy(buf, 0, this.iRead, this.iWrite);
6390      return buf;
6391    }
6392  }, {
6393    key: "read",
6394    value: function read(size) {
6395      var buf; // read size bytes from buffer and return buffer
6396
6397      if (size === 0) {
6398        // special case - return null if no data requested
6399        return null;
6400      }
6401
6402      if (size === undefined || size >= this.length) {
6403        // if no size specified or size is at least what we have then return all of the bytes
6404        buf = this.toBuffer();
6405        this.iRead = this.iWrite;
6406        return buf;
6407      } // otherwise return a chunk
6408
6409
6410      buf = Buffer.alloc(size);
6411      this.buffer.copy(buf, 0, this.iRead, size);
6412      this.iRead += size;
6413      return buf;
6414    }
6415  }, {
6416    key: "write",
6417    value: function write(chunk, offset, length) {
6418      // write as many bytes from data from optional source offset
6419      // and return number of bytes written
6420      var size = Math.min(length, this.size - this.iWrite);
6421      chunk.copy(this.buffer, this.iWrite, offset, offset + size);
6422      this.iWrite += size;
6423      return size;
6424    }
6425  }, {
6426    key: "length",
6427    get: function get() {
6428      return this.iWrite - this.iRead;
6429    }
6430  }, {
6431    key: "eod",
6432    get: function get() {
6433      return this.iRead === this.iWrite;
6434    }
6435  }, {
6436    key: "full",
6437    get: function get() {
6438      return this.iWrite === this.size;
6439    }
6440  }]);
6441
6442  return ReadWriteBuf;
6443}(); // =============================================================================
6444// StreamBuf - a multi-purpose read-write stream
6445//  As MemBuf - write as much data as you like. Then call toBuffer() to consolidate
6446//  As StreamHub - pipe to multiple writables
6447//  As readable stream - feed data into the writable part and have some other code read from it.
6448// Note: Not sure why but StreamBuf does not like JS "class" sugar. It fails the
6449// integration tests
6450
6451
6452var StreamBuf = function StreamBuf(options) {
6453  options = options || {};
6454  this.bufSize = options.bufSize || 1024 * 1024;
6455  this.buffers = []; // batch mode fills a buffer completely before passing the data on
6456  // to pipes or 'readable' event listeners
6457
6458  this.batch = options.batch || false;
6459  this.corked = false; // where in the current writable buffer we're up to
6460
6461  this.inPos = 0; // where in the current readable buffer we've read up to
6462
6463  this.outPos = 0; // consuming pipe streams go here
6464
6465  this.pipes = []; // controls emit('data')
6466
6467  this.paused = false;
6468  this.encoding = null;
6469};
6470
6471utils.inherits(StreamBuf, Stream.Duplex, {
6472  toBuffer: function toBuffer() {
6473    switch (this.buffers.length) {
6474      case 0:
6475        return null;
6476
6477      case 1:
6478        return this.buffers[0].toBuffer();
6479
6480      default:
6481        return Buffer.concat(this.buffers.map(function (rwBuf) {
6482          return rwBuf.toBuffer();
6483        }));
6484    }
6485  },
6486  // writable
6487  // event drain - if write returns false (which it won't), indicates when safe to write again.
6488  // finish - end() has been called
6489  // pipe(src) - pipe() has been called on readable
6490  // unpipe(src) - unpipe() has been called on readable
6491  // error - duh
6492  _getWritableBuffer: function _getWritableBuffer() {
6493    if (this.buffers.length) {
6494      var last = this.buffers[this.buffers.length - 1];
6495
6496      if (!last.full) {
6497        return last;
6498      }
6499    }
6500
6501    var buf = new ReadWriteBuf(this.bufSize);
6502    this.buffers.push(buf);
6503    return buf;
6504  },
6505  _pipe: function _pipe(chunk) {
6506    var _this = this;
6507
6508    return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6509      var write;
6510      return regeneratorRuntime.wrap(function _callee$(_context) {
6511        while (1) {
6512          switch (_context.prev = _context.next) {
6513            case 0:
6514              write = function write(pipe) {
6515                return new Promise(function (resolve) {
6516                  pipe.write(chunk.toBuffer(), function () {
6517                    resolve();
6518                  });
6519                });
6520              };
6521
6522              _context.next = 3;
6523              return Promise.all(_this.pipes.map(write));
6524
6525            case 3:
6526            case "end":
6527              return _context.stop();
6528          }
6529        }
6530      }, _callee);
6531    }))();
6532  },
6533  _writeToBuffers: function _writeToBuffers(chunk) {
6534    var inPos = 0;
6535    var inLen = chunk.length;
6536
6537    while (inPos < inLen) {
6538      // find writable buffer
6539      var buffer = this._getWritableBuffer(); // write some data
6540
6541
6542      inPos += buffer.write(chunk, inPos, inLen - inPos);
6543    }
6544  },
6545  write: function write(data, encoding, callback) {
6546    var _this2 = this;
6547
6548    return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
6549      var chunk;
6550      return regeneratorRuntime.wrap(function _callee2$(_context2) {
6551        while (1) {
6552          switch (_context2.prev = _context2.next) {
6553            case 0:
6554              if (encoding instanceof Function) {
6555                callback = encoding;
6556                encoding = 'utf8';
6557              }
6558
6559              callback = callback || utils.nop; // encapsulate data into a chunk
6560
6561              if (!(data instanceof StringBuf)) {
6562                _context2.next = 6;
6563                break;
6564              }
6565
6566              chunk = new StringBufChunk(data);
6567              _context2.next = 15;
6568              break;
6569
6570            case 6:
6571              if (!(data instanceof Buffer)) {
6572                _context2.next = 10;
6573                break;
6574              }
6575
6576              chunk = new BufferChunk(data);
6577              _context2.next = 15;
6578              break;
6579
6580            case 10:
6581              if (!(typeof data === 'string' || data instanceof String || data instanceof ArrayBuffer)) {
6582                _context2.next = 14;
6583                break;
6584              }
6585
6586              chunk = new StringChunk(data, encoding);
6587              _context2.next = 15;
6588              break;
6589
6590            case 14:
6591              throw new Error('Chunk must be one of type String, Buffer or StringBuf.');
6592
6593            case 15:
6594              if (!_this2.pipes.length) {
6595                _context2.next = 31;
6596                break;
6597              }
6598
6599              if (!_this2.batch) {
6600                _context2.next = 21;
6601                break;
6602              }
6603
6604              _this2._writeToBuffers(chunk);
6605
6606              while (!_this2.corked && _this2.buffers.length > 1) {
6607                _this2._pipe(_this2.buffers.shift());
6608              }
6609
6610              _context2.next = 29;
6611              break;
6612
6613            case 21:
6614              if (_this2.corked) {
6615                _context2.next = 27;
6616                break;
6617              }
6618
6619              _context2.next = 24;
6620              return _this2._pipe(chunk);
6621
6622            case 24:
6623              callback();
6624              _context2.next = 29;
6625              break;
6626
6627            case 27:
6628              _this2._writeToBuffers(chunk);
6629
6630              process.nextTick(callback);
6631
6632            case 29:
6633              _context2.next = 34;
6634              break;
6635
6636            case 31:
6637              if (!_this2.paused) {
6638                _this2.emit('data', chunk.toBuffer());
6639              }
6640
6641              _this2._writeToBuffers(chunk);
6642
6643              _this2.emit('readable');
6644
6645            case 34:
6646              return _context2.abrupt("return", true);
6647
6648            case 35:
6649            case "end":
6650              return _context2.stop();
6651          }
6652        }
6653      }, _callee2);
6654    }))();
6655  },
6656  cork: function cork() {
6657    this.corked = true;
6658  },
6659  _flush: function _flush()
6660  /* destination */
6661  {
6662    // if we have comsumers...
6663    if (this.pipes.length) {
6664      // and there's stuff not written
6665      while (this.buffers.length) {
6666        this._pipe(this.buffers.shift());
6667      }
6668    }
6669  },
6670  uncork: function uncork() {
6671    this.corked = false;
6672
6673    this._flush();
6674  },
6675  end: function end(chunk, encoding, callback) {
6676    var _this3 = this;
6677
6678    var writeComplete = function writeComplete(error) {
6679      if (error) {
6680        callback(error);
6681      } else {
6682        _this3._flush();
6683
6684        _this3.pipes.forEach(function (pipe) {
6685          pipe.end();
6686        });
6687
6688        _this3.emit('finish');
6689      }
6690    };
6691
6692    if (chunk) {
6693      this.write(chunk, encoding, writeComplete);
6694    } else {
6695      writeComplete();
6696    }
6697  },
6698  // readable
6699  // event readable - some data is now available
6700  // event data - switch to flowing mode - feeds chunks to handler
6701  // event end - no more data
6702  // event close - optional, indicates upstream close
6703  // event error - duh
6704  read: function read(size) {
6705    var buffers; // read min(buffer, size || infinity)
6706
6707    if (size) {
6708      buffers = [];
6709
6710      while (size && this.buffers.length && !this.buffers[0].eod) {
6711        var first = this.buffers[0];
6712        var buffer = first.read(size);
6713        size -= buffer.length;
6714        buffers.push(buffer);
6715
6716        if (first.eod && first.full) {
6717          this.buffers.shift();
6718        }
6719      }
6720
6721      return Buffer.concat(buffers);
6722    }
6723
6724    buffers = this.buffers.map(function (buf) {
6725      return buf.toBuffer();
6726    }).filter(Boolean);
6727    this.buffers = [];
6728    return Buffer.concat(buffers);
6729  },
6730  setEncoding: function setEncoding(encoding) {
6731    // causes stream.read or stream.on('data) to return strings of encoding instead of Buffer objects
6732    this.encoding = encoding;
6733  },
6734  pause: function pause() {
6735    this.paused = true;
6736  },
6737  resume: function resume() {
6738    this.paused = false;
6739  },
6740  isPaused: function isPaused() {
6741    return !!this.paused;
6742  },
6743  pipe: function pipe(destination) {
6744    // add destination to pipe list & write current buffer
6745    this.pipes.push(destination);
6746
6747    if (!this.paused && this.buffers.length) {
6748      this.end();
6749    }
6750  },
6751  unpipe: function unpipe(destination) {
6752    // remove destination from pipe list
6753    this.pipes = this.pipes.filter(function (pipe) {
6754      return pipe !== destination;
6755    });
6756  },
6757  unshift: function unshift()
6758  /* chunk */
6759  {
6760    // some numpty has read some data that's not for them and they want to put it back!
6761    // Might implement this some day
6762    throw new Error('Not Implemented');
6763  },
6764  wrap: function wrap()
6765  /* stream */
6766  {
6767    // not implemented
6768    throw new Error('Not Implemented');
6769  }
6770});
6771module.exports = StreamBuf;
6772
6773}).call(this,require('_process'),require("buffer").Buffer)
6774
6775},{"./string-buf":24,"./utils":26,"_process":467,"buffer":216,"readable-stream":491}],24:[function(require,module,exports){
6776(function (Buffer){
6777"use strict";
6778
6779function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6780
6781function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6782
6783function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6784
6785// StringBuf - a way to keep string memory operations to a minimum
6786// while building the strings for the xml files
6787var StringBuf = /*#__PURE__*/function () {
6788  function StringBuf(options) {
6789    _classCallCheck(this, StringBuf);
6790
6791    this._buf = Buffer.alloc(options && options.size || 16384);
6792    this._encoding = options && options.encoding || 'utf8'; // where in the buffer we are at
6793
6794    this._inPos = 0; // for use by toBuffer()
6795
6796    this._buffer = undefined;
6797  }
6798
6799  _createClass(StringBuf, [{
6800    key: "toBuffer",
6801    value: function toBuffer() {
6802      // return the current data as a single enclosing buffer
6803      if (!this._buffer) {
6804        this._buffer = Buffer.alloc(this.length);
6805
6806        this._buf.copy(this._buffer, 0, 0, this.length);
6807      }
6808
6809      return this._buffer;
6810    }
6811  }, {
6812    key: "reset",
6813    value: function reset(position) {
6814      position = position || 0;
6815      this._buffer = undefined;
6816      this._inPos = position;
6817    }
6818  }, {
6819    key: "_grow",
6820    value: function _grow(min) {
6821      var size = this._buf.length * 2;
6822
6823      while (size < min) {
6824        size *= 2;
6825      }
6826
6827      var buf = Buffer.alloc(size);
6828
6829      this._buf.copy(buf, 0);
6830
6831      this._buf = buf;
6832    }
6833  }, {
6834    key: "addText",
6835    value: function addText(text) {
6836      this._buffer = undefined;
6837
6838      var inPos = this._inPos + this._buf.write(text, this._inPos, this._encoding); // if we've hit (or nearing capacity), grow the buf
6839
6840
6841      while (inPos >= this._buf.length - 4) {
6842        this._grow(this._inPos + text.length); // keep trying to write until we've completely written the text
6843
6844
6845        inPos = this._inPos + this._buf.write(text, this._inPos, this._encoding);
6846      }
6847
6848      this._inPos = inPos;
6849    }
6850  }, {
6851    key: "addStringBuf",
6852    value: function addStringBuf(inBuf) {
6853      if (inBuf.length) {
6854        this._buffer = undefined;
6855
6856        if (this.length + inBuf.length > this.capacity) {
6857          this._grow(this.length + inBuf.length);
6858        } // eslint-disable-next-line no-underscore-dangle
6859
6860
6861        inBuf._buf.copy(this._buf, this._inPos, 0, inBuf.length);
6862
6863        this._inPos += inBuf.length;
6864      }
6865    }
6866  }, {
6867    key: "length",
6868    get: function get() {
6869      return this._inPos;
6870    }
6871  }, {
6872    key: "capacity",
6873    get: function get() {
6874      return this._buf.length;
6875    }
6876  }, {
6877    key: "buffer",
6878    get: function get() {
6879      return this._buf;
6880    }
6881  }]);
6882
6883  return StringBuf;
6884}();
6885
6886module.exports = StringBuf;
6887
6888}).call(this,require("buffer").Buffer)
6889
6890},{"buffer":216}],25:[function(require,module,exports){
6891"use strict";
6892
6893function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
6894
6895var toString = Object.prototype.toString;
6896var escapeHtmlRegex = /["&<>]/;
6897var _ = {
6898  each: function each(obj, cb) {
6899    if (obj) {
6900      if (Array.isArray(obj)) {
6901        obj.forEach(cb);
6902      } else {
6903        Object.keys(obj).forEach(function (key) {
6904          cb(obj[key], key);
6905        });
6906      }
6907    }
6908  },
6909  some: function some(obj, cb) {
6910    if (obj) {
6911      if (Array.isArray(obj)) {
6912        return obj.some(cb);
6913      }
6914
6915      return Object.keys(obj).some(function (key) {
6916        return cb(obj[key], key);
6917      });
6918    }
6919
6920    return false;
6921  },
6922  every: function every(obj, cb) {
6923    if (obj) {
6924      if (Array.isArray(obj)) {
6925        return obj.every(cb);
6926      }
6927
6928      return Object.keys(obj).every(function (key) {
6929        return cb(obj[key], key);
6930      });
6931    }
6932
6933    return true;
6934  },
6935  map: function map(obj, cb) {
6936    if (obj) {
6937      if (Array.isArray(obj)) {
6938        return obj.map(cb);
6939      }
6940
6941      return Object.keys(obj).map(function (key) {
6942        return cb(obj[key], key);
6943      });
6944    }
6945
6946    return [];
6947  },
6948  keyBy: function keyBy(a, p) {
6949    return a.reduce(function (o, v) {
6950      o[v[p]] = v;
6951      return o;
6952    }, {});
6953  },
6954  isEqual: function isEqual(a, b) {
6955    var aType = _typeof(a);
6956
6957    var bType = _typeof(b);
6958
6959    var aArray = Array.isArray(a);
6960    var bArray = Array.isArray(b);
6961
6962    if (aType !== bType) {
6963      return false;
6964    }
6965
6966    switch (_typeof(a)) {
6967      case 'object':
6968        if (aArray || bArray) {
6969          if (aArray && bArray) {
6970            return a.length === b.length && a.every(function (aValue, index) {
6971              var bValue = b[index];
6972              return _.isEqual(aValue, bValue);
6973            });
6974          }
6975
6976          return false;
6977        }
6978
6979        return _.every(a, function (aValue, key) {
6980          var bValue = b[key];
6981          return _.isEqual(aValue, bValue);
6982        });
6983
6984      default:
6985        return a === b;
6986    }
6987  },
6988  escapeHtml: function escapeHtml(html) {
6989    var regexResult = escapeHtmlRegex.exec(html);
6990    if (!regexResult) return html;
6991    var result = '';
6992    var escape = '';
6993    var lastIndex = 0;
6994    var i = regexResult.index;
6995
6996    for (; i < html.length; i++) {
6997      switch (html.charAt(i)) {
6998        case '"':
6999          escape = '&quot;';
7000          break;
7001
7002        case '&':
7003          escape = '&amp;';
7004          break;
7005
7006        case '\'':
7007          escape = '&apos;';
7008          break;
7009
7010        case '<':
7011          escape = '&lt;';
7012          break;
7013
7014        case '>':
7015          escape = '&gt;';
7016          break;
7017
7018        default:
7019          continue;
7020      }
7021
7022      if (lastIndex !== i) result += html.substring(lastIndex, i);
7023      lastIndex = i + 1;
7024      result += escape;
7025    }
7026
7027    if (lastIndex !== i) return result + html.substring(lastIndex, i);
7028    return result;
7029  },
7030  strcmp: function strcmp(a, b) {
7031    if (a < b) return -1;
7032    if (a > b) return 1;
7033    return 0;
7034  },
7035  isUndefined: function isUndefined(val) {
7036    return toString.call(val) === '[object Undefined]';
7037  },
7038  isObject: function isObject(val) {
7039    return toString.call(val) === '[object Object]';
7040  },
7041  deepMerge: function deepMerge() {
7042    var target = arguments[0] || {};
7043    var length = arguments.length; // eslint-disable-next-line one-var
7044
7045    var src, clone, copyIsArray;
7046
7047    function assignValue(val, key) {
7048      src = target[key];
7049      copyIsArray = Array.isArray(val);
7050
7051      if (_.isObject(val) || copyIsArray) {
7052        if (copyIsArray) {
7053          copyIsArray = false;
7054          clone = src && Array.isArray(src) ? src : [];
7055        } else {
7056          clone = src && _.isObject(src) ? src : {};
7057        }
7058
7059        target[key] = _.deepMerge(clone, val);
7060      } else if (!_.isUndefined(val)) {
7061        target[key] = val;
7062      }
7063    }
7064
7065    for (var i = 0; i < length; i++) {
7066      _.each(arguments[i], assignValue);
7067    }
7068
7069    return target;
7070  }
7071};
7072module.exports = _;
7073
7074},{}],26:[function(require,module,exports){
7075(function (global,setImmediate){
7076"use strict";
7077
7078var fs = require('fs'); // useful stuff
7079
7080
7081var inherits = function inherits(cls, superCtor, statics, prototype) {
7082  // eslint-disable-next-line no-underscore-dangle
7083  cls.super_ = superCtor;
7084
7085  if (!prototype) {
7086    prototype = statics;
7087    statics = null;
7088  }
7089
7090  if (statics) {
7091    Object.keys(statics).forEach(function (i) {
7092      Object.defineProperty(cls, i, Object.getOwnPropertyDescriptor(statics, i));
7093    });
7094  }
7095
7096  var properties = {
7097    constructor: {
7098      value: cls,
7099      enumerable: false,
7100      writable: false,
7101      configurable: true
7102    }
7103  };
7104
7105  if (prototype) {
7106    Object.keys(prototype).forEach(function (i) {
7107      properties[i] = Object.getOwnPropertyDescriptor(prototype, i);
7108    });
7109  }
7110
7111  cls.prototype = Object.create(superCtor.prototype, properties);
7112}; // eslint-disable-next-line no-control-regex
7113
7114
7115var xmlDecodeRegex = /[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/;
7116var utils = {
7117  nop: function nop() {},
7118  promiseImmediate: function promiseImmediate(value) {
7119    return new Promise(function (resolve) {
7120      if (global.setImmediate) {
7121        setImmediate(function () {
7122          resolve(value);
7123        });
7124      } else {
7125        // poorman's setImmediate - must wait at least 1ms
7126        setTimeout(function () {
7127          resolve(value);
7128        }, 1);
7129      }
7130    });
7131  },
7132  inherits: inherits,
7133  dateToExcel: function dateToExcel(d, date1904) {
7134    return 25569 + d.getTime() / (24 * 3600 * 1000) - (date1904 ? 1462 : 0);
7135  },
7136  excelToDate: function excelToDate(v, date1904) {
7137    var millisecondSinceEpoch = Math.round((v - 25569 + (date1904 ? 1462 : 0)) * 24 * 3600 * 1000);
7138    return new Date(millisecondSinceEpoch);
7139  },
7140  parsePath: function parsePath(filepath) {
7141    var last = filepath.lastIndexOf('/');
7142    return {
7143      path: filepath.substring(0, last),
7144      name: filepath.substring(last + 1)
7145    };
7146  },
7147  getRelsPath: function getRelsPath(filepath) {
7148    var path = utils.parsePath(filepath);
7149    return "".concat(path.path, "/_rels/").concat(path.name, ".rels");
7150  },
7151  xmlEncode: function xmlEncode(text) {
7152    var regexResult = xmlDecodeRegex.exec(text);
7153    if (!regexResult) return text;
7154    var result = '';
7155    var escape = '';
7156    var lastIndex = 0;
7157    var i = regexResult.index;
7158
7159    for (; i < text.length; i++) {
7160      var charCode = text.charCodeAt(i);
7161
7162      switch (charCode) {
7163        case 34:
7164          // "
7165          escape = '&quot;';
7166          break;
7167
7168        case 38:
7169          // &
7170          escape = '&amp;';
7171          break;
7172
7173        case 39:
7174          // '
7175          escape = '&apos;';
7176          break;
7177
7178        case 60:
7179          // <
7180          escape = '&lt;';
7181          break;
7182
7183        case 62:
7184          // >
7185          escape = '&gt;';
7186          break;
7187
7188        case 127:
7189          escape = '';
7190          break;
7191
7192        default:
7193          {
7194            if (charCode <= 31 && (charCode <= 8 || charCode >= 11 && charCode !== 13)) {
7195              escape = '';
7196              break;
7197            }
7198
7199            continue;
7200          }
7201      }
7202
7203      if (lastIndex !== i) result += text.substring(lastIndex, i);
7204      lastIndex = i + 1;
7205      if (escape) result += escape;
7206    }
7207
7208    if (lastIndex !== i) return result + text.substring(lastIndex, i);
7209    return result;
7210  },
7211  xmlDecode: function xmlDecode(text) {
7212    return text.replace(/&([a-z]*);/g, function (c) {
7213      switch (c) {
7214        case '&lt;':
7215          return '<';
7216
7217        case '&gt;':
7218          return '>';
7219
7220        case '&amp;':
7221          return '&';
7222
7223        case '&apos;':
7224          return '\'';
7225
7226        case '&quot;':
7227          return '"';
7228
7229        default:
7230          return c;
7231      }
7232    });
7233  },
7234  validInt: function validInt(value) {
7235    var i = parseInt(value, 10);
7236    return !Number.isNaN(i) ? i : 0;
7237  },
7238  isDateFmt: function isDateFmt(fmt) {
7239    if (!fmt) {
7240      return false;
7241    } // must remove all chars inside quotes and []
7242
7243
7244    fmt = fmt.replace(/\[[^\]]*]/g, '');
7245    fmt = fmt.replace(/"[^"]*"/g, ''); // then check for date formatting chars
7246
7247    var result = fmt.match(/[ymdhMsb]+/) !== null;
7248    return result;
7249  },
7250  fs: {
7251    exists: function exists(path) {
7252      return new Promise(function (resolve) {
7253        fs.access(path, fs.constants.F_OK, function (err) {
7254          resolve(!err);
7255        });
7256      });
7257    }
7258  },
7259  toIsoDateString: function toIsoDateString(dt) {
7260    return dt.toIsoString().subsstr(0, 10);
7261  }
7262};
7263module.exports = utils;
7264
7265}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
7266
7267},{"fs":215,"timers":521}],27:[function(require,module,exports){
7268"use strict";
7269
7270function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7271
7272function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
7273
7274function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
7275
7276var _ = require('./under-dash');
7277
7278var utils = require('./utils'); // constants
7279
7280
7281var OPEN_ANGLE = '<';
7282var CLOSE_ANGLE = '>';
7283var OPEN_ANGLE_SLASH = '</';
7284var CLOSE_SLASH_ANGLE = '/>';
7285var EQUALS_QUOTE = '="';
7286var QUOTE = '"';
7287var SPACE = ' ';
7288
7289function pushAttribute(xml, name, value) {
7290  xml.push(SPACE);
7291  xml.push(name);
7292  xml.push(EQUALS_QUOTE);
7293  xml.push(utils.xmlEncode(value.toString()));
7294  xml.push(QUOTE);
7295}
7296
7297function pushAttributes(xml, attributes) {
7298  if (attributes) {
7299    _.each(attributes, function (value, name) {
7300      if (value !== undefined) {
7301        pushAttribute(xml, name, value);
7302      }
7303    });
7304  }
7305}
7306
7307var XmlStream = /*#__PURE__*/function () {
7308  function XmlStream() {
7309    _classCallCheck(this, XmlStream);
7310
7311    this._xml = [];
7312    this._stack = [];
7313    this._rollbacks = [];
7314  }
7315
7316  _createClass(XmlStream, [{
7317    key: "openXml",
7318    value: function openXml(docAttributes) {
7319      var xml = this._xml; // <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
7320
7321      xml.push('<?xml');
7322      pushAttributes(xml, docAttributes);
7323      xml.push('?>\n');
7324    }
7325  }, {
7326    key: "openNode",
7327    value: function openNode(name, attributes) {
7328      var parent = this.tos;
7329      var xml = this._xml;
7330
7331      if (parent && this.open) {
7332        xml.push(CLOSE_ANGLE);
7333      }
7334
7335      this._stack.push(name); // start streaming node
7336
7337
7338      xml.push(OPEN_ANGLE);
7339      xml.push(name);
7340      pushAttributes(xml, attributes);
7341      this.leaf = true;
7342      this.open = true;
7343    }
7344  }, {
7345    key: "addAttribute",
7346    value: function addAttribute(name, value) {
7347      if (!this.open) {
7348        throw new Error('Cannot write attributes to node if it is not open');
7349      }
7350
7351      if (value !== undefined) {
7352        pushAttribute(this._xml, name, value);
7353      }
7354    }
7355  }, {
7356    key: "addAttributes",
7357    value: function addAttributes(attrs) {
7358      if (!this.open) {
7359        throw new Error('Cannot write attributes to node if it is not open');
7360      }
7361
7362      pushAttributes(this._xml, attrs);
7363    }
7364  }, {
7365    key: "writeText",
7366    value: function writeText(text) {
7367      var xml = this._xml;
7368
7369      if (this.open) {
7370        xml.push(CLOSE_ANGLE);
7371        this.open = false;
7372      }
7373
7374      this.leaf = false;
7375      xml.push(utils.xmlEncode(text.toString()));
7376    }
7377  }, {
7378    key: "writeXml",
7379    value: function writeXml(xml) {
7380      if (this.open) {
7381        this._xml.push(CLOSE_ANGLE);
7382
7383        this.open = false;
7384      }
7385
7386      this.leaf = false;
7387
7388      this._xml.push(xml);
7389    }
7390  }, {
7391    key: "closeNode",
7392    value: function closeNode() {
7393      var node = this._stack.pop();
7394
7395      var xml = this._xml;
7396
7397      if (this.leaf) {
7398        xml.push(CLOSE_SLASH_ANGLE);
7399      } else {
7400        xml.push(OPEN_ANGLE_SLASH);
7401        xml.push(node);
7402        xml.push(CLOSE_ANGLE);
7403      }
7404
7405      this.open = false;
7406      this.leaf = false;
7407    }
7408  }, {
7409    key: "leafNode",
7410    value: function leafNode(name, attributes, text) {
7411      this.openNode(name, attributes);
7412
7413      if (text !== undefined) {
7414        // zeros need to be written
7415        this.writeText(text);
7416      }
7417
7418      this.closeNode();
7419    }
7420  }, {
7421    key: "closeAll",
7422    value: function closeAll() {
7423      while (this._stack.length) {
7424        this.closeNode();
7425      }
7426    }
7427  }, {
7428    key: "addRollback",
7429    value: function addRollback() {
7430      this._rollbacks.push({
7431        xml: this._xml.length,
7432        stack: this._stack.length,
7433        leaf: this.leaf,
7434        open: this.open
7435      });
7436
7437      return this.cursor;
7438    }
7439  }, {
7440    key: "commit",
7441    value: function commit() {
7442      this._rollbacks.pop();
7443    }
7444  }, {
7445    key: "rollback",
7446    value: function rollback() {
7447      var r = this._rollbacks.pop();
7448
7449      if (this._xml.length > r.xml) {
7450        this._xml.splice(r.xml, this._xml.length - r.xml);
7451      }
7452
7453      if (this._stack.length > r.stack) {
7454        this._stack.splice(r.stack, this._stack.length - r.stack);
7455      }
7456
7457      this.leaf = r.leaf;
7458      this.open = r.open;
7459    }
7460  }, {
7461    key: "tos",
7462    get: function get() {
7463      return this._stack.length ? this._stack[this._stack.length - 1] : undefined;
7464    }
7465  }, {
7466    key: "cursor",
7467    get: function get() {
7468      // handy way to track whether anything has been added
7469      return this._xml.length;
7470    }
7471  }, {
7472    key: "xml",
7473    get: function get() {
7474      this.closeAll();
7475      return this._xml.join('');
7476    }
7477  }]);
7478
7479  return XmlStream;
7480}();
7481
7482XmlStream.StdDocAttributes = {
7483  version: '1.0',
7484  encoding: 'UTF-8',
7485  standalone: 'yes'
7486};
7487module.exports = XmlStream;
7488
7489},{"./under-dash":25,"./utils":26}],28:[function(require,module,exports){
7490(function (process){
7491"use strict";
7492
7493function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
7494
7495function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
7496
7497function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7498
7499function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7500
7501function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
7502
7503function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
7504
7505function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
7506
7507function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
7508
7509function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7510
7511function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
7512
7513function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
7514
7515function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
7516
7517function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
7518
7519var events = require('events');
7520
7521var JSZip = require('jszip');
7522
7523var StreamBuf = require('./stream-buf');
7524
7525var _require = require('./browser-buffer-encode'),
7526    stringToBuffer = _require.stringToBuffer; // =============================================================================
7527// The ZipWriter class
7528// Packs streamed data into an output zip stream
7529
7530
7531var ZipWriter = /*#__PURE__*/function (_events$EventEmitter) {
7532  _inherits(ZipWriter, _events$EventEmitter);
7533
7534  var _super = _createSuper(ZipWriter);
7535
7536  function ZipWriter(options) {
7537    var _this;
7538
7539    _classCallCheck(this, ZipWriter);
7540
7541    _this = _super.call(this);
7542    _this.options = Object.assign({
7543      type: 'nodebuffer',
7544      compression: 'DEFLATE'
7545    }, options);
7546    _this.zip = new JSZip();
7547    _this.stream = new StreamBuf();
7548    return _this;
7549  }
7550
7551  _createClass(ZipWriter, [{
7552    key: "append",
7553    value: function append(data, options) {
7554      if (options.hasOwnProperty('base64') && options.base64) {
7555        this.zip.file(options.name, data, {
7556          base64: true
7557        });
7558      } else {
7559        // https://www.npmjs.com/package/process
7560        if (process.browser && typeof data === 'string') {
7561          // use TextEncoder in browser
7562          data = stringToBuffer(data);
7563        }
7564
7565        this.zip.file(options.name, data);
7566      }
7567    }
7568  }, {
7569    key: "finalize",
7570    value: function () {
7571      var _finalize = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
7572        var content;
7573        return regeneratorRuntime.wrap(function _callee$(_context) {
7574          while (1) {
7575            switch (_context.prev = _context.next) {
7576              case 0:
7577                _context.next = 2;
7578                return this.zip.generateAsync(this.options);
7579
7580              case 2:
7581                content = _context.sent;
7582                this.stream.end(content);
7583                this.emit('finish');
7584
7585              case 5:
7586              case "end":
7587                return _context.stop();
7588            }
7589          }
7590        }, _callee, this);
7591      }));
7592
7593      function finalize() {
7594        return _finalize.apply(this, arguments);
7595      }
7596
7597      return finalize;
7598    }() // ==========================================================================
7599    // Stream.Readable interface
7600
7601  }, {
7602    key: "read",
7603    value: function read(size) {
7604      return this.stream.read(size);
7605    }
7606  }, {
7607    key: "setEncoding",
7608    value: function setEncoding(encoding) {
7609      return this.stream.setEncoding(encoding);
7610    }
7611  }, {
7612    key: "pause",
7613    value: function pause() {
7614      return this.stream.pause();
7615    }
7616  }, {
7617    key: "resume",
7618    value: function resume() {
7619      return this.stream.resume();
7620    }
7621  }, {
7622    key: "isPaused",
7623    value: function isPaused() {
7624      return this.stream.isPaused();
7625    }
7626  }, {
7627    key: "pipe",
7628    value: function pipe(destination, options) {
7629      return this.stream.pipe(destination, options);
7630    }
7631  }, {
7632    key: "unpipe",
7633    value: function unpipe(destination) {
7634      return this.stream.unpipe(destination);
7635    }
7636  }, {
7637    key: "unshift",
7638    value: function unshift(chunk) {
7639      return this.stream.unshift(chunk);
7640    }
7641  }, {
7642    key: "wrap",
7643    value: function wrap(stream) {
7644      return this.stream.wrap(stream);
7645    }
7646  }]);
7647
7648  return ZipWriter;
7649}(events.EventEmitter); // =============================================================================
7650
7651
7652module.exports = {
7653  ZipWriter: ZipWriter
7654};
7655
7656}).call(this,require('_process'))
7657
7658},{"./browser-buffer-encode":17,"./stream-buf":23,"_process":467,"events":367,"jszip":399}],29:[function(require,module,exports){
7659"use strict";
7660
7661module.exports = {
7662  0: {
7663    f: 'General'
7664  },
7665  1: {
7666    f: '0'
7667  },
7668  2: {
7669    f: '0.00'
7670  },
7671  3: {
7672    f: '#,##0'
7673  },
7674  4: {
7675    f: '#,##0.00'
7676  },
7677  9: {
7678    f: '0%'
7679  },
7680  10: {
7681    f: '0.00%'
7682  },
7683  11: {
7684    f: '0.00E+00'
7685  },
7686  12: {
7687    f: '# ?/?'
7688  },
7689  13: {
7690    f: '# ??/??'
7691  },
7692  14: {
7693    f: 'mm-dd-yy'
7694  },
7695  15: {
7696    f: 'd-mmm-yy'
7697  },
7698  16: {
7699    f: 'd-mmm'
7700  },
7701  17: {
7702    f: 'mmm-yy'
7703  },
7704  18: {
7705    f: 'h:mm AM/PM'
7706  },
7707  19: {
7708    f: 'h:mm:ss AM/PM'
7709  },
7710  20: {
7711    f: 'h:mm'
7712  },
7713  21: {
7714    f: 'h:mm:ss'
7715  },
7716  22: {
7717    f: 'm/d/yy "h":mm'
7718  },
7719  27: {
7720    'zh-tw': '[$-404]e/m/d',
7721    'zh-cn': 'yyyy"年"m"月"',
7722    'ja-jp': '[$-411]ge.m.d',
7723    'ko-kr': 'yyyy"年" mm"月" dd"日"'
7724  },
7725  28: {
7726    'zh-tw': '[$-404]e"年"m"月"d"日"',
7727    'zh-cn': 'm"月"d"日"',
7728    'ja-jp': '[$-411]ggge"年"m"月"d"日"',
7729    'ko-kr': 'mm-dd'
7730  },
7731  29: {
7732    'zh-tw': '[$-404]e"年"m"月"d"日"',
7733    'zh-cn': 'm"月"d"日"',
7734    'ja-jp': '[$-411]ggge"年"m"月"d"日"',
7735    'ko-kr': 'mm-dd'
7736  },
7737  30: {
7738    'zh-tw': 'm/d/yy ',
7739    'zh-cn': 'm-d-yy',
7740    'ja-jp': 'm/d/yy',
7741    'ko-kr': 'mm-dd-yy'
7742  },
7743  31: {
7744    'zh-tw': 'yyyy"年"m"月"d"日"',
7745    'zh-cn': 'yyyy"年"m"月"d"日"',
7746    'ja-jp': 'yyyy"年"m"月"d"日"',
7747    'ko-kr': 'yyyy"년" mm"월" dd"일"'
7748  },
7749  32: {
7750    'zh-tw': 'hh"時"mm"分"',
7751    'zh-cn': 'h"时"mm"分"',
7752    'ja-jp': 'h"時"mm"分"',
7753    'ko-kr': 'h"시" mm"분"'
7754  },
7755  33: {
7756    'zh-tw': 'hh"時"mm"分"ss"秒"',
7757    'zh-cn': 'h"时"mm"分"ss"秒"',
7758    'ja-jp': 'h"時"mm"分"ss"秒"',
7759    'ko-kr': 'h"시" mm"분" ss"초"'
7760  },
7761  34: {
7762    'zh-tw': '上午/下午 hh"時"mm"分"',
7763    'zh-cn': '上午/下午 h"时"mm"分"',
7764    'ja-jp': 'yyyy"年"m"月"',
7765    'ko-kr': 'yyyy-mm-dd'
7766  },
7767  35: {
7768    'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"',
7769    'zh-cn': '上午/下午 h"时"mm"分"ss"秒"',
7770    'ja-jp': 'm"月"d"日"',
7771    'ko-kr': 'yyyy-mm-dd'
7772  },
7773  36: {
7774    'zh-tw': '[$-404]e/m/d',
7775    'zh-cn': 'yyyy"年"m"月"',
7776    'ja-jp': '[$-411]ge.m.d',
7777    'ko-kr': 'yyyy"年" mm"月" dd"日"'
7778  },
7779  37: {
7780    f: '#,##0 ;(#,##0)'
7781  },
7782  38: {
7783    f: '#,##0 ;[Red](#,##0)'
7784  },
7785  39: {
7786    f: '#,##0.00 ;(#,##0.00)'
7787  },
7788  40: {
7789    f: '#,##0.00 ;[Red](#,##0.00)'
7790  },
7791  45: {
7792    f: 'mm:ss'
7793  },
7794  46: {
7795    f: '[h]:mm:ss'
7796  },
7797  47: {
7798    f: 'mmss.0'
7799  },
7800  48: {
7801    f: '##0.0E+0'
7802  },
7803  49: {
7804    f: '@'
7805  },
7806  50: {
7807    'zh-tw': '[$-404]e/m/d',
7808    'zh-cn': 'yyyy"年"m"月"',
7809    'ja-jp': '[$-411]ge.m.d',
7810    'ko-kr': 'yyyy"年" mm"月" dd"日"'
7811  },
7812  51: {
7813    'zh-tw': '[$-404]e"年"m"月"d"日"',
7814    'zh-cn': 'm"月"d"日"',
7815    'ja-jp': '[$-411]ggge"年"m"月"d"日"',
7816    'ko-kr': 'mm-dd'
7817  },
7818  52: {
7819    'zh-tw': '上午/下午 hh"時"mm"分"',
7820    'zh-cn': 'yyyy"年"m"月"',
7821    'ja-jp': 'yyyy"年"m"月"',
7822    'ko-kr': 'yyyy-mm-dd'
7823  },
7824  53: {
7825    'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"',
7826    'zh-cn': 'm"月"d"日"',
7827    'ja-jp': 'm"月"d"日"',
7828    'ko-kr': 'yyyy-mm-dd'
7829  },
7830  54: {
7831    'zh-tw': '[$-404]e"年"m"月"d"日"',
7832    'zh-cn': 'm"月"d"日"',
7833    'ja-jp': '[$-411]ggge"年"m"月"d"日"',
7834    'ko-kr': 'mm-dd'
7835  },
7836  55: {
7837    'zh-tw': '上午/下午 hh"時"mm"分"',
7838    'zh-cn': '上午/下午 h"时"mm"分"',
7839    'ja-jp': 'yyyy"年"m"月"',
7840    'ko-kr': 'yyyy-mm-dd'
7841  },
7842  56: {
7843    'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"',
7844    'zh-cn': '上午/下午 h"时"mm"分"ss"秒"',
7845    'ja-jp': 'm"月"d"日"',
7846    'ko-kr': 'yyyy-mm-dd'
7847  },
7848  57: {
7849    'zh-tw': '[$-404]e/m/d',
7850    'zh-cn': 'yyyy"年"m"月"',
7851    'ja-jp': '[$-411]ge.m.d',
7852    'ko-kr': 'yyyy"年" mm"月" dd"日"'
7853  },
7854  58: {
7855    'zh-tw': '[$-404]e"年"m"月"d"日"',
7856    'zh-cn': 'm"月"d"日"',
7857    'ja-jp': '[$-411]ggge"年"m"月"d"日"',
7858    'ko-kr': 'mm-dd'
7859  },
7860  59: {
7861    'th-th': 't0'
7862  },
7863  60: {
7864    'th-th': 't0.00'
7865  },
7866  61: {
7867    'th-th': 't#,##0'
7868  },
7869  62: {
7870    'th-th': 't#,##0.00'
7871  },
7872  67: {
7873    'th-th': 't0%'
7874  },
7875  68: {
7876    'th-th': 't0.00%'
7877  },
7878  69: {
7879    'th-th': 't# ?/?'
7880  },
7881  70: {
7882    'th-th': 't# ??/??'
7883  },
7884  81: {
7885    'th-th': 'd/m/bb'
7886  }
7887};
7888
7889},{}],30:[function(require,module,exports){
7890'use strict';
7891
7892module.exports = {
7893  OfficeDocument: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
7894  Worksheet: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
7895  CalcChain: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain',
7896  SharedStrings: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
7897  Styles: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
7898  Theme: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
7899  Hyperlink: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
7900  Image: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
7901  CoreProperties: 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
7902  ExtenderProperties: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
7903  Comments: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
7904  VmlDrawing: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
7905  Table: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table'
7906};
7907
7908},{}],31:[function(require,module,exports){
7909"use strict";
7910
7911function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7912
7913function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7914
7915function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7916
7917function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
7918
7919function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7920
7921function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7922
7923function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
7924
7925function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
7926
7927function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); }
7928
7929var parseSax = require('../../utils/parse-sax');
7930
7931var XmlStream = require('../../utils/xml-stream');
7932/* 'virtual' methods used as a form of documentation */
7933
7934/* eslint-disable class-methods-use-this */
7935// Base class for Xforms
7936
7937
7938var BaseXform = /*#__PURE__*/function () {
7939  function BaseXform() {
7940    _classCallCheck(this, BaseXform);
7941  }
7942
7943  _createClass(BaseXform, [{
7944    key: "prepare",
7945    // constructor(/* model, name */) {}
7946    // ============================================================
7947    // Virtual Interface
7948    value: function prepare()
7949    /* model, options */
7950    {// optional preparation (mutation) of model so it is ready for write
7951    }
7952  }, {
7953    key: "render",
7954    value: function render()
7955    /* xmlStream, model */
7956    {// convert model to xml
7957    }
7958  }, {
7959    key: "parseOpen",
7960    value: function parseOpen(node) {// XML node opened
7961    }
7962  }, {
7963    key: "parseText",
7964    value: function parseText(text) {// chunk of text encountered for current node
7965    }
7966  }, {
7967    key: "parseClose",
7968    value: function parseClose(name) {// XML node closed
7969    }
7970  }, {
7971    key: "reconcile",
7972    value: function reconcile(model, options) {// optional post-parse step (opposite to prepare)
7973    } // ============================================================
7974
7975  }, {
7976    key: "reset",
7977    value: function reset() {
7978      // to make sure parses don't bleed to next iteration
7979      this.model = null; // if we have a map - reset them too
7980
7981      if (this.map) {
7982        Object.values(this.map).forEach(function (xform) {
7983          if (xform instanceof BaseXform) {
7984            xform.reset();
7985          } else if (xform.xform) {
7986            xform.xform.reset();
7987          }
7988        });
7989      }
7990    }
7991  }, {
7992    key: "mergeModel",
7993    value: function mergeModel(obj) {
7994      // set obj's props to this.model
7995      this.model = Object.assign(this.model || {}, obj);
7996    }
7997  }, {
7998    key: "parse",
7999    value: function () {
8000      var _parse = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(saxParser) {
8001        var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, events, _iterator2, _step2, _step2$value, eventType, value;
8002
8003        return regeneratorRuntime.wrap(function _callee$(_context) {
8004          while (1) {
8005            switch (_context.prev = _context.next) {
8006              case 0:
8007                _iteratorNormalCompletion = true;
8008                _didIteratorError = false;
8009                _context.prev = 2;
8010                _iterator = _asyncIterator(saxParser);
8011
8012              case 4:
8013                _context.next = 6;
8014                return _iterator.next();
8015
8016              case 6:
8017                _step = _context.sent;
8018                _iteratorNormalCompletion = _step.done;
8019                _context.next = 10;
8020                return _step.value;
8021
8022              case 10:
8023                _value = _context.sent;
8024
8025                if (_iteratorNormalCompletion) {
8026                  _context.next = 42;
8027                  break;
8028                }
8029
8030                events = _value;
8031                _iterator2 = _createForOfIteratorHelper(events);
8032                _context.prev = 14;
8033
8034                _iterator2.s();
8035
8036              case 16:
8037                if ((_step2 = _iterator2.n()).done) {
8038                  _context.next = 31;
8039                  break;
8040                }
8041
8042                _step2$value = _step2.value, eventType = _step2$value.eventType, value = _step2$value.value;
8043
8044                if (!(eventType === 'opentag')) {
8045                  _context.next = 22;
8046                  break;
8047                }
8048
8049                this.parseOpen(value);
8050                _context.next = 29;
8051                break;
8052
8053              case 22:
8054                if (!(eventType === 'text')) {
8055                  _context.next = 26;
8056                  break;
8057                }
8058
8059                this.parseText(value);
8060                _context.next = 29;
8061                break;
8062
8063              case 26:
8064                if (!(eventType === 'closetag')) {
8065                  _context.next = 29;
8066                  break;
8067                }
8068
8069                if (this.parseClose(value.name)) {
8070                  _context.next = 29;
8071                  break;
8072                }
8073
8074                return _context.abrupt("return", this.model);
8075
8076              case 29:
8077                _context.next = 16;
8078                break;
8079
8080              case 31:
8081                _context.next = 36;
8082                break;
8083
8084              case 33:
8085                _context.prev = 33;
8086                _context.t0 = _context["catch"](14);
8087
8088                _iterator2.e(_context.t0);
8089
8090              case 36:
8091                _context.prev = 36;
8092
8093                _iterator2.f();
8094
8095                return _context.finish(36);
8096
8097              case 39:
8098                _iteratorNormalCompletion = true;
8099                _context.next = 4;
8100                break;
8101
8102              case 42:
8103                _context.next = 48;
8104                break;
8105
8106              case 44:
8107                _context.prev = 44;
8108                _context.t1 = _context["catch"](2);
8109                _didIteratorError = true;
8110                _iteratorError = _context.t1;
8111
8112              case 48:
8113                _context.prev = 48;
8114                _context.prev = 49;
8115
8116                if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
8117                  _context.next = 53;
8118                  break;
8119                }
8120
8121                _context.next = 53;
8122                return _iterator.return();
8123
8124              case 53:
8125                _context.prev = 53;
8126
8127                if (!_didIteratorError) {
8128                  _context.next = 56;
8129                  break;
8130                }
8131
8132                throw _iteratorError;
8133
8134              case 56:
8135                return _context.finish(53);
8136
8137              case 57:
8138                return _context.finish(48);
8139
8140              case 58:
8141                return _context.abrupt("return", this.model);
8142
8143              case 59:
8144              case "end":
8145                return _context.stop();
8146            }
8147          }
8148        }, _callee, this, [[2, 44, 48, 58], [14, 33, 36, 39], [49,, 53, 57]]);
8149      }));
8150
8151      function parse(_x) {
8152        return _parse.apply(this, arguments);
8153      }
8154
8155      return parse;
8156    }()
8157  }, {
8158    key: "parseStream",
8159    value: function () {
8160      var _parseStream = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(stream) {
8161        return regeneratorRuntime.wrap(function _callee2$(_context2) {
8162          while (1) {
8163            switch (_context2.prev = _context2.next) {
8164              case 0:
8165                return _context2.abrupt("return", this.parse(parseSax(stream)));
8166
8167              case 1:
8168              case "end":
8169                return _context2.stop();
8170            }
8171          }
8172        }, _callee2, this);
8173      }));
8174
8175      function parseStream(_x2) {
8176        return _parseStream.apply(this, arguments);
8177      }
8178
8179      return parseStream;
8180    }()
8181  }, {
8182    key: "toXml",
8183    value: function toXml(model) {
8184      var xmlStream = new XmlStream();
8185      this.render(xmlStream, model);
8186      return xmlStream.xml;
8187    } // ============================================================
8188    // Useful Utilities
8189
8190  }, {
8191    key: "xml",
8192    get: function get() {
8193      // convenience function to get the xml of this.model
8194      // useful for manager types that are built during the prepare phase
8195      return this.toXml(this.model);
8196    }
8197  }], [{
8198    key: "toAttribute",
8199    value: function toAttribute(value, dflt) {
8200      var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
8201
8202      if (value === undefined) {
8203        if (always) {
8204          return dflt;
8205        }
8206      } else if (always || value !== dflt) {
8207        return value.toString();
8208      }
8209
8210      return undefined;
8211    }
8212  }, {
8213    key: "toStringAttribute",
8214    value: function toStringAttribute(value, dflt) {
8215      var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
8216      return BaseXform.toAttribute(value, dflt, always);
8217    }
8218  }, {
8219    key: "toStringValue",
8220    value: function toStringValue(attr, dflt) {
8221      return attr === undefined ? dflt : attr;
8222    }
8223  }, {
8224    key: "toBoolAttribute",
8225    value: function toBoolAttribute(value, dflt) {
8226      var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
8227
8228      if (value === undefined) {
8229        if (always) {
8230          return dflt;
8231        }
8232      } else if (always || value !== dflt) {
8233        return value ? '1' : '0';
8234      }
8235
8236      return undefined;
8237    }
8238  }, {
8239    key: "toBoolValue",
8240    value: function toBoolValue(attr, dflt) {
8241      return attr === undefined ? dflt : attr === '1';
8242    }
8243  }, {
8244    key: "toIntAttribute",
8245    value: function toIntAttribute(value, dflt) {
8246      var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
8247      return BaseXform.toAttribute(value, dflt, always);
8248    }
8249  }, {
8250    key: "toIntValue",
8251    value: function toIntValue(attr, dflt) {
8252      return attr === undefined ? dflt : parseInt(attr, 10);
8253    }
8254  }, {
8255    key: "toFloatAttribute",
8256    value: function toFloatAttribute(value, dflt) {
8257      var always = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
8258      return BaseXform.toAttribute(value, dflt, always);
8259    }
8260  }, {
8261    key: "toFloatValue",
8262    value: function toFloatValue(attr, dflt) {
8263      return attr === undefined ? dflt : parseFloat(attr);
8264    }
8265  }]);
8266
8267  return BaseXform;
8268}();
8269
8270module.exports = BaseXform;
8271
8272},{"../../utils/parse-sax":21,"../../utils/xml-stream":27}],32:[function(require,module,exports){
8273"use strict";
8274
8275function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8276
8277function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8278
8279function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8280
8281function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8282
8283function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
8284
8285function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8286
8287function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8288
8289function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
8290
8291function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
8292
8293function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
8294
8295function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
8296
8297var BaseXform = require('../base-xform');
8298
8299var colCache = require('../../../utils/col-cache');
8300
8301var DefinedNamesXform = /*#__PURE__*/function (_BaseXform) {
8302  _inherits(DefinedNamesXform, _BaseXform);
8303
8304  var _super = _createSuper(DefinedNamesXform);
8305
8306  function DefinedNamesXform() {
8307    _classCallCheck(this, DefinedNamesXform);
8308
8309    return _super.apply(this, arguments);
8310  }
8311
8312  _createClass(DefinedNamesXform, [{
8313    key: "render",
8314    value: function render(xmlStream, model) {
8315      // <definedNames>
8316      //   <definedName name="name">name.ranges.join(',')</definedName>
8317      //   <definedName name="_xlnm.Print_Area" localSheetId="0">name.ranges.join(',')</definedName>
8318      // </definedNames>
8319      xmlStream.openNode('definedName', {
8320        name: model.name,
8321        localSheetId: model.localSheetId
8322      });
8323      xmlStream.writeText(model.ranges.join(','));
8324      xmlStream.closeNode();
8325    }
8326  }, {
8327    key: "parseOpen",
8328    value: function parseOpen(node) {
8329      switch (node.name) {
8330        case 'definedName':
8331          this._parsedName = node.attributes.name;
8332          this._parsedLocalSheetId = node.attributes.localSheetId;
8333          this._parsedText = [];
8334          return true;
8335
8336        default:
8337          return false;
8338      }
8339    }
8340  }, {
8341    key: "parseText",
8342    value: function parseText(text) {
8343      this._parsedText.push(text);
8344    }
8345  }, {
8346    key: "parseClose",
8347    value: function parseClose() {
8348      this.model = {
8349        name: this._parsedName,
8350        ranges: extractRanges(this._parsedText.join(''))
8351      };
8352
8353      if (this._parsedLocalSheetId !== undefined) {
8354        this.model.localSheetId = parseInt(this._parsedLocalSheetId, 10);
8355      }
8356
8357      return false;
8358    }
8359  }]);
8360
8361  return DefinedNamesXform;
8362}(BaseXform);
8363
8364function isValidRange(range) {
8365  try {
8366    colCache.decodeEx(range);
8367    return true;
8368  } catch (err) {
8369    return false;
8370  }
8371}
8372
8373function extractRanges(parsedText) {
8374  var ranges = [];
8375  var quotesOpened = false;
8376  var last = '';
8377  parsedText.split(',').forEach(function (item) {
8378    if (!item) {
8379      return;
8380    }
8381
8382    var quotes = (item.match(/'/g) || []).length;
8383
8384    if (!quotes) {
8385      if (quotesOpened) {
8386        last += "".concat(item, ",");
8387      } else if (isValidRange(item)) {
8388        ranges.push(item);
8389      }
8390
8391      return;
8392    }
8393
8394    var quotesEven = quotes % 2 === 0;
8395
8396    if (!quotesOpened && quotesEven && isValidRange(item)) {
8397      ranges.push(item);
8398    } else if (quotesOpened && !quotesEven) {
8399      quotesOpened = false;
8400
8401      if (isValidRange(last + item)) {
8402        ranges.push(last + item);
8403      }
8404
8405      last = '';
8406    } else {
8407      quotesOpened = true;
8408      last += "".concat(item, ",");
8409    }
8410  });
8411  return ranges;
8412}
8413
8414module.exports = DefinedNamesXform;
8415
8416},{"../../../utils/col-cache":19,"../base-xform":31}],33:[function(require,module,exports){
8417"use strict";
8418
8419function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8420
8421function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8422
8423function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8424
8425function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8426
8427function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
8428
8429function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8430
8431function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8432
8433function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
8434
8435function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
8436
8437function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
8438
8439function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
8440
8441var utils = require('../../../utils/utils');
8442
8443var BaseXform = require('../base-xform');
8444
8445var WorksheetXform = /*#__PURE__*/function (_BaseXform) {
8446  _inherits(WorksheetXform, _BaseXform);
8447
8448  var _super = _createSuper(WorksheetXform);
8449
8450  function WorksheetXform() {
8451    _classCallCheck(this, WorksheetXform);
8452
8453    return _super.apply(this, arguments);
8454  }
8455
8456  _createClass(WorksheetXform, [{
8457    key: "render",
8458    value: function render(xmlStream, model) {
8459      xmlStream.leafNode('sheet', {
8460        sheetId: model.id,
8461        name: model.name,
8462        state: model.state,
8463        'r:id': model.rId
8464      });
8465    }
8466  }, {
8467    key: "parseOpen",
8468    value: function parseOpen(node) {
8469      if (node.name === 'sheet') {
8470        this.model = {
8471          name: utils.xmlDecode(node.attributes.name),
8472          id: parseInt(node.attributes.sheetId, 10),
8473          state: node.attributes.state,
8474          rId: node.attributes['r:id']
8475        };
8476        return true;
8477      }
8478
8479      return false;
8480    }
8481  }, {
8482    key: "parseText",
8483    value: function parseText() {}
8484  }, {
8485    key: "parseClose",
8486    value: function parseClose() {
8487      return false;
8488    }
8489  }]);
8490
8491  return WorksheetXform;
8492}(BaseXform);
8493
8494module.exports = WorksheetXform;
8495
8496},{"../../../utils/utils":26,"../base-xform":31}],34:[function(require,module,exports){
8497"use strict";
8498
8499function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8500
8501function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8502
8503function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8504
8505function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8506
8507function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
8508
8509function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8510
8511function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8512
8513function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
8514
8515function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
8516
8517function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
8518
8519function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
8520
8521var BaseXform = require('../base-xform');
8522
8523var WorkbookCalcPropertiesXform = /*#__PURE__*/function (_BaseXform) {
8524  _inherits(WorkbookCalcPropertiesXform, _BaseXform);
8525
8526  var _super = _createSuper(WorkbookCalcPropertiesXform);
8527
8528  function WorkbookCalcPropertiesXform() {
8529    _classCallCheck(this, WorkbookCalcPropertiesXform);
8530
8531    return _super.apply(this, arguments);
8532  }
8533
8534  _createClass(WorkbookCalcPropertiesXform, [{
8535    key: "render",
8536    value: function render(xmlStream, model) {
8537      xmlStream.leafNode('calcPr', {
8538        calcId: 171027,
8539        fullCalcOnLoad: model.fullCalcOnLoad ? 1 : undefined
8540      });
8541    }
8542  }, {
8543    key: "parseOpen",
8544    value: function parseOpen(node) {
8545      if (node.name === 'calcPr') {
8546        this.model = {};
8547        return true;
8548      }
8549
8550      return false;
8551    }
8552  }, {
8553    key: "parseText",
8554    value: function parseText() {}
8555  }, {
8556    key: "parseClose",
8557    value: function parseClose() {
8558      return false;
8559    }
8560  }]);
8561
8562  return WorkbookCalcPropertiesXform;
8563}(BaseXform);
8564
8565module.exports = WorkbookCalcPropertiesXform;
8566
8567},{"../base-xform":31}],35:[function(require,module,exports){
8568"use strict";
8569
8570function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8571
8572function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8573
8574function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8575
8576function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8577
8578function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
8579
8580function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8581
8582function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8583
8584function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
8585
8586function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
8587
8588function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
8589
8590function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
8591
8592var BaseXform = require('../base-xform');
8593
8594var WorksheetPropertiesXform = /*#__PURE__*/function (_BaseXform) {
8595  _inherits(WorksheetPropertiesXform, _BaseXform);
8596
8597  var _super = _createSuper(WorksheetPropertiesXform);
8598
8599  function WorksheetPropertiesXform() {
8600    _classCallCheck(this, WorksheetPropertiesXform);
8601
8602    return _super.apply(this, arguments);
8603  }
8604
8605  _createClass(WorksheetPropertiesXform, [{
8606    key: "render",
8607    value: function render(xmlStream, model) {
8608      xmlStream.leafNode('workbookPr', {
8609        date1904: model.date1904 ? 1 : undefined,
8610        defaultThemeVersion: 164011,
8611        filterPrivacy: 1
8612      });
8613    }
8614  }, {
8615    key: "parseOpen",
8616    value: function parseOpen(node) {
8617      if (node.name === 'workbookPr') {
8618        this.model = {
8619          date1904: node.attributes.date1904 === '1'
8620        };
8621        return true;
8622      }
8623
8624      return false;
8625    }
8626  }, {
8627    key: "parseText",
8628    value: function parseText() {}
8629  }, {
8630    key: "parseClose",
8631    value: function parseClose() {
8632      return false;
8633    }
8634  }]);
8635
8636  return WorksheetPropertiesXform;
8637}(BaseXform);
8638
8639module.exports = WorksheetPropertiesXform;
8640
8641},{"../base-xform":31}],36:[function(require,module,exports){
8642"use strict";
8643
8644function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8645
8646function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8647
8648function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8649
8650function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8651
8652function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
8653
8654function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8655
8656function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8657
8658function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
8659
8660function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
8661
8662function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
8663
8664function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
8665
8666var BaseXform = require('../base-xform');
8667
8668var WorkbookViewXform = /*#__PURE__*/function (_BaseXform) {
8669  _inherits(WorkbookViewXform, _BaseXform);
8670
8671  var _super = _createSuper(WorkbookViewXform);
8672
8673  function WorkbookViewXform() {
8674    _classCallCheck(this, WorkbookViewXform);
8675
8676    return _super.apply(this, arguments);
8677  }
8678
8679  _createClass(WorkbookViewXform, [{
8680    key: "render",
8681    value: function render(xmlStream, model) {
8682      var attributes = {
8683        xWindow: model.x || 0,
8684        yWindow: model.y || 0,
8685        windowWidth: model.width || 12000,
8686        windowHeight: model.height || 24000,
8687        firstSheet: model.firstSheet,
8688        activeTab: model.activeTab
8689      };
8690
8691      if (model.visibility && model.visibility !== 'visible') {
8692        attributes.visibility = model.visibility;
8693      }
8694
8695      xmlStream.leafNode('workbookView', attributes);
8696    }
8697  }, {
8698    key: "parseOpen",
8699    value: function parseOpen(node) {
8700      if (node.name === 'workbookView') {
8701        var model = this.model = {};
8702
8703        var addS = function addS(name, value, dflt) {
8704          var s = value !== undefined ? model[name] = value : dflt;
8705
8706          if (s !== undefined) {
8707            model[name] = s;
8708          }
8709        };
8710
8711        var addN = function addN(name, value, dflt) {
8712          var n = value !== undefined ? model[name] = parseInt(value, 10) : dflt;
8713
8714          if (n !== undefined) {
8715            model[name] = n;
8716          }
8717        };
8718
8719        addN('x', node.attributes.xWindow, 0);
8720        addN('y', node.attributes.yWindow, 0);
8721        addN('width', node.attributes.windowWidth, 25000);
8722        addN('height', node.attributes.windowHeight, 10000);
8723        addS('visibility', node.attributes.visibility, 'visible');
8724        addN('activeTab', node.attributes.activeTab, undefined);
8725        addN('firstSheet', node.attributes.firstSheet, undefined);
8726        return true;
8727      }
8728
8729      return false;
8730    }
8731  }, {
8732    key: "parseText",
8733    value: function parseText() {}
8734  }, {
8735    key: "parseClose",
8736    value: function parseClose() {
8737      return false;
8738    }
8739  }]);
8740
8741  return WorkbookViewXform;
8742}(BaseXform);
8743
8744module.exports = WorkbookViewXform;
8745
8746},{"../base-xform":31}],37:[function(require,module,exports){
8747"use strict";
8748
8749function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8750
8751function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8752
8753function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8754
8755function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8756
8757function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
8758
8759function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8760
8761function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8762
8763function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
8764
8765function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
8766
8767function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
8768
8769function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
8770
8771var _ = require('../../../utils/under-dash');
8772
8773var colCache = require('../../../utils/col-cache');
8774
8775var XmlStream = require('../../../utils/xml-stream');
8776
8777var BaseXform = require('../base-xform');
8778
8779var StaticXform = require('../static-xform');
8780
8781var ListXform = require('../list-xform');
8782
8783var DefinedNameXform = require('./defined-name-xform');
8784
8785var SheetXform = require('./sheet-xform');
8786
8787var WorkbookViewXform = require('./workbook-view-xform');
8788
8789var WorkbookPropertiesXform = require('./workbook-properties-xform');
8790
8791var WorkbookCalcPropertiesXform = require('./workbook-calc-properties-xform');
8792
8793var WorkbookXform = /*#__PURE__*/function (_BaseXform) {
8794  _inherits(WorkbookXform, _BaseXform);
8795
8796  var _super = _createSuper(WorkbookXform);
8797
8798  function WorkbookXform() {
8799    var _this;
8800
8801    _classCallCheck(this, WorkbookXform);
8802
8803    _this = _super.call(this);
8804    _this.map = {
8805      fileVersion: WorkbookXform.STATIC_XFORMS.fileVersion,
8806      workbookPr: new WorkbookPropertiesXform(),
8807      bookViews: new ListXform({
8808        tag: 'bookViews',
8809        count: false,
8810        childXform: new WorkbookViewXform()
8811      }),
8812      sheets: new ListXform({
8813        tag: 'sheets',
8814        count: false,
8815        childXform: new SheetXform()
8816      }),
8817      definedNames: new ListXform({
8818        tag: 'definedNames',
8819        count: false,
8820        childXform: new DefinedNameXform()
8821      }),
8822      calcPr: new WorkbookCalcPropertiesXform()
8823    };
8824    return _this;
8825  }
8826
8827  _createClass(WorkbookXform, [{
8828    key: "prepare",
8829    value: function prepare(model) {
8830      model.sheets = model.worksheets; // collate all the print areas from all of the sheets and add them to the defined names
8831
8832      var printAreas = [];
8833      var index = 0; // sheets is sparse array - calc index manually
8834
8835      model.sheets.forEach(function (sheet) {
8836        if (sheet.pageSetup && sheet.pageSetup.printArea) {
8837          sheet.pageSetup.printArea.split('&&').forEach(function (printArea) {
8838            var printAreaComponents = printArea.split(':');
8839            var definedName = {
8840              name: '_xlnm.Print_Area',
8841              ranges: ["'".concat(sheet.name, "'!$").concat(printAreaComponents[0], ":$").concat(printAreaComponents[1])],
8842              localSheetId: index
8843            };
8844            printAreas.push(definedName);
8845          });
8846        }
8847
8848        if (sheet.pageSetup && (sheet.pageSetup.printTitlesRow || sheet.pageSetup.printTitlesColumn)) {
8849          var ranges = [];
8850
8851          if (sheet.pageSetup.printTitlesColumn) {
8852            var titlesColumns = sheet.pageSetup.printTitlesColumn.split(':');
8853            ranges.push("'".concat(sheet.name, "'!$").concat(titlesColumns[0], ":$").concat(titlesColumns[1]));
8854          }
8855
8856          if (sheet.pageSetup.printTitlesRow) {
8857            var titlesRows = sheet.pageSetup.printTitlesRow.split(':');
8858            ranges.push("'".concat(sheet.name, "'!$").concat(titlesRows[0], ":$").concat(titlesRows[1]));
8859          }
8860
8861          var definedName = {
8862            name: '_xlnm.Print_Titles',
8863            ranges: ranges,
8864            localSheetId: index
8865          };
8866          printAreas.push(definedName);
8867        }
8868
8869        index++;
8870      });
8871
8872      if (printAreas.length) {
8873        model.definedNames = model.definedNames.concat(printAreas);
8874      }
8875
8876      (model.media || []).forEach(function (medium, i) {
8877        // assign name
8878        medium.name = medium.type + (i + 1);
8879      });
8880    }
8881  }, {
8882    key: "render",
8883    value: function render(xmlStream, model) {
8884      xmlStream.openXml(XmlStream.StdDocAttributes);
8885      xmlStream.openNode('workbook', WorkbookXform.WORKBOOK_ATTRIBUTES);
8886      this.map.fileVersion.render(xmlStream);
8887      this.map.workbookPr.render(xmlStream, model.properties);
8888      this.map.bookViews.render(xmlStream, model.views);
8889      this.map.sheets.render(xmlStream, model.sheets);
8890      this.map.definedNames.render(xmlStream, model.definedNames);
8891      this.map.calcPr.render(xmlStream, model.calcProperties);
8892      xmlStream.closeNode();
8893    }
8894  }, {
8895    key: "parseOpen",
8896    value: function parseOpen(node) {
8897      if (this.parser) {
8898        this.parser.parseOpen(node);
8899        return true;
8900      }
8901
8902      switch (node.name) {
8903        case 'workbook':
8904          return true;
8905
8906        default:
8907          this.parser = this.map[node.name];
8908
8909          if (this.parser) {
8910            this.parser.parseOpen(node);
8911          }
8912
8913          return true;
8914      }
8915    }
8916  }, {
8917    key: "parseText",
8918    value: function parseText(text) {
8919      if (this.parser) {
8920        this.parser.parseText(text);
8921      }
8922    }
8923  }, {
8924    key: "parseClose",
8925    value: function parseClose(name) {
8926      if (this.parser) {
8927        if (!this.parser.parseClose(name)) {
8928          this.parser = undefined;
8929        }
8930
8931        return true;
8932      }
8933
8934      switch (name) {
8935        case 'workbook':
8936          this.model = {
8937            sheets: this.map.sheets.model,
8938            properties: this.map.workbookPr.model || {},
8939            views: this.map.bookViews.model,
8940            calcProperties: {}
8941          };
8942
8943          if (this.map.definedNames.model) {
8944            this.model.definedNames = this.map.definedNames.model;
8945          }
8946
8947          return false;
8948
8949        default:
8950          // not quite sure how we get here!
8951          return true;
8952      }
8953    }
8954  }, {
8955    key: "reconcile",
8956    value: function reconcile(model) {
8957      var rels = (model.workbookRels || []).reduce(function (map, rel) {
8958        map[rel.Id] = rel;
8959        return map;
8960      }, {}); // reconcile sheet ids, rIds and names
8961
8962      var worksheets = [];
8963      var worksheet;
8964      var index = 0;
8965      (model.sheets || []).forEach(function (sheet) {
8966        var rel = rels[sheet.rId];
8967
8968        if (!rel) {
8969          return;
8970        } // if rel.Target start with `[space]/xl/` or `/xl/` , then it will be replaced with `''` and spliced behind `xl/`,
8971        // otherwise it will be spliced directly behind `xl/`. i.g.
8972
8973
8974        worksheet = model.worksheetHash["xl/".concat(rel.Target.replace(/^(\s|\/xl\/)+/, ''))]; // If there are "chartsheets" in the file, rel.Target will
8975        // come out as chartsheets/sheet1.xml or similar here, and
8976        // that won't be in model.worksheetHash.
8977        // As we don't have the infrastructure to support chartsheets,
8978        // we will ignore them for now:
8979
8980        if (worksheet) {
8981          worksheet.name = sheet.name;
8982          worksheet.id = sheet.id;
8983          worksheet.state = sheet.state;
8984          worksheets[index++] = worksheet;
8985        }
8986      }); // reconcile print areas
8987
8988      var definedNames = [];
8989
8990      _.each(model.definedNames, function (definedName) {
8991        if (definedName.name === '_xlnm.Print_Area') {
8992          worksheet = worksheets[definedName.localSheetId];
8993
8994          if (worksheet) {
8995            if (!worksheet.pageSetup) {
8996              worksheet.pageSetup = {};
8997            }
8998
8999            var range = colCache.decodeEx(definedName.ranges[0]);
9000            worksheet.pageSetup.printArea = worksheet.pageSetup.printArea ? "".concat(worksheet.pageSetup.printArea, "&&").concat(range.dimensions) : range.dimensions;
9001          }
9002        } else if (definedName.name === '_xlnm.Print_Titles') {
9003          worksheet = worksheets[definedName.localSheetId];
9004
9005          if (worksheet) {
9006            if (!worksheet.pageSetup) {
9007              worksheet.pageSetup = {};
9008            }
9009
9010            var rangeString = definedName.ranges.join(',');
9011            var dollarRegex = /\$/g;
9012            var rowRangeRegex = /\$\d+:\$\d+/;
9013            var rowRangeMatches = rangeString.match(rowRangeRegex);
9014
9015            if (rowRangeMatches && rowRangeMatches.length) {
9016              var _range = rowRangeMatches[0];
9017              worksheet.pageSetup.printTitlesRow = _range.replace(dollarRegex, '');
9018            }
9019
9020            var columnRangeRegex = /\$[A-Z]+:\$[A-Z]+/;
9021            var columnRangeMatches = rangeString.match(columnRangeRegex);
9022
9023            if (columnRangeMatches && columnRangeMatches.length) {
9024              var _range2 = columnRangeMatches[0];
9025              worksheet.pageSetup.printTitlesColumn = _range2.replace(dollarRegex, '');
9026            }
9027          }
9028        } else {
9029          definedNames.push(definedName);
9030        }
9031      });
9032
9033      model.definedNames = definedNames; // used by sheets to build their image models
9034
9035      model.media.forEach(function (media, i) {
9036        media.index = i;
9037      });
9038    }
9039  }]);
9040
9041  return WorkbookXform;
9042}(BaseXform);
9043
9044WorkbookXform.WORKBOOK_ATTRIBUTES = {
9045  xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
9046  'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
9047  'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
9048  'mc:Ignorable': 'x15',
9049  'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'
9050};
9051WorkbookXform.STATIC_XFORMS = {
9052  fileVersion: new StaticXform({
9053    tag: 'fileVersion',
9054    $: {
9055      appName: 'xl',
9056      lastEdited: 5,
9057      lowestEdited: 5,
9058      rupBuild: 9303
9059    }
9060  })
9061};
9062module.exports = WorkbookXform;
9063
9064},{"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"../static-xform":119,"./defined-name-xform":32,"./sheet-xform":33,"./workbook-calc-properties-xform":34,"./workbook-properties-xform":35,"./workbook-view-xform":36}],38:[function(require,module,exports){
9065"use strict";
9066
9067function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
9068
9069function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9070
9071function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9072
9073var RichTextXform = require('../strings/rich-text-xform');
9074
9075var utils = require('../../../utils/utils');
9076
9077var BaseXform = require('../base-xform');
9078/**
9079  <comment ref="B1" authorId="0">
9080    <text>
9081      <r>
9082        <rPr>
9083          <b/>
9084          <sz val="9"/>
9085          <rFont val="宋体"/>
9086          <charset val="134"/>
9087        </rPr>
9088        <t>51422:</t>
9089      </r>
9090      <r>
9091        <rPr>
9092          <sz val="9"/>
9093          <rFont val="宋体"/>
9094          <charset val="134"/>
9095        </rPr>
9096        <t xml:space="preserve">&#10;test</t>
9097      </r>
9098    </text>
9099  </comment>
9100 */
9101
9102
9103var CommentXform = module.exports = function (model) {
9104  this.model = model;
9105};
9106
9107utils.inherits(CommentXform, BaseXform, {
9108  get tag() {
9109    return 'r';
9110  },
9111
9112  get richTextXform() {
9113    if (!this._richTextXform) {
9114      this._richTextXform = new RichTextXform();
9115    }
9116
9117    return this._richTextXform;
9118  },
9119
9120  render: function render(xmlStream, model) {
9121    var _this = this;
9122
9123    model = model || this.model;
9124    xmlStream.openNode('comment', {
9125      ref: model.ref,
9126      authorId: 0
9127    });
9128    xmlStream.openNode('text');
9129
9130    if (model && model.note && model.note.texts) {
9131      model.note.texts.forEach(function (text) {
9132        _this.richTextXform.render(xmlStream, text);
9133      });
9134    }
9135
9136    xmlStream.closeNode();
9137    xmlStream.closeNode();
9138  },
9139  parseOpen: function parseOpen(node) {
9140    if (this.parser) {
9141      this.parser.parseOpen(node);
9142      return true;
9143    }
9144
9145    switch (node.name) {
9146      case 'comment':
9147        this.model = _objectSpread({
9148          type: 'note',
9149          note: {
9150            texts: []
9151          }
9152        }, node.attributes);
9153        return true;
9154
9155      case 'r':
9156        this.parser = this.richTextXform;
9157        this.parser.parseOpen(node);
9158        return true;
9159
9160      default:
9161        return false;
9162    }
9163  },
9164  parseText: function parseText(text) {
9165    if (this.parser) {
9166      this.parser.parseText(text);
9167    }
9168  },
9169  parseClose: function parseClose(name) {
9170    switch (name) {
9171      case 'comment':
9172        return false;
9173
9174      case 'r':
9175        this.model.note.texts.push(this.parser.model);
9176        this.parser = undefined;
9177        return true;
9178
9179      default:
9180        if (this.parser) {
9181          this.parser.parseClose(name);
9182        }
9183
9184        return true;
9185    }
9186  }
9187});
9188
9189},{"../../../utils/utils":26,"../base-xform":31,"../strings/rich-text-xform":121}],39:[function(require,module,exports){
9190"use strict";
9191
9192var XmlStream = require('../../../utils/xml-stream');
9193
9194var utils = require('../../../utils/utils');
9195
9196var BaseXform = require('../base-xform');
9197
9198var CommentXform = require('./comment-xform');
9199
9200var CommentsXform = module.exports = function () {
9201  this.map = {
9202    comment: new CommentXform()
9203  };
9204};
9205
9206utils.inherits(CommentsXform, BaseXform, {
9207  COMMENTS_ATTRIBUTES: {
9208    xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'
9209  }
9210}, {
9211  render: function render(xmlStream, model) {
9212    var _this = this;
9213
9214    model = model || this.model;
9215    xmlStream.openXml(XmlStream.StdDocAttributes);
9216    xmlStream.openNode('comments', CommentsXform.COMMENTS_ATTRIBUTES); // authors
9217    // TODO: support authors properly
9218
9219    xmlStream.openNode('authors');
9220    xmlStream.leafNode('author', null, 'Author');
9221    xmlStream.closeNode(); // comments
9222
9223    xmlStream.openNode('commentList');
9224    model.comments.forEach(function (comment) {
9225      _this.map.comment.render(xmlStream, comment);
9226    });
9227    xmlStream.closeNode();
9228    xmlStream.closeNode();
9229  },
9230  parseOpen: function parseOpen(node) {
9231    if (this.parser) {
9232      this.parser.parseOpen(node);
9233      return true;
9234    }
9235
9236    switch (node.name) {
9237      case 'commentList':
9238        this.model = {
9239          comments: []
9240        };
9241        return true;
9242
9243      case 'comment':
9244        this.parser = this.map.comment;
9245        this.parser.parseOpen(node);
9246        return true;
9247
9248      default:
9249        return false;
9250    }
9251  },
9252  parseText: function parseText(text) {
9253    if (this.parser) {
9254      this.parser.parseText(text);
9255    }
9256  },
9257  parseClose: function parseClose(name) {
9258    switch (name) {
9259      case 'commentList':
9260        return false;
9261
9262      case 'comment':
9263        this.model.comments.push(this.parser.model);
9264        this.parser = undefined;
9265        return true;
9266
9267      default:
9268        if (this.parser) {
9269          this.parser.parseClose(name);
9270        }
9271
9272        return true;
9273    }
9274  }
9275});
9276
9277},{"../../../utils/utils":26,"../../../utils/xml-stream":27,"../base-xform":31,"./comment-xform":38}],40:[function(require,module,exports){
9278"use strict";
9279
9280function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9281
9282function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9283
9284function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9285
9286function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9287
9288function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
9289
9290function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9291
9292function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9293
9294function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
9295
9296function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9297
9298function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
9299
9300function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
9301
9302var BaseXform = require('../../base-xform');
9303
9304var VmlPositionXform = /*#__PURE__*/function (_BaseXform) {
9305  _inherits(VmlPositionXform, _BaseXform);
9306
9307  var _super = _createSuper(VmlPositionXform);
9308
9309  function VmlPositionXform(model) {
9310    var _this;
9311
9312    _classCallCheck(this, VmlPositionXform);
9313
9314    _this = _super.call(this);
9315    _this._model = model;
9316    return _this;
9317  }
9318
9319  _createClass(VmlPositionXform, [{
9320    key: "render",
9321    value: function render(xmlStream, model, type) {
9322      if (model === type[2]) {
9323        xmlStream.leafNode(this.tag);
9324      } else if (this.tag === 'x:SizeWithCells' && model === type[1]) {
9325        xmlStream.leafNode(this.tag);
9326      }
9327    }
9328  }, {
9329    key: "parseOpen",
9330    value: function parseOpen(node) {
9331      switch (node.name) {
9332        case this.tag:
9333          this.model = {};
9334          this.model[this.tag] = true;
9335          return true;
9336
9337        default:
9338          return false;
9339      }
9340    }
9341  }, {
9342    key: "parseText",
9343    value: function parseText() {}
9344  }, {
9345    key: "parseClose",
9346    value: function parseClose() {
9347      return false;
9348    }
9349  }, {
9350    key: "tag",
9351    get: function get() {
9352      return this._model && this._model.tag;
9353    }
9354  }]);
9355
9356  return VmlPositionXform;
9357}(BaseXform);
9358
9359module.exports = VmlPositionXform;
9360
9361},{"../../base-xform":31}],41:[function(require,module,exports){
9362"use strict";
9363
9364function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9365
9366function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9367
9368function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9369
9370function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9371
9372function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
9373
9374function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9375
9376function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9377
9378function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
9379
9380function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9381
9382function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
9383
9384function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
9385
9386var BaseXform = require('../../base-xform');
9387
9388var VmlProtectionXform = /*#__PURE__*/function (_BaseXform) {
9389  _inherits(VmlProtectionXform, _BaseXform);
9390
9391  var _super = _createSuper(VmlProtectionXform);
9392
9393  function VmlProtectionXform(model) {
9394    var _this;
9395
9396    _classCallCheck(this, VmlProtectionXform);
9397
9398    _this = _super.call(this);
9399    _this._model = model;
9400    return _this;
9401  }
9402
9403  _createClass(VmlProtectionXform, [{
9404    key: "render",
9405    value: function render(xmlStream, model) {
9406      xmlStream.leafNode(this.tag, null, model);
9407    }
9408  }, {
9409    key: "parseOpen",
9410    value: function parseOpen(node) {
9411      switch (node.name) {
9412        case this.tag:
9413          this.text = '';
9414          return true;
9415
9416        default:
9417          return false;
9418      }
9419    }
9420  }, {
9421    key: "parseText",
9422    value: function parseText(text) {
9423      this.text = text;
9424    }
9425  }, {
9426    key: "parseClose",
9427    value: function parseClose() {
9428      return false;
9429    }
9430  }, {
9431    key: "tag",
9432    get: function get() {
9433      return this._model && this._model.tag;
9434    }
9435  }]);
9436
9437  return VmlProtectionXform;
9438}(BaseXform);
9439
9440module.exports = VmlProtectionXform;
9441
9442},{"../../base-xform":31}],42:[function(require,module,exports){
9443"use strict";
9444
9445function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9446
9447function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9448
9449function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9450
9451function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9452
9453function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
9454
9455function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9456
9457function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9458
9459function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
9460
9461function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9462
9463function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
9464
9465function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
9466
9467var BaseXform = require('../base-xform'); // render the triangle in the cell for the comment
9468
9469
9470var VmlAnchorXform = /*#__PURE__*/function (_BaseXform) {
9471  _inherits(VmlAnchorXform, _BaseXform);
9472
9473  var _super = _createSuper(VmlAnchorXform);
9474
9475  function VmlAnchorXform() {
9476    _classCallCheck(this, VmlAnchorXform);
9477
9478    return _super.apply(this, arguments);
9479  }
9480
9481  _createClass(VmlAnchorXform, [{
9482    key: "getAnchorRect",
9483    value: function getAnchorRect(anchor) {
9484      var l = Math.floor(anchor.left);
9485      var lf = Math.floor((anchor.left - l) * 68);
9486      var t = Math.floor(anchor.top);
9487      var tf = Math.floor((anchor.top - t) * 18);
9488      var r = Math.floor(anchor.right);
9489      var rf = Math.floor((anchor.right - r) * 68);
9490      var b = Math.floor(anchor.bottom);
9491      var bf = Math.floor((anchor.bottom - b) * 18);
9492      return [l, lf, t, tf, r, rf, b, bf];
9493    }
9494  }, {
9495    key: "getDefaultRect",
9496    value: function getDefaultRect(ref) {
9497      var l = ref.col;
9498      var lf = 6;
9499      var t = Math.max(ref.row - 2, 0);
9500      var tf = 14;
9501      var r = l + 2;
9502      var rf = 2;
9503      var b = t + 4;
9504      var bf = 16;
9505      return [l, lf, t, tf, r, rf, b, bf];
9506    }
9507  }, {
9508    key: "render",
9509    value: function render(xmlStream, model) {
9510      var rect = model.anchor ? this.getAnchorRect(model.anchor) : this.getDefaultRect(model.refAddress);
9511      xmlStream.leafNode('x:Anchor', null, rect.join(', '));
9512    }
9513  }, {
9514    key: "parseOpen",
9515    value: function parseOpen(node) {
9516      switch (node.name) {
9517        case this.tag:
9518          this.text = '';
9519          return true;
9520
9521        default:
9522          return false;
9523      }
9524    }
9525  }, {
9526    key: "parseText",
9527    value: function parseText(text) {
9528      this.text = text;
9529    }
9530  }, {
9531    key: "parseClose",
9532    value: function parseClose() {
9533      return false;
9534    }
9535  }, {
9536    key: "tag",
9537    get: function get() {
9538      return 'x:Anchor';
9539    }
9540  }]);
9541
9542  return VmlAnchorXform;
9543}(BaseXform);
9544
9545module.exports = VmlAnchorXform;
9546
9547},{"../base-xform":31}],43:[function(require,module,exports){
9548"use strict";
9549
9550function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9551
9552function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9553
9554function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9555
9556function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9557
9558function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
9559
9560function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9561
9562function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9563
9564function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
9565
9566function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9567
9568function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
9569
9570function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
9571
9572var BaseXform = require('../base-xform');
9573
9574var VmlAnchorXform = require('./vml-anchor-xform');
9575
9576var VmlProtectionXform = require('./style/vml-protection-xform');
9577
9578var VmlPositionXform = require('./style/vml-position-xform');
9579
9580var POSITION_TYPE = ['twoCells', 'oneCells', 'absolute'];
9581
9582var VmlClientDataXform = /*#__PURE__*/function (_BaseXform) {
9583  _inherits(VmlClientDataXform, _BaseXform);
9584
9585  var _super = _createSuper(VmlClientDataXform);
9586
9587  function VmlClientDataXform() {
9588    var _this;
9589
9590    _classCallCheck(this, VmlClientDataXform);
9591
9592    _this = _super.call(this);
9593    _this.map = {
9594      'x:Anchor': new VmlAnchorXform(),
9595      'x:Locked': new VmlProtectionXform({
9596        tag: 'x:Locked'
9597      }),
9598      'x:LockText': new VmlProtectionXform({
9599        tag: 'x:LockText'
9600      }),
9601      'x:SizeWithCells': new VmlPositionXform({
9602        tag: 'x:SizeWithCells'
9603      }),
9604      'x:MoveWithCells': new VmlPositionXform({
9605        tag: 'x:MoveWithCells'
9606      })
9607    };
9608    return _this;
9609  }
9610
9611  _createClass(VmlClientDataXform, [{
9612    key: "render",
9613    value: function render(xmlStream, model) {
9614      var _model$note = model.note,
9615          protection = _model$note.protection,
9616          editAs = _model$note.editAs;
9617      xmlStream.openNode(this.tag, {
9618        ObjectType: 'Note'
9619      });
9620      this.map['x:MoveWithCells'].render(xmlStream, editAs, POSITION_TYPE);
9621      this.map['x:SizeWithCells'].render(xmlStream, editAs, POSITION_TYPE);
9622      this.map['x:Anchor'].render(xmlStream, model);
9623      this.map['x:Locked'].render(xmlStream, protection.locked);
9624      xmlStream.leafNode('x:AutoFill', null, 'False');
9625      this.map['x:LockText'].render(xmlStream, protection.lockText);
9626      xmlStream.leafNode('x:Row', null, model.refAddress.row - 1);
9627      xmlStream.leafNode('x:Column', null, model.refAddress.col - 1);
9628      xmlStream.closeNode();
9629    }
9630  }, {
9631    key: "parseOpen",
9632    value: function parseOpen(node) {
9633      switch (node.name) {
9634        case this.tag:
9635          this.reset();
9636          this.model = {
9637            anchor: [],
9638            protection: {},
9639            editAs: ''
9640          };
9641          break;
9642
9643        default:
9644          this.parser = this.map[node.name];
9645
9646          if (this.parser) {
9647            this.parser.parseOpen(node);
9648          }
9649
9650          break;
9651      }
9652
9653      return true;
9654    }
9655  }, {
9656    key: "parseText",
9657    value: function parseText(text) {
9658      if (this.parser) {
9659        this.parser.parseText(text);
9660      }
9661    }
9662  }, {
9663    key: "parseClose",
9664    value: function parseClose(name) {
9665      if (this.parser) {
9666        if (!this.parser.parseClose(name)) {
9667          this.parser = undefined;
9668        }
9669
9670        return true;
9671      }
9672
9673      switch (name) {
9674        case this.tag:
9675          this.normalizeModel();
9676          return false;
9677
9678        default:
9679          return true;
9680      }
9681    }
9682  }, {
9683    key: "normalizeModel",
9684    value: function normalizeModel() {
9685      var position = Object.assign({}, this.map['x:MoveWithCells'].model, this.map['x:SizeWithCells'].model);
9686      var len = Object.keys(position).length;
9687      this.model.editAs = POSITION_TYPE[len];
9688      this.model.anchor = this.map['x:Anchor'].text;
9689      this.model.protection.locked = this.map['x:Locked'].text;
9690      this.model.protection.lockText = this.map['x:LockText'].text;
9691    }
9692  }, {
9693    key: "tag",
9694    get: function get() {
9695      return 'x:ClientData';
9696    }
9697  }]);
9698
9699  return VmlClientDataXform;
9700}(BaseXform);
9701
9702module.exports = VmlClientDataXform;
9703
9704},{"../base-xform":31,"./style/vml-position-xform":40,"./style/vml-protection-xform":41,"./vml-anchor-xform":42}],44:[function(require,module,exports){
9705"use strict";
9706
9707function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9708
9709function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9710
9711function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9712
9713function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9714
9715function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
9716
9717function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9718
9719function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9720
9721function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
9722
9723function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9724
9725function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
9726
9727function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
9728
9729var XmlStream = require('../../../utils/xml-stream');
9730
9731var BaseXform = require('../base-xform');
9732
9733var VmlShapeXform = require('./vml-shape-xform'); // This class is (currently) single purposed to insert the triangle
9734// drawing icons on commented cells
9735
9736
9737var VmlNotesXform = /*#__PURE__*/function (_BaseXform) {
9738  _inherits(VmlNotesXform, _BaseXform);
9739
9740  var _super = _createSuper(VmlNotesXform);
9741
9742  function VmlNotesXform() {
9743    var _this;
9744
9745    _classCallCheck(this, VmlNotesXform);
9746
9747    _this = _super.call(this);
9748    _this.map = {
9749      'v:shape': new VmlShapeXform()
9750    };
9751    return _this;
9752  }
9753
9754  _createClass(VmlNotesXform, [{
9755    key: "render",
9756    value: function render(xmlStream, model) {
9757      var _this2 = this;
9758
9759      xmlStream.openXml(XmlStream.StdDocAttributes);
9760      xmlStream.openNode(this.tag, VmlNotesXform.DRAWING_ATTRIBUTES);
9761      xmlStream.openNode('o:shapelayout', {
9762        'v:ext': 'edit'
9763      });
9764      xmlStream.leafNode('o:idmap', {
9765        'v:ext': 'edit',
9766        data: 1
9767      });
9768      xmlStream.closeNode();
9769      xmlStream.openNode('v:shapetype', {
9770        id: '_x0000_t202',
9771        coordsize: '21600,21600',
9772        'o:spt': 202,
9773        path: 'm,l,21600r21600,l21600,xe'
9774      });
9775      xmlStream.leafNode('v:stroke', {
9776        joinstyle: 'miter'
9777      });
9778      xmlStream.leafNode('v:path', {
9779        gradientshapeok: 't',
9780        'o:connecttype': 'rect'
9781      });
9782      xmlStream.closeNode();
9783      model.comments.forEach(function (item, index) {
9784        _this2.map['v:shape'].render(xmlStream, item, index);
9785      });
9786      xmlStream.closeNode();
9787    }
9788  }, {
9789    key: "parseOpen",
9790    value: function parseOpen(node) {
9791      if (this.parser) {
9792        this.parser.parseOpen(node);
9793        return true;
9794      }
9795
9796      switch (node.name) {
9797        case this.tag:
9798          this.reset();
9799          this.model = {
9800            comments: []
9801          };
9802          break;
9803
9804        default:
9805          this.parser = this.map[node.name];
9806
9807          if (this.parser) {
9808            this.parser.parseOpen(node);
9809          }
9810
9811          break;
9812      }
9813
9814      return true;
9815    }
9816  }, {
9817    key: "parseText",
9818    value: function parseText(text) {
9819      if (this.parser) {
9820        this.parser.parseText(text);
9821      }
9822    }
9823  }, {
9824    key: "parseClose",
9825    value: function parseClose(name) {
9826      if (this.parser) {
9827        if (!this.parser.parseClose(name)) {
9828          this.model.comments.push(this.parser.model);
9829          this.parser = undefined;
9830        }
9831
9832        return true;
9833      }
9834
9835      switch (name) {
9836        case this.tag:
9837          return false;
9838
9839        default:
9840          // could be some unrecognised tags
9841          return true;
9842      }
9843    }
9844  }, {
9845    key: "reconcile",
9846    value: function reconcile(model, options) {
9847      var _this3 = this;
9848
9849      model.anchors.forEach(function (anchor) {
9850        if (anchor.br) {
9851          _this3.map['xdr:twoCellAnchor'].reconcile(anchor, options);
9852        } else {
9853          _this3.map['xdr:oneCellAnchor'].reconcile(anchor, options);
9854        }
9855      });
9856    }
9857  }, {
9858    key: "tag",
9859    get: function get() {
9860      return 'xml';
9861    }
9862  }]);
9863
9864  return VmlNotesXform;
9865}(BaseXform);
9866
9867VmlNotesXform.DRAWING_ATTRIBUTES = {
9868  'xmlns:v': 'urn:schemas-microsoft-com:vml',
9869  'xmlns:o': 'urn:schemas-microsoft-com:office:office',
9870  'xmlns:x': 'urn:schemas-microsoft-com:office:excel'
9871};
9872module.exports = VmlNotesXform;
9873
9874},{"../../../utils/xml-stream":27,"../base-xform":31,"./vml-shape-xform":45}],45:[function(require,module,exports){
9875"use strict";
9876
9877function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9878
9879function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9880
9881function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9882
9883function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9884
9885function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
9886
9887function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9888
9889function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9890
9891function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
9892
9893function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9894
9895function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
9896
9897function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
9898
9899var BaseXform = require('../base-xform');
9900
9901var VmlTextboxXform = require('./vml-textbox-xform');
9902
9903var VmlClientDataXform = require('./vml-client-data-xform');
9904
9905var VmlShapeXform = /*#__PURE__*/function (_BaseXform) {
9906  _inherits(VmlShapeXform, _BaseXform);
9907
9908  var _super = _createSuper(VmlShapeXform);
9909
9910  function VmlShapeXform() {
9911    var _this;
9912
9913    _classCallCheck(this, VmlShapeXform);
9914
9915    _this = _super.call(this);
9916    _this.map = {
9917      'v:textbox': new VmlTextboxXform(),
9918      'x:ClientData': new VmlClientDataXform()
9919    };
9920    return _this;
9921  }
9922
9923  _createClass(VmlShapeXform, [{
9924    key: "render",
9925    value: function render(xmlStream, model, index) {
9926      xmlStream.openNode('v:shape', VmlShapeXform.V_SHAPE_ATTRIBUTES(model, index));
9927      xmlStream.leafNode('v:fill', {
9928        color2: 'infoBackground [80]'
9929      });
9930      xmlStream.leafNode('v:shadow', {
9931        color: 'none [81]',
9932        obscured: 't'
9933      });
9934      xmlStream.leafNode('v:path', {
9935        'o:connecttype': 'none'
9936      });
9937      this.map['v:textbox'].render(xmlStream, model);
9938      this.map['x:ClientData'].render(xmlStream, model);
9939      xmlStream.closeNode();
9940    }
9941  }, {
9942    key: "parseOpen",
9943    value: function parseOpen(node) {
9944      if (this.parser) {
9945        this.parser.parseOpen(node);
9946        return true;
9947      }
9948
9949      switch (node.name) {
9950        case this.tag:
9951          this.reset();
9952          this.model = {
9953            margins: {
9954              insetmode: node.attributes['o:insetmode']
9955            },
9956            anchor: '',
9957            editAs: '',
9958            protection: {}
9959          };
9960          break;
9961
9962        default:
9963          this.parser = this.map[node.name];
9964
9965          if (this.parser) {
9966            this.parser.parseOpen(node);
9967          }
9968
9969          break;
9970      }
9971
9972      return true;
9973    }
9974  }, {
9975    key: "parseText",
9976    value: function parseText(text) {
9977      if (this.parser) {
9978        this.parser.parseText(text);
9979      }
9980    }
9981  }, {
9982    key: "parseClose",
9983    value: function parseClose(name) {
9984      if (this.parser) {
9985        if (!this.parser.parseClose(name)) {
9986          this.parser = undefined;
9987        }
9988
9989        return true;
9990      }
9991
9992      switch (name) {
9993        case this.tag:
9994          this.model.margins.inset = this.map['v:textbox'].model && this.map['v:textbox'].model.inset;
9995          this.model.protection = this.map['x:ClientData'].model && this.map['x:ClientData'].model.protection;
9996          this.model.anchor = this.map['x:ClientData'].model && this.map['x:ClientData'].model.anchor;
9997          this.model.editAs = this.map['x:ClientData'].model && this.map['x:ClientData'].model.editAs;
9998          return false;
9999
10000        default:
10001          return true;
10002      }
10003    }
10004  }, {
10005    key: "tag",
10006    get: function get() {
10007      return 'v:shape';
10008    }
10009  }]);
10010
10011  return VmlShapeXform;
10012}(BaseXform);
10013
10014VmlShapeXform.V_SHAPE_ATTRIBUTES = function (model, index) {
10015  return {
10016    id: "_x0000_s".concat(1025 + index),
10017    type: '#_x0000_t202',
10018    style: 'position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden',
10019    fillcolor: 'infoBackground [80]',
10020    strokecolor: 'none [81]',
10021    'o:insetmode': model.note.margins && model.note.margins.insetmode
10022  };
10023};
10024
10025module.exports = VmlShapeXform;
10026
10027},{"../base-xform":31,"./vml-client-data-xform":43,"./vml-textbox-xform":46}],46:[function(require,module,exports){
10028"use strict";
10029
10030function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10031
10032function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10033
10034function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10035
10036function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10037
10038function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10039
10040function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10041
10042function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10043
10044function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10045
10046function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10047
10048function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
10049
10050function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10051
10052var BaseXform = require('../base-xform');
10053
10054var VmlTextboxXform = /*#__PURE__*/function (_BaseXform) {
10055  _inherits(VmlTextboxXform, _BaseXform);
10056
10057  var _super = _createSuper(VmlTextboxXform);
10058
10059  function VmlTextboxXform() {
10060    _classCallCheck(this, VmlTextboxXform);
10061
10062    return _super.apply(this, arguments);
10063  }
10064
10065  _createClass(VmlTextboxXform, [{
10066    key: "conversionUnit",
10067    value: function conversionUnit(value, multiple, unit) {
10068      return "".concat(parseFloat(value) * multiple.toFixed(2)).concat(unit);
10069    }
10070  }, {
10071    key: "reverseConversionUnit",
10072    value: function reverseConversionUnit(inset) {
10073      var _this = this;
10074
10075      return (inset || '').split(',').map(function (margin) {
10076        return Number(parseFloat(_this.conversionUnit(parseFloat(margin), 0.1, '')).toFixed(2));
10077      });
10078    }
10079  }, {
10080    key: "render",
10081    value: function render(xmlStream, model) {
10082      var _this2 = this;
10083
10084      var attributes = {
10085        style: 'mso-direction-alt:auto'
10086      };
10087
10088      if (model && model.note) {
10089        var _ref = model.note && model.note.margins,
10090            inset = _ref.inset;
10091
10092        if (Array.isArray(inset)) {
10093          inset = inset.map(function (margin) {
10094            return _this2.conversionUnit(margin, 10, 'mm');
10095          }).join(',');
10096        }
10097
10098        if (inset) {
10099          attributes.inset = inset;
10100        }
10101      }
10102
10103      xmlStream.openNode('v:textbox', attributes);
10104      xmlStream.leafNode('div', {
10105        style: 'text-align:left'
10106      });
10107      xmlStream.closeNode();
10108    }
10109  }, {
10110    key: "parseOpen",
10111    value: function parseOpen(node) {
10112      switch (node.name) {
10113        case this.tag:
10114          this.model = {
10115            inset: this.reverseConversionUnit(node.attributes.inset)
10116          };
10117          return true;
10118
10119        default:
10120          return true;
10121      }
10122    }
10123  }, {
10124    key: "parseText",
10125    value: function parseText() {}
10126  }, {
10127    key: "parseClose",
10128    value: function parseClose(name) {
10129      switch (name) {
10130        case this.tag:
10131          return false;
10132
10133        default:
10134          return true;
10135      }
10136    }
10137  }, {
10138    key: "tag",
10139    get: function get() {
10140      return 'v:textbox';
10141    }
10142  }]);
10143
10144  return VmlTextboxXform;
10145}(BaseXform);
10146
10147module.exports = VmlTextboxXform;
10148
10149},{"../base-xform":31}],47:[function(require,module,exports){
10150"use strict";
10151
10152function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10153
10154function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10155
10156function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10157
10158function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10159
10160function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10161
10162function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10163
10164function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10165
10166function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10167
10168function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10169
10170function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
10171
10172function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10173
10174var BaseXform = require('./base-xform');
10175/* 'virtual' methods used as a form of documentation */
10176
10177/* eslint-disable class-methods-use-this */
10178// base class for xforms that are composed of other xforms
10179// offers some default implementations
10180
10181
10182var CompositeXform = /*#__PURE__*/function (_BaseXform) {
10183  _inherits(CompositeXform, _BaseXform);
10184
10185  var _super = _createSuper(CompositeXform);
10186
10187  function CompositeXform() {
10188    _classCallCheck(this, CompositeXform);
10189
10190    return _super.apply(this, arguments);
10191  }
10192
10193  _createClass(CompositeXform, [{
10194    key: "createNewModel",
10195    value: function createNewModel(node) {
10196      return {};
10197    }
10198  }, {
10199    key: "parseOpen",
10200    value: function parseOpen(node) {
10201      // Typical pattern for composite xform
10202      this.parser = this.parser || this.map[node.name];
10203
10204      if (this.parser) {
10205        this.parser.parseOpen(node);
10206        return true;
10207      }
10208
10209      if (node.name === this.tag) {
10210        this.model = this.createNewModel(node);
10211        return true;
10212      }
10213
10214      return false;
10215    }
10216  }, {
10217    key: "parseText",
10218    value: function parseText(text) {
10219      // Default implementation. Send text to child parser
10220      if (this.parser) {
10221        this.parser.parseText(text);
10222      }
10223    }
10224  }, {
10225    key: "onParserClose",
10226    value: function onParserClose(name, parser) {
10227      // parseClose has seen a child parser close
10228      // now need to incorporate into this.model somehow
10229      this.model[name] = parser.model;
10230    }
10231  }, {
10232    key: "parseClose",
10233    value: function parseClose(name) {
10234      // Default implementation
10235      if (this.parser) {
10236        if (!this.parser.parseClose(name)) {
10237          this.onParserClose(name, this.parser);
10238          this.parser = undefined;
10239        }
10240
10241        return true;
10242      }
10243
10244      return name !== this.tag;
10245    }
10246  }]);
10247
10248  return CompositeXform;
10249}(BaseXform);
10250
10251module.exports = CompositeXform;
10252
10253},{"./base-xform":31}],48:[function(require,module,exports){
10254"use strict";
10255
10256function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10257
10258function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10259
10260function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10261
10262function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10263
10264function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10265
10266function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10267
10268function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10269
10270function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10271
10272function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10273
10274function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
10275
10276function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10277
10278var BaseXform = require('../base-xform');
10279
10280var AppHeadingPairsXform = /*#__PURE__*/function (_BaseXform) {
10281  _inherits(AppHeadingPairsXform, _BaseXform);
10282
10283  var _super = _createSuper(AppHeadingPairsXform);
10284
10285  function AppHeadingPairsXform() {
10286    _classCallCheck(this, AppHeadingPairsXform);
10287
10288    return _super.apply(this, arguments);
10289  }
10290
10291  _createClass(AppHeadingPairsXform, [{
10292    key: "render",
10293    value: function render(xmlStream, model) {
10294      xmlStream.openNode('HeadingPairs');
10295      xmlStream.openNode('vt:vector', {
10296        size: 2,
10297        baseType: 'variant'
10298      });
10299      xmlStream.openNode('vt:variant');
10300      xmlStream.leafNode('vt:lpstr', undefined, 'Worksheets');
10301      xmlStream.closeNode();
10302      xmlStream.openNode('vt:variant');
10303      xmlStream.leafNode('vt:i4', undefined, model.length);
10304      xmlStream.closeNode();
10305      xmlStream.closeNode();
10306      xmlStream.closeNode();
10307    }
10308  }, {
10309    key: "parseOpen",
10310    value: function parseOpen(node) {
10311      // no parsing
10312      return node.name === 'HeadingPairs';
10313    }
10314  }, {
10315    key: "parseText",
10316    value: function parseText() {}
10317  }, {
10318    key: "parseClose",
10319    value: function parseClose(name) {
10320      return name !== 'HeadingPairs';
10321    }
10322  }]);
10323
10324  return AppHeadingPairsXform;
10325}(BaseXform);
10326
10327module.exports = AppHeadingPairsXform;
10328
10329},{"../base-xform":31}],49:[function(require,module,exports){
10330"use strict";
10331
10332function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10333
10334function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10335
10336function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10337
10338function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10339
10340function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10341
10342function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10343
10344function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10345
10346function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10347
10348function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10349
10350function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
10351
10352function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10353
10354var BaseXform = require('../base-xform');
10355
10356var AppTitlesOfPartsXform = /*#__PURE__*/function (_BaseXform) {
10357  _inherits(AppTitlesOfPartsXform, _BaseXform);
10358
10359  var _super = _createSuper(AppTitlesOfPartsXform);
10360
10361  function AppTitlesOfPartsXform() {
10362    _classCallCheck(this, AppTitlesOfPartsXform);
10363
10364    return _super.apply(this, arguments);
10365  }
10366
10367  _createClass(AppTitlesOfPartsXform, [{
10368    key: "render",
10369    value: function render(xmlStream, model) {
10370      xmlStream.openNode('TitlesOfParts');
10371      xmlStream.openNode('vt:vector', {
10372        size: model.length,
10373        baseType: 'lpstr'
10374      });
10375      model.forEach(function (sheet) {
10376        xmlStream.leafNode('vt:lpstr', undefined, sheet.name);
10377      });
10378      xmlStream.closeNode();
10379      xmlStream.closeNode();
10380    }
10381  }, {
10382    key: "parseOpen",
10383    value: function parseOpen(node) {
10384      // no parsing
10385      return node.name === 'TitlesOfParts';
10386    }
10387  }, {
10388    key: "parseText",
10389    value: function parseText() {}
10390  }, {
10391    key: "parseClose",
10392    value: function parseClose(name) {
10393      return name !== 'TitlesOfParts';
10394    }
10395  }]);
10396
10397  return AppTitlesOfPartsXform;
10398}(BaseXform);
10399
10400module.exports = AppTitlesOfPartsXform;
10401
10402},{"../base-xform":31}],50:[function(require,module,exports){
10403"use strict";
10404
10405function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10406
10407function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10408
10409function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10410
10411function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10412
10413function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10414
10415function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10416
10417function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10418
10419function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10420
10421function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10422
10423function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
10424
10425function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10426
10427var XmlStream = require('../../../utils/xml-stream');
10428
10429var BaseXform = require('../base-xform');
10430
10431var StringXform = require('../simple/string-xform');
10432
10433var AppHeadingPairsXform = require('./app-heading-pairs-xform');
10434
10435var AppTitleOfPartsXform = require('./app-titles-of-parts-xform');
10436
10437var AppXform = /*#__PURE__*/function (_BaseXform) {
10438  _inherits(AppXform, _BaseXform);
10439
10440  var _super = _createSuper(AppXform);
10441
10442  function AppXform() {
10443    var _this;
10444
10445    _classCallCheck(this, AppXform);
10446
10447    _this = _super.call(this);
10448    _this.map = {
10449      Company: new StringXform({
10450        tag: 'Company'
10451      }),
10452      Manager: new StringXform({
10453        tag: 'Manager'
10454      }),
10455      HeadingPairs: new AppHeadingPairsXform(),
10456      TitleOfParts: new AppTitleOfPartsXform()
10457    };
10458    return _this;
10459  }
10460
10461  _createClass(AppXform, [{
10462    key: "render",
10463    value: function render(xmlStream, model) {
10464      xmlStream.openXml(XmlStream.StdDocAttributes);
10465      xmlStream.openNode('Properties', AppXform.PROPERTY_ATTRIBUTES);
10466      xmlStream.leafNode('Application', undefined, 'Microsoft Excel');
10467      xmlStream.leafNode('DocSecurity', undefined, '0');
10468      xmlStream.leafNode('ScaleCrop', undefined, 'false');
10469      this.map.HeadingPairs.render(xmlStream, model.worksheets);
10470      this.map.TitleOfParts.render(xmlStream, model.worksheets);
10471      this.map.Company.render(xmlStream, model.company || '');
10472      this.map.Manager.render(xmlStream, model.manager);
10473      xmlStream.leafNode('LinksUpToDate', undefined, 'false');
10474      xmlStream.leafNode('SharedDoc', undefined, 'false');
10475      xmlStream.leafNode('HyperlinksChanged', undefined, 'false');
10476      xmlStream.leafNode('AppVersion', undefined, '16.0300');
10477      xmlStream.closeNode();
10478    }
10479  }, {
10480    key: "parseOpen",
10481    value: function parseOpen(node) {
10482      if (this.parser) {
10483        this.parser.parseOpen(node);
10484        return true;
10485      }
10486
10487      switch (node.name) {
10488        case 'Properties':
10489          return true;
10490
10491        default:
10492          this.parser = this.map[node.name];
10493
10494          if (this.parser) {
10495            this.parser.parseOpen(node);
10496            return true;
10497          } // there's a lot we don't bother to parse
10498
10499
10500          return false;
10501      }
10502    }
10503  }, {
10504    key: "parseText",
10505    value: function parseText(text) {
10506      if (this.parser) {
10507        this.parser.parseText(text);
10508      }
10509    }
10510  }, {
10511    key: "parseClose",
10512    value: function parseClose(name) {
10513      if (this.parser) {
10514        if (!this.parser.parseClose(name)) {
10515          this.parser = undefined;
10516        }
10517
10518        return true;
10519      }
10520
10521      switch (name) {
10522        case 'Properties':
10523          this.model = {
10524            worksheets: this.map.TitleOfParts.model,
10525            company: this.map.Company.model,
10526            manager: this.map.Manager.model
10527          };
10528          return false;
10529
10530        default:
10531          return true;
10532      }
10533    }
10534  }]);
10535
10536  return AppXform;
10537}(BaseXform);
10538
10539AppXform.DateFormat = function (dt) {
10540  return dt.toISOString().replace(/[.]\d{3,6}/, '');
10541};
10542
10543AppXform.DateAttrs = {
10544  'xsi:type': 'dcterms:W3CDTF'
10545};
10546AppXform.PROPERTY_ATTRIBUTES = {
10547  xmlns: 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties',
10548  'xmlns:vt': 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'
10549};
10550module.exports = AppXform;
10551
10552},{"../../../utils/xml-stream":27,"../base-xform":31,"../simple/string-xform":118,"./app-heading-pairs-xform":48,"./app-titles-of-parts-xform":49}],51:[function(require,module,exports){
10553"use strict";
10554
10555function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10556
10557function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10558
10559function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10560
10561function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10562
10563function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10564
10565function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10566
10567function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10568
10569function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10570
10571function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10572
10573function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
10574
10575function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10576
10577var XmlStream = require('../../../utils/xml-stream');
10578
10579var BaseXform = require('../base-xform'); // used for rendering the [Content_Types].xml file
10580// not used for parsing
10581
10582
10583var ContentTypesXform = /*#__PURE__*/function (_BaseXform) {
10584  _inherits(ContentTypesXform, _BaseXform);
10585
10586  var _super = _createSuper(ContentTypesXform);
10587
10588  function ContentTypesXform() {
10589    _classCallCheck(this, ContentTypesXform);
10590
10591    return _super.apply(this, arguments);
10592  }
10593
10594  _createClass(ContentTypesXform, [{
10595    key: "render",
10596    value: function render(xmlStream, model) {
10597      xmlStream.openXml(XmlStream.StdDocAttributes);
10598      xmlStream.openNode('Types', ContentTypesXform.PROPERTY_ATTRIBUTES);
10599      var mediaHash = {};
10600      (model.media || []).forEach(function (medium) {
10601        if (medium.type === 'image') {
10602          var imageType = medium.extension;
10603
10604          if (!mediaHash[imageType]) {
10605            mediaHash[imageType] = true;
10606            xmlStream.leafNode('Default', {
10607              Extension: imageType,
10608              ContentType: "image/".concat(imageType)
10609            });
10610          }
10611        }
10612      });
10613      xmlStream.leafNode('Default', {
10614        Extension: 'rels',
10615        ContentType: 'application/vnd.openxmlformats-package.relationships+xml'
10616      });
10617      xmlStream.leafNode('Default', {
10618        Extension: 'xml',
10619        ContentType: 'application/xml'
10620      });
10621      xmlStream.leafNode('Override', {
10622        PartName: '/xl/workbook.xml',
10623        ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
10624      });
10625      model.worksheets.forEach(function (worksheet) {
10626        var name = "/xl/worksheets/sheet".concat(worksheet.id, ".xml");
10627        xmlStream.leafNode('Override', {
10628          PartName: name,
10629          ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
10630        });
10631      });
10632      xmlStream.leafNode('Override', {
10633        PartName: '/xl/theme/theme1.xml',
10634        ContentType: 'application/vnd.openxmlformats-officedocument.theme+xml'
10635      });
10636      xmlStream.leafNode('Override', {
10637        PartName: '/xl/styles.xml',
10638        ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'
10639      });
10640      var hasSharedStrings = model.sharedStrings && model.sharedStrings.count;
10641
10642      if (hasSharedStrings) {
10643        xmlStream.leafNode('Override', {
10644          PartName: '/xl/sharedStrings.xml',
10645          ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
10646        });
10647      }
10648
10649      if (model.tables) {
10650        model.tables.forEach(function (table) {
10651          xmlStream.leafNode('Override', {
10652            PartName: "/xl/tables/".concat(table.target),
10653            ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml'
10654          });
10655        });
10656      }
10657
10658      if (model.drawings) {
10659        model.drawings.forEach(function (drawing) {
10660          xmlStream.leafNode('Override', {
10661            PartName: "/xl/drawings/".concat(drawing.name, ".xml"),
10662            ContentType: 'application/vnd.openxmlformats-officedocument.drawing+xml'
10663          });
10664        });
10665      }
10666
10667      if (model.commentRefs) {
10668        xmlStream.leafNode('Default', {
10669          Extension: 'vml',
10670          ContentType: 'application/vnd.openxmlformats-officedocument.vmlDrawing'
10671        });
10672        model.commentRefs.forEach(function (_ref) {
10673          var commentName = _ref.commentName;
10674          xmlStream.leafNode('Override', {
10675            PartName: "/xl/".concat(commentName, ".xml"),
10676            ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
10677          });
10678        });
10679      }
10680
10681      xmlStream.leafNode('Override', {
10682        PartName: '/docProps/core.xml',
10683        ContentType: 'application/vnd.openxmlformats-package.core-properties+xml'
10684      });
10685      xmlStream.leafNode('Override', {
10686        PartName: '/docProps/app.xml',
10687        ContentType: 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
10688      });
10689      xmlStream.closeNode();
10690    }
10691  }, {
10692    key: "parseOpen",
10693    value: function parseOpen() {
10694      return false;
10695    }
10696  }, {
10697    key: "parseText",
10698    value: function parseText() {}
10699  }, {
10700    key: "parseClose",
10701    value: function parseClose() {
10702      return false;
10703    }
10704  }]);
10705
10706  return ContentTypesXform;
10707}(BaseXform);
10708
10709ContentTypesXform.PROPERTY_ATTRIBUTES = {
10710  xmlns: 'http://schemas.openxmlformats.org/package/2006/content-types'
10711};
10712module.exports = ContentTypesXform;
10713
10714},{"../../../utils/xml-stream":27,"../base-xform":31}],52:[function(require,module,exports){
10715"use strict";
10716
10717function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10718
10719function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10720
10721function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10722
10723function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10724
10725function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10726
10727function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10728
10729function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10730
10731function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10732
10733function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10734
10735function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
10736
10737function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10738
10739var XmlStream = require('../../../utils/xml-stream');
10740
10741var BaseXform = require('../base-xform');
10742
10743var DateXform = require('../simple/date-xform');
10744
10745var StringXform = require('../simple/string-xform');
10746
10747var IntegerXform = require('../simple/integer-xform');
10748
10749var CoreXform = /*#__PURE__*/function (_BaseXform) {
10750  _inherits(CoreXform, _BaseXform);
10751
10752  var _super = _createSuper(CoreXform);
10753
10754  function CoreXform() {
10755    var _this;
10756
10757    _classCallCheck(this, CoreXform);
10758
10759    _this = _super.call(this);
10760    _this.map = {
10761      'dc:creator': new StringXform({
10762        tag: 'dc:creator'
10763      }),
10764      'dc:title': new StringXform({
10765        tag: 'dc:title'
10766      }),
10767      'dc:subject': new StringXform({
10768        tag: 'dc:subject'
10769      }),
10770      'dc:description': new StringXform({
10771        tag: 'dc:description'
10772      }),
10773      'dc:identifier': new StringXform({
10774        tag: 'dc:identifier'
10775      }),
10776      'dc:language': new StringXform({
10777        tag: 'dc:language'
10778      }),
10779      'cp:keywords': new StringXform({
10780        tag: 'cp:keywords'
10781      }),
10782      'cp:category': new StringXform({
10783        tag: 'cp:category'
10784      }),
10785      'cp:lastModifiedBy': new StringXform({
10786        tag: 'cp:lastModifiedBy'
10787      }),
10788      'cp:lastPrinted': new DateXform({
10789        tag: 'cp:lastPrinted',
10790        format: CoreXform.DateFormat
10791      }),
10792      'cp:revision': new IntegerXform({
10793        tag: 'cp:revision'
10794      }),
10795      'cp:version': new StringXform({
10796        tag: 'cp:version'
10797      }),
10798      'cp:contentStatus': new StringXform({
10799        tag: 'cp:contentStatus'
10800      }),
10801      'cp:contentType': new StringXform({
10802        tag: 'cp:contentType'
10803      }),
10804      'dcterms:created': new DateXform({
10805        tag: 'dcterms:created',
10806        attrs: CoreXform.DateAttrs,
10807        format: CoreXform.DateFormat
10808      }),
10809      'dcterms:modified': new DateXform({
10810        tag: 'dcterms:modified',
10811        attrs: CoreXform.DateAttrs,
10812        format: CoreXform.DateFormat
10813      })
10814    };
10815    return _this;
10816  }
10817
10818  _createClass(CoreXform, [{
10819    key: "render",
10820    value: function render(xmlStream, model) {
10821      xmlStream.openXml(XmlStream.StdDocAttributes);
10822      xmlStream.openNode('cp:coreProperties', CoreXform.CORE_PROPERTY_ATTRIBUTES);
10823      this.map['dc:creator'].render(xmlStream, model.creator);
10824      this.map['dc:title'].render(xmlStream, model.title);
10825      this.map['dc:subject'].render(xmlStream, model.subject);
10826      this.map['dc:description'].render(xmlStream, model.description);
10827      this.map['dc:identifier'].render(xmlStream, model.identifier);
10828      this.map['dc:language'].render(xmlStream, model.language);
10829      this.map['cp:keywords'].render(xmlStream, model.keywords);
10830      this.map['cp:category'].render(xmlStream, model.category);
10831      this.map['cp:lastModifiedBy'].render(xmlStream, model.lastModifiedBy);
10832      this.map['cp:lastPrinted'].render(xmlStream, model.lastPrinted);
10833      this.map['cp:revision'].render(xmlStream, model.revision);
10834      this.map['cp:version'].render(xmlStream, model.version);
10835      this.map['cp:contentStatus'].render(xmlStream, model.contentStatus);
10836      this.map['cp:contentType'].render(xmlStream, model.contentType);
10837      this.map['dcterms:created'].render(xmlStream, model.created);
10838      this.map['dcterms:modified'].render(xmlStream, model.modified);
10839      xmlStream.closeNode();
10840    }
10841  }, {
10842    key: "parseOpen",
10843    value: function parseOpen(node) {
10844      if (this.parser) {
10845        this.parser.parseOpen(node);
10846        return true;
10847      }
10848
10849      switch (node.name) {
10850        case 'cp:coreProperties':
10851        case 'coreProperties':
10852          return true;
10853
10854        default:
10855          this.parser = this.map[node.name];
10856
10857          if (this.parser) {
10858            this.parser.parseOpen(node);
10859            return true;
10860          }
10861
10862          throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(node)));
10863      }
10864    }
10865  }, {
10866    key: "parseText",
10867    value: function parseText(text) {
10868      if (this.parser) {
10869        this.parser.parseText(text);
10870      }
10871    }
10872  }, {
10873    key: "parseClose",
10874    value: function parseClose(name) {
10875      if (this.parser) {
10876        if (!this.parser.parseClose(name)) {
10877          this.parser = undefined;
10878        }
10879
10880        return true;
10881      }
10882
10883      switch (name) {
10884        case 'cp:coreProperties':
10885        case 'coreProperties':
10886          this.model = {
10887            creator: this.map['dc:creator'].model,
10888            title: this.map['dc:title'].model,
10889            subject: this.map['dc:subject'].model,
10890            description: this.map['dc:description'].model,
10891            identifier: this.map['dc:identifier'].model,
10892            language: this.map['dc:language'].model,
10893            keywords: this.map['cp:keywords'].model,
10894            category: this.map['cp:category'].model,
10895            lastModifiedBy: this.map['cp:lastModifiedBy'].model,
10896            lastPrinted: this.map['cp:lastPrinted'].model,
10897            revision: this.map['cp:revision'].model,
10898            contentStatus: this.map['cp:contentStatus'].model,
10899            contentType: this.map['cp:contentType'].model,
10900            created: this.map['dcterms:created'].model,
10901            modified: this.map['dcterms:modified'].model
10902          };
10903          return false;
10904
10905        default:
10906          throw new Error("Unexpected xml node in parseClose: ".concat(name));
10907      }
10908    }
10909  }]);
10910
10911  return CoreXform;
10912}(BaseXform);
10913
10914CoreXform.DateFormat = function (dt) {
10915  return dt.toISOString().replace(/[.]\d{3}/, '');
10916};
10917
10918CoreXform.DateAttrs = {
10919  'xsi:type': 'dcterms:W3CDTF'
10920};
10921CoreXform.CORE_PROPERTY_ATTRIBUTES = {
10922  'xmlns:cp': 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',
10923  'xmlns:dc': 'http://purl.org/dc/elements/1.1/',
10924  'xmlns:dcterms': 'http://purl.org/dc/terms/',
10925  'xmlns:dcmitype': 'http://purl.org/dc/dcmitype/',
10926  'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance'
10927};
10928module.exports = CoreXform;
10929
10930},{"../../../utils/xml-stream":27,"../base-xform":31,"../simple/date-xform":116,"../simple/integer-xform":117,"../simple/string-xform":118}],53:[function(require,module,exports){
10931"use strict";
10932
10933function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10934
10935function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10936
10937function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10938
10939function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10940
10941function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10942
10943function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10944
10945function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10946
10947function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10948
10949function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10950
10951function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
10952
10953function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10954
10955var BaseXform = require('../base-xform');
10956
10957var RelationshipXform = /*#__PURE__*/function (_BaseXform) {
10958  _inherits(RelationshipXform, _BaseXform);
10959
10960  var _super = _createSuper(RelationshipXform);
10961
10962  function RelationshipXform() {
10963    _classCallCheck(this, RelationshipXform);
10964
10965    return _super.apply(this, arguments);
10966  }
10967
10968  _createClass(RelationshipXform, [{
10969    key: "render",
10970    value: function render(xmlStream, model) {
10971      xmlStream.leafNode('Relationship', model);
10972    }
10973  }, {
10974    key: "parseOpen",
10975    value: function parseOpen(node) {
10976      switch (node.name) {
10977        case 'Relationship':
10978          this.model = node.attributes;
10979          return true;
10980
10981        default:
10982          return false;
10983      }
10984    }
10985  }, {
10986    key: "parseText",
10987    value: function parseText() {}
10988  }, {
10989    key: "parseClose",
10990    value: function parseClose() {
10991      return false;
10992    }
10993  }]);
10994
10995  return RelationshipXform;
10996}(BaseXform);
10997
10998module.exports = RelationshipXform;
10999
11000},{"../base-xform":31}],54:[function(require,module,exports){
11001"use strict";
11002
11003function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11004
11005function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11006
11007function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11008
11009function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11010
11011function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11012
11013function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11014
11015function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11016
11017function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11018
11019function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11020
11021function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11022
11023function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11024
11025var XmlStream = require('../../../utils/xml-stream');
11026
11027var BaseXform = require('../base-xform');
11028
11029var RelationshipXform = require('./relationship-xform');
11030
11031var RelationshipsXform = /*#__PURE__*/function (_BaseXform) {
11032  _inherits(RelationshipsXform, _BaseXform);
11033
11034  var _super = _createSuper(RelationshipsXform);
11035
11036  function RelationshipsXform() {
11037    var _this;
11038
11039    _classCallCheck(this, RelationshipsXform);
11040
11041    _this = _super.call(this);
11042    _this.map = {
11043      Relationship: new RelationshipXform()
11044    };
11045    return _this;
11046  }
11047
11048  _createClass(RelationshipsXform, [{
11049    key: "render",
11050    value: function render(xmlStream, model) {
11051      var _this2 = this;
11052
11053      model = model || this._values;
11054      xmlStream.openXml(XmlStream.StdDocAttributes);
11055      xmlStream.openNode('Relationships', RelationshipsXform.RELATIONSHIPS_ATTRIBUTES);
11056      model.forEach(function (relationship) {
11057        _this2.map.Relationship.render(xmlStream, relationship);
11058      });
11059      xmlStream.closeNode();
11060    }
11061  }, {
11062    key: "parseOpen",
11063    value: function parseOpen(node) {
11064      if (this.parser) {
11065        this.parser.parseOpen(node);
11066        return true;
11067      }
11068
11069      switch (node.name) {
11070        case 'Relationships':
11071          this.model = [];
11072          return true;
11073
11074        default:
11075          this.parser = this.map[node.name];
11076
11077          if (this.parser) {
11078            this.parser.parseOpen(node);
11079            return true;
11080          }
11081
11082          throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(node)));
11083      }
11084    }
11085  }, {
11086    key: "parseText",
11087    value: function parseText(text) {
11088      if (this.parser) {
11089        this.parser.parseText(text);
11090      }
11091    }
11092  }, {
11093    key: "parseClose",
11094    value: function parseClose(name) {
11095      if (this.parser) {
11096        if (!this.parser.parseClose(name)) {
11097          this.model.push(this.parser.model);
11098          this.parser = undefined;
11099        }
11100
11101        return true;
11102      }
11103
11104      switch (name) {
11105        case 'Relationships':
11106          return false;
11107
11108        default:
11109          throw new Error("Unexpected xml node in parseClose: ".concat(name));
11110      }
11111    }
11112  }]);
11113
11114  return RelationshipsXform;
11115}(BaseXform);
11116
11117RelationshipsXform.RELATIONSHIPS_ATTRIBUTES = {
11118  xmlns: 'http://schemas.openxmlformats.org/package/2006/relationships'
11119};
11120module.exports = RelationshipsXform;
11121
11122},{"../../../utils/xml-stream":27,"../base-xform":31,"./relationship-xform":53}],55:[function(require,module,exports){
11123"use strict";
11124
11125function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11126
11127function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11128
11129function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11130
11131function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11132
11133function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11134
11135function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11136
11137function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11138
11139function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11140
11141function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11142
11143function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11144
11145function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11146
11147var BaseXform = require('../base-xform');
11148
11149var BaseCellAnchorXform = /*#__PURE__*/function (_BaseXform) {
11150  _inherits(BaseCellAnchorXform, _BaseXform);
11151
11152  var _super = _createSuper(BaseCellAnchorXform);
11153
11154  function BaseCellAnchorXform() {
11155    _classCallCheck(this, BaseCellAnchorXform);
11156
11157    return _super.apply(this, arguments);
11158  }
11159
11160  _createClass(BaseCellAnchorXform, [{
11161    key: "parseOpen",
11162    value: function parseOpen(node) {
11163      if (this.parser) {
11164        this.parser.parseOpen(node);
11165        return true;
11166      }
11167
11168      switch (node.name) {
11169        case this.tag:
11170          this.reset();
11171          this.model = {
11172            range: {
11173              editAs: node.attributes.editAs || 'oneCell'
11174            }
11175          };
11176          break;
11177
11178        default:
11179          this.parser = this.map[node.name];
11180
11181          if (this.parser) {
11182            this.parser.parseOpen(node);
11183          }
11184
11185          break;
11186      }
11187
11188      return true;
11189    }
11190  }, {
11191    key: "parseText",
11192    value: function parseText(text) {
11193      if (this.parser) {
11194        this.parser.parseText(text);
11195      }
11196    }
11197  }, {
11198    key: "reconcilePicture",
11199    value: function reconcilePicture(model, options) {
11200      if (model && model.rId) {
11201        var rel = options.rels[model.rId];
11202        var match = rel.Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);
11203
11204        if (match) {
11205          var name = match[1];
11206          var mediaId = options.mediaIndex[name];
11207          return options.media[mediaId];
11208        }
11209      }
11210
11211      return undefined;
11212    }
11213  }]);
11214
11215  return BaseCellAnchorXform;
11216}(BaseXform);
11217
11218module.exports = BaseCellAnchorXform;
11219
11220},{"../base-xform":31}],56:[function(require,module,exports){
11221"use strict";
11222
11223function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11224
11225function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11226
11227function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11228
11229function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11230
11231function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11232
11233function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11234
11235function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11236
11237function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11238
11239function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11240
11241function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11242
11243function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11244
11245var BaseXform = require('../base-xform');
11246
11247var BlipXform = require('./blip-xform');
11248
11249var BlipFillXform = /*#__PURE__*/function (_BaseXform) {
11250  _inherits(BlipFillXform, _BaseXform);
11251
11252  var _super = _createSuper(BlipFillXform);
11253
11254  function BlipFillXform() {
11255    var _this;
11256
11257    _classCallCheck(this, BlipFillXform);
11258
11259    _this = _super.call(this);
11260    _this.map = {
11261      'a:blip': new BlipXform()
11262    };
11263    return _this;
11264  }
11265
11266  _createClass(BlipFillXform, [{
11267    key: "render",
11268    value: function render(xmlStream, model) {
11269      xmlStream.openNode(this.tag);
11270      this.map['a:blip'].render(xmlStream, model); // TODO: options for this + parsing
11271
11272      xmlStream.openNode('a:stretch');
11273      xmlStream.leafNode('a:fillRect');
11274      xmlStream.closeNode();
11275      xmlStream.closeNode();
11276    }
11277  }, {
11278    key: "parseOpen",
11279    value: function parseOpen(node) {
11280      if (this.parser) {
11281        this.parser.parseOpen(node);
11282        return true;
11283      }
11284
11285      switch (node.name) {
11286        case this.tag:
11287          this.reset();
11288          break;
11289
11290        default:
11291          this.parser = this.map[node.name];
11292
11293          if (this.parser) {
11294            this.parser.parseOpen(node);
11295          }
11296
11297          break;
11298      }
11299
11300      return true;
11301    }
11302  }, {
11303    key: "parseText",
11304    value: function parseText() {}
11305  }, {
11306    key: "parseClose",
11307    value: function parseClose(name) {
11308      if (this.parser) {
11309        if (!this.parser.parseClose(name)) {
11310          this.parser = undefined;
11311        }
11312
11313        return true;
11314      }
11315
11316      switch (name) {
11317        case this.tag:
11318          this.model = this.map['a:blip'].model;
11319          return false;
11320
11321        default:
11322          return true;
11323      }
11324    }
11325  }, {
11326    key: "tag",
11327    get: function get() {
11328      return 'xdr:blipFill';
11329    }
11330  }]);
11331
11332  return BlipFillXform;
11333}(BaseXform);
11334
11335module.exports = BlipFillXform;
11336
11337},{"../base-xform":31,"./blip-xform":57}],57:[function(require,module,exports){
11338"use strict";
11339
11340function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11341
11342function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11343
11344function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11345
11346function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11347
11348function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11349
11350function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11351
11352function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11353
11354function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11355
11356function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11357
11358function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11359
11360function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11361
11362var BaseXform = require('../base-xform');
11363
11364var BlipXform = /*#__PURE__*/function (_BaseXform) {
11365  _inherits(BlipXform, _BaseXform);
11366
11367  var _super = _createSuper(BlipXform);
11368
11369  function BlipXform() {
11370    _classCallCheck(this, BlipXform);
11371
11372    return _super.apply(this, arguments);
11373  }
11374
11375  _createClass(BlipXform, [{
11376    key: "render",
11377    value: function render(xmlStream, model) {
11378      xmlStream.leafNode(this.tag, {
11379        'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
11380        'r:embed': model.rId,
11381        cstate: 'print'
11382      }); // TODO: handle children (e.g. a:extLst=>a:ext=>a14:useLocalDpi
11383    }
11384  }, {
11385    key: "parseOpen",
11386    value: function parseOpen(node) {
11387      switch (node.name) {
11388        case this.tag:
11389          this.model = {
11390            rId: node.attributes['r:embed']
11391          };
11392          return true;
11393
11394        default:
11395          return true;
11396      }
11397    }
11398  }, {
11399    key: "parseText",
11400    value: function parseText() {}
11401  }, {
11402    key: "parseClose",
11403    value: function parseClose(name) {
11404      switch (name) {
11405        case this.tag:
11406          return false;
11407
11408        default:
11409          // unprocessed internal nodes
11410          return true;
11411      }
11412    }
11413  }, {
11414    key: "tag",
11415    get: function get() {
11416      return 'a:blip';
11417    }
11418  }]);
11419
11420  return BlipXform;
11421}(BaseXform);
11422
11423module.exports = BlipXform;
11424
11425},{"../base-xform":31}],58:[function(require,module,exports){
11426"use strict";
11427
11428function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11429
11430function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11431
11432function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11433
11434function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11435
11436function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11437
11438function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11439
11440function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11441
11442function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11443
11444function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11445
11446function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11447
11448function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11449
11450var BaseXform = require('../base-xform');
11451
11452var CNvPicPrXform = /*#__PURE__*/function (_BaseXform) {
11453  _inherits(CNvPicPrXform, _BaseXform);
11454
11455  var _super = _createSuper(CNvPicPrXform);
11456
11457  function CNvPicPrXform() {
11458    _classCallCheck(this, CNvPicPrXform);
11459
11460    return _super.apply(this, arguments);
11461  }
11462
11463  _createClass(CNvPicPrXform, [{
11464    key: "render",
11465    value: function render(xmlStream) {
11466      xmlStream.openNode(this.tag);
11467      xmlStream.leafNode('a:picLocks', {
11468        noChangeAspect: '1'
11469      });
11470      xmlStream.closeNode();
11471    }
11472  }, {
11473    key: "parseOpen",
11474    value: function parseOpen(node) {
11475      switch (node.name) {
11476        case this.tag:
11477          return true;
11478
11479        default:
11480          return true;
11481      }
11482    }
11483  }, {
11484    key: "parseText",
11485    value: function parseText() {}
11486  }, {
11487    key: "parseClose",
11488    value: function parseClose(name) {
11489      switch (name) {
11490        case this.tag:
11491          return false;
11492
11493        default:
11494          // unprocessed internal nodes
11495          return true;
11496      }
11497    }
11498  }, {
11499    key: "tag",
11500    get: function get() {
11501      return 'xdr:cNvPicPr';
11502    }
11503  }]);
11504
11505  return CNvPicPrXform;
11506}(BaseXform);
11507
11508module.exports = CNvPicPrXform;
11509
11510},{"../base-xform":31}],59:[function(require,module,exports){
11511"use strict";
11512
11513function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11514
11515function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11516
11517function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11518
11519function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11520
11521function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11522
11523function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11524
11525function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11526
11527function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11528
11529function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11530
11531function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11532
11533function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11534
11535var BaseXform = require('../base-xform');
11536
11537var HlickClickXform = require('./hlink-click-xform');
11538
11539var ExtLstXform = require('./ext-lst-xform');
11540
11541var CNvPrXform = /*#__PURE__*/function (_BaseXform) {
11542  _inherits(CNvPrXform, _BaseXform);
11543
11544  var _super = _createSuper(CNvPrXform);
11545
11546  function CNvPrXform() {
11547    var _this;
11548
11549    _classCallCheck(this, CNvPrXform);
11550
11551    _this = _super.call(this);
11552    _this.map = {
11553      'a:hlinkClick': new HlickClickXform(),
11554      'a:extLst': new ExtLstXform()
11555    };
11556    return _this;
11557  }
11558
11559  _createClass(CNvPrXform, [{
11560    key: "render",
11561    value: function render(xmlStream, model) {
11562      xmlStream.openNode(this.tag, {
11563        id: model.index,
11564        name: "Picture ".concat(model.index)
11565      });
11566      this.map['a:hlinkClick'].render(xmlStream, model);
11567      this.map['a:extLst'].render(xmlStream, model);
11568      xmlStream.closeNode();
11569    }
11570  }, {
11571    key: "parseOpen",
11572    value: function parseOpen(node) {
11573      if (this.parser) {
11574        this.parser.parseOpen(node);
11575        return true;
11576      }
11577
11578      switch (node.name) {
11579        case this.tag:
11580          this.reset();
11581          break;
11582
11583        default:
11584          this.parser = this.map[node.name];
11585
11586          if (this.parser) {
11587            this.parser.parseOpen(node);
11588          }
11589
11590          break;
11591      }
11592
11593      return true;
11594    }
11595  }, {
11596    key: "parseText",
11597    value: function parseText() {}
11598  }, {
11599    key: "parseClose",
11600    value: function parseClose(name) {
11601      if (this.parser) {
11602        if (!this.parser.parseClose(name)) {
11603          this.parser = undefined;
11604        }
11605
11606        return true;
11607      }
11608
11609      switch (name) {
11610        case this.tag:
11611          this.model = this.map['a:hlinkClick'].model;
11612          return false;
11613
11614        default:
11615          return true;
11616      }
11617    }
11618  }, {
11619    key: "tag",
11620    get: function get() {
11621      return 'xdr:cNvPr';
11622    }
11623  }]);
11624
11625  return CNvPrXform;
11626}(BaseXform);
11627
11628module.exports = CNvPrXform;
11629
11630},{"../base-xform":31,"./ext-lst-xform":62,"./hlink-click-xform":64}],60:[function(require,module,exports){
11631"use strict";
11632
11633function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11634
11635function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11636
11637function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11638
11639function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11640
11641function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11642
11643function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11644
11645function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11646
11647function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11648
11649function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11650
11651function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11652
11653function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11654
11655var BaseXform = require('../base-xform');
11656
11657var IntegerXform = require('../simple/integer-xform');
11658
11659var CellPositionXform = /*#__PURE__*/function (_BaseXform) {
11660  _inherits(CellPositionXform, _BaseXform);
11661
11662  var _super = _createSuper(CellPositionXform);
11663
11664  function CellPositionXform(options) {
11665    var _this;
11666
11667    _classCallCheck(this, CellPositionXform);
11668
11669    _this = _super.call(this);
11670    _this.tag = options.tag;
11671    _this.map = {
11672      'xdr:col': new IntegerXform({
11673        tag: 'xdr:col',
11674        zero: true
11675      }),
11676      'xdr:colOff': new IntegerXform({
11677        tag: 'xdr:colOff',
11678        zero: true
11679      }),
11680      'xdr:row': new IntegerXform({
11681        tag: 'xdr:row',
11682        zero: true
11683      }),
11684      'xdr:rowOff': new IntegerXform({
11685        tag: 'xdr:rowOff',
11686        zero: true
11687      })
11688    };
11689    return _this;
11690  }
11691
11692  _createClass(CellPositionXform, [{
11693    key: "render",
11694    value: function render(xmlStream, model) {
11695      xmlStream.openNode(this.tag);
11696      this.map['xdr:col'].render(xmlStream, model.nativeCol);
11697      this.map['xdr:colOff'].render(xmlStream, model.nativeColOff);
11698      this.map['xdr:row'].render(xmlStream, model.nativeRow);
11699      this.map['xdr:rowOff'].render(xmlStream, model.nativeRowOff);
11700      xmlStream.closeNode();
11701    }
11702  }, {
11703    key: "parseOpen",
11704    value: function parseOpen(node) {
11705      if (this.parser) {
11706        this.parser.parseOpen(node);
11707        return true;
11708      }
11709
11710      switch (node.name) {
11711        case this.tag:
11712          this.reset();
11713          break;
11714
11715        default:
11716          this.parser = this.map[node.name];
11717
11718          if (this.parser) {
11719            this.parser.parseOpen(node);
11720          }
11721
11722          break;
11723      }
11724
11725      return true;
11726    }
11727  }, {
11728    key: "parseText",
11729    value: function parseText(text) {
11730      if (this.parser) {
11731        this.parser.parseText(text);
11732      }
11733    }
11734  }, {
11735    key: "parseClose",
11736    value: function parseClose(name) {
11737      if (this.parser) {
11738        if (!this.parser.parseClose(name)) {
11739          this.parser = undefined;
11740        }
11741
11742        return true;
11743      }
11744
11745      switch (name) {
11746        case this.tag:
11747          this.model = {
11748            nativeCol: this.map['xdr:col'].model,
11749            nativeColOff: this.map['xdr:colOff'].model,
11750            nativeRow: this.map['xdr:row'].model,
11751            nativeRowOff: this.map['xdr:rowOff'].model
11752          };
11753          return false;
11754
11755        default:
11756          // not quite sure how we get here!
11757          return true;
11758      }
11759    }
11760  }]);
11761
11762  return CellPositionXform;
11763}(BaseXform);
11764
11765module.exports = CellPositionXform;
11766
11767},{"../base-xform":31,"../simple/integer-xform":117}],61:[function(require,module,exports){
11768"use strict";
11769
11770function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11771
11772function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11773
11774function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11775
11776function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11777
11778function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11779
11780function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11781
11782function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11783
11784function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11785
11786function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11787
11788function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11789
11790function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11791
11792var colCache = require('../../../utils/col-cache');
11793
11794var XmlStream = require('../../../utils/xml-stream');
11795
11796var BaseXform = require('../base-xform');
11797
11798var TwoCellAnchorXform = require('./two-cell-anchor-xform');
11799
11800var OneCellAnchorXform = require('./one-cell-anchor-xform');
11801
11802function getAnchorType(model) {
11803  var range = typeof model.range === 'string' ? colCache.decode(model.range) : model.range;
11804  return range.br ? 'xdr:twoCellAnchor' : 'xdr:oneCellAnchor';
11805}
11806
11807var DrawingXform = /*#__PURE__*/function (_BaseXform) {
11808  _inherits(DrawingXform, _BaseXform);
11809
11810  var _super = _createSuper(DrawingXform);
11811
11812  function DrawingXform() {
11813    var _this;
11814
11815    _classCallCheck(this, DrawingXform);
11816
11817    _this = _super.call(this);
11818    _this.map = {
11819      'xdr:twoCellAnchor': new TwoCellAnchorXform(),
11820      'xdr:oneCellAnchor': new OneCellAnchorXform()
11821    };
11822    return _this;
11823  }
11824
11825  _createClass(DrawingXform, [{
11826    key: "prepare",
11827    value: function prepare(model) {
11828      var _this2 = this;
11829
11830      model.anchors.forEach(function (item, index) {
11831        item.anchorType = getAnchorType(item);
11832        var anchor = _this2.map[item.anchorType];
11833        anchor.prepare(item, {
11834          index: index
11835        });
11836      });
11837    }
11838  }, {
11839    key: "render",
11840    value: function render(xmlStream, model) {
11841      var _this3 = this;
11842
11843      xmlStream.openXml(XmlStream.StdDocAttributes);
11844      xmlStream.openNode(this.tag, DrawingXform.DRAWING_ATTRIBUTES);
11845      model.anchors.forEach(function (item) {
11846        var anchor = _this3.map[item.anchorType];
11847        anchor.render(xmlStream, item);
11848      });
11849      xmlStream.closeNode();
11850    }
11851  }, {
11852    key: "parseOpen",
11853    value: function parseOpen(node) {
11854      if (this.parser) {
11855        this.parser.parseOpen(node);
11856        return true;
11857      }
11858
11859      switch (node.name) {
11860        case this.tag:
11861          this.reset();
11862          this.model = {
11863            anchors: []
11864          };
11865          break;
11866
11867        default:
11868          this.parser = this.map[node.name];
11869
11870          if (this.parser) {
11871            this.parser.parseOpen(node);
11872          }
11873
11874          break;
11875      }
11876
11877      return true;
11878    }
11879  }, {
11880    key: "parseText",
11881    value: function parseText(text) {
11882      if (this.parser) {
11883        this.parser.parseText(text);
11884      }
11885    }
11886  }, {
11887    key: "parseClose",
11888    value: function parseClose(name) {
11889      if (this.parser) {
11890        if (!this.parser.parseClose(name)) {
11891          this.model.anchors.push(this.parser.model);
11892          this.parser = undefined;
11893        }
11894
11895        return true;
11896      }
11897
11898      switch (name) {
11899        case this.tag:
11900          return false;
11901
11902        default:
11903          // could be some unrecognised tags
11904          return true;
11905      }
11906    }
11907  }, {
11908    key: "reconcile",
11909    value: function reconcile(model, options) {
11910      var _this4 = this;
11911
11912      model.anchors.forEach(function (anchor) {
11913        if (anchor.br) {
11914          _this4.map['xdr:twoCellAnchor'].reconcile(anchor, options);
11915        } else {
11916          _this4.map['xdr:oneCellAnchor'].reconcile(anchor, options);
11917        }
11918      });
11919    }
11920  }, {
11921    key: "tag",
11922    get: function get() {
11923      return 'xdr:wsDr';
11924    }
11925  }]);
11926
11927  return DrawingXform;
11928}(BaseXform);
11929
11930DrawingXform.DRAWING_ATTRIBUTES = {
11931  'xmlns:xdr': 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing',
11932  'xmlns:a': 'http://schemas.openxmlformats.org/drawingml/2006/main'
11933};
11934module.exports = DrawingXform;
11935
11936},{"../../../utils/col-cache":19,"../../../utils/xml-stream":27,"../base-xform":31,"./one-cell-anchor-xform":66,"./two-cell-anchor-xform":69}],62:[function(require,module,exports){
11937"use strict";
11938
11939function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
11940
11941function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11942
11943function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11944
11945function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11946
11947function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
11948
11949function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11950
11951function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11952
11953function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
11954
11955function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11956
11957function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
11958
11959function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11960
11961var BaseXform = require('../base-xform');
11962
11963var ExtLstXform = /*#__PURE__*/function (_BaseXform) {
11964  _inherits(ExtLstXform, _BaseXform);
11965
11966  var _super = _createSuper(ExtLstXform);
11967
11968  function ExtLstXform() {
11969    _classCallCheck(this, ExtLstXform);
11970
11971    return _super.apply(this, arguments);
11972  }
11973
11974  _createClass(ExtLstXform, [{
11975    key: "render",
11976    value: function render(xmlStream) {
11977      xmlStream.openNode(this.tag);
11978      xmlStream.openNode('a:ext', {
11979        uri: '{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}'
11980      });
11981      xmlStream.leafNode('a16:creationId', {
11982        'xmlns:a16': 'http://schemas.microsoft.com/office/drawing/2014/main',
11983        id: '{00000000-0008-0000-0000-000002000000}'
11984      });
11985      xmlStream.closeNode();
11986      xmlStream.closeNode();
11987    }
11988  }, {
11989    key: "parseOpen",
11990    value: function parseOpen(node) {
11991      switch (node.name) {
11992        case this.tag:
11993          return true;
11994
11995        default:
11996          return true;
11997      }
11998    }
11999  }, {
12000    key: "parseText",
12001    value: function parseText() {}
12002  }, {
12003    key: "parseClose",
12004    value: function parseClose(name) {
12005      switch (name) {
12006        case this.tag:
12007          return false;
12008
12009        default:
12010          // unprocessed internal nodes
12011          return true;
12012      }
12013    }
12014  }, {
12015    key: "tag",
12016    get: function get() {
12017      return 'a:extLst';
12018    }
12019  }]);
12020
12021  return ExtLstXform;
12022}(BaseXform);
12023
12024module.exports = ExtLstXform;
12025
12026},{"../base-xform":31}],63:[function(require,module,exports){
12027"use strict";
12028
12029function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12030
12031function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12032
12033function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12034
12035function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12036
12037function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12038
12039function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12040
12041function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12042
12043function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12044
12045function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12046
12047function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12048
12049function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12050
12051var BaseXform = require('../base-xform');
12052/** https://en.wikipedia.org/wiki/Office_Open_XML_file_formats#DrawingML */
12053
12054
12055var EMU_PER_PIXEL_AT_96_DPI = 9525;
12056
12057var ExtXform = /*#__PURE__*/function (_BaseXform) {
12058  _inherits(ExtXform, _BaseXform);
12059
12060  var _super = _createSuper(ExtXform);
12061
12062  function ExtXform(options) {
12063    var _this;
12064
12065    _classCallCheck(this, ExtXform);
12066
12067    _this = _super.call(this);
12068    _this.tag = options.tag;
12069    _this.map = {};
12070    return _this;
12071  }
12072
12073  _createClass(ExtXform, [{
12074    key: "render",
12075    value: function render(xmlStream, model) {
12076      xmlStream.openNode(this.tag);
12077      var width = Math.floor(model.width * EMU_PER_PIXEL_AT_96_DPI);
12078      var height = Math.floor(model.height * EMU_PER_PIXEL_AT_96_DPI);
12079      xmlStream.addAttribute('cx', width);
12080      xmlStream.addAttribute('cy', height);
12081      xmlStream.closeNode();
12082    }
12083  }, {
12084    key: "parseOpen",
12085    value: function parseOpen(node) {
12086      if (node.name === this.tag) {
12087        this.model = {
12088          width: parseInt(node.attributes.cx || '0', 10) / EMU_PER_PIXEL_AT_96_DPI,
12089          height: parseInt(node.attributes.cy || '0', 10) / EMU_PER_PIXEL_AT_96_DPI
12090        };
12091        return true;
12092      }
12093
12094      return false;
12095    }
12096  }, {
12097    key: "parseText",
12098    value: function parseText()
12099    /* text */
12100    {}
12101  }, {
12102    key: "parseClose",
12103    value: function parseClose()
12104    /* name */
12105    {
12106      return false;
12107    }
12108  }]);
12109
12110  return ExtXform;
12111}(BaseXform);
12112
12113module.exports = ExtXform;
12114
12115},{"../base-xform":31}],64:[function(require,module,exports){
12116"use strict";
12117
12118function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12119
12120function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12121
12122function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12123
12124function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12125
12126function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12127
12128function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12129
12130function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12131
12132function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12133
12134function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12135
12136function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12137
12138function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12139
12140var BaseXform = require('../base-xform');
12141
12142var HLinkClickXform = /*#__PURE__*/function (_BaseXform) {
12143  _inherits(HLinkClickXform, _BaseXform);
12144
12145  var _super = _createSuper(HLinkClickXform);
12146
12147  function HLinkClickXform() {
12148    _classCallCheck(this, HLinkClickXform);
12149
12150    return _super.apply(this, arguments);
12151  }
12152
12153  _createClass(HLinkClickXform, [{
12154    key: "render",
12155    value: function render(xmlStream, model) {
12156      if (!(model.hyperlinks && model.hyperlinks.rId)) {
12157        return;
12158      }
12159
12160      xmlStream.leafNode(this.tag, {
12161        'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
12162        'r:id': model.hyperlinks.rId,
12163        tooltip: model.hyperlinks.tooltip
12164      });
12165    }
12166  }, {
12167    key: "parseOpen",
12168    value: function parseOpen(node) {
12169      switch (node.name) {
12170        case this.tag:
12171          this.model = {
12172            hyperlinks: {
12173              rId: node.attributes['r:id'],
12174              tooltip: node.attributes.tooltip
12175            }
12176          };
12177          return true;
12178
12179        default:
12180          return true;
12181      }
12182    }
12183  }, {
12184    key: "parseText",
12185    value: function parseText() {}
12186  }, {
12187    key: "parseClose",
12188    value: function parseClose() {
12189      return false;
12190    }
12191  }, {
12192    key: "tag",
12193    get: function get() {
12194      return 'a:hlinkClick';
12195    }
12196  }]);
12197
12198  return HLinkClickXform;
12199}(BaseXform);
12200
12201module.exports = HLinkClickXform;
12202
12203},{"../base-xform":31}],65:[function(require,module,exports){
12204"use strict";
12205
12206function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12207
12208function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12209
12210function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12211
12212function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12213
12214function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12215
12216function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12217
12218function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12219
12220function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12221
12222function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12223
12224function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12225
12226function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12227
12228var BaseXform = require('../base-xform');
12229
12230var CNvPrXform = require('./c-nv-pr-xform');
12231
12232var CNvPicPrXform = require('./c-nv-pic-pr-xform');
12233
12234var NvPicPrXform = /*#__PURE__*/function (_BaseXform) {
12235  _inherits(NvPicPrXform, _BaseXform);
12236
12237  var _super = _createSuper(NvPicPrXform);
12238
12239  function NvPicPrXform() {
12240    var _this;
12241
12242    _classCallCheck(this, NvPicPrXform);
12243
12244    _this = _super.call(this);
12245    _this.map = {
12246      'xdr:cNvPr': new CNvPrXform(),
12247      'xdr:cNvPicPr': new CNvPicPrXform()
12248    };
12249    return _this;
12250  }
12251
12252  _createClass(NvPicPrXform, [{
12253    key: "render",
12254    value: function render(xmlStream, model) {
12255      xmlStream.openNode(this.tag);
12256      this.map['xdr:cNvPr'].render(xmlStream, model);
12257      this.map['xdr:cNvPicPr'].render(xmlStream, model);
12258      xmlStream.closeNode();
12259    }
12260  }, {
12261    key: "parseOpen",
12262    value: function parseOpen(node) {
12263      if (this.parser) {
12264        this.parser.parseOpen(node);
12265        return true;
12266      }
12267
12268      switch (node.name) {
12269        case this.tag:
12270          this.reset();
12271          break;
12272
12273        default:
12274          this.parser = this.map[node.name];
12275
12276          if (this.parser) {
12277            this.parser.parseOpen(node);
12278          }
12279
12280          break;
12281      }
12282
12283      return true;
12284    }
12285  }, {
12286    key: "parseText",
12287    value: function parseText() {}
12288  }, {
12289    key: "parseClose",
12290    value: function parseClose(name) {
12291      if (this.parser) {
12292        if (!this.parser.parseClose(name)) {
12293          this.parser = undefined;
12294        }
12295
12296        return true;
12297      }
12298
12299      switch (name) {
12300        case this.tag:
12301          this.model = this.map['xdr:cNvPr'].model;
12302          return false;
12303
12304        default:
12305          return true;
12306      }
12307    }
12308  }, {
12309    key: "tag",
12310    get: function get() {
12311      return 'xdr:nvPicPr';
12312    }
12313  }]);
12314
12315  return NvPicPrXform;
12316}(BaseXform);
12317
12318module.exports = NvPicPrXform;
12319
12320},{"../base-xform":31,"./c-nv-pic-pr-xform":58,"./c-nv-pr-xform":59}],66:[function(require,module,exports){
12321"use strict";
12322
12323function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12324
12325function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12326
12327function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12328
12329function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12330
12331function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12332
12333function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12334
12335function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12336
12337function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12338
12339function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12340
12341function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12342
12343function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12344
12345var BaseCellAnchorXform = require('./base-cell-anchor-xform');
12346
12347var StaticXform = require('../static-xform');
12348
12349var CellPositionXform = require('./cell-position-xform');
12350
12351var ExtXform = require('./ext-xform');
12352
12353var PicXform = require('./pic-xform');
12354
12355var OneCellAnchorXform = /*#__PURE__*/function (_BaseCellAnchorXform) {
12356  _inherits(OneCellAnchorXform, _BaseCellAnchorXform);
12357
12358  var _super = _createSuper(OneCellAnchorXform);
12359
12360  function OneCellAnchorXform() {
12361    var _this;
12362
12363    _classCallCheck(this, OneCellAnchorXform);
12364
12365    _this = _super.call(this);
12366    _this.map = {
12367      'xdr:from': new CellPositionXform({
12368        tag: 'xdr:from'
12369      }),
12370      'xdr:ext': new ExtXform({
12371        tag: 'xdr:ext'
12372      }),
12373      'xdr:pic': new PicXform(),
12374      'xdr:clientData': new StaticXform({
12375        tag: 'xdr:clientData'
12376      })
12377    };
12378    return _this;
12379  }
12380
12381  _createClass(OneCellAnchorXform, [{
12382    key: "prepare",
12383    value: function prepare(model, options) {
12384      this.map['xdr:pic'].prepare(model.picture, options);
12385    }
12386  }, {
12387    key: "render",
12388    value: function render(xmlStream, model) {
12389      xmlStream.openNode(this.tag, {
12390        editAs: model.range.editAs || 'oneCell'
12391      });
12392      this.map['xdr:from'].render(xmlStream, model.range.tl);
12393      this.map['xdr:ext'].render(xmlStream, model.range.ext);
12394      this.map['xdr:pic'].render(xmlStream, model.picture);
12395      this.map['xdr:clientData'].render(xmlStream, {});
12396      xmlStream.closeNode();
12397    }
12398  }, {
12399    key: "parseClose",
12400    value: function parseClose(name) {
12401      if (this.parser) {
12402        if (!this.parser.parseClose(name)) {
12403          this.parser = undefined;
12404        }
12405
12406        return true;
12407      }
12408
12409      switch (name) {
12410        case this.tag:
12411          this.model.range.tl = this.map['xdr:from'].model;
12412          this.model.range.ext = this.map['xdr:ext'].model;
12413          this.model.picture = this.map['xdr:pic'].model;
12414          return false;
12415
12416        default:
12417          // could be some unrecognised tags
12418          return true;
12419      }
12420    }
12421  }, {
12422    key: "reconcile",
12423    value: function reconcile(model, options) {
12424      model.medium = this.reconcilePicture(model.picture, options);
12425    }
12426  }, {
12427    key: "tag",
12428    get: function get() {
12429      return 'xdr:oneCellAnchor';
12430    }
12431  }]);
12432
12433  return OneCellAnchorXform;
12434}(BaseCellAnchorXform);
12435
12436module.exports = OneCellAnchorXform;
12437
12438},{"../static-xform":119,"./base-cell-anchor-xform":55,"./cell-position-xform":60,"./ext-xform":63,"./pic-xform":67}],67:[function(require,module,exports){
12439"use strict";
12440
12441function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12442
12443function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12444
12445function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12446
12447function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12448
12449function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12450
12451function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12452
12453function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12454
12455function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12456
12457function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12458
12459function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12460
12461function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12462
12463var BaseXform = require('../base-xform');
12464
12465var StaticXform = require('../static-xform');
12466
12467var BlipFillXform = require('./blip-fill-xform');
12468
12469var NvPicPrXform = require('./nv-pic-pr-xform');
12470
12471var spPrJSON = require('./sp-pr');
12472
12473var PicXform = /*#__PURE__*/function (_BaseXform) {
12474  _inherits(PicXform, _BaseXform);
12475
12476  var _super = _createSuper(PicXform);
12477
12478  function PicXform() {
12479    var _this;
12480
12481    _classCallCheck(this, PicXform);
12482
12483    _this = _super.call(this);
12484    _this.map = {
12485      'xdr:nvPicPr': new NvPicPrXform(),
12486      'xdr:blipFill': new BlipFillXform(),
12487      'xdr:spPr': new StaticXform(spPrJSON)
12488    };
12489    return _this;
12490  }
12491
12492  _createClass(PicXform, [{
12493    key: "prepare",
12494    value: function prepare(model, options) {
12495      model.index = options.index + 1;
12496    }
12497  }, {
12498    key: "render",
12499    value: function render(xmlStream, model) {
12500      xmlStream.openNode(this.tag);
12501      this.map['xdr:nvPicPr'].render(xmlStream, model);
12502      this.map['xdr:blipFill'].render(xmlStream, model);
12503      this.map['xdr:spPr'].render(xmlStream, model);
12504      xmlStream.closeNode();
12505    }
12506  }, {
12507    key: "parseOpen",
12508    value: function parseOpen(node) {
12509      if (this.parser) {
12510        this.parser.parseOpen(node);
12511        return true;
12512      }
12513
12514      switch (node.name) {
12515        case this.tag:
12516          this.reset();
12517          break;
12518
12519        default:
12520          this.parser = this.map[node.name];
12521
12522          if (this.parser) {
12523            this.parser.parseOpen(node);
12524          }
12525
12526          break;
12527      }
12528
12529      return true;
12530    }
12531  }, {
12532    key: "parseText",
12533    value: function parseText() {}
12534  }, {
12535    key: "parseClose",
12536    value: function parseClose(name) {
12537      if (this.parser) {
12538        if (!this.parser.parseClose(name)) {
12539          this.mergeModel(this.parser.model);
12540          this.parser = undefined;
12541        }
12542
12543        return true;
12544      }
12545
12546      switch (name) {
12547        case this.tag:
12548          return false;
12549
12550        default:
12551          // not quite sure how we get here!
12552          return true;
12553      }
12554    }
12555  }, {
12556    key: "tag",
12557    get: function get() {
12558      return 'xdr:pic';
12559    }
12560  }]);
12561
12562  return PicXform;
12563}(BaseXform);
12564
12565module.exports = PicXform;
12566
12567},{"../base-xform":31,"../static-xform":119,"./blip-fill-xform":56,"./nv-pic-pr-xform":65,"./sp-pr":68}],68:[function(require,module,exports){
12568"use strict";
12569
12570module.exports = {
12571  tag: 'xdr:spPr',
12572  c: [{
12573    tag: 'a:xfrm',
12574    c: [{
12575      tag: 'a:off',
12576      $: {
12577        x: '0',
12578        y: '0'
12579      }
12580    }, {
12581      tag: 'a:ext',
12582      $: {
12583        cx: '0',
12584        cy: '0'
12585      }
12586    }]
12587  }, {
12588    tag: 'a:prstGeom',
12589    $: {
12590      prst: 'rect'
12591    },
12592    c: [{
12593      tag: 'a:avLst'
12594    }]
12595  }]
12596};
12597
12598},{}],69:[function(require,module,exports){
12599"use strict";
12600
12601function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12602
12603function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12604
12605function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12606
12607function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12608
12609function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12610
12611function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12612
12613function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12614
12615function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12616
12617function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12618
12619function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12620
12621function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12622
12623var BaseCellAnchorXform = require('./base-cell-anchor-xform');
12624
12625var StaticXform = require('../static-xform');
12626
12627var CellPositionXform = require('./cell-position-xform');
12628
12629var PicXform = require('./pic-xform');
12630
12631var TwoCellAnchorXform = /*#__PURE__*/function (_BaseCellAnchorXform) {
12632  _inherits(TwoCellAnchorXform, _BaseCellAnchorXform);
12633
12634  var _super = _createSuper(TwoCellAnchorXform);
12635
12636  function TwoCellAnchorXform() {
12637    var _this;
12638
12639    _classCallCheck(this, TwoCellAnchorXform);
12640
12641    _this = _super.call(this);
12642    _this.map = {
12643      'xdr:from': new CellPositionXform({
12644        tag: 'xdr:from'
12645      }),
12646      'xdr:to': new CellPositionXform({
12647        tag: 'xdr:to'
12648      }),
12649      'xdr:pic': new PicXform(),
12650      'xdr:clientData': new StaticXform({
12651        tag: 'xdr:clientData'
12652      })
12653    };
12654    return _this;
12655  }
12656
12657  _createClass(TwoCellAnchorXform, [{
12658    key: "prepare",
12659    value: function prepare(model, options) {
12660      this.map['xdr:pic'].prepare(model.picture, options);
12661    }
12662  }, {
12663    key: "render",
12664    value: function render(xmlStream, model) {
12665      xmlStream.openNode(this.tag, {
12666        editAs: model.range.editAs || 'oneCell'
12667      });
12668      this.map['xdr:from'].render(xmlStream, model.range.tl);
12669      this.map['xdr:to'].render(xmlStream, model.range.br);
12670      this.map['xdr:pic'].render(xmlStream, model.picture);
12671      this.map['xdr:clientData'].render(xmlStream, {});
12672      xmlStream.closeNode();
12673    }
12674  }, {
12675    key: "parseClose",
12676    value: function parseClose(name) {
12677      if (this.parser) {
12678        if (!this.parser.parseClose(name)) {
12679          this.parser = undefined;
12680        }
12681
12682        return true;
12683      }
12684
12685      switch (name) {
12686        case this.tag:
12687          this.model.range.tl = this.map['xdr:from'].model;
12688          this.model.range.br = this.map['xdr:to'].model;
12689          this.model.picture = this.map['xdr:pic'].model;
12690          return false;
12691
12692        default:
12693          // could be some unrecognised tags
12694          return true;
12695      }
12696    }
12697  }, {
12698    key: "reconcile",
12699    value: function reconcile(model, options) {
12700      model.medium = this.reconcilePicture(model.picture, options);
12701    }
12702  }, {
12703    key: "tag",
12704    get: function get() {
12705      return 'xdr:twoCellAnchor';
12706    }
12707  }]);
12708
12709  return TwoCellAnchorXform;
12710}(BaseCellAnchorXform);
12711
12712module.exports = TwoCellAnchorXform;
12713
12714},{"../static-xform":119,"./base-cell-anchor-xform":55,"./cell-position-xform":60,"./pic-xform":67}],70:[function(require,module,exports){
12715"use strict";
12716
12717function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12718
12719function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12720
12721function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12722
12723function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12724
12725function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12726
12727function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12728
12729function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12730
12731function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12732
12733function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12734
12735function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12736
12737function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12738
12739var BaseXform = require('./base-xform');
12740
12741var ListXform = /*#__PURE__*/function (_BaseXform) {
12742  _inherits(ListXform, _BaseXform);
12743
12744  var _super = _createSuper(ListXform);
12745
12746  function ListXform(options) {
12747    var _this;
12748
12749    _classCallCheck(this, ListXform);
12750
12751    _this = _super.call(this);
12752    _this.tag = options.tag;
12753    _this.always = !!options.always;
12754    _this.count = options.count;
12755    _this.empty = options.empty;
12756    _this.$count = options.$count || 'count';
12757    _this.$ = options.$;
12758    _this.childXform = options.childXform;
12759    _this.maxItems = options.maxItems;
12760    return _this;
12761  }
12762
12763  _createClass(ListXform, [{
12764    key: "prepare",
12765    value: function prepare(model, options) {
12766      var childXform = this.childXform;
12767
12768      if (model) {
12769        model.forEach(function (childModel, index) {
12770          options.index = index;
12771          childXform.prepare(childModel, options);
12772        });
12773      }
12774    }
12775  }, {
12776    key: "render",
12777    value: function render(xmlStream, model) {
12778      if (this.always || model && model.length) {
12779        xmlStream.openNode(this.tag, this.$);
12780
12781        if (this.count) {
12782          xmlStream.addAttribute(this.$count, model && model.length || 0);
12783        }
12784
12785        var childXform = this.childXform;
12786        (model || []).forEach(function (childModel, index) {
12787          childXform.render(xmlStream, childModel, index);
12788        });
12789        xmlStream.closeNode();
12790      } else if (this.empty) {
12791        xmlStream.leafNode(this.tag);
12792      }
12793    }
12794  }, {
12795    key: "parseOpen",
12796    value: function parseOpen(node) {
12797      if (this.parser) {
12798        this.parser.parseOpen(node);
12799        return true;
12800      }
12801
12802      switch (node.name) {
12803        case this.tag:
12804          this.model = [];
12805          return true;
12806
12807        default:
12808          if (this.childXform.parseOpen(node)) {
12809            this.parser = this.childXform;
12810            return true;
12811          }
12812
12813          return false;
12814      }
12815    }
12816  }, {
12817    key: "parseText",
12818    value: function parseText(text) {
12819      if (this.parser) {
12820        this.parser.parseText(text);
12821      }
12822    }
12823  }, {
12824    key: "parseClose",
12825    value: function parseClose(name) {
12826      if (this.parser) {
12827        if (!this.parser.parseClose(name)) {
12828          this.model.push(this.parser.model);
12829          this.parser = undefined;
12830
12831          if (this.maxItems && this.model.length > this.maxItems) {
12832            throw new Error("Max ".concat(this.childXform.tag, " count (").concat(this.maxItems, ") exceeded"));
12833          }
12834        }
12835
12836        return true;
12837      }
12838
12839      return false;
12840    }
12841  }, {
12842    key: "reconcile",
12843    value: function reconcile(model, options) {
12844      if (model) {
12845        var childXform = this.childXform;
12846        model.forEach(function (childModel) {
12847          childXform.reconcile(childModel, options);
12848        });
12849      }
12850    }
12851  }]);
12852
12853  return ListXform;
12854}(BaseXform);
12855
12856module.exports = ListXform;
12857
12858},{"./base-xform":31}],71:[function(require,module,exports){
12859"use strict";
12860
12861function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12862
12863function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12864
12865function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12866
12867function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12868
12869function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12870
12871function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12872
12873function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12874
12875function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12876
12877function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12878
12879function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12880
12881function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12882
12883var colCache = require('../../../utils/col-cache');
12884
12885var BaseXform = require('../base-xform');
12886
12887var AutoFilterXform = /*#__PURE__*/function (_BaseXform) {
12888  _inherits(AutoFilterXform, _BaseXform);
12889
12890  var _super = _createSuper(AutoFilterXform);
12891
12892  function AutoFilterXform() {
12893    _classCallCheck(this, AutoFilterXform);
12894
12895    return _super.apply(this, arguments);
12896  }
12897
12898  _createClass(AutoFilterXform, [{
12899    key: "render",
12900    value: function render(xmlStream, model) {
12901      if (model) {
12902        if (typeof model === 'string') {
12903          // assume range
12904          xmlStream.leafNode('autoFilter', {
12905            ref: model
12906          });
12907        } else {
12908          var getAddress = function getAddress(addr) {
12909            if (typeof addr === 'string') {
12910              return addr;
12911            }
12912
12913            return colCache.getAddress(addr.row, addr.column).address;
12914          };
12915
12916          var firstAddress = getAddress(model.from);
12917          var secondAddress = getAddress(model.to);
12918
12919          if (firstAddress && secondAddress) {
12920            xmlStream.leafNode('autoFilter', {
12921              ref: "".concat(firstAddress, ":").concat(secondAddress)
12922            });
12923          }
12924        }
12925      }
12926    }
12927  }, {
12928    key: "parseOpen",
12929    value: function parseOpen(node) {
12930      if (node.name === 'autoFilter') {
12931        this.model = node.attributes.ref;
12932      }
12933    }
12934  }, {
12935    key: "tag",
12936    get: function get() {
12937      return 'autoFilter';
12938    }
12939  }]);
12940
12941  return AutoFilterXform;
12942}(BaseXform);
12943
12944module.exports = AutoFilterXform;
12945
12946},{"../../../utils/col-cache":19,"../base-xform":31}],72:[function(require,module,exports){
12947"use strict";
12948
12949function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12950
12951function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
12952
12953function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
12954
12955function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12956
12957function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12958
12959function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12960
12961function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12962
12963function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12964
12965function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12966
12967function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12968
12969function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12970
12971function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12972
12973function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
12974
12975function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12976
12977var utils = require('../../../utils/utils');
12978
12979var BaseXform = require('../base-xform');
12980
12981var Range = require('../../../doc/range');
12982
12983var Enums = require('../../../doc/enums');
12984
12985var RichTextXform = require('../strings/rich-text-xform');
12986
12987function getValueType(v) {
12988  if (v === null || v === undefined) {
12989    return Enums.ValueType.Null;
12990  }
12991
12992  if (v instanceof String || typeof v === 'string') {
12993    return Enums.ValueType.String;
12994  }
12995
12996  if (typeof v === 'number') {
12997    return Enums.ValueType.Number;
12998  }
12999
13000  if (typeof v === 'boolean') {
13001    return Enums.ValueType.Boolean;
13002  }
13003
13004  if (v instanceof Date) {
13005    return Enums.ValueType.Date;
13006  }
13007
13008  if (v.text && v.hyperlink) {
13009    return Enums.ValueType.Hyperlink;
13010  }
13011
13012  if (v.formula) {
13013    return Enums.ValueType.Formula;
13014  }
13015
13016  if (v.error) {
13017    return Enums.ValueType.Error;
13018  }
13019
13020  throw new Error('I could not understand type of value');
13021}
13022
13023function getEffectiveCellType(cell) {
13024  switch (cell.type) {
13025    case Enums.ValueType.Formula:
13026      return getValueType(cell.result);
13027
13028    default:
13029      return cell.type;
13030  }
13031}
13032
13033var CellXform = /*#__PURE__*/function (_BaseXform) {
13034  _inherits(CellXform, _BaseXform);
13035
13036  var _super = _createSuper(CellXform);
13037
13038  function CellXform() {
13039    var _this;
13040
13041    _classCallCheck(this, CellXform);
13042
13043    _this = _super.call(this);
13044    _this.richTextXForm = new RichTextXform();
13045    return _this;
13046  }
13047
13048  _createClass(CellXform, [{
13049    key: "prepare",
13050    value: function prepare(model, options) {
13051      var styleId = options.styles.addStyleModel(model.style || {}, getEffectiveCellType(model));
13052
13053      if (styleId) {
13054        model.styleId = styleId;
13055      }
13056
13057      if (model.comment) {
13058        options.comments.push(_objectSpread(_objectSpread({}, model.comment), {}, {
13059          ref: model.address
13060        }));
13061      }
13062
13063      switch (model.type) {
13064        case Enums.ValueType.String:
13065        case Enums.ValueType.RichText:
13066          if (options.sharedStrings) {
13067            model.ssId = options.sharedStrings.add(model.value);
13068          }
13069
13070          break;
13071
13072        case Enums.ValueType.Date:
13073          if (options.date1904) {
13074            model.date1904 = true;
13075          }
13076
13077          break;
13078
13079        case Enums.ValueType.Hyperlink:
13080          if (options.sharedStrings && model.text !== undefined && model.text !== null) {
13081            model.ssId = options.sharedStrings.add(model.text);
13082          }
13083
13084          options.hyperlinks.push({
13085            address: model.address,
13086            target: model.hyperlink,
13087            tooltip: model.tooltip
13088          });
13089          break;
13090
13091        case Enums.ValueType.Merge:
13092          options.merges.add(model);
13093          break;
13094
13095        case Enums.ValueType.Formula:
13096          if (options.date1904) {
13097            // in case valueType is date
13098            model.date1904 = true;
13099          }
13100
13101          if (model.shareType === 'shared') {
13102            model.si = options.siFormulae++;
13103          }
13104
13105          if (model.formula) {
13106            options.formulae[model.address] = model;
13107          } else if (model.sharedFormula) {
13108            var master = options.formulae[model.sharedFormula];
13109
13110            if (!master) {
13111              throw new Error("Shared Formula master must exist above and or left of clone for cell ".concat(model.address));
13112            }
13113
13114            if (master.si === undefined) {
13115              master.shareType = 'shared';
13116              master.si = options.siFormulae++;
13117              master.range = new Range(master.address, model.address);
13118            } else if (master.range) {
13119              master.range.expandToAddress(model.address);
13120            }
13121
13122            model.si = master.si;
13123          }
13124
13125          break;
13126
13127        default:
13128          break;
13129      }
13130    }
13131  }, {
13132    key: "renderFormula",
13133    value: function renderFormula(xmlStream, model) {
13134      var attrs = null;
13135
13136      switch (model.shareType) {
13137        case 'shared':
13138          attrs = {
13139            t: 'shared',
13140            ref: model.ref || model.range.range,
13141            si: model.si
13142          };
13143          break;
13144
13145        case 'array':
13146          attrs = {
13147            t: 'array',
13148            ref: model.ref
13149          };
13150          break;
13151
13152        default:
13153          if (model.si !== undefined) {
13154            attrs = {
13155              t: 'shared',
13156              si: model.si
13157            };
13158          }
13159
13160          break;
13161      }
13162
13163      switch (getValueType(model.result)) {
13164        case Enums.ValueType.Null:
13165          // ?
13166          xmlStream.leafNode('f', attrs, model.formula);
13167          break;
13168
13169        case Enums.ValueType.String:
13170          // oddly, formula results don't ever use shared strings
13171          xmlStream.addAttribute('t', 'str');
13172          xmlStream.leafNode('f', attrs, model.formula);
13173          xmlStream.leafNode('v', null, model.result);
13174          break;
13175
13176        case Enums.ValueType.Number:
13177          xmlStream.leafNode('f', attrs, model.formula);
13178          xmlStream.leafNode('v', null, model.result);
13179          break;
13180
13181        case Enums.ValueType.Boolean:
13182          xmlStream.addAttribute('t', 'b');
13183          xmlStream.leafNode('f', attrs, model.formula);
13184          xmlStream.leafNode('v', null, model.result ? 1 : 0);
13185          break;
13186
13187        case Enums.ValueType.Error:
13188          xmlStream.addAttribute('t', 'e');
13189          xmlStream.leafNode('f', attrs, model.formula);
13190          xmlStream.leafNode('v', null, model.result.error);
13191          break;
13192
13193        case Enums.ValueType.Date:
13194          xmlStream.leafNode('f', attrs, model.formula);
13195          xmlStream.leafNode('v', null, utils.dateToExcel(model.result, model.date1904));
13196          break;
13197        // case Enums.ValueType.Hyperlink: // ??
13198        // case Enums.ValueType.Formula:
13199
13200        default:
13201          throw new Error('I could not understand type of value');
13202      }
13203    }
13204  }, {
13205    key: "render",
13206    value: function render(xmlStream, model) {
13207      var _this2 = this;
13208
13209      if (model.type === Enums.ValueType.Null && !model.styleId) {
13210        // if null and no style, exit
13211        return;
13212      }
13213
13214      xmlStream.openNode('c');
13215      xmlStream.addAttribute('r', model.address);
13216
13217      if (model.styleId) {
13218        xmlStream.addAttribute('s', model.styleId);
13219      }
13220
13221      switch (model.type) {
13222        case Enums.ValueType.Null:
13223          break;
13224
13225        case Enums.ValueType.Number:
13226          xmlStream.leafNode('v', null, model.value);
13227          break;
13228
13229        case Enums.ValueType.Boolean:
13230          xmlStream.addAttribute('t', 'b');
13231          xmlStream.leafNode('v', null, model.value ? '1' : '0');
13232          break;
13233
13234        case Enums.ValueType.Error:
13235          xmlStream.addAttribute('t', 'e');
13236          xmlStream.leafNode('v', null, model.value.error);
13237          break;
13238
13239        case Enums.ValueType.String:
13240        case Enums.ValueType.RichText:
13241          if (model.ssId !== undefined) {
13242            xmlStream.addAttribute('t', 's');
13243            xmlStream.leafNode('v', null, model.ssId);
13244          } else if (model.value && model.value.richText) {
13245            xmlStream.addAttribute('t', 'inlineStr');
13246            xmlStream.openNode('is');
13247            model.value.richText.forEach(function (text) {
13248              _this2.richTextXForm.render(xmlStream, text);
13249            });
13250            xmlStream.closeNode('is');
13251          } else {
13252            xmlStream.addAttribute('t', 'str');
13253            xmlStream.leafNode('v', null, model.value);
13254          }
13255
13256          break;
13257
13258        case Enums.ValueType.Date:
13259          xmlStream.leafNode('v', null, utils.dateToExcel(model.value, model.date1904));
13260          break;
13261
13262        case Enums.ValueType.Hyperlink:
13263          if (model.ssId !== undefined) {
13264            xmlStream.addAttribute('t', 's');
13265            xmlStream.leafNode('v', null, model.ssId);
13266          } else {
13267            xmlStream.addAttribute('t', 'str');
13268            xmlStream.leafNode('v', null, model.text);
13269          }
13270
13271          break;
13272
13273        case Enums.ValueType.Formula:
13274          this.renderFormula(xmlStream, model);
13275          break;
13276
13277        case Enums.ValueType.Merge:
13278          // nothing to add
13279          break;
13280
13281        default:
13282          break;
13283      }
13284
13285      xmlStream.closeNode(); // </c>
13286    }
13287  }, {
13288    key: "parseOpen",
13289    value: function parseOpen(node) {
13290      if (this.parser) {
13291        this.parser.parseOpen(node);
13292        return true;
13293      }
13294
13295      switch (node.name) {
13296        case 'c':
13297          // const address = colCache.decodeAddress(node.attributes.r);
13298          this.model = {
13299            address: node.attributes.r
13300          };
13301          this.t = node.attributes.t;
13302
13303          if (node.attributes.s) {
13304            this.model.styleId = parseInt(node.attributes.s, 10);
13305          }
13306
13307          return true;
13308
13309        case 'f':
13310          this.currentNode = 'f';
13311          this.model.si = node.attributes.si;
13312          this.model.shareType = node.attributes.t;
13313          this.model.ref = node.attributes.ref;
13314          return true;
13315
13316        case 'v':
13317          this.currentNode = 'v';
13318          return true;
13319
13320        case 't':
13321          this.currentNode = 't';
13322          return true;
13323
13324        case 'r':
13325          this.parser = this.richTextXForm;
13326          this.parser.parseOpen(node);
13327          return true;
13328
13329        default:
13330          return false;
13331      }
13332    }
13333  }, {
13334    key: "parseText",
13335    value: function parseText(text) {
13336      if (this.parser) {
13337        this.parser.parseText(text);
13338        return;
13339      }
13340
13341      switch (this.currentNode) {
13342        case 'f':
13343          this.model.formula = this.model.formula ? this.model.formula + text : text;
13344          break;
13345
13346        case 'v':
13347        case 't':
13348          if (this.model.value && this.model.value.richText) {
13349            this.model.value.richText.text = this.model.value.richText.text ? this.model.value.richText.text + text : text;
13350          } else {
13351            this.model.value = this.model.value ? this.model.value + text : text;
13352          }
13353
13354          break;
13355
13356        default:
13357          break;
13358      }
13359    }
13360  }, {
13361    key: "parseClose",
13362    value: function parseClose(name) {
13363      switch (name) {
13364        case 'c':
13365          {
13366            var model = this.model; // first guess on cell type
13367
13368            if (model.formula || model.shareType) {
13369              model.type = Enums.ValueType.Formula;
13370
13371              if (model.value) {
13372                if (this.t === 'str') {
13373                  model.result = utils.xmlDecode(model.value);
13374                } else if (this.t === 'b') {
13375                  model.result = parseInt(model.value, 10) !== 0;
13376                } else if (this.t === 'e') {
13377                  model.result = {
13378                    error: model.value
13379                  };
13380                } else {
13381                  model.result = parseFloat(model.value);
13382                }
13383
13384                model.value = undefined;
13385              }
13386            } else if (model.value !== undefined) {
13387              switch (this.t) {
13388                case 's':
13389                  model.type = Enums.ValueType.String;
13390                  model.value = parseInt(model.value, 10);
13391                  break;
13392
13393                case 'str':
13394                  model.type = Enums.ValueType.String;
13395                  model.value = utils.xmlDecode(model.value);
13396                  break;
13397
13398                case 'inlineStr':
13399                  model.type = Enums.ValueType.String;
13400                  break;
13401
13402                case 'b':
13403                  model.type = Enums.ValueType.Boolean;
13404                  model.value = parseInt(model.value, 10) !== 0;
13405                  break;
13406
13407                case 'e':
13408                  model.type = Enums.ValueType.Error;
13409                  model.value = {
13410                    error: model.value
13411                  };
13412                  break;
13413
13414                default:
13415                  model.type = Enums.ValueType.Number;
13416                  model.value = parseFloat(model.value);
13417                  break;
13418              }
13419            } else if (model.styleId) {
13420              model.type = Enums.ValueType.Null;
13421            } else {
13422              model.type = Enums.ValueType.Merge;
13423            }
13424
13425            return false;
13426          }
13427
13428        case 'f':
13429        case 'v':
13430        case 'is':
13431          this.currentNode = undefined;
13432          return true;
13433
13434        case 't':
13435          if (this.parser) {
13436            this.parser.parseClose(name);
13437            return true;
13438          }
13439
13440          this.currentNode = undefined;
13441          return true;
13442
13443        case 'r':
13444          this.model.value = this.model.value || {};
13445          this.model.value.richText = this.model.value.richText || [];
13446          this.model.value.richText.push(this.parser.model);
13447          this.parser = undefined;
13448          this.currentNode = undefined;
13449          return true;
13450
13451        default:
13452          if (this.parser) {
13453            this.parser.parseClose(name);
13454            return true;
13455          }
13456
13457          return false;
13458      }
13459    }
13460  }, {
13461    key: "reconcile",
13462    value: function reconcile(model, options) {
13463      var style = model.styleId && options.styles && options.styles.getStyleModel(model.styleId);
13464
13465      if (style) {
13466        model.style = style;
13467      }
13468
13469      if (model.styleId !== undefined) {
13470        model.styleId = undefined;
13471      }
13472
13473      switch (model.type) {
13474        case Enums.ValueType.String:
13475          if (typeof model.value === 'number') {
13476            if (options.sharedStrings) {
13477              model.value = options.sharedStrings.getString(model.value);
13478            }
13479          }
13480
13481          if (model.value.richText) {
13482            model.type = Enums.ValueType.RichText;
13483          }
13484
13485          break;
13486
13487        case Enums.ValueType.Number:
13488          if (style && utils.isDateFmt(style.numFmt)) {
13489            model.type = Enums.ValueType.Date;
13490            model.value = utils.excelToDate(model.value, options.date1904);
13491          }
13492
13493          break;
13494
13495        case Enums.ValueType.Formula:
13496          if (model.result !== undefined && style && utils.isDateFmt(style.numFmt)) {
13497            model.result = utils.excelToDate(model.result, options.date1904);
13498          }
13499
13500          if (model.shareType === 'shared') {
13501            if (model.ref) {
13502              // master
13503              options.formulae[model.si] = model.address;
13504            } else {
13505              // slave
13506              model.sharedFormula = options.formulae[model.si];
13507              delete model.shareType;
13508            }
13509
13510            delete model.si;
13511          }
13512
13513          break;
13514
13515        default:
13516          break;
13517      } // look for hyperlink
13518
13519
13520      var hyperlink = options.hyperlinkMap[model.address];
13521
13522      if (hyperlink) {
13523        if (model.type === Enums.ValueType.Formula) {
13524          model.text = model.result;
13525          model.result = undefined;
13526        } else {
13527          model.text = model.value;
13528          model.value = undefined;
13529        }
13530
13531        model.type = Enums.ValueType.Hyperlink;
13532        model.hyperlink = hyperlink;
13533      }
13534
13535      var comment = options.commentsMap && options.commentsMap[model.address];
13536
13537      if (comment) {
13538        model.comment = comment;
13539      }
13540    }
13541  }, {
13542    key: "tag",
13543    get: function get() {
13544      return 'c';
13545    }
13546  }]);
13547
13548  return CellXform;
13549}(BaseXform);
13550
13551module.exports = CellXform;
13552
13553},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/utils":26,"../base-xform":31,"../strings/rich-text-xform":121}],73:[function(require,module,exports){
13554"use strict";
13555
13556function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13557
13558function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13559
13560function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13561
13562function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13563
13564function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
13565
13566function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13567
13568function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13569
13570function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
13571
13572function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13573
13574function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
13575
13576function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13577
13578var BaseXform = require('../../base-xform');
13579
13580var CfIconExtXform = /*#__PURE__*/function (_BaseXform) {
13581  _inherits(CfIconExtXform, _BaseXform);
13582
13583  var _super = _createSuper(CfIconExtXform);
13584
13585  function CfIconExtXform() {
13586    _classCallCheck(this, CfIconExtXform);
13587
13588    return _super.apply(this, arguments);
13589  }
13590
13591  _createClass(CfIconExtXform, [{
13592    key: "render",
13593    value: function render(xmlStream, model) {
13594      xmlStream.leafNode(this.tag, {
13595        iconSet: model.iconSet,
13596        iconId: model.iconId
13597      });
13598    }
13599  }, {
13600    key: "parseOpen",
13601    value: function parseOpen(_ref) {
13602      var attributes = _ref.attributes;
13603      this.model = {
13604        iconSet: attributes.iconSet,
13605        iconId: BaseXform.toIntValue(attributes.iconId)
13606      };
13607    }
13608  }, {
13609    key: "parseClose",
13610    value: function parseClose(name) {
13611      return name !== this.tag;
13612    }
13613  }, {
13614    key: "tag",
13615    get: function get() {
13616      return 'x14:cfIcon';
13617    }
13618  }]);
13619
13620  return CfIconExtXform;
13621}(BaseXform);
13622
13623module.exports = CfIconExtXform;
13624
13625},{"../../base-xform":31}],74:[function(require,module,exports){
13626"use strict";
13627
13628function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13629
13630function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13631
13632function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13633
13634function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13635
13636function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
13637
13638function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13639
13640function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13641
13642function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
13643
13644function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13645
13646function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
13647
13648function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13649
13650var _require = require('uuid'),
13651    uuidv4 = _require.v4;
13652
13653var BaseXform = require('../../base-xform');
13654
13655var CompositeXform = require('../../composite-xform');
13656
13657var DatabarExtXform = require('./databar-ext-xform');
13658
13659var IconSetExtXform = require('./icon-set-ext-xform');
13660
13661var extIcons = {
13662  '3Triangles': true,
13663  '3Stars': true,
13664  '5Boxes': true
13665};
13666
13667var CfRuleExtXform = /*#__PURE__*/function (_CompositeXform) {
13668  _inherits(CfRuleExtXform, _CompositeXform);
13669
13670  var _super = _createSuper(CfRuleExtXform);
13671
13672  function CfRuleExtXform() {
13673    var _this;
13674
13675    _classCallCheck(this, CfRuleExtXform);
13676
13677    _this = _super.call(this);
13678    _this.map = {
13679      'x14:dataBar': _this.databarXform = new DatabarExtXform(),
13680      'x14:iconSet': _this.iconSetXform = new IconSetExtXform()
13681    };
13682    return _this;
13683  }
13684
13685  _createClass(CfRuleExtXform, [{
13686    key: "prepare",
13687    value: function prepare(model) {
13688      if (CfRuleExtXform.isExt(model)) {
13689        model.x14Id = "{".concat(uuidv4(), "}").toUpperCase();
13690      }
13691    }
13692  }, {
13693    key: "render",
13694    value: function render(xmlStream, model) {
13695      if (!CfRuleExtXform.isExt(model)) {
13696        return;
13697      }
13698
13699      switch (model.type) {
13700        case 'dataBar':
13701          this.renderDataBar(xmlStream, model);
13702          break;
13703
13704        case 'iconSet':
13705          this.renderIconSet(xmlStream, model);
13706          break;
13707      }
13708    }
13709  }, {
13710    key: "renderDataBar",
13711    value: function renderDataBar(xmlStream, model) {
13712      xmlStream.openNode(this.tag, {
13713        type: 'dataBar',
13714        id: model.x14Id
13715      });
13716      this.databarXform.render(xmlStream, model);
13717      xmlStream.closeNode();
13718    }
13719  }, {
13720    key: "renderIconSet",
13721    value: function renderIconSet(xmlStream, model) {
13722      xmlStream.openNode(this.tag, {
13723        type: 'iconSet',
13724        priority: model.priority,
13725        id: model.x14Id || "{".concat(uuidv4(), "}")
13726      });
13727      this.iconSetXform.render(xmlStream, model);
13728      xmlStream.closeNode();
13729    }
13730  }, {
13731    key: "createNewModel",
13732    value: function createNewModel(_ref) {
13733      var attributes = _ref.attributes;
13734      return {
13735        type: attributes.type,
13736        x14Id: attributes.id,
13737        priority: BaseXform.toIntValue(attributes.priority)
13738      };
13739    }
13740  }, {
13741    key: "onParserClose",
13742    value: function onParserClose(name, parser) {
13743      Object.assign(this.model, parser.model);
13744    }
13745  }, {
13746    key: "tag",
13747    get: function get() {
13748      return 'x14:cfRule';
13749    }
13750  }], [{
13751    key: "isExt",
13752    value: function isExt(rule) {
13753      // is this rule primitive?
13754      if (rule.type === 'dataBar') {
13755        return DatabarExtXform.isExt(rule);
13756      }
13757
13758      if (rule.type === 'iconSet') {
13759        if (rule.custom || extIcons[rule.iconSet]) {
13760          return true;
13761        }
13762      }
13763
13764      return false;
13765    }
13766  }]);
13767
13768  return CfRuleExtXform;
13769}(CompositeXform);
13770
13771module.exports = CfRuleExtXform;
13772
13773},{"../../base-xform":31,"../../composite-xform":47,"./databar-ext-xform":78,"./icon-set-ext-xform":80,"uuid":526}],75:[function(require,module,exports){
13774"use strict";
13775
13776function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13777
13778function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13779
13780function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13781
13782function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13783
13784function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
13785
13786function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13787
13788function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13789
13790function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
13791
13792function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13793
13794function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
13795
13796function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13797
13798var CompositeXform = require('../../composite-xform');
13799
13800var FExtXform = require('./f-ext-xform');
13801
13802var CfvoExtXform = /*#__PURE__*/function (_CompositeXform) {
13803  _inherits(CfvoExtXform, _CompositeXform);
13804
13805  var _super = _createSuper(CfvoExtXform);
13806
13807  function CfvoExtXform() {
13808    var _this;
13809
13810    _classCallCheck(this, CfvoExtXform);
13811
13812    _this = _super.call(this);
13813    _this.map = {
13814      'xm:f': _this.fExtXform = new FExtXform()
13815    };
13816    return _this;
13817  }
13818
13819  _createClass(CfvoExtXform, [{
13820    key: "render",
13821    value: function render(xmlStream, model) {
13822      xmlStream.openNode(this.tag, {
13823        type: model.type
13824      });
13825
13826      if (model.value !== undefined) {
13827        this.fExtXform.render(xmlStream, model.value);
13828      }
13829
13830      xmlStream.closeNode();
13831    }
13832  }, {
13833    key: "createNewModel",
13834    value: function createNewModel(node) {
13835      return {
13836        type: node.attributes.type
13837      };
13838    }
13839  }, {
13840    key: "onParserClose",
13841    value: function onParserClose(name, parser) {
13842      switch (name) {
13843        case 'xm:f':
13844          this.model.value = parser.model ? parseFloat(parser.model) : 0;
13845          break;
13846      }
13847    }
13848  }, {
13849    key: "tag",
13850    get: function get() {
13851      return 'x14:cfvo';
13852    }
13853  }]);
13854
13855  return CfvoExtXform;
13856}(CompositeXform);
13857
13858module.exports = CfvoExtXform;
13859
13860},{"../../composite-xform":47,"./f-ext-xform":79}],76:[function(require,module,exports){
13861"use strict";
13862
13863function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13864
13865function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13866
13867function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13868
13869function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13870
13871function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
13872
13873function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13874
13875function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13876
13877function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
13878
13879function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13880
13881function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
13882
13883function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13884
13885var CompositeXform = require('../../composite-xform');
13886
13887var SqRefExtXform = require('./sqref-ext-xform');
13888
13889var CfRuleExtXform = require('./cf-rule-ext-xform');
13890
13891var ConditionalFormattingExtXform = /*#__PURE__*/function (_CompositeXform) {
13892  _inherits(ConditionalFormattingExtXform, _CompositeXform);
13893
13894  var _super = _createSuper(ConditionalFormattingExtXform);
13895
13896  function ConditionalFormattingExtXform() {
13897    var _this;
13898
13899    _classCallCheck(this, ConditionalFormattingExtXform);
13900
13901    _this = _super.call(this);
13902    _this.map = {
13903      'xm:sqref': _this.sqRef = new SqRefExtXform(),
13904      'x14:cfRule': _this.cfRule = new CfRuleExtXform()
13905    };
13906    return _this;
13907  }
13908
13909  _createClass(ConditionalFormattingExtXform, [{
13910    key: "prepare",
13911    value: function prepare(model, options) {
13912      var _this2 = this;
13913
13914      model.rules.forEach(function (rule) {
13915        _this2.cfRule.prepare(rule, options);
13916      });
13917    }
13918  }, {
13919    key: "render",
13920    value: function render(xmlStream, model) {
13921      var _this3 = this;
13922
13923      if (!model.rules.some(CfRuleExtXform.isExt)) {
13924        return;
13925      }
13926
13927      xmlStream.openNode(this.tag, {
13928        'xmlns:xm': 'http://schemas.microsoft.com/office/excel/2006/main'
13929      });
13930      model.rules.filter(CfRuleExtXform.isExt).forEach(function (rule) {
13931        return _this3.cfRule.render(xmlStream, rule);
13932      }); // for some odd reason, Excel needs the <xm:sqref> node to be after the rules
13933
13934      this.sqRef.render(xmlStream, model.ref);
13935      xmlStream.closeNode();
13936    }
13937  }, {
13938    key: "createNewModel",
13939    value: function createNewModel() {
13940      return {
13941        rules: []
13942      };
13943    }
13944  }, {
13945    key: "onParserClose",
13946    value: function onParserClose(name, parser) {
13947      switch (name) {
13948        case 'xm:sqref':
13949          this.model.ref = parser.model;
13950          break;
13951
13952        case 'x14:cfRule':
13953          this.model.rules.push(parser.model);
13954          break;
13955      }
13956    }
13957  }, {
13958    key: "tag",
13959    get: function get() {
13960      return 'x14:conditionalFormatting';
13961    }
13962  }]);
13963
13964  return ConditionalFormattingExtXform;
13965}(CompositeXform);
13966
13967module.exports = ConditionalFormattingExtXform;
13968
13969},{"../../composite-xform":47,"./cf-rule-ext-xform":74,"./sqref-ext-xform":81}],77:[function(require,module,exports){
13970"use strict";
13971
13972function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13973
13974function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13975
13976function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13977
13978function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13979
13980function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
13981
13982function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13983
13984function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13985
13986function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
13987
13988function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13989
13990function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
13991
13992function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13993
13994var CompositeXform = require('../../composite-xform');
13995
13996var CfRuleExtXform = require('./cf-rule-ext-xform');
13997
13998var ConditionalFormattingExtXform = require('./conditional-formatting-ext-xform');
13999
14000var ConditionalFormattingsExtXform = /*#__PURE__*/function (_CompositeXform) {
14001  _inherits(ConditionalFormattingsExtXform, _CompositeXform);
14002
14003  var _super = _createSuper(ConditionalFormattingsExtXform);
14004
14005  function ConditionalFormattingsExtXform() {
14006    var _this;
14007
14008    _classCallCheck(this, ConditionalFormattingsExtXform);
14009
14010    _this = _super.call(this);
14011    _this.map = {
14012      'x14:conditionalFormatting': _this.cfXform = new ConditionalFormattingExtXform()
14013    };
14014    return _this;
14015  }
14016
14017  _createClass(ConditionalFormattingsExtXform, [{
14018    key: "hasContent",
14019    value: function hasContent(model) {
14020      if (model.hasExtContent === undefined) {
14021        model.hasExtContent = model.some(function (cf) {
14022          return cf.rules.some(CfRuleExtXform.isExt);
14023        });
14024      }
14025
14026      return model.hasExtContent;
14027    }
14028  }, {
14029    key: "prepare",
14030    value: function prepare(model, options) {
14031      var _this2 = this;
14032
14033      model.forEach(function (cf) {
14034        _this2.cfXform.prepare(cf, options);
14035      });
14036    }
14037  }, {
14038    key: "render",
14039    value: function render(xmlStream, model) {
14040      var _this3 = this;
14041
14042      if (this.hasContent(model)) {
14043        xmlStream.openNode(this.tag);
14044        model.forEach(function (cf) {
14045          return _this3.cfXform.render(xmlStream, cf);
14046        });
14047        xmlStream.closeNode();
14048      }
14049    }
14050  }, {
14051    key: "createNewModel",
14052    value: function createNewModel() {
14053      return [];
14054    }
14055  }, {
14056    key: "onParserClose",
14057    value: function onParserClose(name, parser) {
14058      // model is array of conditional formatting objects
14059      this.model.push(parser.model);
14060    }
14061  }, {
14062    key: "tag",
14063    get: function get() {
14064      return 'x14:conditionalFormattings';
14065    }
14066  }]);
14067
14068  return ConditionalFormattingsExtXform;
14069}(CompositeXform);
14070
14071module.exports = ConditionalFormattingsExtXform;
14072
14073},{"../../composite-xform":47,"./cf-rule-ext-xform":74,"./conditional-formatting-ext-xform":76}],78:[function(require,module,exports){
14074"use strict";
14075
14076function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14077
14078function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14079
14080function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14081
14082function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14083
14084function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14085
14086function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14087
14088function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14089
14090function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14091
14092function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14093
14094function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14095
14096function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14097
14098function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14099
14100function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14101
14102function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
14103
14104function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14105
14106function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
14107
14108function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14109
14110var BaseXform = require('../../base-xform');
14111
14112var CompositeXform = require('../../composite-xform');
14113
14114var ColorXform = require('../../style/color-xform');
14115
14116var CfvoExtXform = require('./cfvo-ext-xform');
14117
14118var DatabarExtXform = /*#__PURE__*/function (_CompositeXform) {
14119  _inherits(DatabarExtXform, _CompositeXform);
14120
14121  var _super = _createSuper(DatabarExtXform);
14122
14123  function DatabarExtXform() {
14124    var _this;
14125
14126    _classCallCheck(this, DatabarExtXform);
14127
14128    _this = _super.call(this);
14129    _this.map = {
14130      'x14:cfvo': _this.cfvoXform = new CfvoExtXform(),
14131      'x14:borderColor': _this.borderColorXform = new ColorXform('x14:borderColor'),
14132      'x14:negativeBorderColor': _this.negativeBorderColorXform = new ColorXform('x14:negativeBorderColor'),
14133      'x14:negativeFillColor': _this.negativeFillColorXform = new ColorXform('x14:negativeFillColor'),
14134      'x14:axisColor': _this.axisColorXform = new ColorXform('x14:axisColor')
14135    };
14136    return _this;
14137  }
14138
14139  _createClass(DatabarExtXform, [{
14140    key: "render",
14141    value: function render(xmlStream, model) {
14142      var _this2 = this;
14143
14144      xmlStream.openNode(this.tag, {
14145        minLength: BaseXform.toIntAttribute(model.minLength, 0, true),
14146        maxLength: BaseXform.toIntAttribute(model.maxLength, 100, true),
14147        border: BaseXform.toBoolAttribute(model.border, false),
14148        gradient: BaseXform.toBoolAttribute(model.gradient, true),
14149        negativeBarColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarColorSameAsPositive, true),
14150        negativeBarBorderColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarBorderColorSameAsPositive, true),
14151        axisPosition: BaseXform.toAttribute(model.axisPosition, 'auto'),
14152        direction: BaseXform.toAttribute(model.direction, 'leftToRight')
14153      });
14154      model.cfvo.forEach(function (cfvo) {
14155        _this2.cfvoXform.render(xmlStream, cfvo);
14156      });
14157      this.borderColorXform.render(xmlStream, model.borderColor);
14158      this.negativeBorderColorXform.render(xmlStream, model.negativeBorderColor);
14159      this.negativeFillColorXform.render(xmlStream, model.negativeFillColor);
14160      this.axisColorXform.render(xmlStream, model.axisColor);
14161      xmlStream.closeNode();
14162    }
14163  }, {
14164    key: "createNewModel",
14165    value: function createNewModel(_ref) {
14166      var attributes = _ref.attributes;
14167      return {
14168        cfvo: [],
14169        minLength: BaseXform.toIntValue(attributes.minLength, 0),
14170        maxLength: BaseXform.toIntValue(attributes.maxLength, 100),
14171        border: BaseXform.toBoolValue(attributes.border, false),
14172        gradient: BaseXform.toBoolValue(attributes.gradient, true),
14173        negativeBarColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarColorSameAsPositive, true),
14174        negativeBarBorderColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarBorderColorSameAsPositive, true),
14175        axisPosition: BaseXform.toStringValue(attributes.axisPosition, 'auto'),
14176        direction: BaseXform.toStringValue(attributes.direction, 'leftToRight')
14177      };
14178    }
14179  }, {
14180    key: "onParserClose",
14181    value: function onParserClose(name, parser) {
14182      var _name$split = name.split(':'),
14183          _name$split2 = _slicedToArray(_name$split, 2),
14184          prop = _name$split2[1];
14185
14186      switch (prop) {
14187        case 'cfvo':
14188          this.model.cfvo.push(parser.model);
14189          break;
14190
14191        default:
14192          this.model[prop] = parser.model;
14193          break;
14194      }
14195    }
14196  }, {
14197    key: "tag",
14198    get: function get() {
14199      return 'x14:dataBar';
14200    }
14201  }], [{
14202    key: "isExt",
14203    value: function isExt(rule) {
14204      // not all databars need ext
14205      // TODO: refine this
14206      return !rule.gradient;
14207    }
14208  }]);
14209
14210  return DatabarExtXform;
14211}(CompositeXform);
14212
14213module.exports = DatabarExtXform;
14214
14215},{"../../base-xform":31,"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-ext-xform":75}],79:[function(require,module,exports){
14216"use strict";
14217
14218function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14219
14220function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14221
14222function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14223
14224function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14225
14226function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14227
14228function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14229
14230function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14231
14232function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
14233
14234function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14235
14236function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
14237
14238function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14239
14240var BaseXform = require('../../base-xform');
14241
14242var FExtXform = /*#__PURE__*/function (_BaseXform) {
14243  _inherits(FExtXform, _BaseXform);
14244
14245  var _super = _createSuper(FExtXform);
14246
14247  function FExtXform() {
14248    _classCallCheck(this, FExtXform);
14249
14250    return _super.apply(this, arguments);
14251  }
14252
14253  _createClass(FExtXform, [{
14254    key: "render",
14255    value: function render(xmlStream, model) {
14256      xmlStream.leafNode(this.tag, null, model);
14257    }
14258  }, {
14259    key: "parseOpen",
14260    value: function parseOpen() {
14261      this.model = '';
14262    }
14263  }, {
14264    key: "parseText",
14265    value: function parseText(text) {
14266      this.model += text;
14267    }
14268  }, {
14269    key: "parseClose",
14270    value: function parseClose(name) {
14271      return name !== this.tag;
14272    }
14273  }, {
14274    key: "tag",
14275    get: function get() {
14276      return 'xm:f';
14277    }
14278  }]);
14279
14280  return FExtXform;
14281}(BaseXform);
14282
14283module.exports = FExtXform;
14284
14285},{"../../base-xform":31}],80:[function(require,module,exports){
14286"use strict";
14287
14288function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14289
14290function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14291
14292function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14293
14294function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14295
14296function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14297
14298function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14299
14300function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14301
14302function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14303
14304function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14305
14306function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14307
14308function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14309
14310function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14311
14312function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14313
14314function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
14315
14316function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14317
14318function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
14319
14320function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14321
14322var BaseXform = require('../../base-xform');
14323
14324var CompositeXform = require('../../composite-xform');
14325
14326var CfvoExtXform = require('./cfvo-ext-xform');
14327
14328var CfIconExtXform = require('./cf-icon-ext-xform');
14329
14330var IconSetExtXform = /*#__PURE__*/function (_CompositeXform) {
14331  _inherits(IconSetExtXform, _CompositeXform);
14332
14333  var _super = _createSuper(IconSetExtXform);
14334
14335  function IconSetExtXform() {
14336    var _this;
14337
14338    _classCallCheck(this, IconSetExtXform);
14339
14340    _this = _super.call(this);
14341    _this.map = {
14342      'x14:cfvo': _this.cfvoXform = new CfvoExtXform(),
14343      'x14:cfIcon': _this.cfIconXform = new CfIconExtXform()
14344    };
14345    return _this;
14346  }
14347
14348  _createClass(IconSetExtXform, [{
14349    key: "render",
14350    value: function render(xmlStream, model) {
14351      var _this2 = this;
14352
14353      xmlStream.openNode(this.tag, {
14354        iconSet: BaseXform.toStringAttribute(model.iconSet),
14355        reverse: BaseXform.toBoolAttribute(model.reverse, false),
14356        showValue: BaseXform.toBoolAttribute(model.showValue, true),
14357        custom: BaseXform.toBoolAttribute(model.icons, false)
14358      });
14359      model.cfvo.forEach(function (cfvo) {
14360        _this2.cfvoXform.render(xmlStream, cfvo);
14361      });
14362
14363      if (model.icons) {
14364        model.icons.forEach(function (icon, i) {
14365          icon.iconId = i;
14366
14367          _this2.cfIconXform.render(xmlStream, icon);
14368        });
14369      }
14370
14371      xmlStream.closeNode();
14372    }
14373  }, {
14374    key: "createNewModel",
14375    value: function createNewModel(_ref) {
14376      var attributes = _ref.attributes;
14377      return {
14378        cfvo: [],
14379        iconSet: BaseXform.toStringValue(attributes.iconSet, '3TrafficLights'),
14380        reverse: BaseXform.toBoolValue(attributes.reverse, false),
14381        showValue: BaseXform.toBoolValue(attributes.showValue, true)
14382      };
14383    }
14384  }, {
14385    key: "onParserClose",
14386    value: function onParserClose(name, parser) {
14387      var _name$split = name.split(':'),
14388          _name$split2 = _slicedToArray(_name$split, 2),
14389          prop = _name$split2[1];
14390
14391      switch (prop) {
14392        case 'cfvo':
14393          this.model.cfvo.push(parser.model);
14394          break;
14395
14396        case 'cfIcon':
14397          if (!this.model.icons) {
14398            this.model.icons = [];
14399          }
14400
14401          this.model.icons.push(parser.model);
14402          break;
14403
14404        default:
14405          this.model[prop] = parser.model;
14406          break;
14407      }
14408    }
14409  }, {
14410    key: "tag",
14411    get: function get() {
14412      return 'x14:iconSet';
14413    }
14414  }]);
14415
14416  return IconSetExtXform;
14417}(CompositeXform);
14418
14419module.exports = IconSetExtXform;
14420
14421},{"../../base-xform":31,"../../composite-xform":47,"./cf-icon-ext-xform":73,"./cfvo-ext-xform":75}],81:[function(require,module,exports){
14422"use strict";
14423
14424function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14425
14426function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14427
14428function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14429
14430function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14431
14432function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14433
14434function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14435
14436function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14437
14438function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
14439
14440function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14441
14442function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
14443
14444function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14445
14446var BaseXform = require('../../base-xform');
14447
14448var SqrefExtXform = /*#__PURE__*/function (_BaseXform) {
14449  _inherits(SqrefExtXform, _BaseXform);
14450
14451  var _super = _createSuper(SqrefExtXform);
14452
14453  function SqrefExtXform() {
14454    _classCallCheck(this, SqrefExtXform);
14455
14456    return _super.apply(this, arguments);
14457  }
14458
14459  _createClass(SqrefExtXform, [{
14460    key: "render",
14461    value: function render(xmlStream, model) {
14462      xmlStream.leafNode(this.tag, null, model);
14463    }
14464  }, {
14465    key: "parseOpen",
14466    value: function parseOpen() {
14467      this.model = '';
14468    }
14469  }, {
14470    key: "parseText",
14471    value: function parseText(text) {
14472      this.model += text;
14473    }
14474  }, {
14475    key: "parseClose",
14476    value: function parseClose(name) {
14477      return name !== this.tag;
14478    }
14479  }, {
14480    key: "tag",
14481    get: function get() {
14482      return 'xm:sqref';
14483    }
14484  }]);
14485
14486  return SqrefExtXform;
14487}(BaseXform);
14488
14489module.exports = SqrefExtXform;
14490
14491},{"../../base-xform":31}],82:[function(require,module,exports){
14492"use strict";
14493
14494function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14495
14496function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
14497
14498function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14499
14500function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14501
14502function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14503
14504function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14505
14506function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14507
14508function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14509
14510function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14511
14512function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14513
14514function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
14515
14516function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14517
14518function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
14519
14520function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14521
14522var BaseXform = require('../../base-xform');
14523
14524var CompositeXform = require('../../composite-xform');
14525
14526var Range = require('../../../../doc/range');
14527
14528var DatabarXform = require('./databar-xform');
14529
14530var ExtLstRefXform = require('./ext-lst-ref-xform');
14531
14532var FormulaXform = require('./formula-xform');
14533
14534var ColorScaleXform = require('./color-scale-xform');
14535
14536var IconSetXform = require('./icon-set-xform');
14537
14538var extIcons = {
14539  '3Triangles': true,
14540  '3Stars': true,
14541  '5Boxes': true
14542};
14543
14544var getTextFormula = function getTextFormula(model) {
14545  if (model.formulae && model.formulae[0]) {
14546    return model.formulae[0];
14547  }
14548
14549  var range = new Range(model.ref);
14550  var tl = range.tl;
14551
14552  switch (model.operator) {
14553    case 'containsText':
14554      return "NOT(ISERROR(SEARCH(\"".concat(model.text, "\",").concat(tl, ")))");
14555
14556    case 'containsBlanks':
14557      return "LEN(TRIM(".concat(tl, "))=0");
14558
14559    case 'notContainsBlanks':
14560      return "LEN(TRIM(".concat(tl, "))>0");
14561
14562    case 'containsErrors':
14563      return "ISERROR(".concat(tl, ")");
14564
14565    case 'notContainsErrors':
14566      return "NOT(ISERROR(".concat(tl, "))");
14567
14568    default:
14569      return undefined;
14570  }
14571};
14572
14573var getTimePeriodFormula = function getTimePeriodFormula(model) {
14574  if (model.formulae && model.formulae[0]) {
14575    return model.formulae[0];
14576  }
14577
14578  var range = new Range(model.ref);
14579  var tl = range.tl;
14580
14581  switch (model.timePeriod) {
14582    case 'thisWeek':
14583      return "AND(TODAY()-ROUNDDOWN(".concat(tl, ",0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(").concat(tl, ",0)-TODAY()<=7-WEEKDAY(TODAY()))");
14584
14585    case 'lastWeek':
14586      return "AND(TODAY()-ROUNDDOWN(".concat(tl, ",0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(").concat(tl, ",0)<(WEEKDAY(TODAY())+7))");
14587
14588    case 'nextWeek':
14589      return "AND(ROUNDDOWN(".concat(tl, ",0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(").concat(tl, ",0)-TODAY()<(15-WEEKDAY(TODAY())))");
14590
14591    case 'yesterday':
14592      return "FLOOR(".concat(tl, ",1)=TODAY()-1");
14593
14594    case 'today':
14595      return "FLOOR(".concat(tl, ",1)=TODAY()");
14596
14597    case 'tomorrow':
14598      return "FLOOR(".concat(tl, ",1)=TODAY()+1");
14599
14600    case 'last7Days':
14601      return "AND(TODAY()-FLOOR(".concat(tl, ",1)<=6,FLOOR(").concat(tl, ",1)<=TODAY())");
14602
14603    case 'lastMonth':
14604      return "AND(MONTH(".concat(tl, ")=MONTH(EDATE(TODAY(),0-1)),YEAR(").concat(tl, ")=YEAR(EDATE(TODAY(),0-1)))");
14605
14606    case 'thisMonth':
14607      return "AND(MONTH(".concat(tl, ")=MONTH(TODAY()),YEAR(").concat(tl, ")=YEAR(TODAY()))");
14608
14609    case 'nextMonth':
14610      return "AND(MONTH(".concat(tl, ")=MONTH(EDATE(TODAY(),0+1)),YEAR(").concat(tl, ")=YEAR(EDATE(TODAY(),0+1)))");
14611
14612    default:
14613      return undefined;
14614  }
14615};
14616
14617var opType = function opType(attributes) {
14618  var type = attributes.type,
14619      operator = attributes.operator;
14620
14621  switch (type) {
14622    case 'containsText':
14623    case 'containsBlanks':
14624    case 'notContainsBlanks':
14625    case 'containsErrors':
14626    case 'notContainsErrors':
14627      return {
14628        type: 'containsText',
14629        operator: type
14630      };
14631
14632    default:
14633      return {
14634        type: type,
14635        operator: operator
14636      };
14637  }
14638};
14639
14640var CfRuleXform = /*#__PURE__*/function (_CompositeXform) {
14641  _inherits(CfRuleXform, _CompositeXform);
14642
14643  var _super = _createSuper(CfRuleXform);
14644
14645  function CfRuleXform() {
14646    var _this;
14647
14648    _classCallCheck(this, CfRuleXform);
14649
14650    _this = _super.call(this);
14651    _this.map = {
14652      dataBar: _this.databarXform = new DatabarXform(),
14653      extLst: _this.extLstRefXform = new ExtLstRefXform(),
14654      formula: _this.formulaXform = new FormulaXform(),
14655      colorScale: _this.colorScaleXform = new ColorScaleXform(),
14656      iconSet: _this.iconSetXform = new IconSetXform()
14657    };
14658    return _this;
14659  }
14660
14661  _createClass(CfRuleXform, [{
14662    key: "render",
14663    value: function render(xmlStream, model) {
14664      switch (model.type) {
14665        case 'expression':
14666          this.renderExpression(xmlStream, model);
14667          break;
14668
14669        case 'cellIs':
14670          this.renderCellIs(xmlStream, model);
14671          break;
14672
14673        case 'top10':
14674          this.renderTop10(xmlStream, model);
14675          break;
14676
14677        case 'aboveAverage':
14678          this.renderAboveAverage(xmlStream, model);
14679          break;
14680
14681        case 'dataBar':
14682          this.renderDataBar(xmlStream, model);
14683          break;
14684
14685        case 'colorScale':
14686          this.renderColorScale(xmlStream, model);
14687          break;
14688
14689        case 'iconSet':
14690          this.renderIconSet(xmlStream, model);
14691          break;
14692
14693        case 'containsText':
14694          this.renderText(xmlStream, model);
14695          break;
14696
14697        case 'timePeriod':
14698          this.renderTimePeriod(xmlStream, model);
14699          break;
14700      }
14701    }
14702  }, {
14703    key: "renderExpression",
14704    value: function renderExpression(xmlStream, model) {
14705      xmlStream.openNode(this.tag, {
14706        type: 'expression',
14707        dxfId: model.dxfId,
14708        priority: model.priority
14709      });
14710      this.formulaXform.render(xmlStream, model.formulae[0]);
14711      xmlStream.closeNode();
14712    }
14713  }, {
14714    key: "renderCellIs",
14715    value: function renderCellIs(xmlStream, model) {
14716      var _this2 = this;
14717
14718      xmlStream.openNode(this.tag, {
14719        type: 'cellIs',
14720        dxfId: model.dxfId,
14721        priority: model.priority,
14722        operator: model.operator
14723      });
14724      model.formulae.forEach(function (formula) {
14725        _this2.formulaXform.render(xmlStream, formula);
14726      });
14727      xmlStream.closeNode();
14728    }
14729  }, {
14730    key: "renderTop10",
14731    value: function renderTop10(xmlStream, model) {
14732      xmlStream.leafNode(this.tag, {
14733        type: 'top10',
14734        dxfId: model.dxfId,
14735        priority: model.priority,
14736        percent: BaseXform.toBoolAttribute(model.percent, false),
14737        bottom: BaseXform.toBoolAttribute(model.bottom, false),
14738        rank: BaseXform.toIntValue(model.rank, 10, true)
14739      });
14740    }
14741  }, {
14742    key: "renderAboveAverage",
14743    value: function renderAboveAverage(xmlStream, model) {
14744      xmlStream.leafNode(this.tag, {
14745        type: 'aboveAverage',
14746        dxfId: model.dxfId,
14747        priority: model.priority,
14748        aboveAverage: BaseXform.toBoolAttribute(model.aboveAverage, true)
14749      });
14750    }
14751  }, {
14752    key: "renderDataBar",
14753    value: function renderDataBar(xmlStream, model) {
14754      xmlStream.openNode(this.tag, {
14755        type: 'dataBar',
14756        priority: model.priority
14757      });
14758      this.databarXform.render(xmlStream, model);
14759      this.extLstRefXform.render(xmlStream, model);
14760      xmlStream.closeNode();
14761    }
14762  }, {
14763    key: "renderColorScale",
14764    value: function renderColorScale(xmlStream, model) {
14765      xmlStream.openNode(this.tag, {
14766        type: 'colorScale',
14767        priority: model.priority
14768      });
14769      this.colorScaleXform.render(xmlStream, model);
14770      xmlStream.closeNode();
14771    }
14772  }, {
14773    key: "renderIconSet",
14774    value: function renderIconSet(xmlStream, model) {
14775      // iconset is all primitive or all extLst
14776      if (!CfRuleXform.isPrimitive(model)) {
14777        return;
14778      }
14779
14780      xmlStream.openNode(this.tag, {
14781        type: 'iconSet',
14782        priority: model.priority
14783      });
14784      this.iconSetXform.render(xmlStream, model);
14785      xmlStream.closeNode();
14786    }
14787  }, {
14788    key: "renderText",
14789    value: function renderText(xmlStream, model) {
14790      xmlStream.openNode(this.tag, {
14791        type: model.operator,
14792        dxfId: model.dxfId,
14793        priority: model.priority,
14794        operator: BaseXform.toStringAttribute(model.operator, 'containsText')
14795      });
14796      var formula = getTextFormula(model);
14797
14798      if (formula) {
14799        this.formulaXform.render(xmlStream, formula);
14800      }
14801
14802      xmlStream.closeNode();
14803    }
14804  }, {
14805    key: "renderTimePeriod",
14806    value: function renderTimePeriod(xmlStream, model) {
14807      xmlStream.openNode(this.tag, {
14808        type: 'timePeriod',
14809        dxfId: model.dxfId,
14810        priority: model.priority,
14811        timePeriod: model.timePeriod
14812      });
14813      var formula = getTimePeriodFormula(model);
14814
14815      if (formula) {
14816        this.formulaXform.render(xmlStream, formula);
14817      }
14818
14819      xmlStream.closeNode();
14820    }
14821  }, {
14822    key: "createNewModel",
14823    value: function createNewModel(_ref) {
14824      var attributes = _ref.attributes;
14825      return _objectSpread(_objectSpread({}, opType(attributes)), {}, {
14826        dxfId: BaseXform.toIntValue(attributes.dxfId),
14827        priority: BaseXform.toIntValue(attributes.priority),
14828        timePeriod: attributes.timePeriod,
14829        percent: BaseXform.toBoolValue(attributes.percent),
14830        bottom: BaseXform.toBoolValue(attributes.bottom),
14831        rank: BaseXform.toIntValue(attributes.rank),
14832        aboveAverage: BaseXform.toBoolValue(attributes.aboveAverage)
14833      });
14834    }
14835  }, {
14836    key: "onParserClose",
14837    value: function onParserClose(name, parser) {
14838      switch (name) {
14839        case 'dataBar':
14840        case 'extLst':
14841        case 'colorScale':
14842        case 'iconSet':
14843          // merge parser model with ours
14844          Object.assign(this.model, parser.model);
14845          break;
14846
14847        case 'formula':
14848          // except - formula is a string and appends to formulae
14849          this.model.formulae = this.model.formulae || [];
14850          this.model.formulae.push(parser.model);
14851          break;
14852      }
14853    }
14854  }, {
14855    key: "tag",
14856    get: function get() {
14857      return 'cfRule';
14858    }
14859  }], [{
14860    key: "isPrimitive",
14861    value: function isPrimitive(rule) {
14862      // is this rule primitive?
14863      if (rule.type === 'iconSet') {
14864        if (rule.custom || extIcons[rule.iconSet]) {
14865          return false;
14866        }
14867      }
14868
14869      return true;
14870    }
14871  }]);
14872
14873  return CfRuleXform;
14874}(CompositeXform);
14875
14876module.exports = CfRuleXform;
14877
14878},{"../../../../doc/range":10,"../../base-xform":31,"../../composite-xform":47,"./color-scale-xform":84,"./databar-xform":87,"./ext-lst-ref-xform":88,"./formula-xform":89,"./icon-set-xform":90}],83:[function(require,module,exports){
14879"use strict";
14880
14881function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14882
14883function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14884
14885function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14886
14887function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14888
14889function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14890
14891function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14892
14893function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14894
14895function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
14896
14897function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14898
14899function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
14900
14901function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14902
14903var BaseXform = require('../../base-xform');
14904
14905var CfvoXform = /*#__PURE__*/function (_BaseXform) {
14906  _inherits(CfvoXform, _BaseXform);
14907
14908  var _super = _createSuper(CfvoXform);
14909
14910  function CfvoXform() {
14911    _classCallCheck(this, CfvoXform);
14912
14913    return _super.apply(this, arguments);
14914  }
14915
14916  _createClass(CfvoXform, [{
14917    key: "render",
14918    value: function render(xmlStream, model) {
14919      xmlStream.leafNode(this.tag, {
14920        type: model.type,
14921        val: model.value
14922      });
14923    }
14924  }, {
14925    key: "parseOpen",
14926    value: function parseOpen(node) {
14927      this.model = {
14928        type: node.attributes.type,
14929        value: BaseXform.toFloatValue(node.attributes.val)
14930      };
14931    }
14932  }, {
14933    key: "parseClose",
14934    value: function parseClose(name) {
14935      return name !== this.tag;
14936    }
14937  }, {
14938    key: "tag",
14939    get: function get() {
14940      return 'cfvo';
14941    }
14942  }]);
14943
14944  return CfvoXform;
14945}(BaseXform);
14946
14947module.exports = CfvoXform;
14948
14949},{"../../base-xform":31}],84:[function(require,module,exports){
14950"use strict";
14951
14952function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14953
14954function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14955
14956function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14957
14958function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14959
14960function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14961
14962function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14963
14964function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14965
14966function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
14967
14968function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14969
14970function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
14971
14972function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14973
14974var CompositeXform = require('../../composite-xform');
14975
14976var ColorXform = require('../../style/color-xform');
14977
14978var CfvoXform = require('./cfvo-xform');
14979
14980var ColorScaleXform = /*#__PURE__*/function (_CompositeXform) {
14981  _inherits(ColorScaleXform, _CompositeXform);
14982
14983  var _super = _createSuper(ColorScaleXform);
14984
14985  function ColorScaleXform() {
14986    var _this;
14987
14988    _classCallCheck(this, ColorScaleXform);
14989
14990    _this = _super.call(this);
14991    _this.map = {
14992      cfvo: _this.cfvoXform = new CfvoXform(),
14993      color: _this.colorXform = new ColorXform()
14994    };
14995    return _this;
14996  }
14997
14998  _createClass(ColorScaleXform, [{
14999    key: "render",
15000    value: function render(xmlStream, model) {
15001      var _this2 = this;
15002
15003      xmlStream.openNode(this.tag);
15004      model.cfvo.forEach(function (cfvo) {
15005        _this2.cfvoXform.render(xmlStream, cfvo);
15006      });
15007      model.color.forEach(function (color) {
15008        _this2.colorXform.render(xmlStream, color);
15009      });
15010      xmlStream.closeNode();
15011    }
15012  }, {
15013    key: "createNewModel",
15014    value: function createNewModel(node) {
15015      return {
15016        cfvo: [],
15017        color: []
15018      };
15019    }
15020  }, {
15021    key: "onParserClose",
15022    value: function onParserClose(name, parser) {
15023      this.model[name].push(parser.model);
15024    }
15025  }, {
15026    key: "tag",
15027    get: function get() {
15028      return 'colorScale';
15029    }
15030  }]);
15031
15032  return ColorScaleXform;
15033}(CompositeXform);
15034
15035module.exports = ColorScaleXform;
15036
15037},{"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-xform":83}],85:[function(require,module,exports){
15038"use strict";
15039
15040function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15041
15042function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15043
15044function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15045
15046function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15047
15048function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
15049
15050function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15051
15052function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15053
15054function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15055
15056function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15057
15058function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15059
15060function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15061
15062var CompositeXform = require('../../composite-xform');
15063
15064var CfRuleXform = require('./cf-rule-xform');
15065
15066var ConditionalFormattingXform = /*#__PURE__*/function (_CompositeXform) {
15067  _inherits(ConditionalFormattingXform, _CompositeXform);
15068
15069  var _super = _createSuper(ConditionalFormattingXform);
15070
15071  function ConditionalFormattingXform() {
15072    var _this;
15073
15074    _classCallCheck(this, ConditionalFormattingXform);
15075
15076    _this = _super.call(this);
15077    _this.map = {
15078      cfRule: new CfRuleXform()
15079    };
15080    return _this;
15081  }
15082
15083  _createClass(ConditionalFormattingXform, [{
15084    key: "render",
15085    value: function render(xmlStream, model) {
15086      var _this2 = this;
15087
15088      // if there are no primitive rules, exit now
15089      if (!model.rules.some(CfRuleXform.isPrimitive)) {
15090        return;
15091      }
15092
15093      xmlStream.openNode(this.tag, {
15094        sqref: model.ref
15095      });
15096      model.rules.forEach(function (rule) {
15097        if (CfRuleXform.isPrimitive(rule)) {
15098          rule.ref = model.ref;
15099
15100          _this2.map.cfRule.render(xmlStream, rule);
15101        }
15102      });
15103      xmlStream.closeNode();
15104    }
15105  }, {
15106    key: "createNewModel",
15107    value: function createNewModel(_ref) {
15108      var attributes = _ref.attributes;
15109      return {
15110        ref: attributes.sqref,
15111        rules: []
15112      };
15113    }
15114  }, {
15115    key: "onParserClose",
15116    value: function onParserClose(name, parser) {
15117      this.model.rules.push(parser.model);
15118    }
15119  }, {
15120    key: "tag",
15121    get: function get() {
15122      return 'conditionalFormatting';
15123    }
15124  }]);
15125
15126  return ConditionalFormattingXform;
15127}(CompositeXform);
15128
15129module.exports = ConditionalFormattingXform;
15130
15131},{"../../composite-xform":47,"./cf-rule-xform":82}],86:[function(require,module,exports){
15132"use strict";
15133
15134function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15135
15136function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
15137
15138function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15139
15140function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15141
15142function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
15143
15144function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15145
15146function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
15147
15148function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15149
15150function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15151
15152function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15153
15154function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
15155
15156function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15157
15158function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15159
15160function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15161
15162function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15163
15164function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15165
15166function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15167
15168var BaseXform = require('../../base-xform');
15169
15170var ConditionalFormattingXform = require('./conditional-formatting-xform');
15171
15172var ConditionalFormattingsXform = /*#__PURE__*/function (_BaseXform) {
15173  _inherits(ConditionalFormattingsXform, _BaseXform);
15174
15175  var _super = _createSuper(ConditionalFormattingsXform);
15176
15177  function ConditionalFormattingsXform() {
15178    var _this;
15179
15180    _classCallCheck(this, ConditionalFormattingsXform);
15181
15182    _this = _super.call(this);
15183    _this.cfXform = new ConditionalFormattingXform();
15184    return _this;
15185  }
15186
15187  _createClass(ConditionalFormattingsXform, [{
15188    key: "reset",
15189    value: function reset() {
15190      this.model = [];
15191    }
15192  }, {
15193    key: "prepare",
15194    value: function prepare(model, options) {
15195      // ensure each rule has a priority value
15196      var nextPriority = model.reduce(function (p, cf) {
15197        return Math.max.apply(Math, [p].concat(_toConsumableArray(cf.rules.map(function (rule) {
15198          return rule.priority || 0;
15199        }))));
15200      }, 1);
15201      model.forEach(function (cf) {
15202        cf.rules.forEach(function (rule) {
15203          if (!rule.priority) {
15204            rule.priority = nextPriority++;
15205          }
15206
15207          if (rule.style) {
15208            rule.dxfId = options.styles.addDxfStyle(rule.style);
15209          }
15210        });
15211      });
15212    }
15213  }, {
15214    key: "render",
15215    value: function render(xmlStream, model) {
15216      var _this2 = this;
15217
15218      model.forEach(function (cf) {
15219        _this2.cfXform.render(xmlStream, cf);
15220      });
15221    }
15222  }, {
15223    key: "parseOpen",
15224    value: function parseOpen(node) {
15225      if (this.parser) {
15226        this.parser.parseOpen(node);
15227        return true;
15228      }
15229
15230      switch (node.name) {
15231        case 'conditionalFormatting':
15232          this.parser = this.cfXform;
15233          this.parser.parseOpen(node);
15234          return true;
15235
15236        default:
15237          return false;
15238      }
15239    }
15240  }, {
15241    key: "parseText",
15242    value: function parseText(text) {
15243      if (this.parser) {
15244        this.parser.parseText(text);
15245      }
15246    }
15247  }, {
15248    key: "parseClose",
15249    value: function parseClose(name) {
15250      if (this.parser) {
15251        if (!this.parser.parseClose(name)) {
15252          this.model.push(this.parser.model);
15253          this.parser = undefined;
15254          return false;
15255        }
15256
15257        return true;
15258      }
15259
15260      return false;
15261    }
15262  }, {
15263    key: "reconcile",
15264    value: function reconcile(model, options) {
15265      model.forEach(function (cf) {
15266        cf.rules.forEach(function (rule) {
15267          if (rule.dxfId !== undefined) {
15268            rule.style = options.styles.getDxfStyle(rule.dxfId);
15269            delete rule.dxfId;
15270          }
15271        });
15272      });
15273    }
15274  }, {
15275    key: "tag",
15276    get: function get() {
15277      return 'conditionalFormatting';
15278    }
15279  }]);
15280
15281  return ConditionalFormattingsXform;
15282}(BaseXform);
15283
15284module.exports = ConditionalFormattingsXform;
15285
15286},{"../../base-xform":31,"./conditional-formatting-xform":85}],87:[function(require,module,exports){
15287"use strict";
15288
15289function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15290
15291function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15292
15293function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15294
15295function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15296
15297function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
15298
15299function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15300
15301function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15302
15303function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15304
15305function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15306
15307function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15308
15309function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15310
15311var CompositeXform = require('../../composite-xform');
15312
15313var ColorXform = require('../../style/color-xform');
15314
15315var CfvoXform = require('./cfvo-xform');
15316
15317var DatabarXform = /*#__PURE__*/function (_CompositeXform) {
15318  _inherits(DatabarXform, _CompositeXform);
15319
15320  var _super = _createSuper(DatabarXform);
15321
15322  function DatabarXform() {
15323    var _this;
15324
15325    _classCallCheck(this, DatabarXform);
15326
15327    _this = _super.call(this);
15328    _this.map = {
15329      cfvo: _this.cfvoXform = new CfvoXform(),
15330      color: _this.colorXform = new ColorXform()
15331    };
15332    return _this;
15333  }
15334
15335  _createClass(DatabarXform, [{
15336    key: "render",
15337    value: function render(xmlStream, model) {
15338      var _this2 = this;
15339
15340      xmlStream.openNode(this.tag);
15341      model.cfvo.forEach(function (cfvo) {
15342        _this2.cfvoXform.render(xmlStream, cfvo);
15343      });
15344      this.colorXform.render(xmlStream, model.color);
15345      xmlStream.closeNode();
15346    }
15347  }, {
15348    key: "createNewModel",
15349    value: function createNewModel() {
15350      return {
15351        cfvo: []
15352      };
15353    }
15354  }, {
15355    key: "onParserClose",
15356    value: function onParserClose(name, parser) {
15357      switch (name) {
15358        case 'cfvo':
15359          this.model.cfvo.push(parser.model);
15360          break;
15361
15362        case 'color':
15363          this.model.color = parser.model;
15364          break;
15365      }
15366    }
15367  }, {
15368    key: "tag",
15369    get: function get() {
15370      return 'dataBar';
15371    }
15372  }]);
15373
15374  return DatabarXform;
15375}(CompositeXform);
15376
15377module.exports = DatabarXform;
15378
15379},{"../../composite-xform":47,"../../style/color-xform":127,"./cfvo-xform":83}],88:[function(require,module,exports){
15380"use strict";
15381
15382function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15383
15384function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15385
15386function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15387
15388function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15389
15390function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
15391
15392function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15393
15394function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15395
15396function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15397
15398function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15399
15400function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15401
15402function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15403
15404/* eslint-disable max-classes-per-file */
15405var BaseXform = require('../../base-xform');
15406
15407var CompositeXform = require('../../composite-xform');
15408
15409var X14IdXform = /*#__PURE__*/function (_BaseXform) {
15410  _inherits(X14IdXform, _BaseXform);
15411
15412  var _super = _createSuper(X14IdXform);
15413
15414  function X14IdXform() {
15415    _classCallCheck(this, X14IdXform);
15416
15417    return _super.apply(this, arguments);
15418  }
15419
15420  _createClass(X14IdXform, [{
15421    key: "render",
15422    value: function render(xmlStream, model) {
15423      xmlStream.leafNode(this.tag, null, model);
15424    }
15425  }, {
15426    key: "parseOpen",
15427    value: function parseOpen() {
15428      this.model = '';
15429    }
15430  }, {
15431    key: "parseText",
15432    value: function parseText(text) {
15433      this.model += text;
15434    }
15435  }, {
15436    key: "parseClose",
15437    value: function parseClose(name) {
15438      return name !== this.tag;
15439    }
15440  }, {
15441    key: "tag",
15442    get: function get() {
15443      return 'x14:id';
15444    }
15445  }]);
15446
15447  return X14IdXform;
15448}(BaseXform);
15449
15450var ExtXform = /*#__PURE__*/function (_CompositeXform) {
15451  _inherits(ExtXform, _CompositeXform);
15452
15453  var _super2 = _createSuper(ExtXform);
15454
15455  function ExtXform() {
15456    var _this;
15457
15458    _classCallCheck(this, ExtXform);
15459
15460    _this = _super2.call(this);
15461    _this.map = {
15462      'x14:id': _this.idXform = new X14IdXform()
15463    };
15464    return _this;
15465  }
15466
15467  _createClass(ExtXform, [{
15468    key: "render",
15469    value: function render(xmlStream, model) {
15470      xmlStream.openNode(this.tag, {
15471        uri: '{B025F937-C7B1-47D3-B67F-A62EFF666E3E}',
15472        'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main'
15473      });
15474      this.idXform.render(xmlStream, model.x14Id);
15475      xmlStream.closeNode();
15476    }
15477  }, {
15478    key: "createNewModel",
15479    value: function createNewModel() {
15480      return {};
15481    }
15482  }, {
15483    key: "onParserClose",
15484    value: function onParserClose(name, parser) {
15485      this.model.x14Id = parser.model;
15486    }
15487  }, {
15488    key: "tag",
15489    get: function get() {
15490      return 'ext';
15491    }
15492  }]);
15493
15494  return ExtXform;
15495}(CompositeXform);
15496
15497var ExtLstRefXform = /*#__PURE__*/function (_CompositeXform2) {
15498  _inherits(ExtLstRefXform, _CompositeXform2);
15499
15500  var _super3 = _createSuper(ExtLstRefXform);
15501
15502  function ExtLstRefXform() {
15503    var _this2;
15504
15505    _classCallCheck(this, ExtLstRefXform);
15506
15507    _this2 = _super3.call(this);
15508    _this2.map = {
15509      ext: new ExtXform()
15510    };
15511    return _this2;
15512  }
15513
15514  _createClass(ExtLstRefXform, [{
15515    key: "render",
15516    value: function render(xmlStream, model) {
15517      xmlStream.openNode(this.tag);
15518      this.map.ext.render(xmlStream, model);
15519      xmlStream.closeNode();
15520    }
15521  }, {
15522    key: "createNewModel",
15523    value: function createNewModel() {
15524      return {};
15525    }
15526  }, {
15527    key: "onParserClose",
15528    value: function onParserClose(name, parser) {
15529      Object.assign(this.model, parser.model);
15530    }
15531  }, {
15532    key: "tag",
15533    get: function get() {
15534      return 'extLst';
15535    }
15536  }]);
15537
15538  return ExtLstRefXform;
15539}(CompositeXform);
15540
15541module.exports = ExtLstRefXform;
15542
15543},{"../../base-xform":31,"../../composite-xform":47}],89:[function(require,module,exports){
15544"use strict";
15545
15546function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15547
15548function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15549
15550function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15551
15552function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15553
15554function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
15555
15556function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15557
15558function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15559
15560function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15561
15562function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15563
15564function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15565
15566function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15567
15568var BaseXform = require('../../base-xform');
15569
15570var FormulaXform = /*#__PURE__*/function (_BaseXform) {
15571  _inherits(FormulaXform, _BaseXform);
15572
15573  var _super = _createSuper(FormulaXform);
15574
15575  function FormulaXform() {
15576    _classCallCheck(this, FormulaXform);
15577
15578    return _super.apply(this, arguments);
15579  }
15580
15581  _createClass(FormulaXform, [{
15582    key: "render",
15583    value: function render(xmlStream, model) {
15584      xmlStream.leafNode(this.tag, null, model);
15585    }
15586  }, {
15587    key: "parseOpen",
15588    value: function parseOpen() {
15589      this.model = '';
15590    }
15591  }, {
15592    key: "parseText",
15593    value: function parseText(text) {
15594      this.model += text;
15595    }
15596  }, {
15597    key: "parseClose",
15598    value: function parseClose(name) {
15599      return name !== this.tag;
15600    }
15601  }, {
15602    key: "tag",
15603    get: function get() {
15604      return 'formula';
15605    }
15606  }]);
15607
15608  return FormulaXform;
15609}(BaseXform);
15610
15611module.exports = FormulaXform;
15612
15613},{"../../base-xform":31}],90:[function(require,module,exports){
15614"use strict";
15615
15616function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15617
15618function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15619
15620function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15621
15622function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15623
15624function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
15625
15626function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15627
15628function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15629
15630function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15631
15632function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15633
15634function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15635
15636function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15637
15638var BaseXform = require('../../base-xform');
15639
15640var CompositeXform = require('../../composite-xform');
15641
15642var CfvoXform = require('./cfvo-xform');
15643
15644var IconSetXform = /*#__PURE__*/function (_CompositeXform) {
15645  _inherits(IconSetXform, _CompositeXform);
15646
15647  var _super = _createSuper(IconSetXform);
15648
15649  function IconSetXform() {
15650    var _this;
15651
15652    _classCallCheck(this, IconSetXform);
15653
15654    _this = _super.call(this);
15655    _this.map = {
15656      cfvo: _this.cfvoXform = new CfvoXform()
15657    };
15658    return _this;
15659  }
15660
15661  _createClass(IconSetXform, [{
15662    key: "render",
15663    value: function render(xmlStream, model) {
15664      var _this2 = this;
15665
15666      xmlStream.openNode(this.tag, {
15667        iconSet: BaseXform.toStringAttribute(model.iconSet, '3TrafficLights'),
15668        reverse: BaseXform.toBoolAttribute(model.reverse, false),
15669        showValue: BaseXform.toBoolAttribute(model.showValue, true)
15670      });
15671      model.cfvo.forEach(function (cfvo) {
15672        _this2.cfvoXform.render(xmlStream, cfvo);
15673      });
15674      xmlStream.closeNode();
15675    }
15676  }, {
15677    key: "createNewModel",
15678    value: function createNewModel(_ref) {
15679      var attributes = _ref.attributes;
15680      return {
15681        iconSet: BaseXform.toStringValue(attributes.iconSet, '3TrafficLights'),
15682        reverse: BaseXform.toBoolValue(attributes.reverse),
15683        showValue: BaseXform.toBoolValue(attributes.showValue),
15684        cfvo: []
15685      };
15686    }
15687  }, {
15688    key: "onParserClose",
15689    value: function onParserClose(name, parser) {
15690      this.model[name].push(parser.model);
15691    }
15692  }, {
15693    key: "tag",
15694    get: function get() {
15695      return 'iconSet';
15696    }
15697  }]);
15698
15699  return IconSetXform;
15700}(CompositeXform);
15701
15702module.exports = IconSetXform;
15703
15704},{"../../base-xform":31,"../../composite-xform":47,"./cfvo-xform":83}],91:[function(require,module,exports){
15705"use strict";
15706
15707function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15708
15709function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15710
15711function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15712
15713function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15714
15715function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
15716
15717function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15718
15719function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15720
15721function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15722
15723function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15724
15725function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15726
15727function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15728
15729var BaseXform = require('../base-xform');
15730
15731var ColXform = /*#__PURE__*/function (_BaseXform) {
15732  _inherits(ColXform, _BaseXform);
15733
15734  var _super = _createSuper(ColXform);
15735
15736  function ColXform() {
15737    _classCallCheck(this, ColXform);
15738
15739    return _super.apply(this, arguments);
15740  }
15741
15742  _createClass(ColXform, [{
15743    key: "prepare",
15744    value: function prepare(model, options) {
15745      var styleId = options.styles.addStyleModel(model.style || {});
15746
15747      if (styleId) {
15748        model.styleId = styleId;
15749      }
15750    }
15751  }, {
15752    key: "render",
15753    value: function render(xmlStream, model) {
15754      xmlStream.openNode('col');
15755      xmlStream.addAttribute('min', model.min);
15756      xmlStream.addAttribute('max', model.max);
15757
15758      if (model.width) {
15759        xmlStream.addAttribute('width', model.width);
15760      }
15761
15762      if (model.styleId) {
15763        xmlStream.addAttribute('style', model.styleId);
15764      }
15765
15766      if (model.hidden) {
15767        xmlStream.addAttribute('hidden', '1');
15768      }
15769
15770      if (model.bestFit) {
15771        xmlStream.addAttribute('bestFit', '1');
15772      }
15773
15774      if (model.outlineLevel) {
15775        xmlStream.addAttribute('outlineLevel', model.outlineLevel);
15776      }
15777
15778      if (model.collapsed) {
15779        xmlStream.addAttribute('collapsed', '1');
15780      }
15781
15782      xmlStream.addAttribute('customWidth', '1');
15783      xmlStream.closeNode();
15784    }
15785  }, {
15786    key: "parseOpen",
15787    value: function parseOpen(node) {
15788      if (node.name === 'col') {
15789        var model = this.model = {
15790          min: parseInt(node.attributes.min || '0', 10),
15791          max: parseInt(node.attributes.max || '0', 10),
15792          width: node.attributes.width === undefined ? undefined : parseFloat(node.attributes.width || '0')
15793        };
15794
15795        if (node.attributes.style) {
15796          model.styleId = parseInt(node.attributes.style, 10);
15797        }
15798
15799        if (node.attributes.hidden === true || node.attributes.hidden === 'true' || node.attributes.hidden === 1 || node.attributes.hidden === '1') {
15800          model.hidden = true;
15801        }
15802
15803        if (node.attributes.bestFit) {
15804          model.bestFit = true;
15805        }
15806
15807        if (node.attributes.outlineLevel) {
15808          model.outlineLevel = parseInt(node.attributes.outlineLevel, 10);
15809        }
15810
15811        if (node.attributes.collapsed) {
15812          model.collapsed = true;
15813        }
15814
15815        return true;
15816      }
15817
15818      return false;
15819    }
15820  }, {
15821    key: "parseText",
15822    value: function parseText() {}
15823  }, {
15824    key: "parseClose",
15825    value: function parseClose() {
15826      return false;
15827    }
15828  }, {
15829    key: "reconcile",
15830    value: function reconcile(model, options) {
15831      // reconcile column styles
15832      if (model.styleId) {
15833        model.style = options.styles.getStyleModel(model.styleId);
15834      }
15835    }
15836  }, {
15837    key: "tag",
15838    get: function get() {
15839      return 'col';
15840    }
15841  }]);
15842
15843  return ColXform;
15844}(BaseXform);
15845
15846module.exports = ColXform;
15847
15848},{"../base-xform":31}],92:[function(require,module,exports){
15849"use strict";
15850
15851function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15852
15853function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15854
15855function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15856
15857function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15858
15859function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
15860
15861function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15862
15863function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15864
15865function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
15866
15867function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15868
15869function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15870
15871function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15872
15873function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15874
15875function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15876
15877function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15878
15879var _ = require('../../../utils/under-dash');
15880
15881var utils = require('../../../utils/utils');
15882
15883var colCache = require('../../../utils/col-cache');
15884
15885var BaseXform = require('../base-xform');
15886
15887var Range = require('../../../doc/range');
15888
15889function assign(definedName, attributes, name, defaultValue) {
15890  var value = attributes[name];
15891
15892  if (value !== undefined) {
15893    definedName[name] = value;
15894  } else if (defaultValue !== undefined) {
15895    definedName[name] = defaultValue;
15896  }
15897}
15898
15899function parseBool(value) {
15900  switch (value) {
15901    case '1':
15902    case 'true':
15903      return true;
15904
15905    default:
15906      return false;
15907  }
15908}
15909
15910function assignBool(definedName, attributes, name, defaultValue) {
15911  var value = attributes[name];
15912
15913  if (value !== undefined) {
15914    definedName[name] = parseBool(value);
15915  } else if (defaultValue !== undefined) {
15916    definedName[name] = defaultValue;
15917  }
15918}
15919
15920function optimiseDataValidations(model) {
15921  // Squeeze alike data validations together into rectangular ranges
15922  // to reduce file size and speed up Excel load time
15923  var dvList = _.map(model, function (dataValidation, address) {
15924    return {
15925      address: address,
15926      dataValidation: dataValidation,
15927      marked: false
15928    };
15929  }).sort(function (a, b) {
15930    return _.strcmp(a.address, b.address);
15931  });
15932
15933  var dvMap = _.keyBy(dvList, 'address');
15934
15935  var matchCol = function matchCol(addr, height, col) {
15936    for (var i = 0; i < height; i++) {
15937      var otherAddress = colCache.encodeAddress(addr.row + i, col);
15938
15939      if (!model[otherAddress] || !_.isEqual(model[addr.address], model[otherAddress])) {
15940        return false;
15941      }
15942    }
15943
15944    return true;
15945  };
15946
15947  return dvList.map(function (dv) {
15948    if (!dv.marked) {
15949      var addr = colCache.decodeEx(dv.address);
15950
15951      if (addr.dimensions) {
15952        dvMap[addr.dimensions].marked = true;
15953        return _objectSpread(_objectSpread({}, dv.dataValidation), {}, {
15954          sqref: dv.address
15955        });
15956      } // iterate downwards - finding matching cells
15957
15958
15959      var height = 1;
15960      var otherAddress = colCache.encodeAddress(addr.row + height, addr.col);
15961
15962      while (model[otherAddress] && _.isEqual(dv.dataValidation, model[otherAddress])) {
15963        height++;
15964        otherAddress = colCache.encodeAddress(addr.row + height, addr.col);
15965      } // iterate rightwards...
15966
15967
15968      var width = 1;
15969
15970      while (matchCol(addr, height, addr.col + width)) {
15971        width++;
15972      } // mark all included addresses
15973
15974
15975      for (var i = 0; i < height; i++) {
15976        for (var j = 0; j < width; j++) {
15977          otherAddress = colCache.encodeAddress(addr.row + i, addr.col + j);
15978          dvMap[otherAddress].marked = true;
15979        }
15980      }
15981
15982      if (height > 1 || width > 1) {
15983        var bottom = addr.row + (height - 1);
15984        var right = addr.col + (width - 1);
15985        return _objectSpread(_objectSpread({}, dv.dataValidation), {}, {
15986          sqref: "".concat(dv.address, ":").concat(colCache.encodeAddress(bottom, right))
15987        });
15988      }
15989
15990      return _objectSpread(_objectSpread({}, dv.dataValidation), {}, {
15991        sqref: dv.address
15992      });
15993    }
15994
15995    return null;
15996  }).filter(Boolean);
15997}
15998
15999var DataValidationsXform = /*#__PURE__*/function (_BaseXform) {
16000  _inherits(DataValidationsXform, _BaseXform);
16001
16002  var _super = _createSuper(DataValidationsXform);
16003
16004  function DataValidationsXform() {
16005    _classCallCheck(this, DataValidationsXform);
16006
16007    return _super.apply(this, arguments);
16008  }
16009
16010  _createClass(DataValidationsXform, [{
16011    key: "render",
16012    value: function render(xmlStream, model) {
16013      var optimizedModel = optimiseDataValidations(model);
16014
16015      if (optimizedModel.length) {
16016        xmlStream.openNode('dataValidations', {
16017          count: optimizedModel.length
16018        });
16019        optimizedModel.forEach(function (value) {
16020          xmlStream.openNode('dataValidation');
16021
16022          if (value.type !== 'any') {
16023            xmlStream.addAttribute('type', value.type);
16024
16025            if (value.operator && value.type !== 'list' && value.operator !== 'between') {
16026              xmlStream.addAttribute('operator', value.operator);
16027            }
16028
16029            if (value.allowBlank) {
16030              xmlStream.addAttribute('allowBlank', '1');
16031            }
16032          }
16033
16034          if (value.showInputMessage) {
16035            xmlStream.addAttribute('showInputMessage', '1');
16036          }
16037
16038          if (value.promptTitle) {
16039            xmlStream.addAttribute('promptTitle', value.promptTitle);
16040          }
16041
16042          if (value.prompt) {
16043            xmlStream.addAttribute('prompt', value.prompt);
16044          }
16045
16046          if (value.showErrorMessage) {
16047            xmlStream.addAttribute('showErrorMessage', '1');
16048          }
16049
16050          if (value.errorStyle) {
16051            xmlStream.addAttribute('errorStyle', value.errorStyle);
16052          }
16053
16054          if (value.errorTitle) {
16055            xmlStream.addAttribute('errorTitle', value.errorTitle);
16056          }
16057
16058          if (value.error) {
16059            xmlStream.addAttribute('error', value.error);
16060          }
16061
16062          xmlStream.addAttribute('sqref', value.sqref);
16063          (value.formulae || []).forEach(function (formula, index) {
16064            xmlStream.openNode("formula".concat(index + 1));
16065
16066            if (value.type === 'date') {
16067              xmlStream.writeText(utils.dateToExcel(new Date(formula)));
16068            } else {
16069              xmlStream.writeText(formula);
16070            }
16071
16072            xmlStream.closeNode();
16073          });
16074          xmlStream.closeNode();
16075        });
16076        xmlStream.closeNode();
16077      }
16078    }
16079  }, {
16080    key: "parseOpen",
16081    value: function parseOpen(node) {
16082      switch (node.name) {
16083        case 'dataValidations':
16084          this.model = {};
16085          return true;
16086
16087        case 'dataValidation':
16088          {
16089            this._address = node.attributes.sqref;
16090            var dataValidation = {
16091              type: node.attributes.type || 'any',
16092              formulae: []
16093            };
16094
16095            if (node.attributes.type) {
16096              assignBool(dataValidation, node.attributes, 'allowBlank');
16097            }
16098
16099            assignBool(dataValidation, node.attributes, 'showInputMessage');
16100            assignBool(dataValidation, node.attributes, 'showErrorMessage');
16101
16102            switch (dataValidation.type) {
16103              case 'any':
16104              case 'list':
16105              case 'custom':
16106                break;
16107
16108              default:
16109                assign(dataValidation, node.attributes, 'operator', 'between');
16110                break;
16111            }
16112
16113            assign(dataValidation, node.attributes, 'promptTitle');
16114            assign(dataValidation, node.attributes, 'prompt');
16115            assign(dataValidation, node.attributes, 'errorStyle');
16116            assign(dataValidation, node.attributes, 'errorTitle');
16117            assign(dataValidation, node.attributes, 'error');
16118            this._dataValidation = dataValidation;
16119            return true;
16120          }
16121
16122        case 'formula1':
16123        case 'formula2':
16124          this._formula = [];
16125          return true;
16126
16127        default:
16128          return false;
16129      }
16130    }
16131  }, {
16132    key: "parseText",
16133    value: function parseText(text) {
16134      if (this._formula) {
16135        this._formula.push(text);
16136      }
16137    }
16138  }, {
16139    key: "parseClose",
16140    value: function parseClose(name) {
16141      var _this = this;
16142
16143      switch (name) {
16144        case 'dataValidations':
16145          return false;
16146
16147        case 'dataValidation':
16148          {
16149            if (!this._dataValidation.formulae || !this._dataValidation.formulae.length) {
16150              delete this._dataValidation.formulae;
16151              delete this._dataValidation.operator;
16152            } // The four known cases: 1. E4:L9 N4:U9  2.E4 L9  3. N4:U9  4. E4
16153
16154
16155            var list = this._address.split(/\s+/g) || [];
16156            list.forEach(function (addr) {
16157              if (addr.includes(':')) {
16158                var range = new Range(addr);
16159                range.forEachAddress(function (address) {
16160                  _this.model[address] = _this._dataValidation;
16161                });
16162              } else {
16163                _this.model[addr] = _this._dataValidation;
16164              }
16165            });
16166            return true;
16167          }
16168
16169        case 'formula1':
16170        case 'formula2':
16171          {
16172            var formula = this._formula.join('');
16173
16174            switch (this._dataValidation.type) {
16175              case 'whole':
16176              case 'textLength':
16177                formula = parseInt(formula, 10);
16178                break;
16179
16180              case 'decimal':
16181                formula = parseFloat(formula);
16182                break;
16183
16184              case 'date':
16185                formula = utils.excelToDate(parseFloat(formula));
16186                break;
16187
16188              default:
16189                break;
16190            }
16191
16192            this._dataValidation.formulae.push(formula);
16193
16194            this._formula = undefined;
16195            return true;
16196          }
16197
16198        default:
16199          return true;
16200      }
16201    }
16202  }, {
16203    key: "tag",
16204    get: function get() {
16205      return 'dataValidations';
16206    }
16207  }]);
16208
16209  return DataValidationsXform;
16210}(BaseXform);
16211
16212module.exports = DataValidationsXform;
16213
16214},{"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/utils":26,"../base-xform":31}],93:[function(require,module,exports){
16215"use strict";
16216
16217function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16218
16219function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16220
16221function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16222
16223function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16224
16225function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16226
16227function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16228
16229function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16230
16231function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16232
16233function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
16234
16235function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16236
16237function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16238
16239var BaseXform = require('../base-xform');
16240
16241var DimensionXform = /*#__PURE__*/function (_BaseXform) {
16242  _inherits(DimensionXform, _BaseXform);
16243
16244  var _super = _createSuper(DimensionXform);
16245
16246  function DimensionXform() {
16247    _classCallCheck(this, DimensionXform);
16248
16249    return _super.apply(this, arguments);
16250  }
16251
16252  _createClass(DimensionXform, [{
16253    key: "render",
16254    value: function render(xmlStream, model) {
16255      if (model) {
16256        xmlStream.leafNode('dimension', {
16257          ref: model
16258        });
16259      }
16260    }
16261  }, {
16262    key: "parseOpen",
16263    value: function parseOpen(node) {
16264      if (node.name === 'dimension') {
16265        this.model = node.attributes.ref;
16266        return true;
16267      }
16268
16269      return false;
16270    }
16271  }, {
16272    key: "parseText",
16273    value: function parseText() {}
16274  }, {
16275    key: "parseClose",
16276    value: function parseClose() {
16277      return false;
16278    }
16279  }, {
16280    key: "tag",
16281    get: function get() {
16282      return 'dimension';
16283    }
16284  }]);
16285
16286  return DimensionXform;
16287}(BaseXform);
16288
16289module.exports = DimensionXform;
16290
16291},{"../base-xform":31}],94:[function(require,module,exports){
16292"use strict";
16293
16294function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16295
16296function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16297
16298function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16299
16300function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16301
16302function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16303
16304function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16305
16306function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16307
16308function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16309
16310function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
16311
16312function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16313
16314function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16315
16316var BaseXform = require('../base-xform');
16317
16318var DrawingXform = /*#__PURE__*/function (_BaseXform) {
16319  _inherits(DrawingXform, _BaseXform);
16320
16321  var _super = _createSuper(DrawingXform);
16322
16323  function DrawingXform() {
16324    _classCallCheck(this, DrawingXform);
16325
16326    return _super.apply(this, arguments);
16327  }
16328
16329  _createClass(DrawingXform, [{
16330    key: "render",
16331    value: function render(xmlStream, model) {
16332      if (model) {
16333        xmlStream.leafNode(this.tag, {
16334          'r:id': model.rId
16335        });
16336      }
16337    }
16338  }, {
16339    key: "parseOpen",
16340    value: function parseOpen(node) {
16341      switch (node.name) {
16342        case this.tag:
16343          this.model = {
16344            rId: node.attributes['r:id']
16345          };
16346          return true;
16347
16348        default:
16349          return false;
16350      }
16351    }
16352  }, {
16353    key: "parseText",
16354    value: function parseText() {}
16355  }, {
16356    key: "parseClose",
16357    value: function parseClose() {
16358      return false;
16359    }
16360  }, {
16361    key: "tag",
16362    get: function get() {
16363      return 'drawing';
16364    }
16365  }]);
16366
16367  return DrawingXform;
16368}(BaseXform);
16369
16370module.exports = DrawingXform;
16371
16372},{"../base-xform":31}],95:[function(require,module,exports){
16373"use strict";
16374
16375function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16376
16377function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16378
16379function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16380
16381function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16382
16383function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16384
16385function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16386
16387function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16388
16389function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16390
16391function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
16392
16393function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16394
16395function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16396
16397/* eslint-disable max-classes-per-file */
16398var CompositeXform = require('../composite-xform');
16399
16400var ConditionalFormattingsExt = require('./cf-ext/conditional-formattings-ext-xform');
16401
16402var ExtXform = /*#__PURE__*/function (_CompositeXform) {
16403  _inherits(ExtXform, _CompositeXform);
16404
16405  var _super = _createSuper(ExtXform);
16406
16407  function ExtXform() {
16408    var _this;
16409
16410    _classCallCheck(this, ExtXform);
16411
16412    _this = _super.call(this);
16413    _this.map = {
16414      'x14:conditionalFormattings': _this.conditionalFormattings = new ConditionalFormattingsExt()
16415    };
16416    return _this;
16417  }
16418
16419  _createClass(ExtXform, [{
16420    key: "hasContent",
16421    value: function hasContent(model) {
16422      return this.conditionalFormattings.hasContent(model.conditionalFormattings);
16423    }
16424  }, {
16425    key: "prepare",
16426    value: function prepare(model, options) {
16427      this.conditionalFormattings.prepare(model.conditionalFormattings, options);
16428    }
16429  }, {
16430    key: "render",
16431    value: function render(xmlStream, model) {
16432      xmlStream.openNode('ext', {
16433        uri: '{78C0D931-6437-407d-A8EE-F0AAD7539E65}',
16434        'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main'
16435      });
16436      this.conditionalFormattings.render(xmlStream, model.conditionalFormattings);
16437      xmlStream.closeNode();
16438    }
16439  }, {
16440    key: "createNewModel",
16441    value: function createNewModel() {
16442      return {};
16443    }
16444  }, {
16445    key: "onParserClose",
16446    value: function onParserClose(name, parser) {
16447      this.model[name] = parser.model;
16448    }
16449  }, {
16450    key: "tag",
16451    get: function get() {
16452      return 'ext';
16453    }
16454  }]);
16455
16456  return ExtXform;
16457}(CompositeXform);
16458
16459var ExtLstXform = /*#__PURE__*/function (_CompositeXform2) {
16460  _inherits(ExtLstXform, _CompositeXform2);
16461
16462  var _super2 = _createSuper(ExtLstXform);
16463
16464  function ExtLstXform() {
16465    var _this2;
16466
16467    _classCallCheck(this, ExtLstXform);
16468
16469    _this2 = _super2.call(this);
16470    _this2.map = {
16471      ext: _this2.ext = new ExtXform()
16472    };
16473    return _this2;
16474  }
16475
16476  _createClass(ExtLstXform, [{
16477    key: "prepare",
16478    value: function prepare(model, options) {
16479      this.ext.prepare(model, options);
16480    }
16481  }, {
16482    key: "hasContent",
16483    value: function hasContent(model) {
16484      return this.ext.hasContent(model);
16485    }
16486  }, {
16487    key: "render",
16488    value: function render(xmlStream, model) {
16489      if (!this.hasContent(model)) {
16490        return;
16491      }
16492
16493      xmlStream.openNode('extLst');
16494      this.ext.render(xmlStream, model);
16495      xmlStream.closeNode();
16496    }
16497  }, {
16498    key: "createNewModel",
16499    value: function createNewModel() {
16500      return {};
16501    }
16502  }, {
16503    key: "onParserClose",
16504    value: function onParserClose(name, parser) {
16505      Object.assign(this.model, parser.model);
16506    }
16507  }, {
16508    key: "tag",
16509    get: function get() {
16510      return 'extLst';
16511    }
16512  }]);
16513
16514  return ExtLstXform;
16515}(CompositeXform);
16516
16517module.exports = ExtLstXform;
16518
16519},{"../composite-xform":47,"./cf-ext/conditional-formattings-ext-xform":77}],96:[function(require,module,exports){
16520"use strict";
16521
16522function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16523
16524function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16525
16526function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16527
16528function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16529
16530function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16531
16532function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16533
16534function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16535
16536function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16537
16538function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
16539
16540function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16541
16542function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16543
16544var BaseXform = require('../base-xform');
16545
16546var HeaderFooterXform = /*#__PURE__*/function (_BaseXform) {
16547  _inherits(HeaderFooterXform, _BaseXform);
16548
16549  var _super = _createSuper(HeaderFooterXform);
16550
16551  function HeaderFooterXform() {
16552    _classCallCheck(this, HeaderFooterXform);
16553
16554    return _super.apply(this, arguments);
16555  }
16556
16557  _createClass(HeaderFooterXform, [{
16558    key: "render",
16559    value: function render(xmlStream, model) {
16560      if (model) {
16561        xmlStream.addRollback();
16562        var createTag = false;
16563        xmlStream.openNode('headerFooter');
16564
16565        if (model.differentFirst) {
16566          xmlStream.addAttribute('differentFirst', '1');
16567          createTag = true;
16568        }
16569
16570        if (model.differentOddEven) {
16571          xmlStream.addAttribute('differentOddEven', '1');
16572          createTag = true;
16573        }
16574
16575        if (model.oddHeader && typeof model.oddHeader === 'string') {
16576          xmlStream.leafNode('oddHeader', null, model.oddHeader);
16577          createTag = true;
16578        }
16579
16580        if (model.oddFooter && typeof model.oddFooter === 'string') {
16581          xmlStream.leafNode('oddFooter', null, model.oddFooter);
16582          createTag = true;
16583        }
16584
16585        if (model.evenHeader && typeof model.evenHeader === 'string') {
16586          xmlStream.leafNode('evenHeader', null, model.evenHeader);
16587          createTag = true;
16588        }
16589
16590        if (model.evenFooter && typeof model.evenFooter === 'string') {
16591          xmlStream.leafNode('evenFooter', null, model.evenFooter);
16592          createTag = true;
16593        }
16594
16595        if (model.firstHeader && typeof model.firstHeader === 'string') {
16596          xmlStream.leafNode('firstHeader', null, model.firstHeader);
16597          createTag = true;
16598        }
16599
16600        if (model.firstFooter && typeof model.firstFooter === 'string') {
16601          xmlStream.leafNode('firstFooter', null, model.firstFooter);
16602          createTag = true;
16603        }
16604
16605        if (createTag) {
16606          xmlStream.closeNode();
16607          xmlStream.commit();
16608        } else {
16609          xmlStream.rollback();
16610        }
16611      }
16612    }
16613  }, {
16614    key: "parseOpen",
16615    value: function parseOpen(node) {
16616      switch (node.name) {
16617        case 'headerFooter':
16618          this.model = {};
16619
16620          if (node.attributes.differentFirst) {
16621            this.model.differentFirst = parseInt(node.attributes.differentFirst, 0) === 1;
16622          }
16623
16624          if (node.attributes.differentOddEven) {
16625            this.model.differentOddEven = parseInt(node.attributes.differentOddEven, 0) === 1;
16626          }
16627
16628          return true;
16629
16630        case 'oddHeader':
16631          this.currentNode = 'oddHeader';
16632          return true;
16633
16634        case 'oddFooter':
16635          this.currentNode = 'oddFooter';
16636          return true;
16637
16638        case 'evenHeader':
16639          this.currentNode = 'evenHeader';
16640          return true;
16641
16642        case 'evenFooter':
16643          this.currentNode = 'evenFooter';
16644          return true;
16645
16646        case 'firstHeader':
16647          this.currentNode = 'firstHeader';
16648          return true;
16649
16650        case 'firstFooter':
16651          this.currentNode = 'firstFooter';
16652          return true;
16653
16654        default:
16655          return false;
16656      }
16657    }
16658  }, {
16659    key: "parseText",
16660    value: function parseText(text) {
16661      switch (this.currentNode) {
16662        case 'oddHeader':
16663          this.model.oddHeader = text;
16664          break;
16665
16666        case 'oddFooter':
16667          this.model.oddFooter = text;
16668          break;
16669
16670        case 'evenHeader':
16671          this.model.evenHeader = text;
16672          break;
16673
16674        case 'evenFooter':
16675          this.model.evenFooter = text;
16676          break;
16677
16678        case 'firstHeader':
16679          this.model.firstHeader = text;
16680          break;
16681
16682        case 'firstFooter':
16683          this.model.firstFooter = text;
16684          break;
16685
16686        default:
16687          break;
16688      }
16689    }
16690  }, {
16691    key: "parseClose",
16692    value: function parseClose() {
16693      switch (this.currentNode) {
16694        case 'oddHeader':
16695        case 'oddFooter':
16696        case 'evenHeader':
16697        case 'evenFooter':
16698        case 'firstHeader':
16699        case 'firstFooter':
16700          this.currentNode = undefined;
16701          return true;
16702
16703        default:
16704          return false;
16705      }
16706    }
16707  }, {
16708    key: "tag",
16709    get: function get() {
16710      return 'headerFooter';
16711    }
16712  }]);
16713
16714  return HeaderFooterXform;
16715}(BaseXform);
16716
16717module.exports = HeaderFooterXform;
16718
16719},{"../base-xform":31}],97:[function(require,module,exports){
16720"use strict";
16721
16722function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16723
16724function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16725
16726function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16727
16728function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16729
16730function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16731
16732function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16733
16734function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16735
16736function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16737
16738function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
16739
16740function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16741
16742function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16743
16744var BaseXform = require('../base-xform');
16745
16746var HyperlinkXform = /*#__PURE__*/function (_BaseXform) {
16747  _inherits(HyperlinkXform, _BaseXform);
16748
16749  var _super = _createSuper(HyperlinkXform);
16750
16751  function HyperlinkXform() {
16752    _classCallCheck(this, HyperlinkXform);
16753
16754    return _super.apply(this, arguments);
16755  }
16756
16757  _createClass(HyperlinkXform, [{
16758    key: "render",
16759    value: function render(xmlStream, model) {
16760      xmlStream.leafNode('hyperlink', {
16761        ref: model.address,
16762        'r:id': model.rId,
16763        tooltip: model.tooltip
16764      });
16765    }
16766  }, {
16767    key: "parseOpen",
16768    value: function parseOpen(node) {
16769      if (node.name === 'hyperlink') {
16770        this.model = {
16771          address: node.attributes.ref,
16772          rId: node.attributes['r:id'],
16773          tooltip: node.attributes.tooltip
16774        };
16775        return true;
16776      }
16777
16778      return false;
16779    }
16780  }, {
16781    key: "parseText",
16782    value: function parseText() {}
16783  }, {
16784    key: "parseClose",
16785    value: function parseClose() {
16786      return false;
16787    }
16788  }, {
16789    key: "tag",
16790    get: function get() {
16791      return 'hyperlink';
16792    }
16793  }]);
16794
16795  return HyperlinkXform;
16796}(BaseXform);
16797
16798module.exports = HyperlinkXform;
16799
16800},{"../base-xform":31}],98:[function(require,module,exports){
16801"use strict";
16802
16803function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16804
16805function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16806
16807function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16808
16809function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16810
16811function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16812
16813function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16814
16815function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16816
16817function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16818
16819function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
16820
16821function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16822
16823function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16824
16825var BaseXform = require('../base-xform');
16826
16827var MergeCellXform = /*#__PURE__*/function (_BaseXform) {
16828  _inherits(MergeCellXform, _BaseXform);
16829
16830  var _super = _createSuper(MergeCellXform);
16831
16832  function MergeCellXform() {
16833    _classCallCheck(this, MergeCellXform);
16834
16835    return _super.apply(this, arguments);
16836  }
16837
16838  _createClass(MergeCellXform, [{
16839    key: "render",
16840    value: function render(xmlStream, model) {
16841      xmlStream.leafNode('mergeCell', {
16842        ref: model
16843      });
16844    }
16845  }, {
16846    key: "parseOpen",
16847    value: function parseOpen(node) {
16848      if (node.name === 'mergeCell') {
16849        this.model = node.attributes.ref;
16850        return true;
16851      }
16852
16853      return false;
16854    }
16855  }, {
16856    key: "parseText",
16857    value: function parseText() {}
16858  }, {
16859    key: "parseClose",
16860    value: function parseClose() {
16861      return false;
16862    }
16863  }, {
16864    key: "tag",
16865    get: function get() {
16866      return 'mergeCell';
16867    }
16868  }]);
16869
16870  return MergeCellXform;
16871}(BaseXform);
16872
16873module.exports = MergeCellXform;
16874
16875},{"../base-xform":31}],99:[function(require,module,exports){
16876"use strict";
16877
16878function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16879
16880function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16881
16882function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16883
16884var _ = require('../../../utils/under-dash');
16885
16886var Range = require('../../../doc/range');
16887
16888var colCache = require('../../../utils/col-cache');
16889
16890var Enums = require('../../../doc/enums');
16891
16892var Merges = /*#__PURE__*/function () {
16893  function Merges() {
16894    _classCallCheck(this, Merges);
16895
16896    // optional mergeCells is array of ranges (like the xml)
16897    this.merges = {};
16898  }
16899
16900  _createClass(Merges, [{
16901    key: "add",
16902    value: function add(merge) {
16903      // merge is {address, master}
16904      if (this.merges[merge.master]) {
16905        this.merges[merge.master].expandToAddress(merge.address);
16906      } else {
16907        var range = "".concat(merge.master, ":").concat(merge.address);
16908        this.merges[merge.master] = new Range(range);
16909      }
16910    }
16911  }, {
16912    key: "reconcile",
16913    value: function reconcile(mergeCells, rows) {
16914      // reconcile merge list with merge cells
16915      _.each(mergeCells, function (merge) {
16916        var dimensions = colCache.decode(merge);
16917
16918        for (var i = dimensions.top; i <= dimensions.bottom; i++) {
16919          var row = rows[i - 1];
16920
16921          for (var j = dimensions.left; j <= dimensions.right; j++) {
16922            var cell = row.cells[j - 1];
16923
16924            if (!cell) {
16925              // nulls are not included in document - so if master cell has no value - add a null one here
16926              row.cells[j] = {
16927                type: Enums.ValueType.Null,
16928                address: colCache.encodeAddress(i, j)
16929              };
16930            } else if (cell.type === Enums.ValueType.Merge) {
16931              cell.master = dimensions.tl;
16932            }
16933          }
16934        }
16935      });
16936    }
16937  }, {
16938    key: "getMasterAddress",
16939    value: function getMasterAddress(address) {
16940      // if address has been merged, return its master's address. Assumes reconcile has been called
16941      var range = this.hash[address];
16942      return range && range.tl;
16943    }
16944  }, {
16945    key: "mergeCells",
16946    get: function get() {
16947      return _.map(this.merges, function (merge) {
16948        return merge.range;
16949      });
16950    }
16951  }]);
16952
16953  return Merges;
16954}();
16955
16956module.exports = Merges;
16957
16958},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":25}],100:[function(require,module,exports){
16959"use strict";
16960
16961function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16962
16963function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16964
16965function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
16966
16967function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16968
16969function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16970
16971function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16972
16973function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16974
16975function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16976
16977function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
16978
16979function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16980
16981function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16982
16983var BaseXform = require('../base-xform');
16984
16985var isDefined = function isDefined(attr) {
16986  return typeof attr !== 'undefined';
16987};
16988
16989var OutlinePropertiesXform = /*#__PURE__*/function (_BaseXform) {
16990  _inherits(OutlinePropertiesXform, _BaseXform);
16991
16992  var _super = _createSuper(OutlinePropertiesXform);
16993
16994  function OutlinePropertiesXform() {
16995    _classCallCheck(this, OutlinePropertiesXform);
16996
16997    return _super.apply(this, arguments);
16998  }
16999
17000  _createClass(OutlinePropertiesXform, [{
17001    key: "render",
17002    value: function render(xmlStream, model) {
17003      if (model && (isDefined(model.summaryBelow) || isDefined(model.summaryRight))) {
17004        xmlStream.leafNode(this.tag, {
17005          summaryBelow: isDefined(model.summaryBelow) ? Number(model.summaryBelow) : undefined,
17006          summaryRight: isDefined(model.summaryRight) ? Number(model.summaryRight) : undefined
17007        });
17008        return true;
17009      }
17010
17011      return false;
17012    }
17013  }, {
17014    key: "parseOpen",
17015    value: function parseOpen(node) {
17016      if (node.name === this.tag) {
17017        this.model = {
17018          summaryBelow: isDefined(node.attributes.summaryBelow) ? Boolean(Number(node.attributes.summaryBelow)) : undefined,
17019          summaryRight: isDefined(node.attributes.summaryRight) ? Boolean(Number(node.attributes.summaryRight)) : undefined
17020        };
17021        return true;
17022      }
17023
17024      return false;
17025    }
17026  }, {
17027    key: "parseText",
17028    value: function parseText() {}
17029  }, {
17030    key: "parseClose",
17031    value: function parseClose() {
17032      return false;
17033    }
17034  }, {
17035    key: "tag",
17036    get: function get() {
17037      return 'outlinePr';
17038    }
17039  }]);
17040
17041  return OutlinePropertiesXform;
17042}(BaseXform);
17043
17044module.exports = OutlinePropertiesXform;
17045
17046},{"../base-xform":31}],101:[function(require,module,exports){
17047"use strict";
17048
17049function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17050
17051function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17052
17053function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17054
17055function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17056
17057function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17058
17059function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17060
17061function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17062
17063function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17064
17065function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17066
17067function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17068
17069function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17070
17071var BaseXform = require('../base-xform');
17072
17073var PageBreaksXform = /*#__PURE__*/function (_BaseXform) {
17074  _inherits(PageBreaksXform, _BaseXform);
17075
17076  var _super = _createSuper(PageBreaksXform);
17077
17078  function PageBreaksXform() {
17079    _classCallCheck(this, PageBreaksXform);
17080
17081    return _super.apply(this, arguments);
17082  }
17083
17084  _createClass(PageBreaksXform, [{
17085    key: "render",
17086    value: function render(xmlStream, model) {
17087      xmlStream.leafNode('brk', model);
17088    }
17089  }, {
17090    key: "parseOpen",
17091    value: function parseOpen(node) {
17092      if (node.name === 'brk') {
17093        this.model = node.attributes.ref;
17094        return true;
17095      }
17096
17097      return false;
17098    }
17099  }, {
17100    key: "parseText",
17101    value: function parseText() {}
17102  }, {
17103    key: "parseClose",
17104    value: function parseClose() {
17105      return false;
17106    }
17107  }, {
17108    key: "tag",
17109    get: function get() {
17110      return 'brk';
17111    }
17112  }]);
17113
17114  return PageBreaksXform;
17115}(BaseXform);
17116
17117module.exports = PageBreaksXform;
17118
17119},{"../base-xform":31}],102:[function(require,module,exports){
17120"use strict";
17121
17122function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17123
17124function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17125
17126function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17127
17128function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17129
17130function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17131
17132function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17133
17134function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17135
17136function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17137
17138function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17139
17140function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17141
17142function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17143
17144var _ = require('../../../utils/under-dash');
17145
17146var BaseXform = require('../base-xform');
17147
17148var PageMarginsXform = /*#__PURE__*/function (_BaseXform) {
17149  _inherits(PageMarginsXform, _BaseXform);
17150
17151  var _super = _createSuper(PageMarginsXform);
17152
17153  function PageMarginsXform() {
17154    _classCallCheck(this, PageMarginsXform);
17155
17156    return _super.apply(this, arguments);
17157  }
17158
17159  _createClass(PageMarginsXform, [{
17160    key: "render",
17161    value: function render(xmlStream, model) {
17162      if (model) {
17163        var attributes = {
17164          left: model.left,
17165          right: model.right,
17166          top: model.top,
17167          bottom: model.bottom,
17168          header: model.header,
17169          footer: model.footer
17170        };
17171
17172        if (_.some(attributes, function (value) {
17173          return value !== undefined;
17174        })) {
17175          xmlStream.leafNode(this.tag, attributes);
17176        }
17177      }
17178    }
17179  }, {
17180    key: "parseOpen",
17181    value: function parseOpen(node) {
17182      switch (node.name) {
17183        case this.tag:
17184          this.model = {
17185            left: parseFloat(node.attributes.left || 0.7),
17186            right: parseFloat(node.attributes.right || 0.7),
17187            top: parseFloat(node.attributes.top || 0.75),
17188            bottom: parseFloat(node.attributes.bottom || 0.75),
17189            header: parseFloat(node.attributes.header || 0.3),
17190            footer: parseFloat(node.attributes.footer || 0.3)
17191          };
17192          return true;
17193
17194        default:
17195          return false;
17196      }
17197    }
17198  }, {
17199    key: "parseText",
17200    value: function parseText() {}
17201  }, {
17202    key: "parseClose",
17203    value: function parseClose() {
17204      return false;
17205    }
17206  }, {
17207    key: "tag",
17208    get: function get() {
17209      return 'pageMargins';
17210    }
17211  }]);
17212
17213  return PageMarginsXform;
17214}(BaseXform);
17215
17216module.exports = PageMarginsXform;
17217
17218},{"../../../utils/under-dash":25,"../base-xform":31}],103:[function(require,module,exports){
17219"use strict";
17220
17221function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17222
17223function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17224
17225function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17226
17227function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17228
17229function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17230
17231function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17232
17233function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17234
17235function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17236
17237function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17238
17239function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17240
17241function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17242
17243var BaseXform = require('../base-xform');
17244
17245var PageSetupPropertiesXform = /*#__PURE__*/function (_BaseXform) {
17246  _inherits(PageSetupPropertiesXform, _BaseXform);
17247
17248  var _super = _createSuper(PageSetupPropertiesXform);
17249
17250  function PageSetupPropertiesXform() {
17251    _classCallCheck(this, PageSetupPropertiesXform);
17252
17253    return _super.apply(this, arguments);
17254  }
17255
17256  _createClass(PageSetupPropertiesXform, [{
17257    key: "render",
17258    value: function render(xmlStream, model) {
17259      if (model && model.fitToPage) {
17260        xmlStream.leafNode(this.tag, {
17261          fitToPage: model.fitToPage ? '1' : undefined
17262        });
17263        return true;
17264      }
17265
17266      return false;
17267    }
17268  }, {
17269    key: "parseOpen",
17270    value: function parseOpen(node) {
17271      if (node.name === this.tag) {
17272        this.model = {
17273          fitToPage: node.attributes.fitToPage === '1'
17274        };
17275        return true;
17276      }
17277
17278      return false;
17279    }
17280  }, {
17281    key: "parseText",
17282    value: function parseText() {}
17283  }, {
17284    key: "parseClose",
17285    value: function parseClose() {
17286      return false;
17287    }
17288  }, {
17289    key: "tag",
17290    get: function get() {
17291      return 'pageSetUpPr';
17292    }
17293  }]);
17294
17295  return PageSetupPropertiesXform;
17296}(BaseXform);
17297
17298module.exports = PageSetupPropertiesXform;
17299
17300},{"../base-xform":31}],104:[function(require,module,exports){
17301"use strict";
17302
17303function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17304
17305function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17306
17307function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17308
17309function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17310
17311function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17312
17313function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17314
17315function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17316
17317function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17318
17319function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17320
17321function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17322
17323function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17324
17325var _ = require('../../../utils/under-dash');
17326
17327var BaseXform = require('../base-xform');
17328
17329function booleanToXml(model) {
17330  return model ? '1' : undefined;
17331}
17332
17333function pageOrderToXml(model) {
17334  switch (model) {
17335    case 'overThenDown':
17336      return model;
17337
17338    default:
17339      return undefined;
17340  }
17341}
17342
17343function cellCommentsToXml(model) {
17344  switch (model) {
17345    case 'atEnd':
17346    case 'asDisplyed':
17347      return model;
17348
17349    default:
17350      return undefined;
17351  }
17352}
17353
17354function errorsToXml(model) {
17355  switch (model) {
17356    case 'dash':
17357    case 'blank':
17358    case 'NA':
17359      return model;
17360
17361    default:
17362      return undefined;
17363  }
17364}
17365
17366function pageSizeToModel(value) {
17367  return value !== undefined ? parseInt(value, 10) : undefined;
17368}
17369
17370var PageSetupXform = /*#__PURE__*/function (_BaseXform) {
17371  _inherits(PageSetupXform, _BaseXform);
17372
17373  var _super = _createSuper(PageSetupXform);
17374
17375  function PageSetupXform() {
17376    _classCallCheck(this, PageSetupXform);
17377
17378    return _super.apply(this, arguments);
17379  }
17380
17381  _createClass(PageSetupXform, [{
17382    key: "render",
17383    value: function render(xmlStream, model) {
17384      if (model) {
17385        var attributes = {
17386          paperSize: model.paperSize,
17387          orientation: model.orientation,
17388          horizontalDpi: model.horizontalDpi,
17389          verticalDpi: model.verticalDpi,
17390          pageOrder: pageOrderToXml(model.pageOrder),
17391          blackAndWhite: booleanToXml(model.blackAndWhite),
17392          draft: booleanToXml(model.draft),
17393          cellComments: cellCommentsToXml(model.cellComments),
17394          errors: errorsToXml(model.errors),
17395          scale: model.scale,
17396          fitToWidth: model.fitToWidth,
17397          fitToHeight: model.fitToHeight,
17398          firstPageNumber: model.firstPageNumber,
17399          useFirstPageNumber: booleanToXml(model.firstPageNumber),
17400          usePrinterDefaults: booleanToXml(model.usePrinterDefaults),
17401          copies: model.copies
17402        };
17403
17404        if (_.some(attributes, function (value) {
17405          return value !== undefined;
17406        })) {
17407          xmlStream.leafNode(this.tag, attributes);
17408        }
17409      }
17410    }
17411  }, {
17412    key: "parseOpen",
17413    value: function parseOpen(node) {
17414      switch (node.name) {
17415        case this.tag:
17416          this.model = {
17417            paperSize: pageSizeToModel(node.attributes.paperSize),
17418            orientation: node.attributes.orientation || 'portrait',
17419            horizontalDpi: parseInt(node.attributes.horizontalDpi || '4294967295', 10),
17420            verticalDpi: parseInt(node.attributes.verticalDpi || '4294967295', 10),
17421            pageOrder: node.attributes.pageOrder || 'downThenOver',
17422            blackAndWhite: node.attributes.blackAndWhite === '1',
17423            draft: node.attributes.draft === '1',
17424            cellComments: node.attributes.cellComments || 'None',
17425            errors: node.attributes.errors || 'displayed',
17426            scale: parseInt(node.attributes.scale || '100', 10),
17427            fitToWidth: parseInt(node.attributes.fitToWidth || '1', 10),
17428            fitToHeight: parseInt(node.attributes.fitToHeight || '1', 10),
17429            firstPageNumber: parseInt(node.attributes.firstPageNumber || '1', 10),
17430            useFirstPageNumber: node.attributes.useFirstPageNumber === '1',
17431            usePrinterDefaults: node.attributes.usePrinterDefaults === '1',
17432            copies: parseInt(node.attributes.copies || '1', 10)
17433          };
17434          return true;
17435
17436        default:
17437          return false;
17438      }
17439    }
17440  }, {
17441    key: "parseText",
17442    value: function parseText() {}
17443  }, {
17444    key: "parseClose",
17445    value: function parseClose() {
17446      return false;
17447    }
17448  }, {
17449    key: "tag",
17450    get: function get() {
17451      return 'pageSetup';
17452    }
17453  }]);
17454
17455  return PageSetupXform;
17456}(BaseXform);
17457
17458module.exports = PageSetupXform;
17459
17460},{"../../../utils/under-dash":25,"../base-xform":31}],105:[function(require,module,exports){
17461"use strict";
17462
17463function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17464
17465function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17466
17467function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17468
17469function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17470
17471function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17472
17473function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17474
17475function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17476
17477function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17478
17479function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17480
17481function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17482
17483function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17484
17485var BaseXform = require('../base-xform');
17486
17487var PictureXform = /*#__PURE__*/function (_BaseXform) {
17488  _inherits(PictureXform, _BaseXform);
17489
17490  var _super = _createSuper(PictureXform);
17491
17492  function PictureXform() {
17493    _classCallCheck(this, PictureXform);
17494
17495    return _super.apply(this, arguments);
17496  }
17497
17498  _createClass(PictureXform, [{
17499    key: "render",
17500    value: function render(xmlStream, model) {
17501      if (model) {
17502        xmlStream.leafNode(this.tag, {
17503          'r:id': model.rId
17504        });
17505      }
17506    }
17507  }, {
17508    key: "parseOpen",
17509    value: function parseOpen(node) {
17510      switch (node.name) {
17511        case this.tag:
17512          this.model = {
17513            rId: node.attributes['r:id']
17514          };
17515          return true;
17516
17517        default:
17518          return false;
17519      }
17520    }
17521  }, {
17522    key: "parseText",
17523    value: function parseText() {}
17524  }, {
17525    key: "parseClose",
17526    value: function parseClose() {
17527      return false;
17528    }
17529  }, {
17530    key: "tag",
17531    get: function get() {
17532      return 'picture';
17533    }
17534  }]);
17535
17536  return PictureXform;
17537}(BaseXform);
17538
17539module.exports = PictureXform;
17540
17541},{"../base-xform":31}],106:[function(require,module,exports){
17542"use strict";
17543
17544function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17545
17546function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17547
17548function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17549
17550function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17551
17552function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17553
17554function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17555
17556function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17557
17558function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17559
17560function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17561
17562function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17563
17564function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17565
17566var _ = require('../../../utils/under-dash');
17567
17568var BaseXform = require('../base-xform');
17569
17570function booleanToXml(model) {
17571  return model ? '1' : undefined;
17572}
17573
17574var PrintOptionsXform = /*#__PURE__*/function (_BaseXform) {
17575  _inherits(PrintOptionsXform, _BaseXform);
17576
17577  var _super = _createSuper(PrintOptionsXform);
17578
17579  function PrintOptionsXform() {
17580    _classCallCheck(this, PrintOptionsXform);
17581
17582    return _super.apply(this, arguments);
17583  }
17584
17585  _createClass(PrintOptionsXform, [{
17586    key: "render",
17587    value: function render(xmlStream, model) {
17588      if (model) {
17589        var attributes = {
17590          headings: booleanToXml(model.showRowColHeaders),
17591          gridLines: booleanToXml(model.showGridLines),
17592          horizontalCentered: booleanToXml(model.horizontalCentered),
17593          verticalCentered: booleanToXml(model.verticalCentered)
17594        };
17595
17596        if (_.some(attributes, function (value) {
17597          return value !== undefined;
17598        })) {
17599          xmlStream.leafNode(this.tag, attributes);
17600        }
17601      }
17602    }
17603  }, {
17604    key: "parseOpen",
17605    value: function parseOpen(node) {
17606      switch (node.name) {
17607        case this.tag:
17608          this.model = {
17609            showRowColHeaders: node.attributes.headings === '1',
17610            showGridLines: node.attributes.gridLines === '1',
17611            horizontalCentered: node.attributes.horizontalCentered === '1',
17612            verticalCentered: node.attributes.verticalCentered === '1'
17613          };
17614          return true;
17615
17616        default:
17617          return false;
17618      }
17619    }
17620  }, {
17621    key: "parseText",
17622    value: function parseText() {}
17623  }, {
17624    key: "parseClose",
17625    value: function parseClose() {
17626      return false;
17627    }
17628  }, {
17629    key: "tag",
17630    get: function get() {
17631      return 'printOptions';
17632    }
17633  }]);
17634
17635  return PrintOptionsXform;
17636}(BaseXform);
17637
17638module.exports = PrintOptionsXform;
17639
17640},{"../../../utils/under-dash":25,"../base-xform":31}],107:[function(require,module,exports){
17641'use strict';
17642
17643function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17644
17645function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17646
17647function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17648
17649function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17650
17651function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17652
17653function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17654
17655function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17656
17657function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17658
17659function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17660
17661function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17662
17663function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17664
17665var PageBreaksXform = require('./page-breaks-xform');
17666
17667var ListXform = require('../list-xform');
17668
17669var RowBreaksXform = /*#__PURE__*/function (_ListXform) {
17670  _inherits(RowBreaksXform, _ListXform);
17671
17672  var _super = _createSuper(RowBreaksXform);
17673
17674  function RowBreaksXform() {
17675    _classCallCheck(this, RowBreaksXform);
17676
17677    var options = {
17678      tag: 'rowBreaks',
17679      count: true,
17680      childXform: new PageBreaksXform()
17681    };
17682    return _super.call(this, options);
17683  } // get tag() { return 'rowBreaks'; }
17684
17685
17686  _createClass(RowBreaksXform, [{
17687    key: "render",
17688    value: function render(xmlStream, model) {
17689      if (model && model.length) {
17690        xmlStream.openNode(this.tag, this.$);
17691
17692        if (this.count) {
17693          xmlStream.addAttribute(this.$count, model.length);
17694          xmlStream.addAttribute('manualBreakCount', model.length);
17695        }
17696
17697        var childXform = this.childXform;
17698        model.forEach(function (childModel) {
17699          childXform.render(xmlStream, childModel);
17700        });
17701        xmlStream.closeNode();
17702      } else if (this.empty) {
17703        xmlStream.leafNode(this.tag);
17704      }
17705    }
17706  }]);
17707
17708  return RowBreaksXform;
17709}(ListXform);
17710
17711module.exports = RowBreaksXform;
17712
17713},{"../list-xform":70,"./page-breaks-xform":101}],108:[function(require,module,exports){
17714"use strict";
17715
17716function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17717
17718function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17719
17720function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17721
17722function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17723
17724function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17725
17726function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17727
17728function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17729
17730function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17731
17732function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17733
17734function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17735
17736function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17737
17738var BaseXform = require('../base-xform');
17739
17740var CellXform = require('./cell-xform');
17741
17742var RowXform = /*#__PURE__*/function (_BaseXform) {
17743  _inherits(RowXform, _BaseXform);
17744
17745  var _super = _createSuper(RowXform);
17746
17747  function RowXform(options) {
17748    var _this;
17749
17750    _classCallCheck(this, RowXform);
17751
17752    _this = _super.call(this);
17753    _this.maxItems = options && options.maxItems;
17754    _this.map = {
17755      c: new CellXform()
17756    };
17757    return _this;
17758  }
17759
17760  _createClass(RowXform, [{
17761    key: "prepare",
17762    value: function prepare(model, options) {
17763      var styleId = options.styles.addStyleModel(model.style);
17764
17765      if (styleId) {
17766        model.styleId = styleId;
17767      }
17768
17769      var cellXform = this.map.c;
17770      model.cells.forEach(function (cellModel) {
17771        cellXform.prepare(cellModel, options);
17772      });
17773    }
17774  }, {
17775    key: "render",
17776    value: function render(xmlStream, model, options) {
17777      xmlStream.openNode('row');
17778      xmlStream.addAttribute('r', model.number);
17779
17780      if (model.height) {
17781        xmlStream.addAttribute('ht', model.height);
17782        xmlStream.addAttribute('customHeight', '1');
17783      }
17784
17785      if (model.hidden) {
17786        xmlStream.addAttribute('hidden', '1');
17787      }
17788
17789      if (model.min > 0 && model.max > 0 && model.min <= model.max) {
17790        xmlStream.addAttribute('spans', "".concat(model.min, ":").concat(model.max));
17791      }
17792
17793      if (model.styleId) {
17794        xmlStream.addAttribute('s', model.styleId);
17795        xmlStream.addAttribute('customFormat', '1');
17796      }
17797
17798      xmlStream.addAttribute('x14ac:dyDescent', '0.25');
17799
17800      if (model.outlineLevel) {
17801        xmlStream.addAttribute('outlineLevel', model.outlineLevel);
17802      }
17803
17804      if (model.collapsed) {
17805        xmlStream.addAttribute('collapsed', '1');
17806      }
17807
17808      var cellXform = this.map.c;
17809      model.cells.forEach(function (cellModel) {
17810        cellXform.render(xmlStream, cellModel, options);
17811      });
17812      xmlStream.closeNode();
17813    }
17814  }, {
17815    key: "parseOpen",
17816    value: function parseOpen(node) {
17817      if (this.parser) {
17818        this.parser.parseOpen(node);
17819        return true;
17820      }
17821
17822      if (node.name === 'row') {
17823        this.numRowsSeen += 1;
17824        var spans = node.attributes.spans ? node.attributes.spans.split(':').map(function (span) {
17825          return parseInt(span, 10);
17826        }) : [undefined, undefined];
17827        var model = this.model = {
17828          number: parseInt(node.attributes.r, 10),
17829          min: spans[0],
17830          max: spans[1],
17831          cells: []
17832        };
17833
17834        if (node.attributes.s) {
17835          model.styleId = parseInt(node.attributes.s, 10);
17836        }
17837
17838        if (node.attributes.hidden === true || node.attributes.hidden === 'true' || node.attributes.hidden === 1 || node.attributes.hidden === '1') {
17839          model.hidden = true;
17840        }
17841
17842        if (node.attributes.bestFit) {
17843          model.bestFit = true;
17844        }
17845
17846        if (node.attributes.ht) {
17847          model.height = parseFloat(node.attributes.ht);
17848        }
17849
17850        if (node.attributes.outlineLevel) {
17851          model.outlineLevel = parseInt(node.attributes.outlineLevel, 10);
17852        }
17853
17854        if (node.attributes.collapsed) {
17855          model.collapsed = true;
17856        }
17857
17858        return true;
17859      }
17860
17861      this.parser = this.map[node.name];
17862
17863      if (this.parser) {
17864        this.parser.parseOpen(node);
17865        return true;
17866      }
17867
17868      return false;
17869    }
17870  }, {
17871    key: "parseText",
17872    value: function parseText(text) {
17873      if (this.parser) {
17874        this.parser.parseText(text);
17875      }
17876    }
17877  }, {
17878    key: "parseClose",
17879    value: function parseClose(name) {
17880      if (this.parser) {
17881        if (!this.parser.parseClose(name)) {
17882          this.model.cells.push(this.parser.model);
17883
17884          if (this.maxItems && this.model.cells.length > this.maxItems) {
17885            throw new Error("Max column count (".concat(this.maxItems, ") exceeded"));
17886          }
17887
17888          this.parser = undefined;
17889        }
17890
17891        return true;
17892      }
17893
17894      return false;
17895    }
17896  }, {
17897    key: "reconcile",
17898    value: function reconcile(model, options) {
17899      model.style = model.styleId ? options.styles.getStyleModel(model.styleId) : {};
17900
17901      if (model.styleId !== undefined) {
17902        model.styleId = undefined;
17903      }
17904
17905      var cellXform = this.map.c;
17906      model.cells.forEach(function (cellModel) {
17907        cellXform.reconcile(cellModel, options);
17908      });
17909    }
17910  }, {
17911    key: "tag",
17912    get: function get() {
17913      return 'row';
17914    }
17915  }]);
17916
17917  return RowXform;
17918}(BaseXform);
17919
17920module.exports = RowXform;
17921
17922},{"../base-xform":31,"./cell-xform":72}],109:[function(require,module,exports){
17923"use strict";
17924
17925function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17926
17927function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17928
17929function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17930
17931function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17932
17933function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
17934
17935function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17936
17937function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17938
17939function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
17940
17941function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17942
17943function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
17944
17945function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17946
17947var _ = require('../../../utils/under-dash');
17948
17949var BaseXform = require('../base-xform');
17950
17951var SheetFormatPropertiesXform = /*#__PURE__*/function (_BaseXform) {
17952  _inherits(SheetFormatPropertiesXform, _BaseXform);
17953
17954  var _super = _createSuper(SheetFormatPropertiesXform);
17955
17956  function SheetFormatPropertiesXform() {
17957    _classCallCheck(this, SheetFormatPropertiesXform);
17958
17959    return _super.apply(this, arguments);
17960  }
17961
17962  _createClass(SheetFormatPropertiesXform, [{
17963    key: "render",
17964    value: function render(xmlStream, model) {
17965      if (model) {
17966        var attributes = {
17967          defaultRowHeight: model.defaultRowHeight,
17968          outlineLevelRow: model.outlineLevelRow,
17969          outlineLevelCol: model.outlineLevelCol,
17970          'x14ac:dyDescent': model.dyDescent
17971        };
17972
17973        if (model.defaultColWidth) {
17974          attributes.defaultColWidth = model.defaultColWidth;
17975        } // default value for 'defaultRowHeight' is 15, this should not be 'custom'
17976
17977
17978        if (!model.defaultRowHeight || model.defaultRowHeight !== 15) {
17979          attributes.customHeight = '1';
17980        }
17981
17982        if (_.some(attributes, function (value) {
17983          return value !== undefined;
17984        })) {
17985          xmlStream.leafNode('sheetFormatPr', attributes);
17986        }
17987      }
17988    }
17989  }, {
17990    key: "parseOpen",
17991    value: function parseOpen(node) {
17992      if (node.name === 'sheetFormatPr') {
17993        this.model = {
17994          defaultRowHeight: parseFloat(node.attributes.defaultRowHeight || '0'),
17995          dyDescent: parseFloat(node.attributes['x14ac:dyDescent'] || '0'),
17996          outlineLevelRow: parseInt(node.attributes.outlineLevelRow || '0', 10),
17997          outlineLevelCol: parseInt(node.attributes.outlineLevelCol || '0', 10)
17998        };
17999
18000        if (node.attributes.defaultColWidth) {
18001          this.model.defaultColWidth = parseFloat(node.attributes.defaultColWidth);
18002        }
18003
18004        return true;
18005      }
18006
18007      return false;
18008    }
18009  }, {
18010    key: "parseText",
18011    value: function parseText() {}
18012  }, {
18013    key: "parseClose",
18014    value: function parseClose() {
18015      return false;
18016    }
18017  }, {
18018    key: "tag",
18019    get: function get() {
18020      return 'sheetFormatPr';
18021    }
18022  }]);
18023
18024  return SheetFormatPropertiesXform;
18025}(BaseXform);
18026
18027module.exports = SheetFormatPropertiesXform;
18028
18029},{"../../../utils/under-dash":25,"../base-xform":31}],110:[function(require,module,exports){
18030"use strict";
18031
18032function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
18033
18034function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18035
18036function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
18037
18038function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
18039
18040function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
18041
18042function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18043
18044function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18045
18046function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
18047
18048function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18049
18050function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
18051
18052function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18053
18054var BaseXform = require('../base-xform');
18055
18056var ColorXform = require('../style/color-xform');
18057
18058var PageSetupPropertiesXform = require('./page-setup-properties-xform');
18059
18060var OutlinePropertiesXform = require('./outline-properties-xform');
18061
18062var SheetPropertiesXform = /*#__PURE__*/function (_BaseXform) {
18063  _inherits(SheetPropertiesXform, _BaseXform);
18064
18065  var _super = _createSuper(SheetPropertiesXform);
18066
18067  function SheetPropertiesXform() {
18068    var _this;
18069
18070    _classCallCheck(this, SheetPropertiesXform);
18071
18072    _this = _super.call(this);
18073    _this.map = {
18074      tabColor: new ColorXform('tabColor'),
18075      pageSetUpPr: new PageSetupPropertiesXform(),
18076      outlinePr: new OutlinePropertiesXform()
18077    };
18078    return _this;
18079  }
18080
18081  _createClass(SheetPropertiesXform, [{
18082    key: "render",
18083    value: function render(xmlStream, model) {
18084      if (model) {
18085        xmlStream.addRollback();
18086        xmlStream.openNode('sheetPr');
18087        var inner = false;
18088        inner = this.map.tabColor.render(xmlStream, model.tabColor) || inner;
18089        inner = this.map.pageSetUpPr.render(xmlStream, model.pageSetup) || inner;
18090        inner = this.map.outlinePr.render(xmlStream, model.outlineProperties) || inner;
18091
18092        if (inner) {
18093          xmlStream.closeNode();
18094          xmlStream.commit();
18095        } else {
18096          xmlStream.rollback();
18097        }
18098      }
18099    }
18100  }, {
18101    key: "parseOpen",
18102    value: function parseOpen(node) {
18103      if (this.parser) {
18104        this.parser.parseOpen(node);
18105        return true;
18106      }
18107
18108      if (node.name === this.tag) {
18109        this.reset();
18110        return true;
18111      }
18112
18113      if (this.map[node.name]) {
18114        this.parser = this.map[node.name];
18115        this.parser.parseOpen(node);
18116        return true;
18117      }
18118
18119      return false;
18120    }
18121  }, {
18122    key: "parseText",
18123    value: function parseText(text) {
18124      if (this.parser) {
18125        this.parser.parseText(text);
18126        return true;
18127      }
18128
18129      return false;
18130    }
18131  }, {
18132    key: "parseClose",
18133    value: function parseClose(name) {
18134      if (this.parser) {
18135        if (!this.parser.parseClose(name)) {
18136          this.parser = undefined;
18137        }
18138
18139        return true;
18140      }
18141
18142      if (this.map.tabColor.model || this.map.pageSetUpPr.model || this.map.outlinePr.model) {
18143        this.model = {};
18144
18145        if (this.map.tabColor.model) {
18146          this.model.tabColor = this.map.tabColor.model;
18147        }
18148
18149        if (this.map.pageSetUpPr.model) {
18150          this.model.pageSetup = this.map.pageSetUpPr.model;
18151        }
18152
18153        if (this.map.outlinePr.model) {
18154          this.model.outlineProperties = this.map.outlinePr.model;
18155        }
18156      } else {
18157        this.model = null;
18158      }
18159
18160      return false;
18161    }
18162  }, {
18163    key: "tag",
18164    get: function get() {
18165      return 'sheetPr';
18166    }
18167  }]);
18168
18169  return SheetPropertiesXform;
18170}(BaseXform);
18171
18172module.exports = SheetPropertiesXform;
18173
18174},{"../base-xform":31,"../style/color-xform":127,"./outline-properties-xform":100,"./page-setup-properties-xform":103}],111:[function(require,module,exports){
18175"use strict";
18176
18177function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
18178
18179function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18180
18181function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
18182
18183function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
18184
18185function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
18186
18187function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18188
18189function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18190
18191function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
18192
18193function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18194
18195function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
18196
18197function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18198
18199var _ = require('../../../utils/under-dash');
18200
18201var BaseXform = require('../base-xform');
18202
18203function booleanToXml(model, value) {
18204  return model ? value : undefined;
18205}
18206
18207function xmlToBoolean(value, equals) {
18208  return value === equals ? true : undefined;
18209}
18210
18211var SheetProtectionXform = /*#__PURE__*/function (_BaseXform) {
18212  _inherits(SheetProtectionXform, _BaseXform);
18213
18214  var _super = _createSuper(SheetProtectionXform);
18215
18216  function SheetProtectionXform() {
18217    _classCallCheck(this, SheetProtectionXform);
18218
18219    return _super.apply(this, arguments);
18220  }
18221
18222  _createClass(SheetProtectionXform, [{
18223    key: "render",
18224    value: function render(xmlStream, model) {
18225      if (model) {
18226        var attributes = {
18227          sheet: booleanToXml(model.sheet, '1'),
18228          selectLockedCells: model.selectLockedCells === false ? '1' : undefined,
18229          selectUnlockedCells: model.selectUnlockedCells === false ? '1' : undefined,
18230          formatCells: booleanToXml(model.formatCells, '0'),
18231          formatColumns: booleanToXml(model.formatColumns, '0'),
18232          formatRows: booleanToXml(model.formatRows, '0'),
18233          insertColumns: booleanToXml(model.insertColumns, '0'),
18234          insertRows: booleanToXml(model.insertRows, '0'),
18235          insertHyperlinks: booleanToXml(model.insertHyperlinks, '0'),
18236          deleteColumns: booleanToXml(model.deleteColumns, '0'),
18237          deleteRows: booleanToXml(model.deleteRows, '0'),
18238          sort: booleanToXml(model.sort, '0'),
18239          autoFilter: booleanToXml(model.autoFilter, '0'),
18240          pivotTables: booleanToXml(model.pivotTables, '0')
18241        };
18242
18243        if (model.sheet) {
18244          attributes.algorithmName = model.algorithmName;
18245          attributes.hashValue = model.hashValue;
18246          attributes.saltValue = model.saltValue;
18247          attributes.spinCount = model.spinCount;
18248          attributes.objects = booleanToXml(model.objects === false, '1');
18249          attributes.scenarios = booleanToXml(model.scenarios === false, '1');
18250        }
18251
18252        if (_.some(attributes, function (value) {
18253          return value !== undefined;
18254        })) {
18255          xmlStream.leafNode(this.tag, attributes);
18256        }
18257      }
18258    }
18259  }, {
18260    key: "parseOpen",
18261    value: function parseOpen(node) {
18262      switch (node.name) {
18263        case this.tag:
18264          this.model = {
18265            sheet: xmlToBoolean(node.attributes.sheet, '1'),
18266            objects: node.attributes.objects === '1' ? false : undefined,
18267            scenarios: node.attributes.scenarios === '1' ? false : undefined,
18268            selectLockedCells: node.attributes.selectLockedCells === '1' ? false : undefined,
18269            selectUnlockedCells: node.attributes.selectUnlockedCells === '1' ? false : undefined,
18270            formatCells: xmlToBoolean(node.attributes.formatCells, '0'),
18271            formatColumns: xmlToBoolean(node.attributes.formatColumns, '0'),
18272            formatRows: xmlToBoolean(node.attributes.formatRows, '0'),
18273            insertColumns: xmlToBoolean(node.attributes.insertColumns, '0'),
18274            insertRows: xmlToBoolean(node.attributes.insertRows, '0'),
18275            insertHyperlinks: xmlToBoolean(node.attributes.insertHyperlinks, '0'),
18276            deleteColumns: xmlToBoolean(node.attributes.deleteColumns, '0'),
18277            deleteRows: xmlToBoolean(node.attributes.deleteRows, '0'),
18278            sort: xmlToBoolean(node.attributes.sort, '0'),
18279            autoFilter: xmlToBoolean(node.attributes.autoFilter, '0'),
18280            pivotTables: xmlToBoolean(node.attributes.pivotTables, '0')
18281          };
18282
18283          if (node.attributes.algorithmName) {
18284            this.model.algorithmName = node.attributes.algorithmName;
18285            this.model.hashValue = node.attributes.hashValue;
18286            this.model.saltValue = node.attributes.saltValue;
18287            this.model.spinCount = parseInt(node.attributes.spinCount, 10);
18288          }
18289
18290          return true;
18291
18292        default:
18293          return false;
18294      }
18295    }
18296  }, {
18297    key: "parseText",
18298    value: function parseText() {}
18299  }, {
18300    key: "parseClose",
18301    value: function parseClose() {
18302      return false;
18303    }
18304  }, {
18305    key: "tag",
18306    get: function get() {
18307      return 'sheetProtection';
18308    }
18309  }]);
18310
18311  return SheetProtectionXform;
18312}(BaseXform);
18313
18314module.exports = SheetProtectionXform;
18315
18316},{"../../../utils/under-dash":25,"../base-xform":31}],112:[function(require,module,exports){
18317"use strict";
18318
18319function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
18320
18321function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18322
18323function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
18324
18325function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
18326
18327function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
18328
18329function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18330
18331function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18332
18333function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
18334
18335function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18336
18337function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
18338
18339function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18340
18341var colCache = require('../../../utils/col-cache');
18342
18343var BaseXform = require('../base-xform');
18344
18345var VIEW_STATES = {
18346  frozen: 'frozen',
18347  frozenSplit: 'frozen',
18348  split: 'split'
18349};
18350
18351var SheetViewXform = /*#__PURE__*/function (_BaseXform) {
18352  _inherits(SheetViewXform, _BaseXform);
18353
18354  var _super = _createSuper(SheetViewXform);
18355
18356  function SheetViewXform() {
18357    _classCallCheck(this, SheetViewXform);
18358
18359    return _super.apply(this, arguments);
18360  }
18361
18362  _createClass(SheetViewXform, [{
18363    key: "prepare",
18364    value: function prepare(model) {
18365      switch (model.state) {
18366        case 'frozen':
18367        case 'split':
18368          break;
18369
18370        default:
18371          model.state = 'normal';
18372          break;
18373      }
18374    }
18375  }, {
18376    key: "render",
18377    value: function render(xmlStream, model) {
18378      xmlStream.openNode('sheetView', {
18379        workbookViewId: model.workbookViewId || 0
18380      });
18381
18382      var add = function add(name, value, included) {
18383        if (included) {
18384          xmlStream.addAttribute(name, value);
18385        }
18386      };
18387
18388      add('rightToLeft', '1', model.rightToLeft === true);
18389      add('tabSelected', '1', model.tabSelected);
18390      add('showRuler', '0', model.showRuler === false);
18391      add('showRowColHeaders', '0', model.showRowColHeaders === false);
18392      add('showGridLines', '0', model.showGridLines === false);
18393      add('zoomScale', model.zoomScale, model.zoomScale);
18394      add('zoomScaleNormal', model.zoomScaleNormal, model.zoomScaleNormal);
18395      add('view', model.style, model.style);
18396      var topLeftCell;
18397      var xSplit;
18398      var ySplit;
18399      var activePane;
18400
18401      switch (model.state) {
18402        case 'frozen':
18403          xSplit = model.xSplit || 0;
18404          ySplit = model.ySplit || 0;
18405          topLeftCell = model.topLeftCell || colCache.getAddress(ySplit + 1, xSplit + 1).address;
18406          activePane = model.xSplit && model.ySplit && 'bottomRight' || model.xSplit && 'topRight' || 'bottomLeft';
18407          xmlStream.leafNode('pane', {
18408            xSplit: model.xSplit || undefined,
18409            ySplit: model.ySplit || undefined,
18410            topLeftCell: topLeftCell,
18411            activePane: activePane,
18412            state: 'frozen'
18413          });
18414          xmlStream.leafNode('selection', {
18415            pane: activePane,
18416            activeCell: model.activeCell,
18417            sqref: model.activeCell
18418          });
18419          break;
18420
18421        case 'split':
18422          if (model.activePane === 'topLeft') {
18423            model.activePane = undefined;
18424          }
18425
18426          xmlStream.leafNode('pane', {
18427            xSplit: model.xSplit || undefined,
18428            ySplit: model.ySplit || undefined,
18429            topLeftCell: model.topLeftCell,
18430            activePane: model.activePane
18431          });
18432          xmlStream.leafNode('selection', {
18433            pane: model.activePane,
18434            activeCell: model.activeCell,
18435            sqref: model.activeCell
18436          });
18437          break;
18438
18439        case 'normal':
18440          if (model.activeCell) {
18441            xmlStream.leafNode('selection', {
18442              activeCell: model.activeCell,
18443              sqref: model.activeCell
18444            });
18445          }
18446
18447          break;
18448
18449        default:
18450          break;
18451      }
18452
18453      xmlStream.closeNode();
18454    }
18455  }, {
18456    key: "parseOpen",
18457    value: function parseOpen(node) {
18458      switch (node.name) {
18459        case 'sheetView':
18460          this.sheetView = {
18461            workbookViewId: parseInt(node.attributes.workbookViewId, 10),
18462            rightToLeft: node.attributes.rightToLeft === '1',
18463            tabSelected: node.attributes.tabSelected === '1',
18464            showRuler: !(node.attributes.showRuler === '0'),
18465            showRowColHeaders: !(node.attributes.showRowColHeaders === '0'),
18466            showGridLines: !(node.attributes.showGridLines === '0'),
18467            zoomScale: parseInt(node.attributes.zoomScale || '100', 10),
18468            zoomScaleNormal: parseInt(node.attributes.zoomScaleNormal || '100', 10),
18469            style: node.attributes.view
18470          };
18471          this.pane = undefined;
18472          this.selections = {};
18473          return true;
18474
18475        case 'pane':
18476          this.pane = {
18477            xSplit: parseInt(node.attributes.xSplit || '0', 10),
18478            ySplit: parseInt(node.attributes.ySplit || '0', 10),
18479            topLeftCell: node.attributes.topLeftCell,
18480            activePane: node.attributes.activePane || 'topLeft',
18481            state: node.attributes.state
18482          };
18483          return true;
18484
18485        case 'selection':
18486          {
18487            var name = node.attributes.pane || 'topLeft';
18488            this.selections[name] = {
18489              pane: name,
18490              activeCell: node.attributes.activeCell
18491            };
18492            return true;
18493          }
18494
18495        default:
18496          return false;
18497      }
18498    }
18499  }, {
18500    key: "parseText",
18501    value: function parseText() {}
18502  }, {
18503    key: "parseClose",
18504    value: function parseClose(name) {
18505      var model;
18506      var selection;
18507
18508      switch (name) {
18509        case 'sheetView':
18510          if (this.sheetView && this.pane) {
18511            model = this.model = {
18512              workbookViewId: this.sheetView.workbookViewId,
18513              rightToLeft: this.sheetView.rightToLeft,
18514              state: VIEW_STATES[this.pane.state] || 'split',
18515              // split is default
18516              xSplit: this.pane.xSplit,
18517              ySplit: this.pane.ySplit,
18518              topLeftCell: this.pane.topLeftCell,
18519              showRuler: this.sheetView.showRuler,
18520              showRowColHeaders: this.sheetView.showRowColHeaders,
18521              showGridLines: this.sheetView.showGridLines,
18522              zoomScale: this.sheetView.zoomScale,
18523              zoomScaleNormal: this.sheetView.zoomScaleNormal
18524            };
18525
18526            if (this.model.state === 'split') {
18527              model.activePane = this.pane.activePane;
18528            }
18529
18530            selection = this.selections[this.pane.activePane];
18531
18532            if (selection && selection.activeCell) {
18533              model.activeCell = selection.activeCell;
18534            }
18535
18536            if (this.sheetView.style) {
18537              model.style = this.sheetView.style;
18538            }
18539          } else {
18540            model = this.model = {
18541              workbookViewId: this.sheetView.workbookViewId,
18542              rightToLeft: this.sheetView.rightToLeft,
18543              state: 'normal',
18544              showRuler: this.sheetView.showRuler,
18545              showRowColHeaders: this.sheetView.showRowColHeaders,
18546              showGridLines: this.sheetView.showGridLines,
18547              zoomScale: this.sheetView.zoomScale,
18548              zoomScaleNormal: this.sheetView.zoomScaleNormal
18549            };
18550            selection = this.selections.topLeft;
18551
18552            if (selection && selection.activeCell) {
18553              model.activeCell = selection.activeCell;
18554            }
18555
18556            if (this.sheetView.style) {
18557              model.style = this.sheetView.style;
18558            }
18559          }
18560
18561          return false;
18562
18563        default:
18564          return true;
18565      }
18566    }
18567  }, {
18568    key: "reconcile",
18569    value: function reconcile() {}
18570  }, {
18571    key: "tag",
18572    get: function get() {
18573      return 'sheetView';
18574    }
18575  }]);
18576
18577  return SheetViewXform;
18578}(BaseXform);
18579
18580module.exports = SheetViewXform;
18581
18582},{"../../../utils/col-cache":19,"../base-xform":31}],113:[function(require,module,exports){
18583"use strict";
18584
18585function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
18586
18587function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18588
18589function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
18590
18591function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
18592
18593function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
18594
18595function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18596
18597function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18598
18599function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
18600
18601function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18602
18603function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
18604
18605function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18606
18607var BaseXform = require('../base-xform');
18608
18609var TablePartXform = /*#__PURE__*/function (_BaseXform) {
18610  _inherits(TablePartXform, _BaseXform);
18611
18612  var _super = _createSuper(TablePartXform);
18613
18614  function TablePartXform() {
18615    _classCallCheck(this, TablePartXform);
18616
18617    return _super.apply(this, arguments);
18618  }
18619
18620  _createClass(TablePartXform, [{
18621    key: "render",
18622    value: function render(xmlStream, model) {
18623      if (model) {
18624        xmlStream.leafNode(this.tag, {
18625          'r:id': model.rId
18626        });
18627      }
18628    }
18629  }, {
18630    key: "parseOpen",
18631    value: function parseOpen(node) {
18632      switch (node.name) {
18633        case this.tag:
18634          this.model = {
18635            rId: node.attributes['r:id']
18636          };
18637          return true;
18638
18639        default:
18640          return false;
18641      }
18642    }
18643  }, {
18644    key: "parseText",
18645    value: function parseText() {}
18646  }, {
18647    key: "parseClose",
18648    value: function parseClose() {
18649      return false;
18650    }
18651  }, {
18652    key: "tag",
18653    get: function get() {
18654      return 'tablePart';
18655    }
18656  }]);
18657
18658  return TablePartXform;
18659}(BaseXform);
18660
18661module.exports = TablePartXform;
18662
18663},{"../base-xform":31}],114:[function(require,module,exports){
18664"use strict";
18665
18666function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
18667
18668function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18669
18670function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
18671
18672function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
18673
18674function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
18675
18676function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18677
18678function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18679
18680function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
18681
18682function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18683
18684function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
18685
18686function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18687
18688var _ = require('../../../utils/under-dash');
18689
18690var colCache = require('../../../utils/col-cache');
18691
18692var XmlStream = require('../../../utils/xml-stream');
18693
18694var RelType = require('../../rel-type');
18695
18696var Merges = require('./merges');
18697
18698var BaseXform = require('../base-xform');
18699
18700var ListXform = require('../list-xform');
18701
18702var RowXform = require('./row-xform');
18703
18704var ColXform = require('./col-xform');
18705
18706var DimensionXform = require('./dimension-xform');
18707
18708var HyperlinkXform = require('./hyperlink-xform');
18709
18710var MergeCellXform = require('./merge-cell-xform');
18711
18712var DataValidationsXform = require('./data-validations-xform');
18713
18714var SheetPropertiesXform = require('./sheet-properties-xform');
18715
18716var SheetFormatPropertiesXform = require('./sheet-format-properties-xform');
18717
18718var SheetViewXform = require('./sheet-view-xform');
18719
18720var SheetProtectionXform = require('./sheet-protection-xform');
18721
18722var PageMarginsXform = require('./page-margins-xform');
18723
18724var PageSetupXform = require('./page-setup-xform');
18725
18726var PrintOptionsXform = require('./print-options-xform');
18727
18728var AutoFilterXform = require('./auto-filter-xform');
18729
18730var PictureXform = require('./picture-xform');
18731
18732var DrawingXform = require('./drawing-xform');
18733
18734var TablePartXform = require('./table-part-xform');
18735
18736var RowBreaksXform = require('./row-breaks-xform');
18737
18738var HeaderFooterXform = require('./header-footer-xform');
18739
18740var ConditionalFormattingsXform = require('./cf/conditional-formattings-xform');
18741
18742var ExtListXform = require('./ext-lst-xform');
18743
18744var mergeRule = function mergeRule(rule, extRule) {
18745  Object.keys(extRule).forEach(function (key) {
18746    var value = rule[key];
18747    var extValue = extRule[key];
18748
18749    if (value === undefined && extValue !== undefined) {
18750      rule[key] = extValue;
18751    }
18752  });
18753};
18754
18755var mergeConditionalFormattings = function mergeConditionalFormattings(model, extModel) {
18756  // conditional formattings are rendered in worksheet.conditionalFormatting and also in
18757  // worksheet.extLst.ext.x14:conditionalFormattings
18758  // some (e.g. dataBar) are even spread across both!
18759  if (!extModel || !extModel.length) {
18760    return model;
18761  }
18762
18763  if (!model || !model.length) {
18764    return extModel;
18765  } // index model rules by x14Id
18766
18767
18768  var cfMap = {};
18769  var ruleMap = {};
18770  model.forEach(function (cf) {
18771    cfMap[cf.ref] = cf;
18772    cf.rules.forEach(function (rule) {
18773      var x14Id = rule.x14Id;
18774
18775      if (x14Id) {
18776        ruleMap[x14Id] = rule;
18777      }
18778    });
18779  });
18780  extModel.forEach(function (extCf) {
18781    extCf.rules.forEach(function (extRule) {
18782      var rule = ruleMap[extRule.x14Id];
18783
18784      if (rule) {
18785        // merge with matching rule
18786        mergeRule(rule, extRule);
18787      } else if (cfMap[extCf.ref]) {
18788        // reuse existing cf ref
18789        cfMap[extCf.ref].rules.push(extRule);
18790      } else {
18791        // create new cf
18792        model.push({
18793          ref: extCf.ref,
18794          rules: [extRule]
18795        });
18796      }
18797    });
18798  }); // need to cope with rules in extModel that don't exist in model
18799
18800  return model;
18801};
18802
18803var WorkSheetXform = /*#__PURE__*/function (_BaseXform) {
18804  _inherits(WorkSheetXform, _BaseXform);
18805
18806  var _super = _createSuper(WorkSheetXform);
18807
18808  function WorkSheetXform(options) {
18809    var _this;
18810
18811    _classCallCheck(this, WorkSheetXform);
18812
18813    _this = _super.call(this);
18814
18815    var _ref = options || {},
18816        maxRows = _ref.maxRows,
18817        maxCols = _ref.maxCols;
18818
18819    _this.map = {
18820      sheetPr: new SheetPropertiesXform(),
18821      dimension: new DimensionXform(),
18822      sheetViews: new ListXform({
18823        tag: 'sheetViews',
18824        count: false,
18825        childXform: new SheetViewXform()
18826      }),
18827      sheetFormatPr: new SheetFormatPropertiesXform(),
18828      cols: new ListXform({
18829        tag: 'cols',
18830        count: false,
18831        childXform: new ColXform()
18832      }),
18833      sheetData: new ListXform({
18834        tag: 'sheetData',
18835        count: false,
18836        empty: true,
18837        childXform: new RowXform({
18838          maxItems: maxCols
18839        }),
18840        maxItems: maxRows
18841      }),
18842      autoFilter: new AutoFilterXform(),
18843      mergeCells: new ListXform({
18844        tag: 'mergeCells',
18845        count: true,
18846        childXform: new MergeCellXform()
18847      }),
18848      rowBreaks: new RowBreaksXform(),
18849      hyperlinks: new ListXform({
18850        tag: 'hyperlinks',
18851        count: false,
18852        childXform: new HyperlinkXform()
18853      }),
18854      pageMargins: new PageMarginsXform(),
18855      dataValidations: new DataValidationsXform(),
18856      pageSetup: new PageSetupXform(),
18857      headerFooter: new HeaderFooterXform(),
18858      printOptions: new PrintOptionsXform(),
18859      picture: new PictureXform(),
18860      drawing: new DrawingXform(),
18861      sheetProtection: new SheetProtectionXform(),
18862      tableParts: new ListXform({
18863        tag: 'tableParts',
18864        count: true,
18865        childXform: new TablePartXform()
18866      }),
18867      conditionalFormatting: new ConditionalFormattingsXform(),
18868      extLst: new ExtListXform()
18869    };
18870    return _this;
18871  }
18872
18873  _createClass(WorkSheetXform, [{
18874    key: "prepare",
18875    value: function prepare(model, options) {
18876      var _this2 = this;
18877
18878      options.merges = new Merges();
18879      model.hyperlinks = options.hyperlinks = [];
18880      model.comments = options.comments = [];
18881      options.formulae = {};
18882      options.siFormulae = 0;
18883      this.map.cols.prepare(model.cols, options);
18884      this.map.sheetData.prepare(model.rows, options);
18885      this.map.conditionalFormatting.prepare(model.conditionalFormattings, options);
18886      model.mergeCells = options.merges.mergeCells; // prepare relationships
18887
18888      var rels = model.rels = [];
18889
18890      function nextRid(r) {
18891        return "rId".concat(r.length + 1);
18892      }
18893
18894      model.hyperlinks.forEach(function (hyperlink) {
18895        var rId = nextRid(rels);
18896        hyperlink.rId = rId;
18897        rels.push({
18898          Id: rId,
18899          Type: RelType.Hyperlink,
18900          Target: hyperlink.target,
18901          TargetMode: 'External'
18902        });
18903      }); // prepare comment relationships
18904
18905      if (model.comments.length > 0) {
18906        var comment = {
18907          Id: nextRid(rels),
18908          Type: RelType.Comments,
18909          Target: "../comments".concat(model.id, ".xml")
18910        };
18911        rels.push(comment);
18912        var vmlDrawing = {
18913          Id: nextRid(rels),
18914          Type: RelType.VmlDrawing,
18915          Target: "../drawings/vmlDrawing".concat(model.id, ".vml")
18916        };
18917        rels.push(vmlDrawing);
18918        model.comments.forEach(function (item) {
18919          item.refAddress = colCache.decodeAddress(item.ref);
18920        });
18921        options.commentRefs.push({
18922          commentName: "comments".concat(model.id),
18923          vmlDrawing: "vmlDrawing".concat(model.id)
18924        });
18925      }
18926
18927      var drawingRelsHash = [];
18928      var bookImage;
18929      model.media.forEach(function (medium) {
18930        if (medium.type === 'background') {
18931          var rId = nextRid(rels);
18932          bookImage = options.media[medium.imageId];
18933          rels.push({
18934            Id: rId,
18935            Type: RelType.Image,
18936            Target: "../media/".concat(bookImage.name, ".").concat(bookImage.extension)
18937          });
18938          model.background = {
18939            rId: rId
18940          };
18941          model.image = options.media[medium.imageId];
18942        } else if (medium.type === 'image') {
18943          var drawing = model.drawing;
18944          bookImage = options.media[medium.imageId];
18945
18946          if (!drawing) {
18947            drawing = model.drawing = {
18948              rId: nextRid(rels),
18949              name: "drawing".concat(++options.drawingsCount),
18950              anchors: [],
18951              rels: []
18952            };
18953            options.drawings.push(drawing);
18954            rels.push({
18955              Id: drawing.rId,
18956              Type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing',
18957              Target: "../drawings/".concat(drawing.name, ".xml")
18958            });
18959          }
18960
18961          var rIdImage = _this2.preImageId === medium.imageId ? drawingRelsHash[medium.imageId] : drawingRelsHash[drawing.rels.length];
18962
18963          if (!rIdImage) {
18964            rIdImage = nextRid(drawing.rels);
18965            drawingRelsHash[drawing.rels.length] = rIdImage;
18966            drawing.rels.push({
18967              Id: rIdImage,
18968              Type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
18969              Target: "../media/".concat(bookImage.name, ".").concat(bookImage.extension)
18970            });
18971          }
18972
18973          var anchor = {
18974            picture: {
18975              rId: rIdImage
18976            },
18977            range: medium.range
18978          };
18979
18980          if (medium.hyperlinks && medium.hyperlinks.hyperlink) {
18981            var rIdHyperLink = nextRid(drawing.rels);
18982            drawingRelsHash[drawing.rels.length] = rIdHyperLink;
18983            anchor.picture.hyperlinks = {
18984              tooltip: medium.hyperlinks.tooltip,
18985              rId: rIdHyperLink
18986            };
18987            drawing.rels.push({
18988              Id: rIdHyperLink,
18989              Type: RelType.Hyperlink,
18990              Target: medium.hyperlinks.hyperlink,
18991              TargetMode: 'External'
18992            });
18993          }
18994
18995          _this2.preImageId = medium.imageId;
18996          drawing.anchors.push(anchor);
18997        }
18998      }); // prepare tables
18999
19000      model.tables.forEach(function (table) {
19001        // relationships
19002        var rId = nextRid(rels);
19003        table.rId = rId;
19004        rels.push({
19005          Id: rId,
19006          Type: RelType.Table,
19007          Target: "../tables/".concat(table.target)
19008        }); // dynamic styles
19009
19010        table.columns.forEach(function (column) {
19011          var style = column.style;
19012
19013          if (style) {
19014            column.dxfId = options.styles.addDxfStyle(style);
19015          }
19016        });
19017      }); // prepare ext items
19018
19019      this.map.extLst.prepare(model, options);
19020    }
19021  }, {
19022    key: "render",
19023    value: function render(xmlStream, model) {
19024      xmlStream.openXml(XmlStream.StdDocAttributes);
19025      xmlStream.openNode('worksheet', WorkSheetXform.WORKSHEET_ATTRIBUTES);
19026      var sheetFormatPropertiesModel = model.properties ? {
19027        defaultRowHeight: model.properties.defaultRowHeight,
19028        dyDescent: model.properties.dyDescent,
19029        outlineLevelCol: model.properties.outlineLevelCol,
19030        outlineLevelRow: model.properties.outlineLevelRow
19031      } : undefined;
19032
19033      if (model.properties && model.properties.defaultColWidth) {
19034        sheetFormatPropertiesModel.defaultColWidth = model.properties.defaultColWidth;
19035      }
19036
19037      var sheetPropertiesModel = {
19038        outlineProperties: model.properties && model.properties.outlineProperties,
19039        tabColor: model.properties && model.properties.tabColor,
19040        pageSetup: model.pageSetup && model.pageSetup.fitToPage ? {
19041          fitToPage: model.pageSetup.fitToPage
19042        } : undefined
19043      };
19044      var pageMarginsModel = model.pageSetup && model.pageSetup.margins;
19045      var printOptionsModel = {
19046        showRowColHeaders: model.pageSetup && model.pageSetup.showRowColHeaders,
19047        showGridLines: model.pageSetup && model.pageSetup.showGridLines,
19048        horizontalCentered: model.pageSetup && model.pageSetup.horizontalCentered,
19049        verticalCentered: model.pageSetup && model.pageSetup.verticalCentered
19050      };
19051      var sheetProtectionModel = model.sheetProtection;
19052      this.map.sheetPr.render(xmlStream, sheetPropertiesModel);
19053      this.map.dimension.render(xmlStream, model.dimensions);
19054      this.map.sheetViews.render(xmlStream, model.views);
19055      this.map.sheetFormatPr.render(xmlStream, sheetFormatPropertiesModel);
19056      this.map.cols.render(xmlStream, model.cols);
19057      this.map.sheetData.render(xmlStream, model.rows);
19058      this.map.sheetProtection.render(xmlStream, sheetProtectionModel); // Note: must be after sheetData and before autoFilter
19059
19060      this.map.autoFilter.render(xmlStream, model.autoFilter);
19061      this.map.mergeCells.render(xmlStream, model.mergeCells);
19062      this.map.conditionalFormatting.render(xmlStream, model.conditionalFormattings); // Note: must be before dataValidations
19063
19064      this.map.dataValidations.render(xmlStream, model.dataValidations); // For some reason hyperlinks have to be after the data validations
19065
19066      this.map.hyperlinks.render(xmlStream, model.hyperlinks);
19067      this.map.printOptions.render(xmlStream, printOptionsModel); // Note: must be before pageMargins
19068
19069      this.map.pageMargins.render(xmlStream, pageMarginsModel);
19070      this.map.pageSetup.render(xmlStream, model.pageSetup);
19071      this.map.headerFooter.render(xmlStream, model.headerFooter);
19072      this.map.rowBreaks.render(xmlStream, model.rowBreaks);
19073      this.map.drawing.render(xmlStream, model.drawing); // Note: must be after rowBreaks
19074
19075      this.map.picture.render(xmlStream, model.background); // Note: must be after drawing
19076
19077      this.map.tableParts.render(xmlStream, model.tables);
19078      this.map.extLst.render(xmlStream, model);
19079
19080      if (model.rels) {
19081        // add a <legacyDrawing /> node for each comment
19082        model.rels.forEach(function (rel) {
19083          if (rel.Type === RelType.VmlDrawing) {
19084            xmlStream.leafNode('legacyDrawing', {
19085              'r:id': rel.Id
19086            });
19087          }
19088        });
19089      }
19090
19091      xmlStream.closeNode();
19092    }
19093  }, {
19094    key: "parseOpen",
19095    value: function parseOpen(node) {
19096      if (this.parser) {
19097        this.parser.parseOpen(node);
19098        return true;
19099      }
19100
19101      if (node.name === 'worksheet') {
19102        _.each(this.map, function (xform) {
19103          xform.reset();
19104        });
19105
19106        return true;
19107      }
19108
19109      this.parser = this.map[node.name];
19110
19111      if (this.parser) {
19112        this.parser.parseOpen(node);
19113      }
19114
19115      return true;
19116    }
19117  }, {
19118    key: "parseText",
19119    value: function parseText(text) {
19120      if (this.parser) {
19121        this.parser.parseText(text);
19122      }
19123    }
19124  }, {
19125    key: "parseClose",
19126    value: function parseClose(name) {
19127      if (this.parser) {
19128        if (!this.parser.parseClose(name)) {
19129          this.parser = undefined;
19130        }
19131
19132        return true;
19133      }
19134
19135      switch (name) {
19136        case 'worksheet':
19137          {
19138            var properties = this.map.sheetFormatPr.model || {};
19139
19140            if (this.map.sheetPr.model && this.map.sheetPr.model.tabColor) {
19141              properties.tabColor = this.map.sheetPr.model.tabColor;
19142            }
19143
19144            if (this.map.sheetPr.model && this.map.sheetPr.model.outlineProperties) {
19145              properties.outlineProperties = this.map.sheetPr.model.outlineProperties;
19146            }
19147
19148            var sheetProperties = {
19149              fitToPage: this.map.sheetPr.model && this.map.sheetPr.model.pageSetup && this.map.sheetPr.model.pageSetup.fitToPage || false,
19150              margins: this.map.pageMargins.model
19151            };
19152            var pageSetup = Object.assign(sheetProperties, this.map.pageSetup.model, this.map.printOptions.model);
19153            var conditionalFormattings = mergeConditionalFormattings(this.map.conditionalFormatting.model, this.map.extLst.model && this.map.extLst.model['x14:conditionalFormattings']);
19154            this.model = {
19155              dimensions: this.map.dimension.model,
19156              cols: this.map.cols.model,
19157              rows: this.map.sheetData.model,
19158              mergeCells: this.map.mergeCells.model,
19159              hyperlinks: this.map.hyperlinks.model,
19160              dataValidations: this.map.dataValidations.model,
19161              properties: properties,
19162              views: this.map.sheetViews.model,
19163              pageSetup: pageSetup,
19164              headerFooter: this.map.headerFooter.model,
19165              background: this.map.picture.model,
19166              drawing: this.map.drawing.model,
19167              tables: this.map.tableParts.model,
19168              conditionalFormattings: conditionalFormattings
19169            };
19170
19171            if (this.map.autoFilter.model) {
19172              this.model.autoFilter = this.map.autoFilter.model;
19173            }
19174
19175            if (this.map.sheetProtection.model) {
19176              this.model.sheetProtection = this.map.sheetProtection.model;
19177            }
19178
19179            return false;
19180          }
19181
19182        default:
19183          // not quite sure how we get here!
19184          return true;
19185      }
19186    }
19187  }, {
19188    key: "reconcile",
19189    value: function reconcile(model, options) {
19190      // options.merges = new Merges();
19191      // options.merges.reconcile(model.mergeCells, model.rows);
19192      var rels = (model.relationships || []).reduce(function (h, rel) {
19193        h[rel.Id] = rel;
19194
19195        if (rel.Type === RelType.Comments) {
19196          model.comments = options.comments[rel.Target].comments;
19197        }
19198
19199        if (rel.Type === RelType.VmlDrawing && model.comments && model.comments.length) {
19200          var vmlComment = options.vmlDrawings[rel.Target].comments;
19201          model.comments.forEach(function (comment, index) {
19202            comment.note = Object.assign({}, comment.note, vmlComment[index]);
19203          });
19204        }
19205
19206        return h;
19207      }, {});
19208      options.commentsMap = (model.comments || []).reduce(function (h, comment) {
19209        if (comment.ref) {
19210          h[comment.ref] = comment;
19211        }
19212
19213        return h;
19214      }, {});
19215      options.hyperlinkMap = (model.hyperlinks || []).reduce(function (h, hyperlink) {
19216        if (hyperlink.rId) {
19217          h[hyperlink.address] = rels[hyperlink.rId].Target;
19218        }
19219
19220        return h;
19221      }, {});
19222      options.formulae = {}; // compact the rows and cells
19223
19224      model.rows = model.rows && model.rows.filter(Boolean) || [];
19225      model.rows.forEach(function (row) {
19226        row.cells = row.cells && row.cells.filter(Boolean) || [];
19227      });
19228      this.map.cols.reconcile(model.cols, options);
19229      this.map.sheetData.reconcile(model.rows, options);
19230      this.map.conditionalFormatting.reconcile(model.conditionalFormattings, options);
19231      model.media = [];
19232
19233      if (model.drawing) {
19234        var drawingRel = rels[model.drawing.rId];
19235        var match = drawingRel.Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);
19236
19237        if (match) {
19238          var drawingName = match[1];
19239          var drawing = options.drawings[drawingName];
19240          drawing.anchors.forEach(function (anchor) {
19241            if (anchor.medium) {
19242              var image = {
19243                type: 'image',
19244                imageId: anchor.medium.index,
19245                range: anchor.range,
19246                hyperlinks: anchor.picture.hyperlinks
19247              };
19248              model.media.push(image);
19249            }
19250          });
19251        }
19252      }
19253
19254      var backgroundRel = model.background && rels[model.background.rId];
19255
19256      if (backgroundRel) {
19257        var target = backgroundRel.Target.split('/media/')[1];
19258        var imageId = options.mediaIndex && options.mediaIndex[target];
19259
19260        if (imageId !== undefined) {
19261          model.media.push({
19262            type: 'background',
19263            imageId: imageId
19264          });
19265        }
19266      }
19267
19268      model.tables = (model.tables || []).map(function (tablePart) {
19269        var rel = rels[tablePart.rId];
19270        return options.tables[rel.Target];
19271      });
19272      delete model.relationships;
19273      delete model.hyperlinks;
19274      delete model.comments;
19275    }
19276  }]);
19277
19278  return WorkSheetXform;
19279}(BaseXform);
19280
19281WorkSheetXform.WORKSHEET_ATTRIBUTES = {
19282  xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
19283  'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
19284  'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
19285  'mc:Ignorable': 'x14ac',
19286  'xmlns:x14ac': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'
19287};
19288module.exports = WorkSheetXform;
19289
19290},{"../../../utils/col-cache":19,"../../../utils/under-dash":25,"../../../utils/xml-stream":27,"../../rel-type":30,"../base-xform":31,"../list-xform":70,"./auto-filter-xform":71,"./cf/conditional-formattings-xform":86,"./col-xform":91,"./data-validations-xform":92,"./dimension-xform":93,"./drawing-xform":94,"./ext-lst-xform":95,"./header-footer-xform":96,"./hyperlink-xform":97,"./merge-cell-xform":98,"./merges":99,"./page-margins-xform":102,"./page-setup-xform":104,"./picture-xform":105,"./print-options-xform":106,"./row-breaks-xform":107,"./row-xform":108,"./sheet-format-properties-xform":109,"./sheet-properties-xform":110,"./sheet-protection-xform":111,"./sheet-view-xform":112,"./table-part-xform":113}],115:[function(require,module,exports){
19291"use strict";
19292
19293function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19294
19295function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19296
19297function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19298
19299function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19300
19301function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
19302
19303function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19304
19305function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19306
19307function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
19308
19309function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19310
19311function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19312
19313function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19314
19315var BaseXform = require('../base-xform');
19316
19317var BooleanXform = /*#__PURE__*/function (_BaseXform) {
19318  _inherits(BooleanXform, _BaseXform);
19319
19320  var _super = _createSuper(BooleanXform);
19321
19322  function BooleanXform(options) {
19323    var _this;
19324
19325    _classCallCheck(this, BooleanXform);
19326
19327    _this = _super.call(this);
19328    _this.tag = options.tag;
19329    _this.attr = options.attr;
19330    return _this;
19331  }
19332
19333  _createClass(BooleanXform, [{
19334    key: "render",
19335    value: function render(xmlStream, model) {
19336      if (model) {
19337        xmlStream.openNode(this.tag);
19338        xmlStream.closeNode();
19339      }
19340    }
19341  }, {
19342    key: "parseOpen",
19343    value: function parseOpen(node) {
19344      if (node.name === this.tag) {
19345        this.model = true;
19346      }
19347    }
19348  }, {
19349    key: "parseText",
19350    value: function parseText() {}
19351  }, {
19352    key: "parseClose",
19353    value: function parseClose() {
19354      return false;
19355    }
19356  }]);
19357
19358  return BooleanXform;
19359}(BaseXform);
19360
19361module.exports = BooleanXform;
19362
19363},{"../base-xform":31}],116:[function(require,module,exports){
19364"use strict";
19365
19366function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19367
19368function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19369
19370function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19371
19372function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19373
19374function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
19375
19376function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19377
19378function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19379
19380function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
19381
19382function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19383
19384function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19385
19386function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19387
19388var BaseXform = require('../base-xform');
19389
19390var DateXform = /*#__PURE__*/function (_BaseXform) {
19391  _inherits(DateXform, _BaseXform);
19392
19393  var _super = _createSuper(DateXform);
19394
19395  function DateXform(options) {
19396    var _this;
19397
19398    _classCallCheck(this, DateXform);
19399
19400    _this = _super.call(this);
19401    _this.tag = options.tag;
19402    _this.attr = options.attr;
19403    _this.attrs = options.attrs;
19404
19405    _this._format = options.format || function (dt) {
19406      try {
19407        if (Number.isNaN(dt.getTime())) return '';
19408        return dt.toISOString();
19409      } catch (e) {
19410        return '';
19411      }
19412    };
19413
19414    _this._parse = options.parse || function (str) {
19415      return new Date(str);
19416    };
19417
19418    return _this;
19419  }
19420
19421  _createClass(DateXform, [{
19422    key: "render",
19423    value: function render(xmlStream, model) {
19424      if (model) {
19425        xmlStream.openNode(this.tag);
19426
19427        if (this.attrs) {
19428          xmlStream.addAttributes(this.attrs);
19429        }
19430
19431        if (this.attr) {
19432          xmlStream.addAttribute(this.attr, this._format(model));
19433        } else {
19434          xmlStream.writeText(this._format(model));
19435        }
19436
19437        xmlStream.closeNode();
19438      }
19439    }
19440  }, {
19441    key: "parseOpen",
19442    value: function parseOpen(node) {
19443      if (node.name === this.tag) {
19444        if (this.attr) {
19445          this.model = this._parse(node.attributes[this.attr]);
19446        } else {
19447          this.text = [];
19448        }
19449      }
19450    }
19451  }, {
19452    key: "parseText",
19453    value: function parseText(text) {
19454      if (!this.attr) {
19455        this.text.push(text);
19456      }
19457    }
19458  }, {
19459    key: "parseClose",
19460    value: function parseClose() {
19461      if (!this.attr) {
19462        this.model = this._parse(this.text.join(''));
19463      }
19464
19465      return false;
19466    }
19467  }]);
19468
19469  return DateXform;
19470}(BaseXform);
19471
19472module.exports = DateXform;
19473
19474},{"../base-xform":31}],117:[function(require,module,exports){
19475"use strict";
19476
19477function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19478
19479function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19480
19481function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19482
19483function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19484
19485function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
19486
19487function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19488
19489function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19490
19491function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
19492
19493function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19494
19495function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19496
19497function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19498
19499var BaseXform = require('../base-xform');
19500
19501var IntegerXform = /*#__PURE__*/function (_BaseXform) {
19502  _inherits(IntegerXform, _BaseXform);
19503
19504  var _super = _createSuper(IntegerXform);
19505
19506  function IntegerXform(options) {
19507    var _this;
19508
19509    _classCallCheck(this, IntegerXform);
19510
19511    _this = _super.call(this);
19512    _this.tag = options.tag;
19513    _this.attr = options.attr;
19514    _this.attrs = options.attrs; // option to render zero
19515
19516    _this.zero = options.zero;
19517    return _this;
19518  }
19519
19520  _createClass(IntegerXform, [{
19521    key: "render",
19522    value: function render(xmlStream, model) {
19523      // int is different to float in that zero is not rendered
19524      if (model || this.zero) {
19525        xmlStream.openNode(this.tag);
19526
19527        if (this.attrs) {
19528          xmlStream.addAttributes(this.attrs);
19529        }
19530
19531        if (this.attr) {
19532          xmlStream.addAttribute(this.attr, model);
19533        } else {
19534          xmlStream.writeText(model);
19535        }
19536
19537        xmlStream.closeNode();
19538      }
19539    }
19540  }, {
19541    key: "parseOpen",
19542    value: function parseOpen(node) {
19543      if (node.name === this.tag) {
19544        if (this.attr) {
19545          this.model = parseInt(node.attributes[this.attr], 10);
19546        } else {
19547          this.text = [];
19548        }
19549
19550        return true;
19551      }
19552
19553      return false;
19554    }
19555  }, {
19556    key: "parseText",
19557    value: function parseText(text) {
19558      if (!this.attr) {
19559        this.text.push(text);
19560      }
19561    }
19562  }, {
19563    key: "parseClose",
19564    value: function parseClose() {
19565      if (!this.attr) {
19566        this.model = parseInt(this.text.join('') || 0, 10);
19567      }
19568
19569      return false;
19570    }
19571  }]);
19572
19573  return IntegerXform;
19574}(BaseXform);
19575
19576module.exports = IntegerXform;
19577
19578},{"../base-xform":31}],118:[function(require,module,exports){
19579"use strict";
19580
19581function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19582
19583function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19584
19585function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19586
19587function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19588
19589function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
19590
19591function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19592
19593function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19594
19595function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
19596
19597function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19598
19599function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19600
19601function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19602
19603var BaseXform = require('../base-xform');
19604
19605var StringXform = /*#__PURE__*/function (_BaseXform) {
19606  _inherits(StringXform, _BaseXform);
19607
19608  var _super = _createSuper(StringXform);
19609
19610  function StringXform(options) {
19611    var _this;
19612
19613    _classCallCheck(this, StringXform);
19614
19615    _this = _super.call(this);
19616    _this.tag = options.tag;
19617    _this.attr = options.attr;
19618    _this.attrs = options.attrs;
19619    return _this;
19620  }
19621
19622  _createClass(StringXform, [{
19623    key: "render",
19624    value: function render(xmlStream, model) {
19625      if (model !== undefined) {
19626        xmlStream.openNode(this.tag);
19627
19628        if (this.attrs) {
19629          xmlStream.addAttributes(this.attrs);
19630        }
19631
19632        if (this.attr) {
19633          xmlStream.addAttribute(this.attr, model);
19634        } else {
19635          xmlStream.writeText(model);
19636        }
19637
19638        xmlStream.closeNode();
19639      }
19640    }
19641  }, {
19642    key: "parseOpen",
19643    value: function parseOpen(node) {
19644      if (node.name === this.tag) {
19645        if (this.attr) {
19646          this.model = node.attributes[this.attr];
19647        } else {
19648          this.text = [];
19649        }
19650      }
19651    }
19652  }, {
19653    key: "parseText",
19654    value: function parseText(text) {
19655      if (!this.attr) {
19656        this.text.push(text);
19657      }
19658    }
19659  }, {
19660    key: "parseClose",
19661    value: function parseClose() {
19662      if (!this.attr) {
19663        this.model = this.text.join('');
19664      }
19665
19666      return false;
19667    }
19668  }]);
19669
19670  return StringXform;
19671}(BaseXform);
19672
19673module.exports = StringXform;
19674
19675},{"../base-xform":31}],119:[function(require,module,exports){
19676"use strict";
19677
19678function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19679
19680function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19681
19682function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19683
19684function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19685
19686function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
19687
19688function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19689
19690function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19691
19692function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
19693
19694function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19695
19696function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19697
19698function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19699
19700var BaseXform = require('./base-xform');
19701
19702var XmlStream = require('../../utils/xml-stream'); // const model = {
19703//   tag: 'name',
19704//   $: {attr: 'value'},
19705//   c: [
19706//     { tag: 'child' }
19707//   ],
19708//   t: 'some text'
19709// };
19710
19711
19712function build(xmlStream, model) {
19713  xmlStream.openNode(model.tag, model.$);
19714
19715  if (model.c) {
19716    model.c.forEach(function (child) {
19717      build(xmlStream, child);
19718    });
19719  }
19720
19721  if (model.t) {
19722    xmlStream.writeText(model.t);
19723  }
19724
19725  xmlStream.closeNode();
19726}
19727
19728var StaticXform = /*#__PURE__*/function (_BaseXform) {
19729  _inherits(StaticXform, _BaseXform);
19730
19731  var _super = _createSuper(StaticXform);
19732
19733  function StaticXform(model) {
19734    var _this;
19735
19736    _classCallCheck(this, StaticXform);
19737
19738    _this = _super.call(this); // This class is an optimisation for static (unimportant and unchanging) xml
19739    // It is stateless - apart from its static model and so can be used as a singleton
19740    // Being stateless - it will only track entry to and exit from it's root xml tag during parsing and nothing else
19741    // Known issues:
19742    //    since stateless - parseOpen always returns true. Parent xform must know when to start using this xform
19743    //    if the root tag is recursive, the parsing will behave unpredictably
19744
19745    _this._model = model;
19746    return _this;
19747  }
19748
19749  _createClass(StaticXform, [{
19750    key: "render",
19751    value: function render(xmlStream) {
19752      if (!this._xml) {
19753        var stream = new XmlStream();
19754        build(stream, this._model);
19755        this._xml = stream.xml;
19756      }
19757
19758      xmlStream.writeXml(this._xml);
19759    }
19760  }, {
19761    key: "parseOpen",
19762    value: function parseOpen() {
19763      return true;
19764    }
19765  }, {
19766    key: "parseText",
19767    value: function parseText() {}
19768  }, {
19769    key: "parseClose",
19770    value: function parseClose(name) {
19771      switch (name) {
19772        case this._model.tag:
19773          return false;
19774
19775        default:
19776          return true;
19777      }
19778    }
19779  }]);
19780
19781  return StaticXform;
19782}(BaseXform);
19783
19784module.exports = StaticXform;
19785
19786},{"../../utils/xml-stream":27,"./base-xform":31}],120:[function(require,module,exports){
19787"use strict";
19788
19789function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19790
19791function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19792
19793function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19794
19795function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19796
19797function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
19798
19799function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19800
19801function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19802
19803function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
19804
19805function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19806
19807function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19808
19809function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19810
19811var TextXform = require('./text-xform');
19812
19813var RichTextXform = require('./rich-text-xform');
19814
19815var BaseXform = require('../base-xform'); // <rPh sb="0" eb="1">
19816//   <t>(its pronounciation in KATAKANA)</t>
19817// </rPh>
19818
19819
19820var PhoneticTextXform = /*#__PURE__*/function (_BaseXform) {
19821  _inherits(PhoneticTextXform, _BaseXform);
19822
19823  var _super = _createSuper(PhoneticTextXform);
19824
19825  function PhoneticTextXform() {
19826    var _this;
19827
19828    _classCallCheck(this, PhoneticTextXform);
19829
19830    _this = _super.call(this);
19831    _this.map = {
19832      r: new RichTextXform(),
19833      t: new TextXform()
19834    };
19835    return _this;
19836  }
19837
19838  _createClass(PhoneticTextXform, [{
19839    key: "render",
19840    value: function render(xmlStream, model) {
19841      xmlStream.openNode(this.tag, {
19842        sb: model.sb || 0,
19843        eb: model.eb || 0
19844      });
19845
19846      if (model && model.hasOwnProperty('richText') && model.richText) {
19847        var r = this.map.r;
19848        model.richText.forEach(function (text) {
19849          r.render(xmlStream, text);
19850        });
19851      } else if (model) {
19852        this.map.t.render(xmlStream, model.text);
19853      }
19854
19855      xmlStream.closeNode();
19856    }
19857  }, {
19858    key: "parseOpen",
19859    value: function parseOpen(node) {
19860      var name = node.name;
19861
19862      if (this.parser) {
19863        this.parser.parseOpen(node);
19864        return true;
19865      }
19866
19867      if (name === this.tag) {
19868        this.model = {
19869          sb: parseInt(node.attributes.sb, 10),
19870          eb: parseInt(node.attributes.eb, 10)
19871        };
19872        return true;
19873      }
19874
19875      this.parser = this.map[name];
19876
19877      if (this.parser) {
19878        this.parser.parseOpen(node);
19879        return true;
19880      }
19881
19882      return false;
19883    }
19884  }, {
19885    key: "parseText",
19886    value: function parseText(text) {
19887      if (this.parser) {
19888        this.parser.parseText(text);
19889      }
19890    }
19891  }, {
19892    key: "parseClose",
19893    value: function parseClose(name) {
19894      if (this.parser) {
19895        if (!this.parser.parseClose(name)) {
19896          switch (name) {
19897            case 'r':
19898              {
19899                var rt = this.model.richText;
19900
19901                if (!rt) {
19902                  rt = this.model.richText = [];
19903                }
19904
19905                rt.push(this.parser.model);
19906                break;
19907              }
19908
19909            case 't':
19910              this.model.text = this.parser.model;
19911              break;
19912
19913            default:
19914              break;
19915          }
19916
19917          this.parser = undefined;
19918        }
19919
19920        return true;
19921      }
19922
19923      switch (name) {
19924        case this.tag:
19925          return false;
19926
19927        default:
19928          return true;
19929      }
19930    }
19931  }, {
19932    key: "tag",
19933    get: function get() {
19934      return 'rPh';
19935    }
19936  }]);
19937
19938  return PhoneticTextXform;
19939}(BaseXform);
19940
19941module.exports = PhoneticTextXform;
19942
19943},{"../base-xform":31,"./rich-text-xform":121,"./text-xform":124}],121:[function(require,module,exports){
19944"use strict";
19945
19946function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19947
19948function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19949
19950function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19951
19952function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19953
19954function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
19955
19956function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19957
19958function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19959
19960function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
19961
19962function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19963
19964function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19965
19966function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19967
19968var TextXform = require('./text-xform');
19969
19970var FontXform = require('../style/font-xform');
19971
19972var BaseXform = require('../base-xform'); // <r>
19973//   <rPr>
19974//     <sz val="11"/>
19975//     <color theme="1" tint="5"/>
19976//     <rFont val="Calibri"/>
19977//     <family val="2"/>
19978//     <scheme val="minor"/>
19979//   </rPr>
19980//   <t xml:space="preserve"> is </t>
19981// </r>
19982
19983
19984var RichTextXform = /*#__PURE__*/function (_BaseXform) {
19985  _inherits(RichTextXform, _BaseXform);
19986
19987  var _super = _createSuper(RichTextXform);
19988
19989  function RichTextXform(model) {
19990    var _this;
19991
19992    _classCallCheck(this, RichTextXform);
19993
19994    _this = _super.call(this);
19995    _this.model = model;
19996    return _this;
19997  }
19998
19999  _createClass(RichTextXform, [{
20000    key: "render",
20001    value: function render(xmlStream, model) {
20002      model = model || this.model;
20003      xmlStream.openNode('r');
20004
20005      if (model.font) {
20006        this.fontXform.render(xmlStream, model.font);
20007      }
20008
20009      this.textXform.render(xmlStream, model.text);
20010      xmlStream.closeNode();
20011    }
20012  }, {
20013    key: "parseOpen",
20014    value: function parseOpen(node) {
20015      if (this.parser) {
20016        this.parser.parseOpen(node);
20017        return true;
20018      }
20019
20020      switch (node.name) {
20021        case 'r':
20022          this.model = {};
20023          return true;
20024
20025        case 't':
20026          this.parser = this.textXform;
20027          this.parser.parseOpen(node);
20028          return true;
20029
20030        case 'rPr':
20031          this.parser = this.fontXform;
20032          this.parser.parseOpen(node);
20033          return true;
20034
20035        default:
20036          return false;
20037      }
20038    }
20039  }, {
20040    key: "parseText",
20041    value: function parseText(text) {
20042      if (this.parser) {
20043        this.parser.parseText(text);
20044      }
20045    }
20046  }, {
20047    key: "parseClose",
20048    value: function parseClose(name) {
20049      switch (name) {
20050        case 'r':
20051          return false;
20052
20053        case 't':
20054          this.model.text = this.parser.model;
20055          this.parser = undefined;
20056          return true;
20057
20058        case 'rPr':
20059          this.model.font = this.parser.model;
20060          this.parser = undefined;
20061          return true;
20062
20063        default:
20064          if (this.parser) {
20065            this.parser.parseClose(name);
20066          }
20067
20068          return true;
20069      }
20070    }
20071  }, {
20072    key: "tag",
20073    get: function get() {
20074      return 'r';
20075    }
20076  }, {
20077    key: "textXform",
20078    get: function get() {
20079      return this._textXform || (this._textXform = new TextXform());
20080    }
20081  }, {
20082    key: "fontXform",
20083    get: function get() {
20084      return this._fontXform || (this._fontXform = new FontXform(RichTextXform.FONT_OPTIONS));
20085    }
20086  }]);
20087
20088  return RichTextXform;
20089}(BaseXform);
20090
20091RichTextXform.FONT_OPTIONS = {
20092  tagName: 'rPr',
20093  fontNameTag: 'rFont'
20094};
20095module.exports = RichTextXform;
20096
20097},{"../base-xform":31,"../style/font-xform":130,"./text-xform":124}],122:[function(require,module,exports){
20098"use strict";
20099
20100function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
20101
20102function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20103
20104function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
20105
20106function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
20107
20108function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
20109
20110function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20111
20112function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20113
20114function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
20115
20116function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20117
20118function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20119
20120function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20121
20122var TextXform = require('./text-xform');
20123
20124var RichTextXform = require('./rich-text-xform');
20125
20126var PhoneticTextXform = require('./phonetic-text-xform');
20127
20128var BaseXform = require('../base-xform'); // <si>
20129//   <r></r><r></r>...
20130// </si>
20131// <si>
20132//   <t></t>
20133// </si>
20134
20135
20136var SharedStringXform = /*#__PURE__*/function (_BaseXform) {
20137  _inherits(SharedStringXform, _BaseXform);
20138
20139  var _super = _createSuper(SharedStringXform);
20140
20141  function SharedStringXform(model) {
20142    var _this;
20143
20144    _classCallCheck(this, SharedStringXform);
20145
20146    _this = _super.call(this);
20147    _this.model = model;
20148    _this.map = {
20149      r: new RichTextXform(),
20150      t: new TextXform(),
20151      rPh: new PhoneticTextXform()
20152    };
20153    return _this;
20154  }
20155
20156  _createClass(SharedStringXform, [{
20157    key: "render",
20158    value: function render(xmlStream, model) {
20159      var _this2 = this;
20160
20161      xmlStream.openNode(this.tag);
20162
20163      if (model && model.hasOwnProperty('richText') && model.richText) {
20164        if (model.richText.length) {
20165          model.richText.forEach(function (text) {
20166            _this2.map.r.render(xmlStream, text);
20167          });
20168        } else {
20169          this.map.t.render(xmlStream, '');
20170        }
20171      } else if (model !== undefined && model !== null) {
20172        this.map.t.render(xmlStream, model);
20173      }
20174
20175      xmlStream.closeNode();
20176    }
20177  }, {
20178    key: "parseOpen",
20179    value: function parseOpen(node) {
20180      var name = node.name;
20181
20182      if (this.parser) {
20183        this.parser.parseOpen(node);
20184        return true;
20185      }
20186
20187      if (name === this.tag) {
20188        this.model = {};
20189        return true;
20190      }
20191
20192      this.parser = this.map[name];
20193
20194      if (this.parser) {
20195        this.parser.parseOpen(node);
20196        return true;
20197      }
20198
20199      return false;
20200    }
20201  }, {
20202    key: "parseText",
20203    value: function parseText(text) {
20204      if (this.parser) {
20205        this.parser.parseText(text);
20206      }
20207    }
20208  }, {
20209    key: "parseClose",
20210    value: function parseClose(name) {
20211      if (this.parser) {
20212        if (!this.parser.parseClose(name)) {
20213          switch (name) {
20214            case 'r':
20215              {
20216                var rt = this.model.richText;
20217
20218                if (!rt) {
20219                  rt = this.model.richText = [];
20220                }
20221
20222                rt.push(this.parser.model);
20223                break;
20224              }
20225
20226            case 't':
20227              this.model = this.parser.model;
20228              break;
20229
20230            default:
20231              break;
20232          }
20233
20234          this.parser = undefined;
20235        }
20236
20237        return true;
20238      }
20239
20240      switch (name) {
20241        case this.tag:
20242          return false;
20243
20244        default:
20245          return true;
20246      }
20247    }
20248  }, {
20249    key: "tag",
20250    get: function get() {
20251      return 'si';
20252    }
20253  }]);
20254
20255  return SharedStringXform;
20256}(BaseXform);
20257
20258module.exports = SharedStringXform;
20259
20260},{"../base-xform":31,"./phonetic-text-xform":120,"./rich-text-xform":121,"./text-xform":124}],123:[function(require,module,exports){
20261"use strict";
20262
20263function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
20264
20265function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20266
20267function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
20268
20269function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
20270
20271function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
20272
20273function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20274
20275function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20276
20277function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
20278
20279function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20280
20281function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20282
20283function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20284
20285var XmlStream = require('../../../utils/xml-stream');
20286
20287var BaseXform = require('../base-xform');
20288
20289var SharedStringXform = require('./shared-string-xform');
20290
20291var SharedStringsXform = /*#__PURE__*/function (_BaseXform) {
20292  _inherits(SharedStringsXform, _BaseXform);
20293
20294  var _super = _createSuper(SharedStringsXform);
20295
20296  function SharedStringsXform(model) {
20297    var _this;
20298
20299    _classCallCheck(this, SharedStringsXform);
20300
20301    _this = _super.call(this);
20302    _this.model = model || {
20303      values: [],
20304      count: 0
20305    };
20306    _this.hash = Object.create(null);
20307    _this.rich = Object.create(null);
20308    return _this;
20309  }
20310
20311  _createClass(SharedStringsXform, [{
20312    key: "getString",
20313    value: function getString(index) {
20314      return this.model.values[index];
20315    }
20316  }, {
20317    key: "add",
20318    value: function add(value) {
20319      return value.richText ? this.addRichText(value) : this.addText(value);
20320    }
20321  }, {
20322    key: "addText",
20323    value: function addText(value) {
20324      var index = this.hash[value];
20325
20326      if (index === undefined) {
20327        index = this.hash[value] = this.model.values.length;
20328        this.model.values.push(value);
20329      }
20330
20331      this.model.count++;
20332      return index;
20333    }
20334  }, {
20335    key: "addRichText",
20336    value: function addRichText(value) {
20337      // TODO: add WeakMap here
20338      var xml = this.sharedStringXform.toXml(value);
20339      var index = this.rich[xml];
20340
20341      if (index === undefined) {
20342        index = this.rich[xml] = this.model.values.length;
20343        this.model.values.push(value);
20344      }
20345
20346      this.model.count++;
20347      return index;
20348    } // <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
20349    // <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="<%=totalRefs%>" uniqueCount="<%=count%>">
20350    //   <si><t><%=text%></t></si>
20351    //   <si><r><rPr></rPr><t></t></r></si>
20352    // </sst>
20353
20354  }, {
20355    key: "render",
20356    value: function render(xmlStream, model) {
20357      model = model || this._values;
20358      xmlStream.openXml(XmlStream.StdDocAttributes);
20359      xmlStream.openNode('sst', {
20360        xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
20361        count: model.count,
20362        uniqueCount: model.values.length
20363      });
20364      var sx = this.sharedStringXform;
20365      model.values.forEach(function (sharedString) {
20366        sx.render(xmlStream, sharedString);
20367      });
20368      xmlStream.closeNode();
20369    }
20370  }, {
20371    key: "parseOpen",
20372    value: function parseOpen(node) {
20373      if (this.parser) {
20374        this.parser.parseOpen(node);
20375        return true;
20376      }
20377
20378      switch (node.name) {
20379        case 'sst':
20380          return true;
20381
20382        case 'si':
20383          this.parser = this.sharedStringXform;
20384          this.parser.parseOpen(node);
20385          return true;
20386
20387        default:
20388          throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(node)));
20389      }
20390    }
20391  }, {
20392    key: "parseText",
20393    value: function parseText(text) {
20394      if (this.parser) {
20395        this.parser.parseText(text);
20396      }
20397    }
20398  }, {
20399    key: "parseClose",
20400    value: function parseClose(name) {
20401      if (this.parser) {
20402        if (!this.parser.parseClose(name)) {
20403          this.model.values.push(this.parser.model);
20404          this.model.count++;
20405          this.parser = undefined;
20406        }
20407
20408        return true;
20409      }
20410
20411      switch (name) {
20412        case 'sst':
20413          return false;
20414
20415        default:
20416          throw new Error("Unexpected xml node in parseClose: ".concat(name));
20417      }
20418    }
20419  }, {
20420    key: "sharedStringXform",
20421    get: function get() {
20422      return this._sharedStringXform || (this._sharedStringXform = new SharedStringXform());
20423    }
20424  }, {
20425    key: "values",
20426    get: function get() {
20427      return this.model.values;
20428    }
20429  }, {
20430    key: "uniqueCount",
20431    get: function get() {
20432      return this.model.values.length;
20433    }
20434  }, {
20435    key: "count",
20436    get: function get() {
20437      return this.model.count;
20438    }
20439  }]);
20440
20441  return SharedStringsXform;
20442}(BaseXform);
20443
20444module.exports = SharedStringsXform;
20445
20446},{"../../../utils/xml-stream":27,"../base-xform":31,"./shared-string-xform":122}],124:[function(require,module,exports){
20447"use strict";
20448
20449function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
20450
20451function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20452
20453function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
20454
20455function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
20456
20457function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
20458
20459function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20460
20461function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20462
20463function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
20464
20465function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20466
20467function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20468
20469function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20470
20471var BaseXform = require('../base-xform'); //   <t xml:space="preserve"> is </t>
20472
20473
20474var TextXform = /*#__PURE__*/function (_BaseXform) {
20475  _inherits(TextXform, _BaseXform);
20476
20477  var _super = _createSuper(TextXform);
20478
20479  function TextXform() {
20480    _classCallCheck(this, TextXform);
20481
20482    return _super.apply(this, arguments);
20483  }
20484
20485  _createClass(TextXform, [{
20486    key: "render",
20487    value: function render(xmlStream, model) {
20488      xmlStream.openNode('t');
20489
20490      if (/^\s|\n|\s$/.test(model)) {
20491        xmlStream.addAttribute('xml:space', 'preserve');
20492      }
20493
20494      xmlStream.writeText(model);
20495      xmlStream.closeNode();
20496    }
20497  }, {
20498    key: "parseOpen",
20499    value: function parseOpen(node) {
20500      switch (node.name) {
20501        case 't':
20502          this._text = [];
20503          return true;
20504
20505        default:
20506          return false;
20507      }
20508    }
20509  }, {
20510    key: "parseText",
20511    value: function parseText(text) {
20512      this._text.push(text);
20513    }
20514  }, {
20515    key: "parseClose",
20516    value: function parseClose() {
20517      return false;
20518    }
20519  }, {
20520    key: "tag",
20521    get: function get() {
20522      return 't';
20523    }
20524  }, {
20525    key: "model",
20526    get: function get() {
20527      return this._text.join('').replace(/_x([0-9A-F]{4})_/g, function ($0, $1) {
20528        return String.fromCharCode(parseInt($1, 16));
20529      });
20530    }
20531  }]);
20532
20533  return TextXform;
20534}(BaseXform);
20535
20536module.exports = TextXform;
20537
20538},{"../base-xform":31}],125:[function(require,module,exports){
20539"use strict";
20540
20541function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
20542
20543function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20544
20545function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
20546
20547function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
20548
20549function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
20550
20551function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20552
20553function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20554
20555function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
20556
20557function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20558
20559function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20560
20561function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20562
20563var Enums = require('../../../doc/enums');
20564
20565var utils = require('../../../utils/utils');
20566
20567var BaseXform = require('../base-xform');
20568
20569var validation = {
20570  horizontalValues: ['left', 'center', 'right', 'fill', 'centerContinuous', 'distributed', 'justify'].reduce(function (p, v) {
20571    p[v] = true;
20572    return p;
20573  }, {}),
20574  horizontal: function horizontal(value) {
20575    return this.horizontalValues[value] ? value : undefined;
20576  },
20577  verticalValues: ['top', 'middle', 'bottom', 'distributed', 'justify'].reduce(function (p, v) {
20578    p[v] = true;
20579    return p;
20580  }, {}),
20581  vertical: function vertical(value) {
20582    if (value === 'middle') return 'center';
20583    return this.verticalValues[value] ? value : undefined;
20584  },
20585  wrapText: function wrapText(value) {
20586    return value ? true : undefined;
20587  },
20588  shrinkToFit: function shrinkToFit(value) {
20589    return value ? true : undefined;
20590  },
20591  textRotation: function textRotation(value) {
20592    switch (value) {
20593      case 'vertical':
20594        return value;
20595
20596      default:
20597        value = utils.validInt(value);
20598        return value >= -90 && value <= 90 ? value : undefined;
20599    }
20600  },
20601  indent: function indent(value) {
20602    value = utils.validInt(value);
20603    return Math.max(0, value);
20604  },
20605  readingOrder: function readingOrder(value) {
20606    switch (value) {
20607      case 'ltr':
20608        return Enums.ReadingOrder.LeftToRight;
20609
20610      case 'rtl':
20611        return Enums.ReadingOrder.RightToLeft;
20612
20613      default:
20614        return undefined;
20615    }
20616  }
20617};
20618var textRotationXform = {
20619  toXml: function toXml(textRotation) {
20620    textRotation = validation.textRotation(textRotation);
20621
20622    if (textRotation) {
20623      if (textRotation === 'vertical') {
20624        return 255;
20625      }
20626
20627      var tr = Math.round(textRotation);
20628
20629      if (tr >= 0 && tr <= 90) {
20630        return tr;
20631      }
20632
20633      if (tr < 0 && tr >= -90) {
20634        return 90 - tr;
20635      }
20636    }
20637
20638    return undefined;
20639  },
20640  toModel: function toModel(textRotation) {
20641    var tr = utils.validInt(textRotation);
20642
20643    if (tr !== undefined) {
20644      if (tr === 255) {
20645        return 'vertical';
20646      }
20647
20648      if (tr >= 0 && tr <= 90) {
20649        return tr;
20650      }
20651
20652      if (tr > 90 && tr <= 180) {
20653        return 90 - tr;
20654      }
20655    }
20656
20657    return undefined;
20658  }
20659}; // Alignment encapsulates translation from style.alignment model to/from xlsx
20660
20661var AlignmentXform = /*#__PURE__*/function (_BaseXform) {
20662  _inherits(AlignmentXform, _BaseXform);
20663
20664  var _super = _createSuper(AlignmentXform);
20665
20666  function AlignmentXform() {
20667    _classCallCheck(this, AlignmentXform);
20668
20669    return _super.apply(this, arguments);
20670  }
20671
20672  _createClass(AlignmentXform, [{
20673    key: "render",
20674    value: function render(xmlStream, model) {
20675      xmlStream.addRollback();
20676      xmlStream.openNode('alignment');
20677      var isValid = false;
20678
20679      function add(name, value) {
20680        if (value) {
20681          xmlStream.addAttribute(name, value);
20682          isValid = true;
20683        }
20684      }
20685
20686      add('horizontal', validation.horizontal(model.horizontal));
20687      add('vertical', validation.vertical(model.vertical));
20688      add('wrapText', validation.wrapText(model.wrapText) ? '1' : false);
20689      add('shrinkToFit', validation.shrinkToFit(model.shrinkToFit) ? '1' : false);
20690      add('indent', validation.indent(model.indent));
20691      add('textRotation', textRotationXform.toXml(model.textRotation));
20692      add('readingOrder', validation.readingOrder(model.readingOrder));
20693      xmlStream.closeNode();
20694
20695      if (isValid) {
20696        xmlStream.commit();
20697      } else {
20698        xmlStream.rollback();
20699      }
20700    }
20701  }, {
20702    key: "parseOpen",
20703    value: function parseOpen(node) {
20704      var model = {};
20705      var valid = false;
20706
20707      function add(truthy, name, value) {
20708        if (truthy) {
20709          model[name] = value;
20710          valid = true;
20711        }
20712      }
20713
20714      add(node.attributes.horizontal, 'horizontal', node.attributes.horizontal);
20715      add(node.attributes.vertical, 'vertical', node.attributes.vertical === 'center' ? 'middle' : node.attributes.vertical);
20716      add(node.attributes.wrapText, 'wrapText', !!node.attributes.wrapText);
20717      add(node.attributes.shrinkToFit, 'shrinkToFit', !!node.attributes.shrinkToFit);
20718      add(node.attributes.indent, 'indent', parseInt(node.attributes.indent, 10));
20719      add(node.attributes.textRotation, 'textRotation', textRotationXform.toModel(node.attributes.textRotation));
20720      add(node.attributes.readingOrder, 'readingOrder', node.attributes.readingOrder === '2' ? 'rtl' : 'ltr');
20721      this.model = valid ? model : null;
20722    }
20723  }, {
20724    key: "parseText",
20725    value: function parseText() {}
20726  }, {
20727    key: "parseClose",
20728    value: function parseClose() {
20729      return false;
20730    }
20731  }, {
20732    key: "tag",
20733    get: function get() {
20734      return 'alignment';
20735    }
20736  }]);
20737
20738  return AlignmentXform;
20739}(BaseXform);
20740
20741module.exports = AlignmentXform;
20742
20743},{"../../../doc/enums":7,"../../../utils/utils":26,"../base-xform":31}],126:[function(require,module,exports){
20744"use strict";
20745
20746function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
20747
20748function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
20749
20750function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20751
20752function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
20753
20754function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20755
20756function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
20757
20758function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
20759
20760function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
20761
20762function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20763
20764function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20765
20766function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
20767
20768function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20769
20770function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20771
20772function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20773
20774/* eslint-disable max-classes-per-file */
20775var BaseXform = require('../base-xform');
20776
20777var ColorXform = require('./color-xform');
20778
20779var EdgeXform = /*#__PURE__*/function (_BaseXform) {
20780  _inherits(EdgeXform, _BaseXform);
20781
20782  var _super = _createSuper(EdgeXform);
20783
20784  function EdgeXform(name) {
20785    var _this;
20786
20787    _classCallCheck(this, EdgeXform);
20788
20789    _this = _super.call(this);
20790    _this.name = name;
20791    _this.map = {
20792      color: new ColorXform()
20793    };
20794    return _this;
20795  }
20796
20797  _createClass(EdgeXform, [{
20798    key: "render",
20799    value: function render(xmlStream, model, defaultColor) {
20800      var color = model && model.color || defaultColor || this.defaultColor;
20801      xmlStream.openNode(this.name);
20802
20803      if (model && model.style) {
20804        xmlStream.addAttribute('style', model.style);
20805
20806        if (color) {
20807          this.map.color.render(xmlStream, color);
20808        }
20809      }
20810
20811      xmlStream.closeNode();
20812    }
20813  }, {
20814    key: "parseOpen",
20815    value: function parseOpen(node) {
20816      if (this.parser) {
20817        this.parser.parseOpen(node);
20818        return true;
20819      }
20820
20821      switch (node.name) {
20822        case this.name:
20823          {
20824            var style = node.attributes.style;
20825
20826            if (style) {
20827              this.model = {
20828                style: style
20829              };
20830            } else {
20831              this.model = undefined;
20832            }
20833
20834            return true;
20835          }
20836
20837        case 'color':
20838          this.parser = this.map.color;
20839          this.parser.parseOpen(node);
20840          return true;
20841
20842        default:
20843          return false;
20844      }
20845    }
20846  }, {
20847    key: "parseText",
20848    value: function parseText(text) {
20849      if (this.parser) {
20850        this.parser.parseText(text);
20851      }
20852    }
20853  }, {
20854    key: "parseClose",
20855    value: function parseClose(name) {
20856      if (this.parser) {
20857        if (!this.parser.parseClose(name)) {
20858          this.parser = undefined;
20859        }
20860
20861        return true;
20862      }
20863
20864      if (name === this.name) {
20865        if (this.map.color.model) {
20866          if (!this.model) {
20867            this.model = {};
20868          }
20869
20870          this.model.color = this.map.color.model;
20871        }
20872      }
20873
20874      return false;
20875    }
20876  }, {
20877    key: "validStyle",
20878    value: function validStyle(value) {
20879      return EdgeXform.validStyleValues[value];
20880    }
20881  }, {
20882    key: "tag",
20883    get: function get() {
20884      return this.name;
20885    }
20886  }]);
20887
20888  return EdgeXform;
20889}(BaseXform);
20890
20891EdgeXform.validStyleValues = ['thin', 'dotted', 'dashDot', 'hair', 'dashDotDot', 'slantDashDot', 'mediumDashed', 'mediumDashDotDot', 'mediumDashDot', 'medium', 'double', 'thick'].reduce(function (p, v) {
20892  p[v] = true;
20893  return p;
20894}, {}); // Border encapsulates translation from border model to/from xlsx
20895
20896var BorderXform = /*#__PURE__*/function (_BaseXform2) {
20897  _inherits(BorderXform, _BaseXform2);
20898
20899  var _super2 = _createSuper(BorderXform);
20900
20901  function BorderXform() {
20902    var _this2;
20903
20904    _classCallCheck(this, BorderXform);
20905
20906    _this2 = _super2.call(this);
20907    _this2.map = {
20908      top: new EdgeXform('top'),
20909      left: new EdgeXform('left'),
20910      bottom: new EdgeXform('bottom'),
20911      right: new EdgeXform('right'),
20912      diagonal: new EdgeXform('diagonal')
20913    };
20914    return _this2;
20915  }
20916
20917  _createClass(BorderXform, [{
20918    key: "render",
20919    value: function render(xmlStream, model) {
20920      var color = model.color;
20921      xmlStream.openNode('border');
20922
20923      if (model.diagonal && model.diagonal.style) {
20924        if (model.diagonal.up) {
20925          xmlStream.addAttribute('diagonalUp', '1');
20926        }
20927
20928        if (model.diagonal.down) {
20929          xmlStream.addAttribute('diagonalDown', '1');
20930        }
20931      }
20932
20933      function add(edgeModel, edgeXform) {
20934        if (edgeModel && !edgeModel.color && model.color) {
20935          // don't mess with incoming models
20936          edgeModel = _objectSpread(_objectSpread({}, edgeModel), {}, {
20937            color: model.color
20938          });
20939        }
20940
20941        edgeXform.render(xmlStream, edgeModel, color);
20942      }
20943
20944      add(model.left, this.map.left);
20945      add(model.right, this.map.right);
20946      add(model.top, this.map.top);
20947      add(model.bottom, this.map.bottom);
20948      add(model.diagonal, this.map.diagonal);
20949      xmlStream.closeNode();
20950    }
20951  }, {
20952    key: "parseOpen",
20953    value: function parseOpen(node) {
20954      if (this.parser) {
20955        this.parser.parseOpen(node);
20956        return true;
20957      }
20958
20959      switch (node.name) {
20960        case 'border':
20961          this.reset();
20962          this.diagonalUp = !!node.attributes.diagonalUp;
20963          this.diagonalDown = !!node.attributes.diagonalDown;
20964          return true;
20965
20966        default:
20967          this.parser = this.map[node.name];
20968
20969          if (this.parser) {
20970            this.parser.parseOpen(node);
20971            return true;
20972          }
20973
20974          return false;
20975      }
20976    }
20977  }, {
20978    key: "parseText",
20979    value: function parseText(text) {
20980      if (this.parser) {
20981        this.parser.parseText(text);
20982      }
20983    }
20984  }, {
20985    key: "parseClose",
20986    value: function parseClose(name) {
20987      if (this.parser) {
20988        if (!this.parser.parseClose(name)) {
20989          this.parser = undefined;
20990        }
20991
20992        return true;
20993      }
20994
20995      if (name === 'border') {
20996        var model = this.model = {};
20997
20998        var add = function add(key, edgeModel, extensions) {
20999          if (edgeModel) {
21000            if (extensions) {
21001              Object.assign(edgeModel, extensions);
21002            }
21003
21004            model[key] = edgeModel;
21005          }
21006        };
21007
21008        add('left', this.map.left.model);
21009        add('right', this.map.right.model);
21010        add('top', this.map.top.model);
21011        add('bottom', this.map.bottom.model);
21012        add('diagonal', this.map.diagonal.model, {
21013          up: this.diagonalUp,
21014          down: this.diagonalDown
21015        });
21016      }
21017
21018      return false;
21019    }
21020  }]);
21021
21022  return BorderXform;
21023}(BaseXform);
21024
21025module.exports = BorderXform;
21026
21027},{"../base-xform":31,"./color-xform":127}],127:[function(require,module,exports){
21028"use strict";
21029
21030function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
21031
21032function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21033
21034function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
21035
21036function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21037
21038function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
21039
21040function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21041
21042function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21043
21044function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
21045
21046function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21047
21048function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
21049
21050function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21051
21052var BaseXform = require('../base-xform'); // Color encapsulates translation from color model to/from xlsx
21053
21054
21055var ColorXform = /*#__PURE__*/function (_BaseXform) {
21056  _inherits(ColorXform, _BaseXform);
21057
21058  var _super = _createSuper(ColorXform);
21059
21060  function ColorXform(name) {
21061    var _this;
21062
21063    _classCallCheck(this, ColorXform);
21064
21065    _this = _super.call(this); // this.name controls the xm node name
21066
21067    _this.name = name || 'color';
21068    return _this;
21069  }
21070
21071  _createClass(ColorXform, [{
21072    key: "render",
21073    value: function render(xmlStream, model) {
21074      if (model) {
21075        xmlStream.openNode(this.name);
21076
21077        if (model.argb) {
21078          xmlStream.addAttribute('rgb', model.argb);
21079        } else if (model.theme !== undefined) {
21080          xmlStream.addAttribute('theme', model.theme);
21081
21082          if (model.tint !== undefined) {
21083            xmlStream.addAttribute('tint', model.tint);
21084          }
21085        } else if (model.indexed !== undefined) {
21086          xmlStream.addAttribute('indexed', model.indexed);
21087        } else {
21088          xmlStream.addAttribute('auto', '1');
21089        }
21090
21091        xmlStream.closeNode();
21092        return true;
21093      }
21094
21095      return false;
21096    }
21097  }, {
21098    key: "parseOpen",
21099    value: function parseOpen(node) {
21100      if (node.name === this.name) {
21101        if (node.attributes.rgb) {
21102          this.model = {
21103            argb: node.attributes.rgb
21104          };
21105        } else if (node.attributes.theme) {
21106          this.model = {
21107            theme: parseInt(node.attributes.theme, 10)
21108          };
21109
21110          if (node.attributes.tint) {
21111            this.model.tint = parseFloat(node.attributes.tint);
21112          }
21113        } else if (node.attributes.indexed) {
21114          this.model = {
21115            indexed: parseInt(node.attributes.indexed, 10)
21116          };
21117        } else {
21118          this.model = undefined;
21119        }
21120
21121        return true;
21122      }
21123
21124      return false;
21125    }
21126  }, {
21127    key: "parseText",
21128    value: function parseText() {}
21129  }, {
21130    key: "parseClose",
21131    value: function parseClose() {
21132      return false;
21133    }
21134  }, {
21135    key: "tag",
21136    get: function get() {
21137      return this.name;
21138    }
21139  }]);
21140
21141  return ColorXform;
21142}(BaseXform);
21143
21144module.exports = ColorXform;
21145
21146},{"../base-xform":31}],128:[function(require,module,exports){
21147"use strict";
21148
21149function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
21150
21151function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21152
21153function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
21154
21155function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21156
21157function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
21158
21159function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21160
21161function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21162
21163function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
21164
21165function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21166
21167function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
21168
21169function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21170
21171var BaseXform = require('../base-xform');
21172
21173var AlignmentXform = require('./alignment-xform');
21174
21175var BorderXform = require('./border-xform');
21176
21177var FillXform = require('./fill-xform');
21178
21179var FontXform = require('./font-xform');
21180
21181var NumFmtXform = require('./numfmt-xform');
21182
21183var ProtectionXform = require('./protection-xform'); // <xf numFmtId="[numFmtId]" fontId="[fontId]" fillId="[fillId]" borderId="[xf.borderId]" xfId="[xfId]">
21184//   Optional <alignment>
21185//   Optional <protection>
21186// </xf>
21187// Style assists translation from style model to/from xlsx
21188
21189
21190var DxfXform = /*#__PURE__*/function (_BaseXform) {
21191  _inherits(DxfXform, _BaseXform);
21192
21193  var _super = _createSuper(DxfXform);
21194
21195  function DxfXform() {
21196    var _this;
21197
21198    _classCallCheck(this, DxfXform);
21199
21200    _this = _super.call(this);
21201    _this.map = {
21202      alignment: new AlignmentXform(),
21203      border: new BorderXform(),
21204      fill: new FillXform(),
21205      font: new FontXform(),
21206      numFmt: new NumFmtXform(),
21207      protection: new ProtectionXform()
21208    };
21209    return _this;
21210  }
21211
21212  _createClass(DxfXform, [{
21213    key: "render",
21214    // how do we generate dxfid?
21215    value: function render(xmlStream, model) {
21216      xmlStream.openNode(this.tag);
21217
21218      if (model.font) {
21219        this.map.font.render(xmlStream, model.font);
21220      }
21221
21222      if (model.numFmt) {
21223        this.map.numFmt.render(xmlStream, model.numFmt);
21224      }
21225
21226      if (model.fill) {
21227        this.map.fill.render(xmlStream, model.fill);
21228      }
21229
21230      if (model.alignment) {
21231        this.map.alignment.render(xmlStream, model.alignment);
21232      }
21233
21234      if (model.border) {
21235        this.map.border.render(xmlStream, model.border);
21236      }
21237
21238      if (model.protection) {
21239        this.map.protection.render(xmlStream, model.protection);
21240      }
21241
21242      xmlStream.closeNode();
21243    }
21244  }, {
21245    key: "parseOpen",
21246    value: function parseOpen(node) {
21247      if (this.parser) {
21248        this.parser.parseOpen(node);
21249        return true;
21250      }
21251
21252      switch (node.name) {
21253        case this.tag:
21254          // this node is often repeated. Need to reset children
21255          this.reset();
21256          return true;
21257
21258        default:
21259          this.parser = this.map[node.name];
21260
21261          if (this.parser) {
21262            this.parser.parseOpen(node);
21263          }
21264
21265          return true;
21266      }
21267    }
21268  }, {
21269    key: "parseText",
21270    value: function parseText(text) {
21271      if (this.parser) {
21272        this.parser.parseText(text);
21273      }
21274    }
21275  }, {
21276    key: "parseClose",
21277    value: function parseClose(name) {
21278      if (this.parser) {
21279        if (!this.parser.parseClose(name)) {
21280          this.parser = undefined;
21281        }
21282
21283        return true;
21284      }
21285
21286      if (name === this.tag) {
21287        this.model = {
21288          alignment: this.map.alignment.model,
21289          border: this.map.border.model,
21290          fill: this.map.fill.model,
21291          font: this.map.font.model,
21292          numFmt: this.map.numFmt.model,
21293          protection: this.map.protection.model
21294        };
21295        return false;
21296      }
21297
21298      return true;
21299    }
21300  }, {
21301    key: "tag",
21302    get: function get() {
21303      return 'dxf';
21304    }
21305  }]);
21306
21307  return DxfXform;
21308}(BaseXform);
21309
21310module.exports = DxfXform;
21311
21312},{"../base-xform":31,"./alignment-xform":125,"./border-xform":126,"./fill-xform":129,"./font-xform":130,"./numfmt-xform":131,"./protection-xform":132}],129:[function(require,module,exports){
21313"use strict";
21314
21315function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
21316
21317function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21318
21319function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
21320
21321function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21322
21323function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
21324
21325function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21326
21327function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21328
21329function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
21330
21331function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21332
21333function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
21334
21335function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21336
21337/* eslint-disable max-classes-per-file */
21338var BaseXform = require('../base-xform');
21339
21340var ColorXform = require('./color-xform');
21341
21342var StopXform = /*#__PURE__*/function (_BaseXform) {
21343  _inherits(StopXform, _BaseXform);
21344
21345  var _super = _createSuper(StopXform);
21346
21347  function StopXform() {
21348    var _this;
21349
21350    _classCallCheck(this, StopXform);
21351
21352    _this = _super.call(this);
21353    _this.map = {
21354      color: new ColorXform()
21355    };
21356    return _this;
21357  }
21358
21359  _createClass(StopXform, [{
21360    key: "render",
21361    value: function render(xmlStream, model) {
21362      xmlStream.openNode('stop');
21363      xmlStream.addAttribute('position', model.position);
21364      this.map.color.render(xmlStream, model.color);
21365      xmlStream.closeNode();
21366    }
21367  }, {
21368    key: "parseOpen",
21369    value: function parseOpen(node) {
21370      if (this.parser) {
21371        this.parser.parseOpen(node);
21372        return true;
21373      }
21374
21375      switch (node.name) {
21376        case 'stop':
21377          this.model = {
21378            position: parseFloat(node.attributes.position)
21379          };
21380          return true;
21381
21382        case 'color':
21383          this.parser = this.map.color;
21384          this.parser.parseOpen(node);
21385          return true;
21386
21387        default:
21388          return false;
21389      }
21390    }
21391  }, {
21392    key: "parseText",
21393    value: function parseText() {}
21394  }, {
21395    key: "parseClose",
21396    value: function parseClose(name) {
21397      if (this.parser) {
21398        if (!this.parser.parseClose(name)) {
21399          this.model.color = this.parser.model;
21400          this.parser = undefined;
21401        }
21402
21403        return true;
21404      }
21405
21406      return false;
21407    }
21408  }, {
21409    key: "tag",
21410    get: function get() {
21411      return 'stop';
21412    }
21413  }]);
21414
21415  return StopXform;
21416}(BaseXform);
21417
21418var PatternFillXform = /*#__PURE__*/function (_BaseXform2) {
21419  _inherits(PatternFillXform, _BaseXform2);
21420
21421  var _super2 = _createSuper(PatternFillXform);
21422
21423  function PatternFillXform() {
21424    var _this2;
21425
21426    _classCallCheck(this, PatternFillXform);
21427
21428    _this2 = _super2.call(this);
21429    _this2.map = {
21430      fgColor: new ColorXform('fgColor'),
21431      bgColor: new ColorXform('bgColor')
21432    };
21433    return _this2;
21434  }
21435
21436  _createClass(PatternFillXform, [{
21437    key: "render",
21438    value: function render(xmlStream, model) {
21439      xmlStream.openNode('patternFill');
21440      xmlStream.addAttribute('patternType', model.pattern);
21441
21442      if (model.fgColor) {
21443        this.map.fgColor.render(xmlStream, model.fgColor);
21444      }
21445
21446      if (model.bgColor) {
21447        this.map.bgColor.render(xmlStream, model.bgColor);
21448      }
21449
21450      xmlStream.closeNode();
21451    }
21452  }, {
21453    key: "parseOpen",
21454    value: function parseOpen(node) {
21455      if (this.parser) {
21456        this.parser.parseOpen(node);
21457        return true;
21458      }
21459
21460      switch (node.name) {
21461        case 'patternFill':
21462          this.model = {
21463            type: 'pattern',
21464            pattern: node.attributes.patternType
21465          };
21466          return true;
21467
21468        default:
21469          this.parser = this.map[node.name];
21470
21471          if (this.parser) {
21472            this.parser.parseOpen(node);
21473            return true;
21474          }
21475
21476          return false;
21477      }
21478    }
21479  }, {
21480    key: "parseText",
21481    value: function parseText(text) {
21482      if (this.parser) {
21483        this.parser.parseText(text);
21484      }
21485    }
21486  }, {
21487    key: "parseClose",
21488    value: function parseClose(name) {
21489      if (this.parser) {
21490        if (!this.parser.parseClose(name)) {
21491          if (this.parser.model) {
21492            this.model[name] = this.parser.model;
21493          }
21494
21495          this.parser = undefined;
21496        }
21497
21498        return true;
21499      }
21500
21501      return false;
21502    }
21503  }, {
21504    key: "name",
21505    get: function get() {
21506      return 'pattern';
21507    }
21508  }, {
21509    key: "tag",
21510    get: function get() {
21511      return 'patternFill';
21512    }
21513  }]);
21514
21515  return PatternFillXform;
21516}(BaseXform);
21517
21518var GradientFillXform = /*#__PURE__*/function (_BaseXform3) {
21519  _inherits(GradientFillXform, _BaseXform3);
21520
21521  var _super3 = _createSuper(GradientFillXform);
21522
21523  function GradientFillXform() {
21524    var _this3;
21525
21526    _classCallCheck(this, GradientFillXform);
21527
21528    _this3 = _super3.call(this);
21529    _this3.map = {
21530      stop: new StopXform()
21531    }; // if (model) {
21532    //   this.gradient = model.gradient;
21533    //   if (model.center) {
21534    //     this.center = model.center;
21535    //   }
21536    //   if (model.degree !== undefined) {
21537    //     this.degree = model.degree;
21538    //   }
21539    //   this.stops = model.stops.map(function(stop) { return new StopXform(stop); });
21540    // } else {
21541    //   this.stops = [];
21542    // }
21543
21544    return _this3;
21545  }
21546
21547  _createClass(GradientFillXform, [{
21548    key: "render",
21549    value: function render(xmlStream, model) {
21550      xmlStream.openNode('gradientFill');
21551
21552      switch (model.gradient) {
21553        case 'angle':
21554          xmlStream.addAttribute('degree', model.degree);
21555          break;
21556
21557        case 'path':
21558          xmlStream.addAttribute('type', 'path');
21559
21560          if (model.center.left) {
21561            xmlStream.addAttribute('left', model.center.left);
21562
21563            if (model.center.right === undefined) {
21564              xmlStream.addAttribute('right', model.center.left);
21565            }
21566          }
21567
21568          if (model.center.right) {
21569            xmlStream.addAttribute('right', model.center.right);
21570          }
21571
21572          if (model.center.top) {
21573            xmlStream.addAttribute('top', model.center.top);
21574
21575            if (model.center.bottom === undefined) {
21576              xmlStream.addAttribute('bottom', model.center.top);
21577            }
21578          }
21579
21580          if (model.center.bottom) {
21581            xmlStream.addAttribute('bottom', model.center.bottom);
21582          }
21583
21584          break;
21585
21586        default:
21587          break;
21588      }
21589
21590      var stopXform = this.map.stop;
21591      model.stops.forEach(function (stopModel) {
21592        stopXform.render(xmlStream, stopModel);
21593      });
21594      xmlStream.closeNode();
21595    }
21596  }, {
21597    key: "parseOpen",
21598    value: function parseOpen(node) {
21599      if (this.parser) {
21600        this.parser.parseOpen(node);
21601        return true;
21602      }
21603
21604      switch (node.name) {
21605        case 'gradientFill':
21606          {
21607            var model = this.model = {
21608              stops: []
21609            };
21610
21611            if (node.attributes.degree) {
21612              model.gradient = 'angle';
21613              model.degree = parseInt(node.attributes.degree, 10);
21614            } else if (node.attributes.type === 'path') {
21615              model.gradient = 'path';
21616              model.center = {
21617                left: node.attributes.left ? parseFloat(node.attributes.left) : 0,
21618                top: node.attributes.top ? parseFloat(node.attributes.top) : 0
21619              };
21620
21621              if (node.attributes.right !== node.attributes.left) {
21622                model.center.right = node.attributes.right ? parseFloat(node.attributes.right) : 0;
21623              }
21624
21625              if (node.attributes.bottom !== node.attributes.top) {
21626                model.center.bottom = node.attributes.bottom ? parseFloat(node.attributes.bottom) : 0;
21627              }
21628            }
21629
21630            return true;
21631          }
21632
21633        case 'stop':
21634          this.parser = this.map.stop;
21635          this.parser.parseOpen(node);
21636          return true;
21637
21638        default:
21639          return false;
21640      }
21641    }
21642  }, {
21643    key: "parseText",
21644    value: function parseText(text) {
21645      if (this.parser) {
21646        this.parser.parseText(text);
21647      }
21648    }
21649  }, {
21650    key: "parseClose",
21651    value: function parseClose(name) {
21652      if (this.parser) {
21653        if (!this.parser.parseClose(name)) {
21654          this.model.stops.push(this.parser.model);
21655          this.parser = undefined;
21656        }
21657
21658        return true;
21659      }
21660
21661      return false;
21662    }
21663  }, {
21664    key: "name",
21665    get: function get() {
21666      return 'gradient';
21667    }
21668  }, {
21669    key: "tag",
21670    get: function get() {
21671      return 'gradientFill';
21672    }
21673  }]);
21674
21675  return GradientFillXform;
21676}(BaseXform); // Fill encapsulates translation from fill model to/from xlsx
21677
21678
21679var FillXform = /*#__PURE__*/function (_BaseXform4) {
21680  _inherits(FillXform, _BaseXform4);
21681
21682  var _super4 = _createSuper(FillXform);
21683
21684  function FillXform() {
21685    var _this4;
21686
21687    _classCallCheck(this, FillXform);
21688
21689    _this4 = _super4.call(this);
21690    _this4.map = {
21691      patternFill: new PatternFillXform(),
21692      gradientFill: new GradientFillXform()
21693    };
21694    return _this4;
21695  }
21696
21697  _createClass(FillXform, [{
21698    key: "render",
21699    value: function render(xmlStream, model) {
21700      xmlStream.addRollback();
21701      xmlStream.openNode('fill');
21702
21703      switch (model.type) {
21704        case 'pattern':
21705          this.map.patternFill.render(xmlStream, model);
21706          break;
21707
21708        case 'gradient':
21709          this.map.gradientFill.render(xmlStream, model);
21710          break;
21711
21712        default:
21713          xmlStream.rollback();
21714          return;
21715      }
21716
21717      xmlStream.closeNode();
21718      xmlStream.commit();
21719    }
21720  }, {
21721    key: "parseOpen",
21722    value: function parseOpen(node) {
21723      if (this.parser) {
21724        this.parser.parseOpen(node);
21725        return true;
21726      }
21727
21728      switch (node.name) {
21729        case 'fill':
21730          this.model = {};
21731          return true;
21732
21733        default:
21734          this.parser = this.map[node.name];
21735
21736          if (this.parser) {
21737            this.parser.parseOpen(node);
21738            return true;
21739          }
21740
21741          return false;
21742      }
21743    }
21744  }, {
21745    key: "parseText",
21746    value: function parseText(text) {
21747      if (this.parser) {
21748        this.parser.parseText(text);
21749      }
21750    }
21751  }, {
21752    key: "parseClose",
21753    value: function parseClose(name) {
21754      if (this.parser) {
21755        if (!this.parser.parseClose(name)) {
21756          this.model = this.parser.model;
21757          this.model.type = this.parser.name;
21758          this.parser = undefined;
21759        }
21760
21761        return true;
21762      }
21763
21764      return false;
21765    }
21766  }, {
21767    key: "validStyle",
21768    value: function validStyle(value) {
21769      return FillXform.validPatternValues[value];
21770    }
21771  }, {
21772    key: "tag",
21773    get: function get() {
21774      return 'fill';
21775    }
21776  }]);
21777
21778  return FillXform;
21779}(BaseXform);
21780
21781FillXform.validPatternValues = ['none', 'solid', 'darkVertical', 'darkGray', 'mediumGray', 'lightGray', 'gray125', 'gray0625', 'darkHorizontal', 'darkVertical', 'darkDown', 'darkUp', 'darkGrid', 'darkTrellis', 'lightHorizontal', 'lightVertical', 'lightDown', 'lightUp', 'lightGrid', 'lightTrellis', 'lightGrid'].reduce(function (p, v) {
21782  p[v] = true;
21783  return p;
21784}, {});
21785FillXform.StopXform = StopXform;
21786FillXform.PatternFillXform = PatternFillXform;
21787FillXform.GradientFillXform = GradientFillXform;
21788module.exports = FillXform;
21789
21790},{"../base-xform":31,"./color-xform":127}],130:[function(require,module,exports){
21791'use strict';
21792
21793function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
21794
21795function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21796
21797function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
21798
21799function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21800
21801function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
21802
21803function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21804
21805function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21806
21807function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
21808
21809function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21810
21811function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
21812
21813function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21814
21815var ColorXform = require('./color-xform');
21816
21817var BooleanXform = require('../simple/boolean-xform');
21818
21819var IntegerXform = require('../simple/integer-xform');
21820
21821var StringXform = require('../simple/string-xform');
21822
21823var UnderlineXform = require('./underline-xform');
21824
21825var _ = require('../../../utils/under-dash');
21826
21827var BaseXform = require('../base-xform'); // Font encapsulates translation from font model to xlsx
21828
21829
21830var FontXform = /*#__PURE__*/function (_BaseXform) {
21831  _inherits(FontXform, _BaseXform);
21832
21833  var _super = _createSuper(FontXform);
21834
21835  function FontXform(options) {
21836    var _this;
21837
21838    _classCallCheck(this, FontXform);
21839
21840    _this = _super.call(this);
21841    _this.options = options || FontXform.OPTIONS;
21842    _this.map = {
21843      b: {
21844        prop: 'bold',
21845        xform: new BooleanXform({
21846          tag: 'b',
21847          attr: 'val'
21848        })
21849      },
21850      i: {
21851        prop: 'italic',
21852        xform: new BooleanXform({
21853          tag: 'i',
21854          attr: 'val'
21855        })
21856      },
21857      u: {
21858        prop: 'underline',
21859        xform: new UnderlineXform()
21860      },
21861      charset: {
21862        prop: 'charset',
21863        xform: new IntegerXform({
21864          tag: 'charset',
21865          attr: 'val'
21866        })
21867      },
21868      color: {
21869        prop: 'color',
21870        xform: new ColorXform()
21871      },
21872      condense: {
21873        prop: 'condense',
21874        xform: new BooleanXform({
21875          tag: 'condense',
21876          attr: 'val'
21877        })
21878      },
21879      extend: {
21880        prop: 'extend',
21881        xform: new BooleanXform({
21882          tag: 'extend',
21883          attr: 'val'
21884        })
21885      },
21886      family: {
21887        prop: 'family',
21888        xform: new IntegerXform({
21889          tag: 'family',
21890          attr: 'val'
21891        })
21892      },
21893      outline: {
21894        prop: 'outline',
21895        xform: new BooleanXform({
21896          tag: 'outline',
21897          attr: 'val'
21898        })
21899      },
21900      vertAlign: {
21901        prop: 'vertAlign',
21902        xform: new StringXform({
21903          tag: 'vertAlign',
21904          attr: 'val'
21905        })
21906      },
21907      scheme: {
21908        prop: 'scheme',
21909        xform: new StringXform({
21910          tag: 'scheme',
21911          attr: 'val'
21912        })
21913      },
21914      shadow: {
21915        prop: 'shadow',
21916        xform: new BooleanXform({
21917          tag: 'shadow',
21918          attr: 'val'
21919        })
21920      },
21921      strike: {
21922        prop: 'strike',
21923        xform: new BooleanXform({
21924          tag: 'strike',
21925          attr: 'val'
21926        })
21927      },
21928      sz: {
21929        prop: 'size',
21930        xform: new IntegerXform({
21931          tag: 'sz',
21932          attr: 'val'
21933        })
21934      }
21935    };
21936    _this.map[_this.options.fontNameTag] = {
21937      prop: 'name',
21938      xform: new StringXform({
21939        tag: _this.options.fontNameTag,
21940        attr: 'val'
21941      })
21942    };
21943    return _this;
21944  }
21945
21946  _createClass(FontXform, [{
21947    key: "render",
21948    value: function render(xmlStream, model) {
21949      var map = this.map;
21950      xmlStream.openNode(this.options.tagName);
21951
21952      _.each(this.map, function (defn, tag) {
21953        map[tag].xform.render(xmlStream, model[defn.prop]);
21954      });
21955
21956      xmlStream.closeNode();
21957    }
21958  }, {
21959    key: "parseOpen",
21960    value: function parseOpen(node) {
21961      if (this.parser) {
21962        this.parser.parseOpen(node);
21963        return true;
21964      }
21965
21966      if (this.map[node.name]) {
21967        this.parser = this.map[node.name].xform;
21968        return this.parser.parseOpen(node);
21969      }
21970
21971      switch (node.name) {
21972        case this.options.tagName:
21973          this.model = {};
21974          return true;
21975
21976        default:
21977          return false;
21978      }
21979    }
21980  }, {
21981    key: "parseText",
21982    value: function parseText(text) {
21983      if (this.parser) {
21984        this.parser.parseText(text);
21985      }
21986    }
21987  }, {
21988    key: "parseClose",
21989    value: function parseClose(name) {
21990      if (this.parser && !this.parser.parseClose(name)) {
21991        var item = this.map[name];
21992
21993        if (this.parser.model) {
21994          this.model[item.prop] = this.parser.model;
21995        }
21996
21997        this.parser = undefined;
21998        return true;
21999      }
22000
22001      switch (name) {
22002        case this.options.tagName:
22003          return false;
22004
22005        default:
22006          return true;
22007      }
22008    }
22009  }, {
22010    key: "tag",
22011    get: function get() {
22012      return this.options.tagName;
22013    }
22014  }]);
22015
22016  return FontXform;
22017}(BaseXform);
22018
22019FontXform.OPTIONS = {
22020  tagName: 'font',
22021  fontNameTag: 'name'
22022};
22023module.exports = FontXform;
22024
22025},{"../../../utils/under-dash":25,"../base-xform":31,"../simple/boolean-xform":115,"../simple/integer-xform":117,"../simple/string-xform":118,"./color-xform":127,"./underline-xform":135}],131:[function(require,module,exports){
22026"use strict";
22027
22028function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22029
22030function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22031
22032function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
22033
22034function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
22035
22036function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
22037
22038function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22039
22040function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
22041
22042function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
22043
22044function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22045
22046function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
22047
22048function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22049
22050var _ = require('../../../utils/under-dash');
22051
22052var defaultNumFormats = require('../../defaultnumformats');
22053
22054var BaseXform = require('../base-xform');
22055
22056function hashDefaultFormats() {
22057  var hash = {};
22058
22059  _.each(defaultNumFormats, function (dnf, id) {
22060    if (dnf.f) {
22061      hash[dnf.f] = parseInt(id, 10);
22062    } // at some point, add the other cultures here...
22063
22064  });
22065
22066  return hash;
22067}
22068
22069var defaultFmtHash = hashDefaultFormats(); // NumFmt encapsulates translation between number format and xlsx
22070
22071var NumFmtXform = /*#__PURE__*/function (_BaseXform) {
22072  _inherits(NumFmtXform, _BaseXform);
22073
22074  var _super = _createSuper(NumFmtXform);
22075
22076  function NumFmtXform(id, formatCode) {
22077    var _this;
22078
22079    _classCallCheck(this, NumFmtXform);
22080
22081    _this = _super.call(this);
22082    _this.id = id;
22083    _this.formatCode = formatCode;
22084    return _this;
22085  }
22086
22087  _createClass(NumFmtXform, [{
22088    key: "render",
22089    value: function render(xmlStream, model) {
22090      xmlStream.leafNode('numFmt', {
22091        numFmtId: model.id,
22092        formatCode: model.formatCode
22093      });
22094    }
22095  }, {
22096    key: "parseOpen",
22097    value: function parseOpen(node) {
22098      switch (node.name) {
22099        case 'numFmt':
22100          this.model = {
22101            id: parseInt(node.attributes.numFmtId, 10),
22102            formatCode: node.attributes.formatCode.replace(/[\\](.)/g, '$1')
22103          };
22104          return true;
22105
22106        default:
22107          return false;
22108      }
22109    }
22110  }, {
22111    key: "parseText",
22112    value: function parseText() {}
22113  }, {
22114    key: "parseClose",
22115    value: function parseClose() {
22116      return false;
22117    }
22118  }, {
22119    key: "tag",
22120    get: function get() {
22121      return 'numFmt';
22122    }
22123  }]);
22124
22125  return NumFmtXform;
22126}(BaseXform);
22127
22128NumFmtXform.getDefaultFmtId = function getDefaultFmtId(formatCode) {
22129  return defaultFmtHash[formatCode];
22130};
22131
22132NumFmtXform.getDefaultFmtCode = function getDefaultFmtCode(numFmtId) {
22133  return defaultNumFormats[numFmtId] && defaultNumFormats[numFmtId].f;
22134};
22135
22136module.exports = NumFmtXform;
22137
22138},{"../../../utils/under-dash":25,"../../defaultnumformats":29,"../base-xform":31}],132:[function(require,module,exports){
22139"use strict";
22140
22141function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22142
22143function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22144
22145function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
22146
22147function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
22148
22149function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
22150
22151function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22152
22153function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
22154
22155function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
22156
22157function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22158
22159function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
22160
22161function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22162
22163var BaseXform = require('../base-xform');
22164
22165var validation = {
22166  boolean: function boolean(value, dflt) {
22167    if (value === undefined) {
22168      return dflt;
22169    }
22170
22171    return value;
22172  }
22173}; // Protection encapsulates translation from style.protection model to/from xlsx
22174
22175var ProtectionXform = /*#__PURE__*/function (_BaseXform) {
22176  _inherits(ProtectionXform, _BaseXform);
22177
22178  var _super = _createSuper(ProtectionXform);
22179
22180  function ProtectionXform() {
22181    _classCallCheck(this, ProtectionXform);
22182
22183    return _super.apply(this, arguments);
22184  }
22185
22186  _createClass(ProtectionXform, [{
22187    key: "render",
22188    value: function render(xmlStream, model) {
22189      xmlStream.addRollback();
22190      xmlStream.openNode('protection');
22191      var isValid = false;
22192
22193      function add(name, value) {
22194        if (value !== undefined) {
22195          xmlStream.addAttribute(name, value);
22196          isValid = true;
22197        }
22198      }
22199
22200      add('locked', validation.boolean(model.locked, true) ? undefined : '0');
22201      add('hidden', validation.boolean(model.hidden, false) ? '1' : undefined);
22202      xmlStream.closeNode();
22203
22204      if (isValid) {
22205        xmlStream.commit();
22206      } else {
22207        xmlStream.rollback();
22208      }
22209    }
22210  }, {
22211    key: "parseOpen",
22212    value: function parseOpen(node) {
22213      var model = {
22214        locked: !(node.attributes.locked === '0'),
22215        hidden: node.attributes.hidden === '1'
22216      }; // only want to record models that differ from defaults
22217
22218      var isSignificant = !model.locked || model.hidden;
22219      this.model = isSignificant ? model : null;
22220    }
22221  }, {
22222    key: "parseText",
22223    value: function parseText() {}
22224  }, {
22225    key: "parseClose",
22226    value: function parseClose() {
22227      return false;
22228    }
22229  }, {
22230    key: "tag",
22231    get: function get() {
22232      return 'protection';
22233    }
22234  }]);
22235
22236  return ProtectionXform;
22237}(BaseXform);
22238
22239module.exports = ProtectionXform;
22240
22241},{"../base-xform":31}],133:[function(require,module,exports){
22242"use strict";
22243
22244function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22245
22246function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22247
22248function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
22249
22250function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
22251
22252function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
22253
22254function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22255
22256function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
22257
22258function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
22259
22260function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22261
22262function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
22263
22264function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22265
22266var BaseXform = require('../base-xform');
22267
22268var AlignmentXform = require('./alignment-xform');
22269
22270var ProtectionXform = require('./protection-xform'); // <xf numFmtId="[numFmtId]" fontId="[fontId]" fillId="[fillId]" borderId="[xf.borderId]" xfId="[xfId]">
22271//   Optional <alignment>
22272//   Optional <protection>
22273// </xf>
22274// Style assists translation from style model to/from xlsx
22275
22276
22277var StyleXform = /*#__PURE__*/function (_BaseXform) {
22278  _inherits(StyleXform, _BaseXform);
22279
22280  var _super = _createSuper(StyleXform);
22281
22282  function StyleXform(options) {
22283    var _this;
22284
22285    _classCallCheck(this, StyleXform);
22286
22287    _this = _super.call(this);
22288    _this.xfId = !!(options && options.xfId);
22289    _this.map = {
22290      alignment: new AlignmentXform(),
22291      protection: new ProtectionXform()
22292    };
22293    return _this;
22294  }
22295
22296  _createClass(StyleXform, [{
22297    key: "render",
22298    value: function render(xmlStream, model) {
22299      xmlStream.openNode('xf', {
22300        numFmtId: model.numFmtId || 0,
22301        fontId: model.fontId || 0,
22302        fillId: model.fillId || 0,
22303        borderId: model.borderId || 0
22304      });
22305
22306      if (this.xfId) {
22307        xmlStream.addAttribute('xfId', model.xfId || 0);
22308      }
22309
22310      if (model.numFmtId) {
22311        xmlStream.addAttribute('applyNumberFormat', '1');
22312      }
22313
22314      if (model.fontId) {
22315        xmlStream.addAttribute('applyFont', '1');
22316      }
22317
22318      if (model.fillId) {
22319        xmlStream.addAttribute('applyFill', '1');
22320      }
22321
22322      if (model.borderId) {
22323        xmlStream.addAttribute('applyBorder', '1');
22324      }
22325
22326      if (model.alignment) {
22327        xmlStream.addAttribute('applyAlignment', '1');
22328      }
22329
22330      if (model.protection) {
22331        xmlStream.addAttribute('applyProtection', '1');
22332      }
22333      /**
22334       * Rendering tags causes close of XML stream.
22335       * Therefore adding attributes must be done before rendering tags.
22336       */
22337
22338
22339      if (model.alignment) {
22340        this.map.alignment.render(xmlStream, model.alignment);
22341      }
22342
22343      if (model.protection) {
22344        this.map.protection.render(xmlStream, model.protection);
22345      }
22346
22347      xmlStream.closeNode();
22348    }
22349  }, {
22350    key: "parseOpen",
22351    value: function parseOpen(node) {
22352      if (this.parser) {
22353        this.parser.parseOpen(node);
22354        return true;
22355      } // used during sax parsing of xml to build font object
22356
22357
22358      switch (node.name) {
22359        case 'xf':
22360          this.model = {
22361            numFmtId: parseInt(node.attributes.numFmtId, 10),
22362            fontId: parseInt(node.attributes.fontId, 10),
22363            fillId: parseInt(node.attributes.fillId, 10),
22364            borderId: parseInt(node.attributes.borderId, 10)
22365          };
22366
22367          if (this.xfId) {
22368            this.model.xfId = parseInt(node.attributes.xfId, 10);
22369          }
22370
22371          return true;
22372
22373        case 'alignment':
22374          this.parser = this.map.alignment;
22375          this.parser.parseOpen(node);
22376          return true;
22377
22378        case 'protection':
22379          this.parser = this.map.protection;
22380          this.parser.parseOpen(node);
22381          return true;
22382
22383        default:
22384          return false;
22385      }
22386    }
22387  }, {
22388    key: "parseText",
22389    value: function parseText(text) {
22390      if (this.parser) {
22391        this.parser.parseText(text);
22392      }
22393    }
22394  }, {
22395    key: "parseClose",
22396    value: function parseClose(name) {
22397      if (this.parser) {
22398        if (!this.parser.parseClose(name)) {
22399          if (this.map.protection === this.parser) {
22400            this.model.protection = this.parser.model;
22401          } else {
22402            this.model.alignment = this.parser.model;
22403          }
22404
22405          this.parser = undefined;
22406        }
22407
22408        return true;
22409      }
22410
22411      return name !== 'xf';
22412    }
22413  }, {
22414    key: "tag",
22415    get: function get() {
22416      return 'xf';
22417    }
22418  }]);
22419
22420  return StyleXform;
22421}(BaseXform);
22422
22423module.exports = StyleXform;
22424
22425},{"../base-xform":31,"./alignment-xform":125,"./protection-xform":132}],134:[function(require,module,exports){
22426"use strict";
22427
22428function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22429
22430function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22431
22432function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
22433
22434function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
22435
22436function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
22437
22438function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22439
22440function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
22441
22442function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
22443
22444function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22445
22446function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
22447
22448function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22449
22450/* eslint-disable max-classes-per-file */
22451var Enums = require('../../../doc/enums');
22452
22453var XmlStream = require('../../../utils/xml-stream');
22454
22455var BaseXform = require('../base-xform');
22456
22457var StaticXform = require('../static-xform');
22458
22459var ListXform = require('../list-xform');
22460
22461var FontXform = require('./font-xform');
22462
22463var FillXform = require('./fill-xform');
22464
22465var BorderXform = require('./border-xform');
22466
22467var NumFmtXform = require('./numfmt-xform');
22468
22469var StyleXform = require('./style-xform');
22470
22471var DxfXform = require('./dxf-xform'); // custom numfmt ids start here
22472
22473
22474var NUMFMT_BASE = 164; // =============================================================================
22475// StylesXform is used to generate and parse the styles.xml file
22476// it manages the collections of fonts, number formats, alignments, etc
22477
22478var StylesXform = /*#__PURE__*/function (_BaseXform) {
22479  _inherits(StylesXform, _BaseXform);
22480
22481  var _super = _createSuper(StylesXform);
22482
22483  function StylesXform(initialise) {
22484    var _this;
22485
22486    _classCallCheck(this, StylesXform);
22487
22488    _this = _super.call(this);
22489    _this.map = {
22490      numFmts: new ListXform({
22491        tag: 'numFmts',
22492        count: true,
22493        childXform: new NumFmtXform()
22494      }),
22495      fonts: new ListXform({
22496        tag: 'fonts',
22497        count: true,
22498        childXform: new FontXform(),
22499        $: {
22500          'x14ac:knownFonts': 1
22501        }
22502      }),
22503      fills: new ListXform({
22504        tag: 'fills',
22505        count: true,
22506        childXform: new FillXform()
22507      }),
22508      borders: new ListXform({
22509        tag: 'borders',
22510        count: true,
22511        childXform: new BorderXform()
22512      }),
22513      cellStyleXfs: new ListXform({
22514        tag: 'cellStyleXfs',
22515        count: true,
22516        childXform: new StyleXform()
22517      }),
22518      cellXfs: new ListXform({
22519        tag: 'cellXfs',
22520        count: true,
22521        childXform: new StyleXform({
22522          xfId: true
22523        })
22524      }),
22525      dxfs: new ListXform({
22526        tag: 'dxfs',
22527        always: true,
22528        count: true,
22529        childXform: new DxfXform()
22530      }),
22531      // for style manager
22532      numFmt: new NumFmtXform(),
22533      font: new FontXform(),
22534      fill: new FillXform(),
22535      border: new BorderXform(),
22536      style: new StyleXform({
22537        xfId: true
22538      }),
22539      cellStyles: StylesXform.STATIC_XFORMS.cellStyles,
22540      tableStyles: StylesXform.STATIC_XFORMS.tableStyles,
22541      extLst: StylesXform.STATIC_XFORMS.extLst
22542    };
22543
22544    if (initialise) {
22545      // StylesXform also acts as style manager and is used to build up styles-model during worksheet processing
22546      _this.init();
22547    }
22548
22549    return _this;
22550  }
22551
22552  _createClass(StylesXform, [{
22553    key: "initIndex",
22554    value: function initIndex() {
22555      this.index = {
22556        style: {},
22557        numFmt: {},
22558        numFmtNextId: 164,
22559        // start custom format ids here
22560        font: {},
22561        border: {},
22562        fill: {}
22563      };
22564    }
22565  }, {
22566    key: "init",
22567    value: function init() {
22568      // Prepare for Style Manager role
22569      this.model = {
22570        styles: [],
22571        numFmts: [],
22572        fonts: [],
22573        borders: [],
22574        fills: [],
22575        dxfs: []
22576      };
22577      this.initIndex(); // default (zero) border
22578
22579      this._addBorder({}); // add default (all zero) style
22580
22581
22582      this._addStyle({
22583        numFmtId: 0,
22584        fontId: 0,
22585        fillId: 0,
22586        borderId: 0,
22587        xfId: 0
22588      }); // add default fills
22589
22590
22591      this._addFill({
22592        type: 'pattern',
22593        pattern: 'none'
22594      });
22595
22596      this._addFill({
22597        type: 'pattern',
22598        pattern: 'gray125'
22599      });
22600
22601      this.weakMap = new WeakMap();
22602    }
22603  }, {
22604    key: "render",
22605    value: function render(xmlStream, model) {
22606      model = model || this.model; //
22607      //   <fonts count="2" x14ac:knownFonts="1">
22608
22609      xmlStream.openXml(XmlStream.StdDocAttributes);
22610      xmlStream.openNode('styleSheet', StylesXform.STYLESHEET_ATTRIBUTES);
22611
22612      if (this.index) {
22613        // model has been built by style manager role (contains xml)
22614        if (model.numFmts && model.numFmts.length) {
22615          xmlStream.openNode('numFmts', {
22616            count: model.numFmts.length
22617          });
22618          model.numFmts.forEach(function (numFmtXml) {
22619            xmlStream.writeXml(numFmtXml);
22620          });
22621          xmlStream.closeNode();
22622        }
22623
22624        if (!model.fonts.length) {
22625          // default (zero) font
22626          this._addFont({
22627            size: 11,
22628            color: {
22629              theme: 1
22630            },
22631            name: 'Calibri',
22632            family: 2,
22633            scheme: 'minor'
22634          });
22635        }
22636
22637        xmlStream.openNode('fonts', {
22638          count: model.fonts.length,
22639          'x14ac:knownFonts': 1
22640        });
22641        model.fonts.forEach(function (fontXml) {
22642          xmlStream.writeXml(fontXml);
22643        });
22644        xmlStream.closeNode();
22645        xmlStream.openNode('fills', {
22646          count: model.fills.length
22647        });
22648        model.fills.forEach(function (fillXml) {
22649          xmlStream.writeXml(fillXml);
22650        });
22651        xmlStream.closeNode();
22652        xmlStream.openNode('borders', {
22653          count: model.borders.length
22654        });
22655        model.borders.forEach(function (borderXml) {
22656          xmlStream.writeXml(borderXml);
22657        });
22658        xmlStream.closeNode();
22659        this.map.cellStyleXfs.render(xmlStream, [{
22660          numFmtId: 0,
22661          fontId: 0,
22662          fillId: 0,
22663          borderId: 0,
22664          xfId: 0
22665        }]);
22666        xmlStream.openNode('cellXfs', {
22667          count: model.styles.length
22668        });
22669        model.styles.forEach(function (styleXml) {
22670          xmlStream.writeXml(styleXml);
22671        });
22672        xmlStream.closeNode();
22673      } else {
22674        // model is plain JSON and needs to be xformed
22675        this.map.numFmts.render(xmlStream, model.numFmts);
22676        this.map.fonts.render(xmlStream, model.fonts);
22677        this.map.fills.render(xmlStream, model.fills);
22678        this.map.borders.render(xmlStream, model.borders);
22679        this.map.cellStyleXfs.render(xmlStream, [{
22680          numFmtId: 0,
22681          fontId: 0,
22682          fillId: 0,
22683          borderId: 0,
22684          xfId: 0
22685        }]);
22686        this.map.cellXfs.render(xmlStream, model.styles);
22687      }
22688
22689      StylesXform.STATIC_XFORMS.cellStyles.render(xmlStream);
22690      this.map.dxfs.render(xmlStream, model.dxfs);
22691      StylesXform.STATIC_XFORMS.tableStyles.render(xmlStream);
22692      StylesXform.STATIC_XFORMS.extLst.render(xmlStream);
22693      xmlStream.closeNode();
22694    }
22695  }, {
22696    key: "parseOpen",
22697    value: function parseOpen(node) {
22698      if (this.parser) {
22699        this.parser.parseOpen(node);
22700        return true;
22701      }
22702
22703      switch (node.name) {
22704        case 'styleSheet':
22705          this.initIndex();
22706          return true;
22707
22708        default:
22709          this.parser = this.map[node.name];
22710
22711          if (this.parser) {
22712            this.parser.parseOpen(node);
22713          }
22714
22715          return true;
22716      }
22717    }
22718  }, {
22719    key: "parseText",
22720    value: function parseText(text) {
22721      if (this.parser) {
22722        this.parser.parseText(text);
22723      }
22724    }
22725  }, {
22726    key: "parseClose",
22727    value: function parseClose(name) {
22728      var _this2 = this;
22729
22730      if (this.parser) {
22731        if (!this.parser.parseClose(name)) {
22732          this.parser = undefined;
22733        }
22734
22735        return true;
22736      }
22737
22738      switch (name) {
22739        case 'styleSheet':
22740          {
22741            this.model = {};
22742
22743            var add = function add(propName, xform) {
22744              if (xform.model && xform.model.length) {
22745                _this2.model[propName] = xform.model;
22746              }
22747            };
22748
22749            add('numFmts', this.map.numFmts);
22750            add('fonts', this.map.fonts);
22751            add('fills', this.map.fills);
22752            add('borders', this.map.borders);
22753            add('styles', this.map.cellXfs);
22754            add('dxfs', this.map.dxfs); // index numFmts
22755
22756            this.index = {
22757              model: [],
22758              numFmt: []
22759            };
22760
22761            if (this.model.numFmts) {
22762              var numFmtIndex = this.index.numFmt;
22763              this.model.numFmts.forEach(function (numFmt) {
22764                numFmtIndex[numFmt.id] = numFmt.formatCode;
22765              });
22766            }
22767
22768            return false;
22769          }
22770
22771        default:
22772          // not quite sure how we get here!
22773          return true;
22774      }
22775    } // add a cell's style model to the collection
22776    // each style property is processed and cross-referenced, etc.
22777    // the styleId is returned. Note: cellType is used when numFmt not defined
22778
22779  }, {
22780    key: "addStyleModel",
22781    value: function addStyleModel(model, cellType) {
22782      if (!model) {
22783        return 0;
22784      } // if we have no default font, add it here now
22785
22786
22787      if (!this.model.fonts.length) {
22788        // default (zero) font
22789        this._addFont({
22790          size: 11,
22791          color: {
22792            theme: 1
22793          },
22794          name: 'Calibri',
22795          family: 2,
22796          scheme: 'minor'
22797        });
22798      } // if we have seen this style object before, assume it has the same styleId
22799
22800
22801      if (this.weakMap && this.weakMap.has(model)) {
22802        return this.weakMap.get(model);
22803      }
22804
22805      var style = {};
22806      cellType = cellType || Enums.ValueType.Number;
22807
22808      if (model.numFmt) {
22809        style.numFmtId = this._addNumFmtStr(model.numFmt);
22810      } else {
22811        switch (cellType) {
22812          case Enums.ValueType.Number:
22813            style.numFmtId = this._addNumFmtStr('General');
22814            break;
22815
22816          case Enums.ValueType.Date:
22817            style.numFmtId = this._addNumFmtStr('mm-dd-yy');
22818            break;
22819
22820          default:
22821            break;
22822        }
22823      }
22824
22825      if (model.font) {
22826        style.fontId = this._addFont(model.font);
22827      }
22828
22829      if (model.border) {
22830        style.borderId = this._addBorder(model.border);
22831      }
22832
22833      if (model.fill) {
22834        style.fillId = this._addFill(model.fill);
22835      }
22836
22837      if (model.alignment) {
22838        style.alignment = model.alignment;
22839      }
22840
22841      if (model.protection) {
22842        style.protection = model.protection;
22843      }
22844
22845      var styleId = this._addStyle(style);
22846
22847      if (this.weakMap) {
22848        this.weakMap.set(model, styleId);
22849      }
22850
22851      return styleId;
22852    } // given a styleId (i.e. s="n"), get the cell's style model
22853    // objects are shared where possible.
22854
22855  }, {
22856    key: "getStyleModel",
22857    value: function getStyleModel(id) {
22858      // if the style doesn't exist return null
22859      var style = this.model.styles[id];
22860      if (!style) return null; // have we built this model before?
22861
22862      var model = this.index.model[id];
22863      if (model) return model; // build a new model
22864
22865      model = this.index.model[id] = {}; // -------------------------------------------------------
22866      // number format
22867
22868      if (style.numFmtId) {
22869        var numFmt = this.index.numFmt[style.numFmtId] || NumFmtXform.getDefaultFmtCode(style.numFmtId);
22870
22871        if (numFmt) {
22872          model.numFmt = numFmt;
22873        }
22874      }
22875
22876      function addStyle(name, group, styleId) {
22877        if (styleId || styleId === 0) {
22878          var part = group[styleId];
22879
22880          if (part) {
22881            model[name] = part;
22882          }
22883        }
22884      }
22885
22886      addStyle('font', this.model.fonts, style.fontId);
22887      addStyle('border', this.model.borders, style.borderId);
22888      addStyle('fill', this.model.fills, style.fillId); // -------------------------------------------------------
22889      // alignment
22890
22891      if (style.alignment) {
22892        model.alignment = style.alignment;
22893      } // -------------------------------------------------------
22894      // protection
22895
22896
22897      if (style.protection) {
22898        model.protection = style.protection;
22899      }
22900
22901      return model;
22902    }
22903  }, {
22904    key: "addDxfStyle",
22905    value: function addDxfStyle(style) {
22906      this.model.dxfs.push(style);
22907      return this.model.dxfs.length - 1;
22908    }
22909  }, {
22910    key: "getDxfStyle",
22911    value: function getDxfStyle(id) {
22912      return this.model.dxfs[id];
22913    } // =========================================================================
22914    // Private Interface
22915
22916  }, {
22917    key: "_addStyle",
22918    value: function _addStyle(style) {
22919      var xml = this.map.style.toXml(style);
22920      var index = this.index.style[xml];
22921
22922      if (index === undefined) {
22923        index = this.index.style[xml] = this.model.styles.length;
22924        this.model.styles.push(xml);
22925      }
22926
22927      return index;
22928    } // =========================================================================
22929    // Number Formats
22930
22931  }, {
22932    key: "_addNumFmtStr",
22933    value: function _addNumFmtStr(formatCode) {
22934      // check if default format
22935      var index = NumFmtXform.getDefaultFmtId(formatCode);
22936      if (index !== undefined) return index; // check if already in
22937
22938      index = this.index.numFmt[formatCode];
22939      if (index !== undefined) return index;
22940      index = this.index.numFmt[formatCode] = NUMFMT_BASE + this.model.numFmts.length;
22941      var xml = this.map.numFmt.toXml({
22942        id: index,
22943        formatCode: formatCode
22944      });
22945      this.model.numFmts.push(xml);
22946      return index;
22947    } // =========================================================================
22948    // Fonts
22949
22950  }, {
22951    key: "_addFont",
22952    value: function _addFont(font) {
22953      var xml = this.map.font.toXml(font);
22954      var index = this.index.font[xml];
22955
22956      if (index === undefined) {
22957        index = this.index.font[xml] = this.model.fonts.length;
22958        this.model.fonts.push(xml);
22959      }
22960
22961      return index;
22962    } // =========================================================================
22963    // Borders
22964
22965  }, {
22966    key: "_addBorder",
22967    value: function _addBorder(border) {
22968      var xml = this.map.border.toXml(border);
22969      var index = this.index.border[xml];
22970
22971      if (index === undefined) {
22972        index = this.index.border[xml] = this.model.borders.length;
22973        this.model.borders.push(xml);
22974      }
22975
22976      return index;
22977    } // =========================================================================
22978    // Fills
22979
22980  }, {
22981    key: "_addFill",
22982    value: function _addFill(fill) {
22983      var xml = this.map.fill.toXml(fill);
22984      var index = this.index.fill[xml];
22985
22986      if (index === undefined) {
22987        index = this.index.fill[xml] = this.model.fills.length;
22988        this.model.fills.push(xml);
22989      }
22990
22991      return index;
22992    } // =========================================================================
22993
22994  }]);
22995
22996  return StylesXform;
22997}(BaseXform);
22998
22999StylesXform.STYLESHEET_ATTRIBUTES = {
23000  xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
23001  'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
23002  'mc:Ignorable': 'x14ac x16r2',
23003  'xmlns:x14ac': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac',
23004  'xmlns:x16r2': 'http://schemas.microsoft.com/office/spreadsheetml/2015/02/main'
23005};
23006StylesXform.STATIC_XFORMS = {
23007  cellStyles: new StaticXform({
23008    tag: 'cellStyles',
23009    $: {
23010      count: 1
23011    },
23012    c: [{
23013      tag: 'cellStyle',
23014      $: {
23015        name: 'Normal',
23016        xfId: 0,
23017        builtinId: 0
23018      }
23019    }]
23020  }),
23021  dxfs: new StaticXform({
23022    tag: 'dxfs',
23023    $: {
23024      count: 0
23025    }
23026  }),
23027  tableStyles: new StaticXform({
23028    tag: 'tableStyles',
23029    $: {
23030      count: 0,
23031      defaultTableStyle: 'TableStyleMedium2',
23032      defaultPivotStyle: 'PivotStyleLight16'
23033    }
23034  }),
23035  extLst: new StaticXform({
23036    tag: 'extLst',
23037    c: [{
23038      tag: 'ext',
23039      $: {
23040        uri: '{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}',
23041        'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main'
23042      },
23043      c: [{
23044        tag: 'x14:slicerStyles',
23045        $: {
23046          defaultSlicerStyle: 'SlicerStyleLight1'
23047        }
23048      }]
23049    }, {
23050      tag: 'ext',
23051      $: {
23052        uri: '{9260A510-F301-46a8-8635-F512D64BE5F5}',
23053        'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'
23054      },
23055      c: [{
23056        tag: 'x15:timelineStyles',
23057        $: {
23058          defaultTimelineStyle: 'TimeSlicerStyleLight1'
23059        }
23060      }]
23061    }]
23062  })
23063}; // the stylemanager mock acts like StyleManager except that it always returns 0 or {}
23064
23065var StylesXformMock = /*#__PURE__*/function (_StylesXform) {
23066  _inherits(StylesXformMock, _StylesXform);
23067
23068  var _super2 = _createSuper(StylesXformMock);
23069
23070  function StylesXformMock() {
23071    var _this3;
23072
23073    _classCallCheck(this, StylesXformMock);
23074
23075    _this3 = _super2.call(this);
23076    _this3.model = {
23077      styles: [{
23078        numFmtId: 0,
23079        fontId: 0,
23080        fillId: 0,
23081        borderId: 0,
23082        xfId: 0
23083      }],
23084      numFmts: [],
23085      fonts: [{
23086        size: 11,
23087        color: {
23088          theme: 1
23089        },
23090        name: 'Calibri',
23091        family: 2,
23092        scheme: 'minor'
23093      }],
23094      borders: [{}],
23095      fills: [{
23096        type: 'pattern',
23097        pattern: 'none'
23098      }, {
23099        type: 'pattern',
23100        pattern: 'gray125'
23101      }]
23102    };
23103    return _this3;
23104  } // =========================================================================
23105  // Style Manager Interface
23106  // override normal behaviour - consume and dispose
23107
23108
23109  _createClass(StylesXformMock, [{
23110    key: "parseStream",
23111    value: function parseStream(stream) {
23112      stream.autodrain();
23113      return Promise.resolve();
23114    } // add a cell's style model to the collection
23115    // each style property is processed and cross-referenced, etc.
23116    // the styleId is returned. Note: cellType is used when numFmt not defined
23117
23118  }, {
23119    key: "addStyleModel",
23120    value: function addStyleModel(model, cellType) {
23121      switch (cellType) {
23122        case Enums.ValueType.Date:
23123          return this.dateStyleId;
23124
23125        default:
23126          return 0;
23127      }
23128    }
23129  }, {
23130    key: "getStyleModel",
23131    // given a styleId (i.e. s="n"), get the cell's style model
23132    // objects are shared where possible.
23133    value: function getStyleModel()
23134    /* id */
23135    {
23136      return {};
23137    }
23138  }, {
23139    key: "dateStyleId",
23140    get: function get() {
23141      if (!this._dateStyleId) {
23142        var dateStyle = {
23143          numFmtId: NumFmtXform.getDefaultFmtId('mm-dd-yy')
23144        };
23145        this._dateStyleId = this.model.styles.length;
23146        this.model.styles.push(dateStyle);
23147      }
23148
23149      return this._dateStyleId;
23150    }
23151  }]);
23152
23153  return StylesXformMock;
23154}(StylesXform);
23155
23156StylesXform.Mock = StylesXformMock;
23157module.exports = StylesXform;
23158
23159},{"../../../doc/enums":7,"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"../static-xform":119,"./border-xform":126,"./dxf-xform":128,"./fill-xform":129,"./font-xform":130,"./numfmt-xform":131,"./style-xform":133}],135:[function(require,module,exports){
23160"use strict";
23161
23162function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23163
23164function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23165
23166function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23167
23168function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23169
23170function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
23171
23172function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23173
23174function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23175
23176function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23177
23178function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23179
23180function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
23181
23182function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23183
23184var BaseXform = require('../base-xform');
23185
23186var UnderlineXform = /*#__PURE__*/function (_BaseXform) {
23187  _inherits(UnderlineXform, _BaseXform);
23188
23189  var _super = _createSuper(UnderlineXform);
23190
23191  function UnderlineXform(model) {
23192    var _this;
23193
23194    _classCallCheck(this, UnderlineXform);
23195
23196    _this = _super.call(this);
23197    _this.model = model;
23198    return _this;
23199  }
23200
23201  _createClass(UnderlineXform, [{
23202    key: "render",
23203    value: function render(xmlStream, model) {
23204      model = model || this.model;
23205
23206      if (model === true) {
23207        xmlStream.leafNode('u');
23208      } else {
23209        var attr = UnderlineXform.Attributes[model];
23210
23211        if (attr) {
23212          xmlStream.leafNode('u', attr);
23213        }
23214      }
23215    }
23216  }, {
23217    key: "parseOpen",
23218    value: function parseOpen(node) {
23219      if (node.name === 'u') {
23220        this.model = node.attributes.val || true;
23221      }
23222    }
23223  }, {
23224    key: "parseText",
23225    value: function parseText() {}
23226  }, {
23227    key: "parseClose",
23228    value: function parseClose() {
23229      return false;
23230    }
23231  }, {
23232    key: "tag",
23233    get: function get() {
23234      return 'u';
23235    }
23236  }]);
23237
23238  return UnderlineXform;
23239}(BaseXform);
23240
23241UnderlineXform.Attributes = {
23242  single: {},
23243  double: {
23244    val: 'double'
23245  },
23246  singleAccounting: {
23247    val: 'singleAccounting'
23248  },
23249  doubleAccounting: {
23250    val: 'doubleAccounting'
23251  }
23252};
23253module.exports = UnderlineXform;
23254
23255},{"../base-xform":31}],136:[function(require,module,exports){
23256"use strict";
23257
23258function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23259
23260function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23261
23262function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23263
23264function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23265
23266function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
23267
23268function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23269
23270function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23271
23272function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23273
23274function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23275
23276function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
23277
23278function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23279
23280var BaseXform = require('../base-xform');
23281
23282var FilterColumnXform = require('./filter-column-xform');
23283
23284var AutoFilterXform = /*#__PURE__*/function (_BaseXform) {
23285  _inherits(AutoFilterXform, _BaseXform);
23286
23287  var _super = _createSuper(AutoFilterXform);
23288
23289  function AutoFilterXform() {
23290    var _this;
23291
23292    _classCallCheck(this, AutoFilterXform);
23293
23294    _this = _super.call(this);
23295    _this.map = {
23296      filterColumn: new FilterColumnXform()
23297    };
23298    return _this;
23299  }
23300
23301  _createClass(AutoFilterXform, [{
23302    key: "prepare",
23303    value: function prepare(model) {
23304      var _this2 = this;
23305
23306      model.columns.forEach(function (column, index) {
23307        _this2.map.filterColumn.prepare(column, {
23308          index: index
23309        });
23310      });
23311    }
23312  }, {
23313    key: "render",
23314    value: function render(xmlStream, model) {
23315      var _this3 = this;
23316
23317      xmlStream.openNode(this.tag, {
23318        ref: model.autoFilterRef
23319      });
23320      model.columns.forEach(function (column) {
23321        _this3.map.filterColumn.render(xmlStream, column);
23322      });
23323      xmlStream.closeNode();
23324      return true;
23325    }
23326  }, {
23327    key: "parseOpen",
23328    value: function parseOpen(node) {
23329      if (this.parser) {
23330        this.parser.parseOpen(node);
23331        return true;
23332      }
23333
23334      switch (node.name) {
23335        case this.tag:
23336          this.model = {
23337            autoFilterRef: node.attributes.ref,
23338            columns: []
23339          };
23340          return true;
23341
23342        default:
23343          this.parser = this.map[node.name];
23344
23345          if (this.parser) {
23346            this.parseOpen(node);
23347            return true;
23348          }
23349
23350          throw new Error("Unexpected xml node in parseOpen: ".concat(JSON.stringify(node)));
23351      }
23352    }
23353  }, {
23354    key: "parseText",
23355    value: function parseText(text) {
23356      if (this.parser) {
23357        this.parser.parseText(text);
23358      }
23359    }
23360  }, {
23361    key: "parseClose",
23362    value: function parseClose(name) {
23363      if (this.parser) {
23364        if (!this.parser.parseClose(name)) {
23365          this.model.columns.push(this.parser.model);
23366          this.parser = undefined;
23367        }
23368
23369        return true;
23370      }
23371
23372      switch (name) {
23373        case this.tag:
23374          return false;
23375
23376        default:
23377          throw new Error("Unexpected xml node in parseClose: ".concat(name));
23378      }
23379    }
23380  }, {
23381    key: "tag",
23382    get: function get() {
23383      return 'autoFilter';
23384    }
23385  }]);
23386
23387  return AutoFilterXform;
23388}(BaseXform);
23389
23390module.exports = AutoFilterXform;
23391
23392},{"../base-xform":31,"./filter-column-xform":137}],137:[function(require,module,exports){
23393"use strict";
23394
23395function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23396
23397function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23398
23399function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23400
23401function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23402
23403function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
23404
23405function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23406
23407function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23408
23409function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23410
23411function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23412
23413function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
23414
23415function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23416
23417var BaseXform = require('../base-xform');
23418
23419var FilterColumnXform = /*#__PURE__*/function (_BaseXform) {
23420  _inherits(FilterColumnXform, _BaseXform);
23421
23422  var _super = _createSuper(FilterColumnXform);
23423
23424  function FilterColumnXform() {
23425    _classCallCheck(this, FilterColumnXform);
23426
23427    return _super.apply(this, arguments);
23428  }
23429
23430  _createClass(FilterColumnXform, [{
23431    key: "prepare",
23432    value: function prepare(model, options) {
23433      model.colId = options.index.toString();
23434    }
23435  }, {
23436    key: "render",
23437    value: function render(xmlStream, model) {
23438      xmlStream.leafNode(this.tag, {
23439        colId: model.colId,
23440        hiddenButton: model.filterButton ? '0' : '1'
23441      });
23442      return true;
23443    }
23444  }, {
23445    key: "parseOpen",
23446    value: function parseOpen(node) {
23447      if (node.name === this.tag) {
23448        var attributes = node.attributes;
23449        this.model = {
23450          filterButton: attributes.hiddenButton === '0'
23451        };
23452        return true;
23453      }
23454
23455      return false;
23456    }
23457  }, {
23458    key: "parseText",
23459    value: function parseText() {}
23460  }, {
23461    key: "parseClose",
23462    value: function parseClose() {
23463      return false;
23464    }
23465  }, {
23466    key: "tag",
23467    get: function get() {
23468      return 'filterColumn';
23469    }
23470  }]);
23471
23472  return FilterColumnXform;
23473}(BaseXform);
23474
23475module.exports = FilterColumnXform;
23476
23477},{"../base-xform":31}],138:[function(require,module,exports){
23478"use strict";
23479
23480function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23481
23482function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23483
23484function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23485
23486function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23487
23488function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
23489
23490function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23491
23492function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23493
23494function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23495
23496function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23497
23498function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
23499
23500function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23501
23502var BaseXform = require('../base-xform');
23503
23504var TableColumnXform = /*#__PURE__*/function (_BaseXform) {
23505  _inherits(TableColumnXform, _BaseXform);
23506
23507  var _super = _createSuper(TableColumnXform);
23508
23509  function TableColumnXform() {
23510    _classCallCheck(this, TableColumnXform);
23511
23512    return _super.apply(this, arguments);
23513  }
23514
23515  _createClass(TableColumnXform, [{
23516    key: "prepare",
23517    value: function prepare(model, options) {
23518      model.id = options.index + 1;
23519    }
23520  }, {
23521    key: "render",
23522    value: function render(xmlStream, model) {
23523      xmlStream.leafNode(this.tag, {
23524        id: model.id.toString(),
23525        name: model.name,
23526        totalsRowLabel: model.totalsRowLabel,
23527        totalsRowFunction: model.totalsRowFunction,
23528        dxfId: model.dxfId
23529      });
23530      return true;
23531    }
23532  }, {
23533    key: "parseOpen",
23534    value: function parseOpen(node) {
23535      if (node.name === this.tag) {
23536        var attributes = node.attributes;
23537        this.model = {
23538          name: attributes.name,
23539          totalsRowLabel: attributes.totalsRowLabel,
23540          totalsRowFunction: attributes.totalsRowFunction,
23541          dxfId: attributes.dxfId
23542        };
23543        return true;
23544      }
23545
23546      return false;
23547    }
23548  }, {
23549    key: "parseText",
23550    value: function parseText() {}
23551  }, {
23552    key: "parseClose",
23553    value: function parseClose() {
23554      return false;
23555    }
23556  }, {
23557    key: "tag",
23558    get: function get() {
23559      return 'tableColumn';
23560    }
23561  }]);
23562
23563  return TableColumnXform;
23564}(BaseXform);
23565
23566module.exports = TableColumnXform;
23567
23568},{"../base-xform":31}],139:[function(require,module,exports){
23569"use strict";
23570
23571function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23572
23573function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23574
23575function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23576
23577function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23578
23579function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
23580
23581function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23582
23583function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23584
23585function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23586
23587function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23588
23589function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
23590
23591function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23592
23593var BaseXform = require('../base-xform');
23594
23595var TableStyleInfoXform = /*#__PURE__*/function (_BaseXform) {
23596  _inherits(TableStyleInfoXform, _BaseXform);
23597
23598  var _super = _createSuper(TableStyleInfoXform);
23599
23600  function TableStyleInfoXform() {
23601    _classCallCheck(this, TableStyleInfoXform);
23602
23603    return _super.apply(this, arguments);
23604  }
23605
23606  _createClass(TableStyleInfoXform, [{
23607    key: "render",
23608    value: function render(xmlStream, model) {
23609      xmlStream.leafNode(this.tag, {
23610        name: model.theme ? model.theme : undefined,
23611        showFirstColumn: model.showFirstColumn ? '1' : '0',
23612        showLastColumn: model.showLastColumn ? '1' : '0',
23613        showRowStripes: model.showRowStripes ? '1' : '0',
23614        showColumnStripes: model.showColumnStripes ? '1' : '0'
23615      });
23616      return true;
23617    }
23618  }, {
23619    key: "parseOpen",
23620    value: function parseOpen(node) {
23621      if (node.name === this.tag) {
23622        var attributes = node.attributes;
23623        this.model = {
23624          theme: attributes.name ? attributes.name : null,
23625          showFirstColumn: attributes.showFirstColumn === '1',
23626          showLastColumn: attributes.showLastColumn === '1',
23627          showRowStripes: attributes.showRowStripes === '1',
23628          showColumnStripes: attributes.showColumnStripes === '1'
23629        };
23630        return true;
23631      }
23632
23633      return false;
23634    }
23635  }, {
23636    key: "parseText",
23637    value: function parseText() {}
23638  }, {
23639    key: "parseClose",
23640    value: function parseClose() {
23641      return false;
23642    }
23643  }, {
23644    key: "tag",
23645    get: function get() {
23646      return 'tableStyleInfo';
23647    }
23648  }]);
23649
23650  return TableStyleInfoXform;
23651}(BaseXform);
23652
23653module.exports = TableStyleInfoXform;
23654
23655},{"../base-xform":31}],140:[function(require,module,exports){
23656"use strict";
23657
23658function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23659
23660function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
23661
23662function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23663
23664function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23665
23666function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23667
23668function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23669
23670function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23671
23672function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
23673
23674function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23675
23676function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23677
23678function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23679
23680function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23681
23682function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
23683
23684function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23685
23686var XmlStream = require('../../../utils/xml-stream');
23687
23688var BaseXform = require('../base-xform');
23689
23690var ListXform = require('../list-xform');
23691
23692var AutoFilterXform = require('./auto-filter-xform');
23693
23694var TableColumnXform = require('./table-column-xform');
23695
23696var TableStyleInfoXform = require('./table-style-info-xform');
23697
23698var TableXform = /*#__PURE__*/function (_BaseXform) {
23699  _inherits(TableXform, _BaseXform);
23700
23701  var _super = _createSuper(TableXform);
23702
23703  function TableXform() {
23704    var _this;
23705
23706    _classCallCheck(this, TableXform);
23707
23708    _this = _super.call(this);
23709    _this.map = {
23710      autoFilter: new AutoFilterXform(),
23711      tableColumns: new ListXform({
23712        tag: 'tableColumns',
23713        count: true,
23714        empty: true,
23715        childXform: new TableColumnXform()
23716      }),
23717      tableStyleInfo: new TableStyleInfoXform()
23718    };
23719    return _this;
23720  }
23721
23722  _createClass(TableXform, [{
23723    key: "prepare",
23724    value: function prepare(model, options) {
23725      this.map.autoFilter.prepare(model);
23726      this.map.tableColumns.prepare(model.columns, options);
23727    }
23728  }, {
23729    key: "render",
23730    value: function render(xmlStream, model) {
23731      xmlStream.openXml(XmlStream.StdDocAttributes);
23732      xmlStream.openNode(this.tag, _objectSpread(_objectSpread({}, TableXform.TABLE_ATTRIBUTES), {}, {
23733        id: model.id,
23734        name: model.name,
23735        displayName: model.displayName || model.name,
23736        ref: model.tableRef,
23737        totalsRowCount: model.totalsRow ? '1' : undefined,
23738        totalsRowShown: model.totalsRow ? undefined : '1',
23739        headerRowCount: model.headerRow ? '1' : '0'
23740      }));
23741      this.map.autoFilter.render(xmlStream, model);
23742      this.map.tableColumns.render(xmlStream, model.columns);
23743      this.map.tableStyleInfo.render(xmlStream, model.style);
23744      xmlStream.closeNode();
23745    }
23746  }, {
23747    key: "parseOpen",
23748    value: function parseOpen(node) {
23749      if (this.parser) {
23750        this.parser.parseOpen(node);
23751        return true;
23752      }
23753
23754      var name = node.name,
23755          attributes = node.attributes;
23756
23757      switch (name) {
23758        case this.tag:
23759          this.reset();
23760          this.model = {
23761            name: attributes.name,
23762            displayName: attributes.displayName || attributes.name,
23763            tableRef: attributes.ref,
23764            totalsRow: attributes.totalsRowCount === '1',
23765            headerRow: attributes.headerRowCount === '1'
23766          };
23767          break;
23768
23769        default:
23770          this.parser = this.map[node.name];
23771
23772          if (this.parser) {
23773            this.parser.parseOpen(node);
23774          }
23775
23776          break;
23777      }
23778
23779      return true;
23780    }
23781  }, {
23782    key: "parseText",
23783    value: function parseText(text) {
23784      if (this.parser) {
23785        this.parser.parseText(text);
23786      }
23787    }
23788  }, {
23789    key: "parseClose",
23790    value: function parseClose(name) {
23791      var _this2 = this;
23792
23793      if (this.parser) {
23794        if (!this.parser.parseClose(name)) {
23795          this.parser = undefined;
23796        }
23797
23798        return true;
23799      }
23800
23801      switch (name) {
23802        case this.tag:
23803          this.model.columns = this.map.tableColumns.model;
23804
23805          if (this.map.autoFilter.model) {
23806            this.model.autoFilterRef = this.map.autoFilter.model.autoFilterRef;
23807            this.map.autoFilter.model.columns.forEach(function (column, index) {
23808              _this2.model.columns[index].filterButton = column.filterButton;
23809            });
23810          }
23811
23812          this.model.style = this.map.tableStyleInfo.model;
23813          return false;
23814
23815        default:
23816          // could be some unrecognised tags
23817          return true;
23818      }
23819    }
23820  }, {
23821    key: "reconcile",
23822    value: function reconcile(model, options) {
23823      // fetch the dfxs from styles
23824      model.columns.forEach(function (column) {
23825        if (column.dxfId !== undefined) {
23826          column.style = options.styles.getDxfStyle(column.dxfId);
23827        }
23828      });
23829    }
23830  }, {
23831    key: "tag",
23832    get: function get() {
23833      return 'table';
23834    }
23835  }]);
23836
23837  return TableXform;
23838}(BaseXform);
23839
23840TableXform.TABLE_ATTRIBUTES = {
23841  xmlns: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
23842  'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
23843  'mc:Ignorable': 'xr xr3',
23844  'xmlns:xr': 'http://schemas.microsoft.com/office/spreadsheetml/2014/revision',
23845  'xmlns:xr3': 'http://schemas.microsoft.com/office/spreadsheetml/2016/revision3' // 'xr:uid': '{00000000-000C-0000-FFFF-FFFF00000000}',
23846
23847};
23848module.exports = TableXform;
23849
23850},{"../../../utils/xml-stream":27,"../base-xform":31,"../list-xform":70,"./auto-filter-xform":136,"./table-column-xform":138,"./table-style-info-xform":139}],141:[function(require,module,exports){
23851(function (process,Buffer){
23852"use strict";
23853
23854function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
23855
23856function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
23857
23858function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23859
23860function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23861
23862function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23863
23864function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); }
23865
23866var fs = require('fs');
23867
23868var JSZip = require('jszip');
23869
23870var _require = require('readable-stream'),
23871    PassThrough = _require.PassThrough;
23872
23873var ZipStream = require('../utils/zip-stream');
23874
23875var StreamBuf = require('../utils/stream-buf');
23876
23877var utils = require('../utils/utils');
23878
23879var XmlStream = require('../utils/xml-stream');
23880
23881var _require2 = require('../utils/browser-buffer-decode'),
23882    bufferToString = _require2.bufferToString;
23883
23884var StylesXform = require('./xform/style/styles-xform');
23885
23886var CoreXform = require('./xform/core/core-xform');
23887
23888var SharedStringsXform = require('./xform/strings/shared-strings-xform');
23889
23890var RelationshipsXform = require('./xform/core/relationships-xform');
23891
23892var ContentTypesXform = require('./xform/core/content-types-xform');
23893
23894var AppXform = require('./xform/core/app-xform');
23895
23896var WorkbookXform = require('./xform/book/workbook-xform');
23897
23898var WorksheetXform = require('./xform/sheet/worksheet-xform');
23899
23900var DrawingXform = require('./xform/drawing/drawing-xform');
23901
23902var TableXform = require('./xform/table/table-xform');
23903
23904var CommentsXform = require('./xform/comment/comments-xform');
23905
23906var VmlNotesXform = require('./xform/comment/vml-notes-xform');
23907
23908var theme1Xml = require('./xml/theme1.js');
23909
23910function fsReadFileAsync(filename, options) {
23911  return new Promise(function (resolve, reject) {
23912    fs.readFile(filename, options, function (error, data) {
23913      if (error) {
23914        reject(error);
23915      } else {
23916        resolve(data);
23917      }
23918    });
23919  });
23920}
23921
23922var XLSX = /*#__PURE__*/function () {
23923  function XLSX(workbook) {
23924    _classCallCheck(this, XLSX);
23925
23926    this.workbook = workbook;
23927  } // ===============================================================================
23928  // Workbook
23929  // =========================================================================
23930  // Read
23931
23932
23933  _createClass(XLSX, [{
23934    key: "readFile",
23935    value: function () {
23936      var _readFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(filename, options) {
23937        var stream, workbook;
23938        return regeneratorRuntime.wrap(function _callee$(_context) {
23939          while (1) {
23940            switch (_context.prev = _context.next) {
23941              case 0:
23942                _context.next = 2;
23943                return utils.fs.exists(filename);
23944
23945              case 2:
23946                if (_context.sent) {
23947                  _context.next = 4;
23948                  break;
23949                }
23950
23951                throw new Error("File not found: ".concat(filename));
23952
23953              case 4:
23954                stream = fs.createReadStream(filename);
23955                _context.prev = 5;
23956                _context.next = 8;
23957                return this.read(stream, options);
23958
23959              case 8:
23960                workbook = _context.sent;
23961                stream.close();
23962                return _context.abrupt("return", workbook);
23963
23964              case 13:
23965                _context.prev = 13;
23966                _context.t0 = _context["catch"](5);
23967                stream.close();
23968                throw _context.t0;
23969
23970              case 17:
23971              case "end":
23972                return _context.stop();
23973            }
23974          }
23975        }, _callee, this, [[5, 13]]);
23976      }));
23977
23978      function readFile(_x, _x2) {
23979        return _readFile.apply(this, arguments);
23980      }
23981
23982      return readFile;
23983    }()
23984  }, {
23985    key: "parseRels",
23986    value: function parseRels(stream) {
23987      var xform = new RelationshipsXform();
23988      return xform.parseStream(stream);
23989    }
23990  }, {
23991    key: "parseWorkbook",
23992    value: function parseWorkbook(stream) {
23993      var xform = new WorkbookXform();
23994      return xform.parseStream(stream);
23995    }
23996  }, {
23997    key: "parseSharedStrings",
23998    value: function parseSharedStrings(stream) {
23999      var xform = new SharedStringsXform();
24000      return xform.parseStream(stream);
24001    }
24002  }, {
24003    key: "reconcile",
24004    value: function reconcile(model, options) {
24005      var workbookXform = new WorkbookXform();
24006      var worksheetXform = new WorksheetXform(options);
24007      var drawingXform = new DrawingXform();
24008      var tableXform = new TableXform();
24009      workbookXform.reconcile(model); // reconcile drawings with their rels
24010
24011      var drawingOptions = {
24012        media: model.media,
24013        mediaIndex: model.mediaIndex
24014      };
24015      Object.keys(model.drawings).forEach(function (name) {
24016        var drawing = model.drawings[name];
24017        var drawingRel = model.drawingRels[name];
24018
24019        if (drawingRel) {
24020          drawingOptions.rels = drawingRel.reduce(function (o, rel) {
24021            o[rel.Id] = rel;
24022            return o;
24023          }, {});
24024          (drawing.anchors || []).forEach(function (anchor) {
24025            var hyperlinks = anchor.picture && anchor.picture.hyperlinks;
24026
24027            if (hyperlinks && drawingOptions.rels[hyperlinks.rId]) {
24028              hyperlinks.hyperlink = drawingOptions.rels[hyperlinks.rId].Target;
24029              delete hyperlinks.rId;
24030            }
24031          });
24032          drawingXform.reconcile(drawing, drawingOptions);
24033        }
24034      }); // reconcile tables with the default styles
24035
24036      var tableOptions = {
24037        styles: model.styles
24038      };
24039      Object.values(model.tables).forEach(function (table) {
24040        tableXform.reconcile(table, tableOptions);
24041      });
24042      var sheetOptions = {
24043        styles: model.styles,
24044        sharedStrings: model.sharedStrings,
24045        media: model.media,
24046        mediaIndex: model.mediaIndex,
24047        date1904: model.properties && model.properties.date1904,
24048        drawings: model.drawings,
24049        comments: model.comments,
24050        tables: model.tables,
24051        vmlDrawings: model.vmlDrawings
24052      };
24053      model.worksheets.forEach(function (worksheet) {
24054        worksheet.relationships = model.worksheetRels[worksheet.sheetNo];
24055        worksheetXform.reconcile(worksheet, sheetOptions);
24056      }); // delete unnecessary parts
24057
24058      delete model.worksheetHash;
24059      delete model.worksheetRels;
24060      delete model.globalRels;
24061      delete model.sharedStrings;
24062      delete model.workbookRels;
24063      delete model.sheetDefs;
24064      delete model.styles;
24065      delete model.mediaIndex;
24066      delete model.drawings;
24067      delete model.drawingRels;
24068      delete model.vmlDrawings;
24069    }
24070  }, {
24071    key: "_processWorksheetEntry",
24072    value: function () {
24073      var _processWorksheetEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(stream, model, sheetNo, options, path) {
24074        var xform, worksheet;
24075        return regeneratorRuntime.wrap(function _callee2$(_context2) {
24076          while (1) {
24077            switch (_context2.prev = _context2.next) {
24078              case 0:
24079                xform = new WorksheetXform(options);
24080                _context2.next = 3;
24081                return xform.parseStream(stream);
24082
24083              case 3:
24084                worksheet = _context2.sent;
24085                worksheet.sheetNo = sheetNo;
24086                model.worksheetHash[path] = worksheet;
24087                model.worksheets.push(worksheet);
24088
24089              case 7:
24090              case "end":
24091                return _context2.stop();
24092            }
24093          }
24094        }, _callee2);
24095      }));
24096
24097      function _processWorksheetEntry(_x3, _x4, _x5, _x6, _x7) {
24098        return _processWorksheetEntry2.apply(this, arguments);
24099      }
24100
24101      return _processWorksheetEntry;
24102    }()
24103  }, {
24104    key: "_processCommentEntry",
24105    value: function () {
24106      var _processCommentEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(stream, model, name) {
24107        var xform, comments;
24108        return regeneratorRuntime.wrap(function _callee3$(_context3) {
24109          while (1) {
24110            switch (_context3.prev = _context3.next) {
24111              case 0:
24112                xform = new CommentsXform();
24113                _context3.next = 3;
24114                return xform.parseStream(stream);
24115
24116              case 3:
24117                comments = _context3.sent;
24118                model.comments["../".concat(name, ".xml")] = comments;
24119
24120              case 5:
24121              case "end":
24122                return _context3.stop();
24123            }
24124          }
24125        }, _callee3);
24126      }));
24127
24128      function _processCommentEntry(_x8, _x9, _x10) {
24129        return _processCommentEntry2.apply(this, arguments);
24130      }
24131
24132      return _processCommentEntry;
24133    }()
24134  }, {
24135    key: "_processTableEntry",
24136    value: function () {
24137      var _processTableEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(stream, model, name) {
24138        var xform, table;
24139        return regeneratorRuntime.wrap(function _callee4$(_context4) {
24140          while (1) {
24141            switch (_context4.prev = _context4.next) {
24142              case 0:
24143                xform = new TableXform();
24144                _context4.next = 3;
24145                return xform.parseStream(stream);
24146
24147              case 3:
24148                table = _context4.sent;
24149                model.tables["../tables/".concat(name, ".xml")] = table;
24150
24151              case 5:
24152              case "end":
24153                return _context4.stop();
24154            }
24155          }
24156        }, _callee4);
24157      }));
24158
24159      function _processTableEntry(_x11, _x12, _x13) {
24160        return _processTableEntry2.apply(this, arguments);
24161      }
24162
24163      return _processTableEntry;
24164    }()
24165  }, {
24166    key: "_processWorksheetRelsEntry",
24167    value: function () {
24168      var _processWorksheetRelsEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(stream, model, sheetNo) {
24169        var xform, relationships;
24170        return regeneratorRuntime.wrap(function _callee5$(_context5) {
24171          while (1) {
24172            switch (_context5.prev = _context5.next) {
24173              case 0:
24174                xform = new RelationshipsXform();
24175                _context5.next = 3;
24176                return xform.parseStream(stream);
24177
24178              case 3:
24179                relationships = _context5.sent;
24180                model.worksheetRels[sheetNo] = relationships;
24181
24182              case 5:
24183              case "end":
24184                return _context5.stop();
24185            }
24186          }
24187        }, _callee5);
24188      }));
24189
24190      function _processWorksheetRelsEntry(_x14, _x15, _x16) {
24191        return _processWorksheetRelsEntry2.apply(this, arguments);
24192      }
24193
24194      return _processWorksheetRelsEntry;
24195    }()
24196  }, {
24197    key: "_processMediaEntry",
24198    value: function () {
24199      var _processMediaEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(entry, model, filename) {
24200        var lastDot, extension, name;
24201        return regeneratorRuntime.wrap(function _callee6$(_context6) {
24202          while (1) {
24203            switch (_context6.prev = _context6.next) {
24204              case 0:
24205                lastDot = filename.lastIndexOf('.'); // if we can't determine extension, ignore it
24206
24207                if (!(lastDot >= 1)) {
24208                  _context6.next = 6;
24209                  break;
24210                }
24211
24212                extension = filename.substr(lastDot + 1);
24213                name = filename.substr(0, lastDot);
24214                _context6.next = 6;
24215                return new Promise(function (resolve, reject) {
24216                  var streamBuf = new StreamBuf();
24217                  streamBuf.on('finish', function () {
24218                    model.mediaIndex[filename] = model.media.length;
24219                    model.mediaIndex[name] = model.media.length;
24220                    var medium = {
24221                      type: 'image',
24222                      name: name,
24223                      extension: extension,
24224                      buffer: streamBuf.toBuffer()
24225                    };
24226                    model.media.push(medium);
24227                    resolve();
24228                  });
24229                  entry.on('error', function (error) {
24230                    reject(error);
24231                  });
24232                  entry.pipe(streamBuf);
24233                });
24234
24235              case 6:
24236              case "end":
24237                return _context6.stop();
24238            }
24239          }
24240        }, _callee6);
24241      }));
24242
24243      function _processMediaEntry(_x17, _x18, _x19) {
24244        return _processMediaEntry2.apply(this, arguments);
24245      }
24246
24247      return _processMediaEntry;
24248    }()
24249  }, {
24250    key: "_processDrawingEntry",
24251    value: function () {
24252      var _processDrawingEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(entry, model, name) {
24253        var xform, drawing;
24254        return regeneratorRuntime.wrap(function _callee7$(_context7) {
24255          while (1) {
24256            switch (_context7.prev = _context7.next) {
24257              case 0:
24258                xform = new DrawingXform();
24259                _context7.next = 3;
24260                return xform.parseStream(entry);
24261
24262              case 3:
24263                drawing = _context7.sent;
24264                model.drawings[name] = drawing;
24265
24266              case 5:
24267              case "end":
24268                return _context7.stop();
24269            }
24270          }
24271        }, _callee7);
24272      }));
24273
24274      function _processDrawingEntry(_x20, _x21, _x22) {
24275        return _processDrawingEntry2.apply(this, arguments);
24276      }
24277
24278      return _processDrawingEntry;
24279    }()
24280  }, {
24281    key: "_processDrawingRelsEntry",
24282    value: function () {
24283      var _processDrawingRelsEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(entry, model, name) {
24284        var xform, relationships;
24285        return regeneratorRuntime.wrap(function _callee8$(_context8) {
24286          while (1) {
24287            switch (_context8.prev = _context8.next) {
24288              case 0:
24289                xform = new RelationshipsXform();
24290                _context8.next = 3;
24291                return xform.parseStream(entry);
24292
24293              case 3:
24294                relationships = _context8.sent;
24295                model.drawingRels[name] = relationships;
24296
24297              case 5:
24298              case "end":
24299                return _context8.stop();
24300            }
24301          }
24302        }, _callee8);
24303      }));
24304
24305      function _processDrawingRelsEntry(_x23, _x24, _x25) {
24306        return _processDrawingRelsEntry2.apply(this, arguments);
24307      }
24308
24309      return _processDrawingRelsEntry;
24310    }()
24311  }, {
24312    key: "_processVmlDrawingEntry",
24313    value: function () {
24314      var _processVmlDrawingEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(entry, model, name) {
24315        var xform, vmlDrawing;
24316        return regeneratorRuntime.wrap(function _callee9$(_context9) {
24317          while (1) {
24318            switch (_context9.prev = _context9.next) {
24319              case 0:
24320                xform = new VmlNotesXform();
24321                _context9.next = 3;
24322                return xform.parseStream(entry);
24323
24324              case 3:
24325                vmlDrawing = _context9.sent;
24326                model.vmlDrawings["../drawings/".concat(name, ".vml")] = vmlDrawing;
24327
24328              case 5:
24329              case "end":
24330                return _context9.stop();
24331            }
24332          }
24333        }, _callee9);
24334      }));
24335
24336      function _processVmlDrawingEntry(_x26, _x27, _x28) {
24337        return _processVmlDrawingEntry2.apply(this, arguments);
24338      }
24339
24340      return _processVmlDrawingEntry;
24341    }()
24342  }, {
24343    key: "_processThemeEntry",
24344    value: function () {
24345      var _processThemeEntry2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(entry, model, name) {
24346        return regeneratorRuntime.wrap(function _callee10$(_context10) {
24347          while (1) {
24348            switch (_context10.prev = _context10.next) {
24349              case 0:
24350                _context10.next = 2;
24351                return new Promise(function (resolve, reject) {
24352                  // TODO: stream entry into buffer and store the xml in the model.themes[]
24353                  var stream = new StreamBuf();
24354                  entry.on('error', reject);
24355                  stream.on('error', reject);
24356                  stream.on('finish', function () {
24357                    model.themes[name] = stream.read().toString();
24358                    resolve();
24359                  });
24360                  entry.pipe(stream);
24361                });
24362
24363              case 2:
24364              case "end":
24365                return _context10.stop();
24366            }
24367          }
24368        }, _callee10);
24369      }));
24370
24371      function _processThemeEntry(_x29, _x30, _x31) {
24372        return _processThemeEntry2.apply(this, arguments);
24373      }
24374
24375      return _processThemeEntry;
24376    }()
24377    /**
24378     * @deprecated since version 4.0. You should use `#read` instead. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md
24379     */
24380
24381  }, {
24382    key: "createInputStream",
24383    value: function createInputStream() {
24384      throw new Error('`XLSX#createInputStream` is deprecated. You should use `XLSX#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md');
24385    }
24386  }, {
24387    key: "read",
24388    value: function () {
24389      var _read = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(stream, options) {
24390        var chunks, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk;
24391
24392        return regeneratorRuntime.wrap(function _callee11$(_context11) {
24393          while (1) {
24394            switch (_context11.prev = _context11.next) {
24395              case 0:
24396                // TODO: Remove once node v8 is deprecated
24397                // Detect and upgrade old streams
24398                if (!stream[Symbol.asyncIterator] && stream.pipe) {
24399                  stream = stream.pipe(new PassThrough());
24400                }
24401
24402                chunks = [];
24403                _iteratorNormalCompletion = true;
24404                _didIteratorError = false;
24405                _context11.prev = 4;
24406                _iterator = _asyncIterator(stream);
24407
24408              case 6:
24409                _context11.next = 8;
24410                return _iterator.next();
24411
24412              case 8:
24413                _step = _context11.sent;
24414                _iteratorNormalCompletion = _step.done;
24415                _context11.next = 12;
24416                return _step.value;
24417
24418              case 12:
24419                _value = _context11.sent;
24420
24421                if (_iteratorNormalCompletion) {
24422                  _context11.next = 19;
24423                  break;
24424                }
24425
24426                chunk = _value;
24427                chunks.push(chunk);
24428
24429              case 16:
24430                _iteratorNormalCompletion = true;
24431                _context11.next = 6;
24432                break;
24433
24434              case 19:
24435                _context11.next = 25;
24436                break;
24437
24438              case 21:
24439                _context11.prev = 21;
24440                _context11.t0 = _context11["catch"](4);
24441                _didIteratorError = true;
24442                _iteratorError = _context11.t0;
24443
24444              case 25:
24445                _context11.prev = 25;
24446                _context11.prev = 26;
24447
24448                if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
24449                  _context11.next = 30;
24450                  break;
24451                }
24452
24453                _context11.next = 30;
24454                return _iterator.return();
24455
24456              case 30:
24457                _context11.prev = 30;
24458
24459                if (!_didIteratorError) {
24460                  _context11.next = 33;
24461                  break;
24462                }
24463
24464                throw _iteratorError;
24465
24466              case 33:
24467                return _context11.finish(30);
24468
24469              case 34:
24470                return _context11.finish(25);
24471
24472              case 35:
24473                return _context11.abrupt("return", this.load(Buffer.concat(chunks), options));
24474
24475              case 36:
24476              case "end":
24477                return _context11.stop();
24478            }
24479          }
24480        }, _callee11, this, [[4, 21, 25, 35], [26,, 30, 34]]);
24481      }));
24482
24483      function read(_x32, _x33) {
24484        return _read.apply(this, arguments);
24485      }
24486
24487      return read;
24488    }()
24489  }, {
24490    key: "load",
24491    value: function () {
24492      var _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(data, options) {
24493        var buffer, model, zip, _i, _Object$values, entry, entryName, stream, content, chunkSize, i, workbook, appXform, appProperties, coreXform, coreProperties, match;
24494
24495        return regeneratorRuntime.wrap(function _callee12$(_context12) {
24496          while (1) {
24497            switch (_context12.prev = _context12.next) {
24498              case 0:
24499                if (options && options.base64) {
24500                  buffer = Buffer.from(data.toString(), 'base64');
24501                } else {
24502                  buffer = data;
24503                }
24504
24505                model = {
24506                  worksheets: [],
24507                  worksheetHash: {},
24508                  worksheetRels: [],
24509                  themes: {},
24510                  media: [],
24511                  mediaIndex: {},
24512                  drawings: {},
24513                  drawingRels: {},
24514                  comments: {},
24515                  tables: {},
24516                  vmlDrawings: {}
24517                };
24518                _context12.next = 4;
24519                return JSZip.loadAsync(buffer);
24520
24521              case 4:
24522                zip = _context12.sent;
24523                _i = 0, _Object$values = Object.values(zip.files);
24524
24525              case 6:
24526                if (!(_i < _Object$values.length)) {
24527                  _context12.next = 126;
24528                  break;
24529                }
24530
24531                entry = _Object$values[_i];
24532
24533                if (entry.dir) {
24534                  _context12.next = 123;
24535                  break;
24536                }
24537
24538                entryName = entry.name;
24539
24540                if (entryName[0] === '/') {
24541                  entryName = entryName.substr(1);
24542                }
24543
24544                stream = void 0;
24545
24546                if (!(entryName.match(/xl\/media\//) || // themes are not parsed as stream
24547                entryName.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/))) {
24548                  _context12.next = 21;
24549                  break;
24550                }
24551
24552                stream = new PassThrough();
24553                _context12.t0 = stream;
24554                _context12.next = 17;
24555                return entry.async('nodebuffer');
24556
24557              case 17:
24558                _context12.t1 = _context12.sent;
24559
24560                _context12.t0.write.call(_context12.t0, _context12.t1);
24561
24562                _context12.next = 36;
24563                break;
24564
24565              case 21:
24566                // use object mode to avoid buffer-string convention
24567                stream = new PassThrough({
24568                  writableObjectMode: true,
24569                  readableObjectMode: true
24570                });
24571                content = void 0; // https://www.npmjs.com/package/process
24572
24573                if (!process.browser) {
24574                  _context12.next = 31;
24575                  break;
24576                }
24577
24578                _context12.t2 = bufferToString;
24579                _context12.next = 27;
24580                return entry.async('nodebuffer');
24581
24582              case 27:
24583                _context12.t3 = _context12.sent;
24584                content = (0, _context12.t2)(_context12.t3);
24585                _context12.next = 34;
24586                break;
24587
24588              case 31:
24589                _context12.next = 33;
24590                return entry.async('string');
24591
24592              case 33:
24593                content = _context12.sent;
24594
24595              case 34:
24596                chunkSize = 16 * 1024;
24597
24598                for (i = 0; i < content.length; i += chunkSize) {
24599                  stream.write(content.substring(i, i + chunkSize));
24600                }
24601
24602              case 36:
24603                stream.end();
24604                _context12.t4 = entryName;
24605                _context12.next = _context12.t4 === '_rels/.rels' ? 40 : _context12.t4 === 'xl/workbook.xml' ? 44 : _context12.t4 === 'xl/_rels/workbook.xml.rels' ? 53 : _context12.t4 === 'xl/sharedStrings.xml' ? 57 : _context12.t4 === 'xl/styles.xml' ? 61 : _context12.t4 === 'docProps/app.xml' ? 65 : _context12.t4 === 'docProps/core.xml' ? 72 : 78;
24606                break;
24607
24608              case 40:
24609                _context12.next = 42;
24610                return this.parseRels(stream);
24611
24612              case 42:
24613                model.globalRels = _context12.sent;
24614                return _context12.abrupt("break", 123);
24615
24616              case 44:
24617                _context12.next = 46;
24618                return this.parseWorkbook(stream);
24619
24620              case 46:
24621                workbook = _context12.sent;
24622                model.sheets = workbook.sheets;
24623                model.definedNames = workbook.definedNames;
24624                model.views = workbook.views;
24625                model.properties = workbook.properties;
24626                model.calcProperties = workbook.calcProperties;
24627                return _context12.abrupt("break", 123);
24628
24629              case 53:
24630                _context12.next = 55;
24631                return this.parseRels(stream);
24632
24633              case 55:
24634                model.workbookRels = _context12.sent;
24635                return _context12.abrupt("break", 123);
24636
24637              case 57:
24638                model.sharedStrings = new SharedStringsXform();
24639                _context12.next = 60;
24640                return model.sharedStrings.parseStream(stream);
24641
24642              case 60:
24643                return _context12.abrupt("break", 123);
24644
24645              case 61:
24646                model.styles = new StylesXform();
24647                _context12.next = 64;
24648                return model.styles.parseStream(stream);
24649
24650              case 64:
24651                return _context12.abrupt("break", 123);
24652
24653              case 65:
24654                appXform = new AppXform();
24655                _context12.next = 68;
24656                return appXform.parseStream(stream);
24657
24658              case 68:
24659                appProperties = _context12.sent;
24660                model.company = appProperties.company;
24661                model.manager = appProperties.manager;
24662                return _context12.abrupt("break", 123);
24663
24664              case 72:
24665                coreXform = new CoreXform();
24666                _context12.next = 75;
24667                return coreXform.parseStream(stream);
24668
24669              case 75:
24670                coreProperties = _context12.sent;
24671                Object.assign(model, coreProperties);
24672                return _context12.abrupt("break", 123);
24673
24674              case 78:
24675                match = entryName.match(/xl\/worksheets\/sheet(\d+)[.]xml/);
24676
24677                if (!match) {
24678                  _context12.next = 83;
24679                  break;
24680                }
24681
24682                _context12.next = 82;
24683                return this._processWorksheetEntry(stream, model, match[1], options, entryName);
24684
24685              case 82:
24686                return _context12.abrupt("break", 123);
24687
24688              case 83:
24689                match = entryName.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/);
24690
24691                if (!match) {
24692                  _context12.next = 88;
24693                  break;
24694                }
24695
24696                _context12.next = 87;
24697                return this._processWorksheetRelsEntry(stream, model, match[1]);
24698
24699              case 87:
24700                return _context12.abrupt("break", 123);
24701
24702              case 88:
24703                match = entryName.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/);
24704
24705                if (!match) {
24706                  _context12.next = 93;
24707                  break;
24708                }
24709
24710                _context12.next = 92;
24711                return this._processThemeEntry(stream, model, match[1]);
24712
24713              case 92:
24714                return _context12.abrupt("break", 123);
24715
24716              case 93:
24717                match = entryName.match(/xl\/media\/([a-zA-Z0-9]+[.][a-zA-Z0-9]{3,4})$/);
24718
24719                if (!match) {
24720                  _context12.next = 98;
24721                  break;
24722                }
24723
24724                _context12.next = 97;
24725                return this._processMediaEntry(stream, model, match[1]);
24726
24727              case 97:
24728                return _context12.abrupt("break", 123);
24729
24730              case 98:
24731                match = entryName.match(/xl\/drawings\/([a-zA-Z0-9]+)[.]xml/);
24732
24733                if (!match) {
24734                  _context12.next = 103;
24735                  break;
24736                }
24737
24738                _context12.next = 102;
24739                return this._processDrawingEntry(stream, model, match[1]);
24740
24741              case 102:
24742                return _context12.abrupt("break", 123);
24743
24744              case 103:
24745                match = entryName.match(/xl\/(comments\d+)[.]xml/);
24746
24747                if (!match) {
24748                  _context12.next = 108;
24749                  break;
24750                }
24751
24752                _context12.next = 107;
24753                return this._processCommentEntry(stream, model, match[1]);
24754
24755              case 107:
24756                return _context12.abrupt("break", 123);
24757
24758              case 108:
24759                match = entryName.match(/xl\/tables\/(table\d+)[.]xml/);
24760
24761                if (!match) {
24762                  _context12.next = 113;
24763                  break;
24764                }
24765
24766                _context12.next = 112;
24767                return this._processTableEntry(stream, model, match[1]);
24768
24769              case 112:
24770                return _context12.abrupt("break", 123);
24771
24772              case 113:
24773                match = entryName.match(/xl\/drawings\/_rels\/([a-zA-Z0-9]+)[.]xml[.]rels/);
24774
24775                if (!match) {
24776                  _context12.next = 118;
24777                  break;
24778                }
24779
24780                _context12.next = 117;
24781                return this._processDrawingRelsEntry(stream, model, match[1]);
24782
24783              case 117:
24784                return _context12.abrupt("break", 123);
24785
24786              case 118:
24787                match = entryName.match(/xl\/drawings\/(vmlDrawing\d+)[.]vml/);
24788
24789                if (!match) {
24790                  _context12.next = 123;
24791                  break;
24792                }
24793
24794                _context12.next = 122;
24795                return this._processVmlDrawingEntry(stream, model, match[1]);
24796
24797              case 122:
24798                return _context12.abrupt("break", 123);
24799
24800              case 123:
24801                _i++;
24802                _context12.next = 6;
24803                break;
24804
24805              case 126:
24806                this.reconcile(model, options); // apply model
24807
24808                this.workbook.model = model;
24809                return _context12.abrupt("return", this.workbook);
24810
24811              case 129:
24812              case "end":
24813                return _context12.stop();
24814            }
24815          }
24816        }, _callee12, this);
24817      }));
24818
24819      function load(_x34, _x35) {
24820        return _load.apply(this, arguments);
24821      }
24822
24823      return load;
24824    }() // =========================================================================
24825    // Write
24826
24827  }, {
24828    key: "addMedia",
24829    value: function () {
24830      var _addMedia = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(zip, model) {
24831        return regeneratorRuntime.wrap(function _callee14$(_context14) {
24832          while (1) {
24833            switch (_context14.prev = _context14.next) {
24834              case 0:
24835                _context14.next = 2;
24836                return Promise.all(model.media.map( /*#__PURE__*/function () {
24837                  var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(medium) {
24838                    var filename, data, dataimg64, content;
24839                    return regeneratorRuntime.wrap(function _callee13$(_context13) {
24840                      while (1) {
24841                        switch (_context13.prev = _context13.next) {
24842                          case 0:
24843                            if (!(medium.type === 'image')) {
24844                              _context13.next = 13;
24845                              break;
24846                            }
24847
24848                            filename = "xl/media/".concat(medium.name, ".").concat(medium.extension);
24849
24850                            if (!medium.filename) {
24851                              _context13.next = 7;
24852                              break;
24853                            }
24854
24855                            _context13.next = 5;
24856                            return fsReadFileAsync(medium.filename);
24857
24858                          case 5:
24859                            data = _context13.sent;
24860                            return _context13.abrupt("return", zip.append(data, {
24861                              name: filename
24862                            }));
24863
24864                          case 7:
24865                            if (!medium.buffer) {
24866                              _context13.next = 9;
24867                              break;
24868                            }
24869
24870                            return _context13.abrupt("return", zip.append(medium.buffer, {
24871                              name: filename
24872                            }));
24873
24874                          case 9:
24875                            if (!medium.base64) {
24876                              _context13.next = 13;
24877                              break;
24878                            }
24879
24880                            dataimg64 = medium.base64;
24881                            content = dataimg64.substring(dataimg64.indexOf(',') + 1);
24882                            return _context13.abrupt("return", zip.append(content, {
24883                              name: filename,
24884                              base64: true
24885                            }));
24886
24887                          case 13:
24888                            throw new Error('Unsupported media');
24889
24890                          case 14:
24891                          case "end":
24892                            return _context13.stop();
24893                        }
24894                      }
24895                    }, _callee13);
24896                  }));
24897
24898                  return function (_x38) {
24899                    return _ref.apply(this, arguments);
24900                  };
24901                }()));
24902
24903              case 2:
24904              case "end":
24905                return _context14.stop();
24906            }
24907          }
24908        }, _callee14);
24909      }));
24910
24911      function addMedia(_x36, _x37) {
24912        return _addMedia.apply(this, arguments);
24913      }
24914
24915      return addMedia;
24916    }()
24917  }, {
24918    key: "addDrawings",
24919    value: function addDrawings(zip, model) {
24920      var drawingXform = new DrawingXform();
24921      var relsXform = new RelationshipsXform();
24922      model.worksheets.forEach(function (worksheet) {
24923        var drawing = worksheet.drawing;
24924
24925        if (drawing) {
24926          drawingXform.prepare(drawing, {});
24927          var xml = drawingXform.toXml(drawing);
24928          zip.append(xml, {
24929            name: "xl/drawings/".concat(drawing.name, ".xml")
24930          });
24931          xml = relsXform.toXml(drawing.rels);
24932          zip.append(xml, {
24933            name: "xl/drawings/_rels/".concat(drawing.name, ".xml.rels")
24934          });
24935        }
24936      });
24937    }
24938  }, {
24939    key: "addTables",
24940    value: function addTables(zip, model) {
24941      var tableXform = new TableXform();
24942      model.worksheets.forEach(function (worksheet) {
24943        var tables = worksheet.tables;
24944        tables.forEach(function (table) {
24945          tableXform.prepare(table, {});
24946          var tableXml = tableXform.toXml(table);
24947          zip.append(tableXml, {
24948            name: "xl/tables/".concat(table.target)
24949          });
24950        });
24951      });
24952    }
24953  }, {
24954    key: "addContentTypes",
24955    value: function () {
24956      var _addContentTypes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(zip, model) {
24957        var xform, xml;
24958        return regeneratorRuntime.wrap(function _callee15$(_context15) {
24959          while (1) {
24960            switch (_context15.prev = _context15.next) {
24961              case 0:
24962                xform = new ContentTypesXform();
24963                xml = xform.toXml(model);
24964                zip.append(xml, {
24965                  name: '[Content_Types].xml'
24966                });
24967
24968              case 3:
24969              case "end":
24970                return _context15.stop();
24971            }
24972          }
24973        }, _callee15);
24974      }));
24975
24976      function addContentTypes(_x39, _x40) {
24977        return _addContentTypes.apply(this, arguments);
24978      }
24979
24980      return addContentTypes;
24981    }()
24982  }, {
24983    key: "addApp",
24984    value: function () {
24985      var _addApp = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(zip, model) {
24986        var xform, xml;
24987        return regeneratorRuntime.wrap(function _callee16$(_context16) {
24988          while (1) {
24989            switch (_context16.prev = _context16.next) {
24990              case 0:
24991                xform = new AppXform();
24992                xml = xform.toXml(model);
24993                zip.append(xml, {
24994                  name: 'docProps/app.xml'
24995                });
24996
24997              case 3:
24998              case "end":
24999                return _context16.stop();
25000            }
25001          }
25002        }, _callee16);
25003      }));
25004
25005      function addApp(_x41, _x42) {
25006        return _addApp.apply(this, arguments);
25007      }
25008
25009      return addApp;
25010    }()
25011  }, {
25012    key: "addCore",
25013    value: function () {
25014      var _addCore = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(zip, model) {
25015        var coreXform;
25016        return regeneratorRuntime.wrap(function _callee17$(_context17) {
25017          while (1) {
25018            switch (_context17.prev = _context17.next) {
25019              case 0:
25020                coreXform = new CoreXform();
25021                zip.append(coreXform.toXml(model), {
25022                  name: 'docProps/core.xml'
25023                });
25024
25025              case 2:
25026              case "end":
25027                return _context17.stop();
25028            }
25029          }
25030        }, _callee17);
25031      }));
25032
25033      function addCore(_x43, _x44) {
25034        return _addCore.apply(this, arguments);
25035      }
25036
25037      return addCore;
25038    }()
25039  }, {
25040    key: "addThemes",
25041    value: function () {
25042      var _addThemes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18(zip, model) {
25043        var themes;
25044        return regeneratorRuntime.wrap(function _callee18$(_context18) {
25045          while (1) {
25046            switch (_context18.prev = _context18.next) {
25047              case 0:
25048                themes = model.themes || {
25049                  theme1: theme1Xml
25050                };
25051                Object.keys(themes).forEach(function (name) {
25052                  var xml = themes[name];
25053                  var path = "xl/theme/".concat(name, ".xml");
25054                  zip.append(xml, {
25055                    name: path
25056                  });
25057                });
25058
25059              case 2:
25060              case "end":
25061                return _context18.stop();
25062            }
25063          }
25064        }, _callee18);
25065      }));
25066
25067      function addThemes(_x45, _x46) {
25068        return _addThemes.apply(this, arguments);
25069      }
25070
25071      return addThemes;
25072    }()
25073  }, {
25074    key: "addOfficeRels",
25075    value: function () {
25076      var _addOfficeRels = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(zip) {
25077        var xform, xml;
25078        return regeneratorRuntime.wrap(function _callee19$(_context19) {
25079          while (1) {
25080            switch (_context19.prev = _context19.next) {
25081              case 0:
25082                xform = new RelationshipsXform();
25083                xml = xform.toXml([{
25084                  Id: 'rId1',
25085                  Type: XLSX.RelType.OfficeDocument,
25086                  Target: 'xl/workbook.xml'
25087                }, {
25088                  Id: 'rId2',
25089                  Type: XLSX.RelType.CoreProperties,
25090                  Target: 'docProps/core.xml'
25091                }, {
25092                  Id: 'rId3',
25093                  Type: XLSX.RelType.ExtenderProperties,
25094                  Target: 'docProps/app.xml'
25095                }]);
25096                zip.append(xml, {
25097                  name: '_rels/.rels'
25098                });
25099
25100              case 3:
25101              case "end":
25102                return _context19.stop();
25103            }
25104          }
25105        }, _callee19);
25106      }));
25107
25108      function addOfficeRels(_x47) {
25109        return _addOfficeRels.apply(this, arguments);
25110      }
25111
25112      return addOfficeRels;
25113    }()
25114  }, {
25115    key: "addWorkbookRels",
25116    value: function () {
25117      var _addWorkbookRels = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(zip, model) {
25118        var count, relationships, xform, xml;
25119        return regeneratorRuntime.wrap(function _callee20$(_context20) {
25120          while (1) {
25121            switch (_context20.prev = _context20.next) {
25122              case 0:
25123                count = 1;
25124                relationships = [{
25125                  Id: "rId".concat(count++),
25126                  Type: XLSX.RelType.Styles,
25127                  Target: 'styles.xml'
25128                }, {
25129                  Id: "rId".concat(count++),
25130                  Type: XLSX.RelType.Theme,
25131                  Target: 'theme/theme1.xml'
25132                }];
25133
25134                if (model.sharedStrings.count) {
25135                  relationships.push({
25136                    Id: "rId".concat(count++),
25137                    Type: XLSX.RelType.SharedStrings,
25138                    Target: 'sharedStrings.xml'
25139                  });
25140                }
25141
25142                model.worksheets.forEach(function (worksheet) {
25143                  worksheet.rId = "rId".concat(count++);
25144                  relationships.push({
25145                    Id: worksheet.rId,
25146                    Type: XLSX.RelType.Worksheet,
25147                    Target: "worksheets/sheet".concat(worksheet.id, ".xml")
25148                  });
25149                });
25150                xform = new RelationshipsXform();
25151                xml = xform.toXml(relationships);
25152                zip.append(xml, {
25153                  name: 'xl/_rels/workbook.xml.rels'
25154                });
25155
25156              case 7:
25157              case "end":
25158                return _context20.stop();
25159            }
25160          }
25161        }, _callee20);
25162      }));
25163
25164      function addWorkbookRels(_x48, _x49) {
25165        return _addWorkbookRels.apply(this, arguments);
25166      }
25167
25168      return addWorkbookRels;
25169    }()
25170  }, {
25171    key: "addSharedStrings",
25172    value: function () {
25173      var _addSharedStrings = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21(zip, model) {
25174        return regeneratorRuntime.wrap(function _callee21$(_context21) {
25175          while (1) {
25176            switch (_context21.prev = _context21.next) {
25177              case 0:
25178                if (model.sharedStrings && model.sharedStrings.count) {
25179                  zip.append(model.sharedStrings.xml, {
25180                    name: 'xl/sharedStrings.xml'
25181                  });
25182                }
25183
25184              case 1:
25185              case "end":
25186                return _context21.stop();
25187            }
25188          }
25189        }, _callee21);
25190      }));
25191
25192      function addSharedStrings(_x50, _x51) {
25193        return _addSharedStrings.apply(this, arguments);
25194      }
25195
25196      return addSharedStrings;
25197    }()
25198  }, {
25199    key: "addStyles",
25200    value: function () {
25201      var _addStyles = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(zip, model) {
25202        var xml;
25203        return regeneratorRuntime.wrap(function _callee22$(_context22) {
25204          while (1) {
25205            switch (_context22.prev = _context22.next) {
25206              case 0:
25207                xml = model.styles.xml;
25208
25209                if (xml) {
25210                  zip.append(xml, {
25211                    name: 'xl/styles.xml'
25212                  });
25213                }
25214
25215              case 2:
25216              case "end":
25217                return _context22.stop();
25218            }
25219          }
25220        }, _callee22);
25221      }));
25222
25223      function addStyles(_x52, _x53) {
25224        return _addStyles.apply(this, arguments);
25225      }
25226
25227      return addStyles;
25228    }()
25229  }, {
25230    key: "addWorkbook",
25231    value: function () {
25232      var _addWorkbook = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(zip, model) {
25233        var xform;
25234        return regeneratorRuntime.wrap(function _callee23$(_context23) {
25235          while (1) {
25236            switch (_context23.prev = _context23.next) {
25237              case 0:
25238                xform = new WorkbookXform();
25239                zip.append(xform.toXml(model), {
25240                  name: 'xl/workbook.xml'
25241                });
25242
25243              case 2:
25244              case "end":
25245                return _context23.stop();
25246            }
25247          }
25248        }, _callee23);
25249      }));
25250
25251      function addWorkbook(_x54, _x55) {
25252        return _addWorkbook.apply(this, arguments);
25253      }
25254
25255      return addWorkbook;
25256    }()
25257  }, {
25258    key: "addWorksheets",
25259    value: function () {
25260      var _addWorksheets = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24(zip, model) {
25261        var worksheetXform, relationshipsXform, commentsXform, vmlNotesXform;
25262        return regeneratorRuntime.wrap(function _callee24$(_context24) {
25263          while (1) {
25264            switch (_context24.prev = _context24.next) {
25265              case 0:
25266                // preparation phase
25267                worksheetXform = new WorksheetXform();
25268                relationshipsXform = new RelationshipsXform();
25269                commentsXform = new CommentsXform();
25270                vmlNotesXform = new VmlNotesXform(); // write sheets
25271
25272                model.worksheets.forEach(function (worksheet) {
25273                  var xmlStream = new XmlStream();
25274                  worksheetXform.render(xmlStream, worksheet);
25275                  zip.append(xmlStream.xml, {
25276                    name: "xl/worksheets/sheet".concat(worksheet.id, ".xml")
25277                  });
25278
25279                  if (worksheet.rels && worksheet.rels.length) {
25280                    xmlStream = new XmlStream();
25281                    relationshipsXform.render(xmlStream, worksheet.rels);
25282                    zip.append(xmlStream.xml, {
25283                      name: "xl/worksheets/_rels/sheet".concat(worksheet.id, ".xml.rels")
25284                    });
25285                  }
25286
25287                  if (worksheet.comments.length > 0) {
25288                    xmlStream = new XmlStream();
25289                    commentsXform.render(xmlStream, worksheet);
25290                    zip.append(xmlStream.xml, {
25291                      name: "xl/comments".concat(worksheet.id, ".xml")
25292                    });
25293                    xmlStream = new XmlStream();
25294                    vmlNotesXform.render(xmlStream, worksheet);
25295                    zip.append(xmlStream.xml, {
25296                      name: "xl/drawings/vmlDrawing".concat(worksheet.id, ".vml")
25297                    });
25298                  }
25299                });
25300
25301              case 5:
25302              case "end":
25303                return _context24.stop();
25304            }
25305          }
25306        }, _callee24);
25307      }));
25308
25309      function addWorksheets(_x56, _x57) {
25310        return _addWorksheets.apply(this, arguments);
25311      }
25312
25313      return addWorksheets;
25314    }()
25315  }, {
25316    key: "_finalize",
25317    value: function _finalize(zip) {
25318      var _this = this;
25319
25320      return new Promise(function (resolve, reject) {
25321        zip.on('finish', function () {
25322          resolve(_this);
25323        });
25324        zip.on('error', reject);
25325        zip.finalize();
25326      });
25327    }
25328  }, {
25329    key: "prepareModel",
25330    value: function prepareModel(model, options) {
25331      // ensure following properties have sane values
25332      model.creator = model.creator || 'ExcelJS';
25333      model.lastModifiedBy = model.lastModifiedBy || 'ExcelJS';
25334      model.created = model.created || new Date();
25335      model.modified = model.modified || new Date();
25336      model.useSharedStrings = options.useSharedStrings !== undefined ? options.useSharedStrings : true;
25337      model.useStyles = options.useStyles !== undefined ? options.useStyles : true; // Manage the shared strings
25338
25339      model.sharedStrings = new SharedStringsXform(); // add a style manager to handle cell formats, fonts, etc.
25340
25341      model.styles = model.useStyles ? new StylesXform(true) : new StylesXform.Mock(); // prepare all of the things before the render
25342
25343      var workbookXform = new WorkbookXform();
25344      var worksheetXform = new WorksheetXform();
25345      workbookXform.prepare(model);
25346      var worksheetOptions = {
25347        sharedStrings: model.sharedStrings,
25348        styles: model.styles,
25349        date1904: model.properties.date1904,
25350        drawingsCount: 0,
25351        media: model.media
25352      };
25353      worksheetOptions.drawings = model.drawings = [];
25354      worksheetOptions.commentRefs = model.commentRefs = [];
25355      var tableCount = 0;
25356      model.tables = [];
25357      model.worksheets.forEach(function (worksheet) {
25358        // assign unique filenames to tables
25359        worksheet.tables.forEach(function (table) {
25360          tableCount++;
25361          table.target = "table".concat(tableCount, ".xml");
25362          table.id = tableCount;
25363          model.tables.push(table);
25364        });
25365        worksheetXform.prepare(worksheet, worksheetOptions);
25366      }); // TODO: workbook drawing list
25367    }
25368  }, {
25369    key: "write",
25370    value: function () {
25371      var _write = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25(stream, options) {
25372        var model, zip;
25373        return regeneratorRuntime.wrap(function _callee25$(_context25) {
25374          while (1) {
25375            switch (_context25.prev = _context25.next) {
25376              case 0:
25377                options = options || {};
25378                model = this.workbook.model;
25379                zip = new ZipStream.ZipWriter(options.zip);
25380                zip.pipe(stream);
25381                this.prepareModel(model, options); // render
25382
25383                _context25.next = 7;
25384                return this.addContentTypes(zip, model);
25385
25386              case 7:
25387                _context25.next = 9;
25388                return this.addOfficeRels(zip, model);
25389
25390              case 9:
25391                _context25.next = 11;
25392                return this.addWorkbookRels(zip, model);
25393
25394              case 11:
25395                _context25.next = 13;
25396                return this.addWorksheets(zip, model);
25397
25398              case 13:
25399                _context25.next = 15;
25400                return this.addSharedStrings(zip, model);
25401
25402              case 15:
25403                _context25.next = 17;
25404                return this.addDrawings(zip, model);
25405
25406              case 17:
25407                _context25.next = 19;
25408                return this.addTables(zip, model);
25409
25410              case 19:
25411                _context25.next = 21;
25412                return Promise.all([this.addThemes(zip, model), this.addStyles(zip, model)]);
25413
25414              case 21:
25415                _context25.next = 23;
25416                return this.addMedia(zip, model);
25417
25418              case 23:
25419                _context25.next = 25;
25420                return Promise.all([this.addApp(zip, model), this.addCore(zip, model)]);
25421
25422              case 25:
25423                _context25.next = 27;
25424                return this.addWorkbook(zip, model);
25425
25426              case 27:
25427                return _context25.abrupt("return", this._finalize(zip));
25428
25429              case 28:
25430              case "end":
25431                return _context25.stop();
25432            }
25433          }
25434        }, _callee25, this);
25435      }));
25436
25437      function write(_x58, _x59) {
25438        return _write.apply(this, arguments);
25439      }
25440
25441      return write;
25442    }()
25443  }, {
25444    key: "writeFile",
25445    value: function writeFile(filename, options) {
25446      var _this2 = this;
25447
25448      var stream = fs.createWriteStream(filename);
25449      return new Promise(function (resolve, reject) {
25450        stream.on('finish', function () {
25451          resolve();
25452        });
25453        stream.on('error', function (error) {
25454          reject(error);
25455        });
25456
25457        _this2.write(stream, options).then(function () {
25458          stream.end();
25459        });
25460      });
25461    }
25462  }, {
25463    key: "writeBuffer",
25464    value: function () {
25465      var _writeBuffer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26(options) {
25466        var stream;
25467        return regeneratorRuntime.wrap(function _callee26$(_context26) {
25468          while (1) {
25469            switch (_context26.prev = _context26.next) {
25470              case 0:
25471                stream = new StreamBuf();
25472                _context26.next = 3;
25473                return this.write(stream, options);
25474
25475              case 3:
25476                return _context26.abrupt("return", stream.read());
25477
25478              case 4:
25479              case "end":
25480                return _context26.stop();
25481            }
25482          }
25483        }, _callee26, this);
25484      }));
25485
25486      function writeBuffer(_x60) {
25487        return _writeBuffer.apply(this, arguments);
25488      }
25489
25490      return writeBuffer;
25491    }()
25492  }]);
25493
25494  return XLSX;
25495}();
25496
25497XLSX.RelType = require('./rel-type');
25498module.exports = XLSX;
25499
25500}).call(this,require('_process'),require("buffer").Buffer)
25501
25502},{"../utils/browser-buffer-decode":16,"../utils/stream-buf":23,"../utils/utils":26,"../utils/xml-stream":27,"../utils/zip-stream":28,"./rel-type":30,"./xform/book/workbook-xform":37,"./xform/comment/comments-xform":39,"./xform/comment/vml-notes-xform":44,"./xform/core/app-xform":50,"./xform/core/content-types-xform":51,"./xform/core/core-xform":52,"./xform/core/relationships-xform":54,"./xform/drawing/drawing-xform":61,"./xform/sheet/worksheet-xform":114,"./xform/strings/shared-strings-xform":123,"./xform/style/styles-xform":134,"./xform/table/table-xform":140,"./xml/theme1.js":142,"_process":467,"buffer":216,"fs":215,"jszip":399,"readable-stream":491}],142:[function(require,module,exports){
25503"use strict";
25504
25505/* eslint-disable */
25506module.exports = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>';
25507
25508},{}],143:[function(require,module,exports){
25509(function (Buffer){
25510"use strict";
25511
25512function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
25513
25514function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25515
25516function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
25517
25518function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
25519
25520function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
25521
25522function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25523
25524function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
25525
25526function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
25527
25528function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25529
25530function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
25531
25532function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25533
25534Object.defineProperty(exports, "__esModule", {
25535  value: true
25536});
25537exports.CsvFormatterStream = void 0;
25538
25539var stream_1 = require("stream");
25540
25541var formatter_1 = require("./formatter");
25542
25543var CsvFormatterStream = /*#__PURE__*/function (_stream_1$Transform) {
25544  _inherits(CsvFormatterStream, _stream_1$Transform);
25545
25546  var _super = _createSuper(CsvFormatterStream);
25547
25548  function CsvFormatterStream(formatterOptions) {
25549    var _this;
25550
25551    _classCallCheck(this, CsvFormatterStream);
25552
25553    _this = _super.call(this, {
25554      writableObjectMode: formatterOptions.objectMode
25555    });
25556    _this.hasWrittenBOM = false;
25557    _this.formatterOptions = formatterOptions;
25558    _this.rowFormatter = new formatter_1.RowFormatter(formatterOptions); // if writeBOM is false then set to true
25559    // if writeBOM is true then set to false by default so it is written out
25560
25561    _this.hasWrittenBOM = !formatterOptions.writeBOM;
25562    return _this;
25563  }
25564
25565  _createClass(CsvFormatterStream, [{
25566    key: "transform",
25567    value: function transform(transformFunction) {
25568      this.rowFormatter.rowTransform = transformFunction;
25569      return this;
25570    }
25571  }, {
25572    key: "_transform",
25573    value: function _transform(row, encoding, cb) {
25574      var _this2 = this;
25575
25576      var cbCalled = false;
25577
25578      try {
25579        if (!this.hasWrittenBOM) {
25580          this.push(this.formatterOptions.BOM);
25581          this.hasWrittenBOM = true;
25582        }
25583
25584        this.rowFormatter.format(row, function (err, rows) {
25585          if (err) {
25586            cbCalled = true;
25587            return cb(err);
25588          }
25589
25590          if (rows) {
25591            rows.forEach(function (r) {
25592              _this2.push(Buffer.from(r, 'utf8'));
25593            });
25594          }
25595
25596          cbCalled = true;
25597          return cb();
25598        });
25599      } catch (e) {
25600        if (cbCalled) {
25601          throw e;
25602        }
25603
25604        cb(e);
25605      }
25606    }
25607  }, {
25608    key: "_flush",
25609    value: function _flush(cb) {
25610      var _this3 = this;
25611
25612      this.rowFormatter.finish(function (err, rows) {
25613        if (err) {
25614          return cb(err);
25615        }
25616
25617        if (rows) {
25618          rows.forEach(function (r) {
25619            _this3.push(Buffer.from(r, 'utf8'));
25620          });
25621        }
25622
25623        return cb();
25624      });
25625    }
25626  }]);
25627
25628  return CsvFormatterStream;
25629}(stream_1.Transform);
25630
25631exports.CsvFormatterStream = CsvFormatterStream;
25632
25633}).call(this,require("buffer").Buffer)
25634
25635},{"./formatter":147,"buffer":216,"stream":506}],144:[function(require,module,exports){
25636"use strict";
25637
25638function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25639
25640Object.defineProperty(exports, "__esModule", {
25641  value: true
25642});
25643exports.FormatterOptions = void 0;
25644
25645var FormatterOptions = function FormatterOptions() {
25646  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25647
25648  _classCallCheck(this, FormatterOptions);
25649
25650  var _a;
25651
25652  this.objectMode = true;
25653  this.delimiter = ',';
25654  this.rowDelimiter = '\n';
25655  this.quote = '"';
25656  this.escape = this.quote;
25657  this.quoteColumns = false;
25658  this.quoteHeaders = this.quoteColumns;
25659  this.headers = null;
25660  this.includeEndRowDelimiter = false;
25661  this.writeBOM = false;
25662  this.BOM = "\uFEFF";
25663  this.alwaysWriteHeaders = false;
25664  Object.assign(this, opts || {});
25665
25666  if (typeof (opts === null || opts === void 0 ? void 0 : opts.quoteHeaders) === 'undefined') {
25667    this.quoteHeaders = this.quoteColumns;
25668  }
25669
25670  if ((opts === null || opts === void 0 ? void 0 : opts.quote) === true) {
25671    this.quote = '"';
25672  } else if ((opts === null || opts === void 0 ? void 0 : opts.quote) === false) {
25673    this.quote = '';
25674  }
25675
25676  if (typeof (opts === null || opts === void 0 ? void 0 : opts.escape) !== 'string') {
25677    this.escape = this.quote;
25678  }
25679
25680  this.shouldWriteHeaders = !!this.headers && ((_a = opts.writeHeaders) !== null && _a !== void 0 ? _a : true);
25681  this.headers = Array.isArray(this.headers) ? this.headers : null;
25682  this.escapedQuote = "".concat(this.escape).concat(this.quote);
25683};
25684
25685exports.FormatterOptions = FormatterOptions;
25686
25687},{}],145:[function(require,module,exports){
25688"use strict";
25689
25690function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25691
25692function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
25693
25694function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
25695
25696var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
25697  return mod && mod.__esModule ? mod : {
25698    "default": mod
25699  };
25700};
25701
25702Object.defineProperty(exports, "__esModule", {
25703  value: true
25704});
25705exports.FieldFormatter = void 0;
25706
25707var lodash_isboolean_1 = __importDefault(require("lodash.isboolean"));
25708
25709var lodash_isnil_1 = __importDefault(require("lodash.isnil"));
25710
25711var lodash_escaperegexp_1 = __importDefault(require("lodash.escaperegexp"));
25712
25713var FieldFormatter = /*#__PURE__*/function () {
25714  function FieldFormatter(formatterOptions) {
25715    _classCallCheck(this, FieldFormatter);
25716
25717    this._headers = null;
25718    this.formatterOptions = formatterOptions;
25719
25720    if (formatterOptions.headers !== null) {
25721      this.headers = formatterOptions.headers;
25722    }
25723
25724    this.REPLACE_REGEXP = new RegExp(formatterOptions.quote, 'g');
25725    var escapePattern = "[".concat(formatterOptions.delimiter).concat(lodash_escaperegexp_1.default(formatterOptions.rowDelimiter), "|\r|\n']");
25726    this.ESCAPE_REGEXP = new RegExp(escapePattern);
25727  }
25728
25729  _createClass(FieldFormatter, [{
25730    key: "shouldQuote",
25731    value: function shouldQuote(fieldIndex, isHeader) {
25732      var quoteConfig = isHeader ? this.formatterOptions.quoteHeaders : this.formatterOptions.quoteColumns;
25733
25734      if (lodash_isboolean_1.default(quoteConfig)) {
25735        return quoteConfig;
25736      }
25737
25738      if (Array.isArray(quoteConfig)) {
25739        return quoteConfig[fieldIndex];
25740      }
25741
25742      if (this._headers !== null) {
25743        return quoteConfig[this._headers[fieldIndex]];
25744      }
25745
25746      return false;
25747    }
25748  }, {
25749    key: "format",
25750    value: function format(field, fieldIndex, isHeader) {
25751      var preparedField = "".concat(lodash_isnil_1.default(field) ? '' : field).replace(/\0/g, '');
25752      var formatterOptions = this.formatterOptions;
25753
25754      if (formatterOptions.quote !== '') {
25755        var shouldEscape = preparedField.indexOf(formatterOptions.quote) !== -1;
25756
25757        if (shouldEscape) {
25758          return this.quoteField(preparedField.replace(this.REPLACE_REGEXP, formatterOptions.escapedQuote));
25759        }
25760      }
25761
25762      var hasEscapeCharacters = preparedField.search(this.ESCAPE_REGEXP) !== -1;
25763
25764      if (hasEscapeCharacters || this.shouldQuote(fieldIndex, isHeader)) {
25765        return this.quoteField(preparedField);
25766      }
25767
25768      return preparedField;
25769    }
25770  }, {
25771    key: "quoteField",
25772    value: function quoteField(field) {
25773      var quote = this.formatterOptions.quote;
25774      return "".concat(quote).concat(field).concat(quote);
25775    }
25776  }, {
25777    key: "headers",
25778    set: function set(headers) {
25779      this._headers = headers;
25780    }
25781  }]);
25782
25783  return FieldFormatter;
25784}();
25785
25786exports.FieldFormatter = FieldFormatter;
25787
25788},{"lodash.escaperegexp":426,"lodash.isboolean":428,"lodash.isnil":431}],146:[function(require,module,exports){
25789"use strict";
25790
25791function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25792
25793function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
25794
25795function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
25796
25797var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
25798  return mod && mod.__esModule ? mod : {
25799    "default": mod
25800  };
25801};
25802
25803Object.defineProperty(exports, "__esModule", {
25804  value: true
25805});
25806exports.RowFormatter = void 0;
25807
25808var lodash_isfunction_1 = __importDefault(require("lodash.isfunction"));
25809
25810var lodash_isequal_1 = __importDefault(require("lodash.isequal"));
25811
25812var FieldFormatter_1 = require("./FieldFormatter");
25813
25814var types_1 = require("../types");
25815
25816var RowFormatter = /*#__PURE__*/function () {
25817  function RowFormatter(formatterOptions) {
25818    _classCallCheck(this, RowFormatter);
25819
25820    this.rowCount = 0;
25821    this.formatterOptions = formatterOptions;
25822    this.fieldFormatter = new FieldFormatter_1.FieldFormatter(formatterOptions);
25823    this.headers = formatterOptions.headers;
25824    this.shouldWriteHeaders = formatterOptions.shouldWriteHeaders;
25825    this.hasWrittenHeaders = false;
25826
25827    if (this.headers !== null) {
25828      this.fieldFormatter.headers = this.headers;
25829    }
25830
25831    if (formatterOptions.transform) {
25832      this.rowTransform = formatterOptions.transform;
25833    }
25834  }
25835
25836  _createClass(RowFormatter, [{
25837    key: "format",
25838    value: function format(row, cb) {
25839      var _this = this;
25840
25841      this.callTransformer(row, function (err, transformedRow) {
25842        if (err) {
25843          return cb(err);
25844        }
25845
25846        if (!row) {
25847          return cb(null);
25848        }
25849
25850        var rows = [];
25851
25852        if (transformedRow) {
25853          var _this$checkHeaders = _this.checkHeaders(transformedRow),
25854              shouldFormatColumns = _this$checkHeaders.shouldFormatColumns,
25855              headers = _this$checkHeaders.headers;
25856
25857          if (_this.shouldWriteHeaders && headers && !_this.hasWrittenHeaders) {
25858            rows.push(_this.formatColumns(headers, true));
25859            _this.hasWrittenHeaders = true;
25860          }
25861
25862          if (shouldFormatColumns) {
25863            var columns = _this.gatherColumns(transformedRow);
25864
25865            rows.push(_this.formatColumns(columns, false));
25866          }
25867        }
25868
25869        return cb(null, rows);
25870      });
25871    }
25872  }, {
25873    key: "finish",
25874    value: function finish(cb) {
25875      var rows = []; // check if we should write headers and we didnt get any rows
25876
25877      if (this.formatterOptions.alwaysWriteHeaders && this.rowCount === 0) {
25878        if (!this.headers) {
25879          return cb(new Error('`alwaysWriteHeaders` option is set to true but `headers` option not provided.'));
25880        }
25881
25882        rows.push(this.formatColumns(this.headers, true));
25883      }
25884
25885      if (this.formatterOptions.includeEndRowDelimiter) {
25886        rows.push(this.formatterOptions.rowDelimiter);
25887      }
25888
25889      return cb(null, rows);
25890    } // check if we need to write header return true if we should also write a row
25891    // could be false if headers is true and the header row(first item) is passed in
25892
25893  }, {
25894    key: "checkHeaders",
25895    value: function checkHeaders(row) {
25896      if (this.headers) {
25897        // either the headers were provided by the user or we have already gathered them.
25898        return {
25899          shouldFormatColumns: true,
25900          headers: this.headers
25901        };
25902      }
25903
25904      var headers = RowFormatter.gatherHeaders(row);
25905      this.headers = headers;
25906      this.fieldFormatter.headers = headers;
25907
25908      if (!this.shouldWriteHeaders) {
25909        // if we are not supposed to write the headers then
25910        // always format the columns
25911        return {
25912          shouldFormatColumns: true,
25913          headers: null
25914        };
25915      } // if the row is equal to headers dont format
25916
25917
25918      return {
25919        shouldFormatColumns: !lodash_isequal_1.default(headers, row),
25920        headers: headers
25921      };
25922    } // todo change this method to unknown[]
25923
25924  }, {
25925    key: "gatherColumns",
25926    value: function gatherColumns(row) {
25927      if (this.headers === null) {
25928        throw new Error('Headers is currently null');
25929      }
25930
25931      if (!Array.isArray(row)) {
25932        return this.headers.map(function (header) {
25933          return row[header];
25934        });
25935      }
25936
25937      if (RowFormatter.isHashArray(row)) {
25938        return this.headers.map(function (header, i) {
25939          var col = row[i];
25940
25941          if (col) {
25942            return col[1];
25943          }
25944
25945          return '';
25946        });
25947      }
25948
25949      return this.headers.map(function (header, i) {
25950        return row[i];
25951      });
25952    }
25953  }, {
25954    key: "callTransformer",
25955    value: function callTransformer(row, cb) {
25956      if (!this._rowTransform) {
25957        return cb(null, row);
25958      }
25959
25960      return this._rowTransform(row, cb);
25961    }
25962  }, {
25963    key: "formatColumns",
25964    value: function formatColumns(columns, isHeadersRow) {
25965      var _this2 = this;
25966
25967      var formattedCols = columns.map(function (field, i) {
25968        return _this2.fieldFormatter.format(field, i, isHeadersRow);
25969      }).join(this.formatterOptions.delimiter);
25970      var rowCount = this.rowCount;
25971      this.rowCount += 1;
25972
25973      if (rowCount) {
25974        return [this.formatterOptions.rowDelimiter, formattedCols].join('');
25975      }
25976
25977      return formattedCols;
25978    }
25979  }, {
25980    key: "rowTransform",
25981    set: function set(transformFunction) {
25982      if (!lodash_isfunction_1.default(transformFunction)) {
25983        throw new TypeError('The transform should be a function');
25984      }
25985
25986      this._rowTransform = RowFormatter.createTransform(transformFunction);
25987    }
25988  }], [{
25989    key: "isHashArray",
25990    value: function isHashArray(row) {
25991      if (Array.isArray(row)) {
25992        return Array.isArray(row[0]) && row[0].length === 2;
25993      }
25994
25995      return false;
25996    } // get headers from a row item
25997
25998  }, {
25999    key: "gatherHeaders",
26000    value: function gatherHeaders(row) {
26001      if (RowFormatter.isHashArray(row)) {
26002        // lets assume a multi-dimesional array with item 0 being the header
26003        return row.map(function (it) {
26004          return it[0];
26005        });
26006      }
26007
26008      if (Array.isArray(row)) {
26009        return row;
26010      }
26011
26012      return Object.keys(row);
26013    }
26014  }, {
26015    key: "createTransform",
26016    value: function createTransform(transformFunction) {
26017      if (types_1.isSyncTransform(transformFunction)) {
26018        return function (row, cb) {
26019          var transformedRow = null;
26020
26021          try {
26022            transformedRow = transformFunction(row);
26023          } catch (e) {
26024            return cb(e);
26025          }
26026
26027          return cb(null, transformedRow);
26028        };
26029      }
26030
26031      return function (row, cb) {
26032        transformFunction(row, cb);
26033      };
26034    }
26035  }]);
26036
26037  return RowFormatter;
26038}();
26039
26040exports.RowFormatter = RowFormatter;
26041
26042},{"../types":149,"./FieldFormatter":145,"lodash.isequal":429,"lodash.isfunction":430}],147:[function(require,module,exports){
26043"use strict";
26044
26045Object.defineProperty(exports, "__esModule", {
26046  value: true
26047});
26048
26049var RowFormatter_1 = require("./RowFormatter");
26050
26051Object.defineProperty(exports, "RowFormatter", {
26052  enumerable: true,
26053  get: function get() {
26054    return RowFormatter_1.RowFormatter;
26055  }
26056});
26057
26058var FieldFormatter_1 = require("./FieldFormatter");
26059
26060Object.defineProperty(exports, "FieldFormatter", {
26061  enumerable: true,
26062  get: function get() {
26063    return FieldFormatter_1.FieldFormatter;
26064  }
26065});
26066
26067},{"./FieldFormatter":145,"./RowFormatter":146}],148:[function(require,module,exports){
26068(function (Buffer){
26069"use strict";
26070
26071var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
26072  if (k2 === undefined) k2 = k;
26073  Object.defineProperty(o, k2, {
26074    enumerable: true,
26075    get: function get() {
26076      return m[k];
26077    }
26078  });
26079} : function (o, m, k, k2) {
26080  if (k2 === undefined) k2 = k;
26081  o[k2] = m[k];
26082});
26083
26084var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) {
26085  Object.defineProperty(o, "default", {
26086    enumerable: true,
26087    value: v
26088  });
26089} : function (o, v) {
26090  o["default"] = v;
26091});
26092
26093var __importStar = void 0 && (void 0).__importStar || function (mod) {
26094  if (mod && mod.__esModule) return mod;
26095  var result = {};
26096  if (mod != null) for (var k in mod) {
26097    if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26098  }
26099
26100  __setModuleDefault(result, mod);
26101
26102  return result;
26103};
26104
26105var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
26106  for (var p in m) {
26107    if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
26108  }
26109};
26110
26111Object.defineProperty(exports, "__esModule", {
26112  value: true
26113});
26114exports.writeToPath = exports.writeToString = exports.writeToBuffer = exports.writeToStream = exports.write = exports.format = void 0;
26115
26116var util_1 = require("util");
26117
26118var stream_1 = require("stream");
26119
26120var fs = __importStar(require("fs"));
26121
26122var FormatterOptions_1 = require("./FormatterOptions");
26123
26124var CsvFormatterStream_1 = require("./CsvFormatterStream");
26125
26126__exportStar(require("./types"), exports);
26127
26128var CsvFormatterStream_2 = require("./CsvFormatterStream");
26129
26130Object.defineProperty(exports, "CsvFormatterStream", {
26131  enumerable: true,
26132  get: function get() {
26133    return CsvFormatterStream_2.CsvFormatterStream;
26134  }
26135});
26136
26137var FormatterOptions_2 = require("./FormatterOptions");
26138
26139Object.defineProperty(exports, "FormatterOptions", {
26140  enumerable: true,
26141  get: function get() {
26142    return FormatterOptions_2.FormatterOptions;
26143  }
26144});
26145
26146exports.format = function (options) {
26147  return new CsvFormatterStream_1.CsvFormatterStream(new FormatterOptions_1.FormatterOptions(options));
26148};
26149
26150exports.write = function (rows, options) {
26151  var csvStream = exports.format(options);
26152  var promiseWrite = util_1.promisify(function (row, cb) {
26153    csvStream.write(row, undefined, cb);
26154  });
26155  rows.reduce(function (prev, row) {
26156    return prev.then(function () {
26157      return promiseWrite(row);
26158    });
26159  }, Promise.resolve()).then(function () {
26160    return csvStream.end();
26161  }).catch(function (err) {
26162    csvStream.emit('error', err);
26163  });
26164  return csvStream;
26165};
26166
26167exports.writeToStream = function (ws, rows, options) {
26168  return exports.write(rows, options).pipe(ws);
26169};
26170
26171exports.writeToBuffer = function (rows) {
26172  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26173  var buffers = [];
26174  var ws = new stream_1.Writable({
26175    write: function write(data, enc, writeCb) {
26176      buffers.push(data);
26177      writeCb();
26178    }
26179  });
26180  return new Promise(function (res, rej) {
26181    ws.on('error', rej).on('finish', function () {
26182      return res(Buffer.concat(buffers));
26183    });
26184    exports.write(rows, opts).pipe(ws);
26185  });
26186};
26187
26188exports.writeToString = function (rows, options) {
26189  return exports.writeToBuffer(rows, options).then(function (buffer) {
26190    return buffer.toString();
26191  });
26192};
26193
26194exports.writeToPath = function (path, rows, options) {
26195  var stream = fs.createWriteStream(path, {
26196    encoding: 'utf8'
26197  });
26198  return exports.write(rows, options).pipe(stream);
26199};
26200
26201}).call(this,require("buffer").Buffer)
26202
26203},{"./CsvFormatterStream":143,"./FormatterOptions":144,"./types":149,"buffer":216,"fs":215,"stream":506,"util":525}],149:[function(require,module,exports){
26204"use strict";
26205/* eslint-disable @typescript-eslint/no-explicit-any */
26206
26207Object.defineProperty(exports, "__esModule", {
26208  value: true
26209});
26210exports.isSyncTransform = void 0;
26211
26212exports.isSyncTransform = function (transform) {
26213  return transform.length === 1;
26214};
26215
26216},{}],150:[function(require,module,exports){
26217(function (setImmediate){
26218"use strict";
26219
26220function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
26221
26222function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26223
26224function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
26225
26226function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
26227
26228function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
26229
26230function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
26231
26232function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
26233
26234function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
26235
26236function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
26237
26238function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
26239
26240function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26241
26242function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
26243
26244function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26245
26246Object.defineProperty(exports, "__esModule", {
26247  value: true
26248});
26249exports.CsvParserStream = void 0;
26250
26251var string_decoder_1 = require("string_decoder");
26252
26253var stream_1 = require("stream");
26254
26255var transforms_1 = require("./transforms");
26256
26257var parser_1 = require("./parser");
26258
26259var CsvParserStream = /*#__PURE__*/function (_stream_1$Transform) {
26260  _inherits(CsvParserStream, _stream_1$Transform);
26261
26262  var _super = _createSuper(CsvParserStream);
26263
26264  function CsvParserStream(parserOptions) {
26265    var _this;
26266
26267    _classCallCheck(this, CsvParserStream);
26268
26269    _this = _super.call(this, {
26270      objectMode: parserOptions.objectMode
26271    });
26272    _this.lines = '';
26273    _this.rowCount = 0;
26274    _this.parsedRowCount = 0;
26275    _this.parsedLineCount = 0;
26276    _this.endEmitted = false;
26277    _this.headersEmitted = false;
26278    _this.parserOptions = parserOptions;
26279    _this.parser = new parser_1.Parser(parserOptions);
26280    _this.headerTransformer = new transforms_1.HeaderTransformer(parserOptions);
26281    _this.decoder = new string_decoder_1.StringDecoder(parserOptions.encoding);
26282    _this.rowTransformerValidator = new transforms_1.RowTransformerValidator();
26283    return _this;
26284  }
26285
26286  _createClass(CsvParserStream, [{
26287    key: "transform",
26288    value: function transform(transformFunction) {
26289      this.rowTransformerValidator.rowTransform = transformFunction;
26290      return this;
26291    }
26292  }, {
26293    key: "validate",
26294    value: function validate(validateFunction) {
26295      this.rowTransformerValidator.rowValidator = validateFunction;
26296      return this;
26297    } // eslint-disable-next-line @typescript-eslint/no-explicit-any
26298
26299  }, {
26300    key: "emit",
26301    value: function emit(event) {
26302      var _get2;
26303
26304      if (event === 'end') {
26305        if (!this.endEmitted) {
26306          this.endEmitted = true;
26307
26308          _get(_getPrototypeOf(CsvParserStream.prototype), "emit", this).call(this, 'end', this.rowCount);
26309        }
26310
26311        return false;
26312      }
26313
26314      for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
26315        rest[_key - 1] = arguments[_key];
26316      }
26317
26318      return (_get2 = _get(_getPrototypeOf(CsvParserStream.prototype), "emit", this)).call.apply(_get2, [this, event].concat(rest));
26319    }
26320  }, {
26321    key: "_transform",
26322    value: function _transform(data, encoding, done) {
26323      // if we have hit our maxRows parsing limit then skip parsing
26324      if (this.hasHitRowLimit) {
26325        return done();
26326      }
26327
26328      try {
26329        var lines = this.lines;
26330        var newLine = lines + this.decoder.write(data);
26331        var rows = this.parse(newLine, true);
26332        return this.processRows(rows, done);
26333      } catch (e) {
26334        return done(e);
26335      }
26336    }
26337  }, {
26338    key: "_flush",
26339    value: function _flush(done) {
26340      // if we have hit our maxRows parsing limit then skip parsing
26341      if (this.hasHitRowLimit) {
26342        return done();
26343      }
26344
26345      try {
26346        var newLine = this.lines + this.decoder.end();
26347        var rows = this.parse(newLine, false);
26348        return this.processRows(rows, done);
26349      } catch (e) {
26350        return done(e);
26351      }
26352    }
26353  }, {
26354    key: "parse",
26355    value: function parse(data, hasMoreData) {
26356      if (!data) {
26357        return [];
26358      }
26359
26360      var _this$parser$parse = this.parser.parse(data, hasMoreData),
26361          line = _this$parser$parse.line,
26362          rows = _this$parser$parse.rows;
26363
26364      this.lines = line;
26365      return rows;
26366    }
26367  }, {
26368    key: "processRows",
26369    value: function processRows(rows, cb) {
26370      var _this2 = this;
26371
26372      var rowsLength = rows.length;
26373
26374      var iterate = function iterate(i) {
26375        var callNext = function callNext(err) {
26376          if (err) {
26377            return cb(err);
26378          }
26379
26380          if (i % 100 === 0) {
26381            // incase the transform are sync insert a next tick to prevent stack overflow
26382            setImmediate(function () {
26383              return iterate(i + 1);
26384            });
26385            return undefined;
26386          }
26387
26388          return iterate(i + 1);
26389        };
26390
26391        _this2.checkAndEmitHeaders(); // if we have emitted all rows or we have hit the maxRows limit option
26392        // then end
26393
26394
26395        if (i >= rowsLength || _this2.hasHitRowLimit) {
26396          return cb();
26397        }
26398
26399        _this2.parsedLineCount += 1;
26400
26401        if (_this2.shouldSkipLine) {
26402          return callNext();
26403        }
26404
26405        var row = rows[i];
26406        _this2.rowCount += 1;
26407        _this2.parsedRowCount += 1;
26408        var nextRowCount = _this2.rowCount;
26409        return _this2.transformRow(row, function (err, transformResult) {
26410          if (err) {
26411            _this2.rowCount -= 1;
26412            return callNext(err);
26413          }
26414
26415          if (!transformResult) {
26416            return callNext(new Error('expected transform result'));
26417          }
26418
26419          if (!transformResult.isValid) {
26420            _this2.emit('data-invalid', transformResult.row, nextRowCount, transformResult.reason);
26421          } else if (transformResult.row) {
26422            return _this2.pushRow(transformResult.row, callNext);
26423          }
26424
26425          return callNext();
26426        });
26427      };
26428
26429      iterate(0);
26430    }
26431  }, {
26432    key: "transformRow",
26433    value: function transformRow(parsedRow, cb) {
26434      var _this3 = this;
26435
26436      try {
26437        this.headerTransformer.transform(parsedRow, function (err, withHeaders) {
26438          if (err) {
26439            return cb(err);
26440          }
26441
26442          if (!withHeaders) {
26443            return cb(new Error('Expected result from header transform'));
26444          }
26445
26446          if (!withHeaders.isValid) {
26447            if (_this3.shouldEmitRows) {
26448              return cb(null, {
26449                isValid: false,
26450                row: parsedRow
26451              });
26452            } // skipped because of skipRows option remove from total row count
26453
26454
26455            return _this3.skipRow(cb);
26456          }
26457
26458          if (withHeaders.row) {
26459            if (_this3.shouldEmitRows) {
26460              return _this3.rowTransformerValidator.transformAndValidate(withHeaders.row, cb);
26461            } // skipped because of skipRows option remove from total row count
26462
26463
26464            return _this3.skipRow(cb);
26465          } // this is a header row dont include in the rowCount or parsedRowCount
26466
26467
26468          _this3.rowCount -= 1;
26469          _this3.parsedRowCount -= 1;
26470          return cb(null, {
26471            row: null,
26472            isValid: true
26473          });
26474        });
26475      } catch (e) {
26476        cb(e);
26477      }
26478    }
26479  }, {
26480    key: "checkAndEmitHeaders",
26481    value: function checkAndEmitHeaders() {
26482      if (!this.headersEmitted && this.headerTransformer.headers) {
26483        this.headersEmitted = true;
26484        this.emit('headers', this.headerTransformer.headers);
26485      }
26486    }
26487  }, {
26488    key: "skipRow",
26489    value: function skipRow(cb) {
26490      // skipped because of skipRows option remove from total row count
26491      this.rowCount -= 1;
26492      return cb(null, {
26493        row: null,
26494        isValid: true
26495      });
26496    }
26497  }, {
26498    key: "pushRow",
26499    value: function pushRow(row, cb) {
26500      try {
26501        if (!this.parserOptions.objectMode) {
26502          this.push(JSON.stringify(row));
26503        } else {
26504          this.push(row);
26505        }
26506
26507        cb();
26508      } catch (e) {
26509        cb(e);
26510      }
26511    }
26512  }, {
26513    key: "hasHitRowLimit",
26514    get: function get() {
26515      return this.parserOptions.limitRows && this.rowCount >= this.parserOptions.maxRows;
26516    }
26517  }, {
26518    key: "shouldEmitRows",
26519    get: function get() {
26520      return this.parsedRowCount > this.parserOptions.skipRows;
26521    }
26522  }, {
26523    key: "shouldSkipLine",
26524    get: function get() {
26525      return this.parsedLineCount <= this.parserOptions.skipLines;
26526    }
26527  }]);
26528
26529  return CsvParserStream;
26530}(stream_1.Transform);
26531
26532exports.CsvParserStream = CsvParserStream;
26533
26534}).call(this,require("timers").setImmediate)
26535
26536},{"./parser":162,"./transforms":165,"stream":506,"string_decoder":520,"timers":521}],151:[function(require,module,exports){
26537"use strict";
26538
26539function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26540
26541var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
26542  return mod && mod.__esModule ? mod : {
26543    "default": mod
26544  };
26545};
26546
26547Object.defineProperty(exports, "__esModule", {
26548  value: true
26549});
26550exports.ParserOptions = void 0;
26551
26552var lodash_escaperegexp_1 = __importDefault(require("lodash.escaperegexp"));
26553
26554var lodash_isnil_1 = __importDefault(require("lodash.isnil"));
26555
26556var ParserOptions = function ParserOptions(opts) {
26557  _classCallCheck(this, ParserOptions);
26558
26559  var _a;
26560
26561  this.objectMode = true;
26562  this.delimiter = ',';
26563  this.ignoreEmpty = false;
26564  this.quote = '"';
26565  this.escape = null;
26566  this.escapeChar = this.quote;
26567  this.comment = null;
26568  this.supportsComments = false;
26569  this.ltrim = false;
26570  this.rtrim = false;
26571  this.trim = false;
26572  this.headers = null;
26573  this.renameHeaders = false;
26574  this.strictColumnHandling = false;
26575  this.discardUnmappedColumns = false;
26576  this.carriageReturn = '\r';
26577  this.encoding = 'utf8';
26578  this.limitRows = false;
26579  this.maxRows = 0;
26580  this.skipLines = 0;
26581  this.skipRows = 0;
26582  Object.assign(this, opts || {});
26583
26584  if (this.delimiter.length > 1) {
26585    throw new Error('delimiter option must be one character long');
26586  }
26587
26588  this.escapedDelimiter = lodash_escaperegexp_1.default(this.delimiter);
26589  this.escapeChar = (_a = this.escape) !== null && _a !== void 0 ? _a : this.quote;
26590  this.supportsComments = !lodash_isnil_1.default(this.comment);
26591  this.NEXT_TOKEN_REGEXP = new RegExp("([^\\s]|\\r\\n|\\n|\\r|".concat(this.escapedDelimiter, ")"));
26592
26593  if (this.maxRows > 0) {
26594    this.limitRows = true;
26595  }
26596};
26597
26598exports.ParserOptions = ParserOptions;
26599
26600},{"lodash.escaperegexp":426,"lodash.isnil":431}],152:[function(require,module,exports){
26601"use strict";
26602
26603var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
26604  if (k2 === undefined) k2 = k;
26605  Object.defineProperty(o, k2, {
26606    enumerable: true,
26607    get: function get() {
26608      return m[k];
26609    }
26610  });
26611} : function (o, m, k, k2) {
26612  if (k2 === undefined) k2 = k;
26613  o[k2] = m[k];
26614});
26615
26616var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) {
26617  Object.defineProperty(o, "default", {
26618    enumerable: true,
26619    value: v
26620  });
26621} : function (o, v) {
26622  o["default"] = v;
26623});
26624
26625var __importStar = void 0 && (void 0).__importStar || function (mod) {
26626  if (mod && mod.__esModule) return mod;
26627  var result = {};
26628  if (mod != null) for (var k in mod) {
26629    if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26630  }
26631
26632  __setModuleDefault(result, mod);
26633
26634  return result;
26635};
26636
26637var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
26638  for (var p in m) {
26639    if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
26640  }
26641};
26642
26643Object.defineProperty(exports, "__esModule", {
26644  value: true
26645});
26646exports.parseString = exports.parseFile = exports.parseStream = exports.parse = void 0;
26647
26648var fs = __importStar(require("fs"));
26649
26650var stream_1 = require("stream");
26651
26652var ParserOptions_1 = require("./ParserOptions");
26653
26654var CsvParserStream_1 = require("./CsvParserStream");
26655
26656__exportStar(require("./types"), exports);
26657
26658var CsvParserStream_2 = require("./CsvParserStream");
26659
26660Object.defineProperty(exports, "CsvParserStream", {
26661  enumerable: true,
26662  get: function get() {
26663    return CsvParserStream_2.CsvParserStream;
26664  }
26665});
26666
26667var ParserOptions_2 = require("./ParserOptions");
26668
26669Object.defineProperty(exports, "ParserOptions", {
26670  enumerable: true,
26671  get: function get() {
26672    return ParserOptions_2.ParserOptions;
26673  }
26674});
26675
26676exports.parse = function (args) {
26677  return new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(args));
26678};
26679
26680exports.parseStream = function (stream, options) {
26681  return stream.pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
26682};
26683
26684exports.parseFile = function (location) {
26685  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26686  return fs.createReadStream(location).pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
26687};
26688
26689exports.parseString = function (string, options) {
26690  var rs = new stream_1.Readable();
26691  rs.push(string);
26692  rs.push(null);
26693  return rs.pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
26694};
26695
26696},{"./CsvParserStream":150,"./ParserOptions":151,"./types":166,"fs":215,"stream":506}],153:[function(require,module,exports){
26697"use strict";
26698
26699function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26700
26701function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
26702
26703function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
26704
26705Object.defineProperty(exports, "__esModule", {
26706  value: true
26707});
26708exports.Parser = void 0;
26709
26710var Scanner_1 = require("./Scanner");
26711
26712var RowParser_1 = require("./RowParser");
26713
26714var Token_1 = require("./Token");
26715
26716var EMPTY_ROW_REGEXP = /^\s*(?:''|"")?\s*(?:,\s*(?:''|"")?\s*)*$/;
26717
26718var Parser = /*#__PURE__*/function () {
26719  function Parser(parserOptions) {
26720    _classCallCheck(this, Parser);
26721
26722    this.parserOptions = parserOptions;
26723    this.rowParser = new RowParser_1.RowParser(this.parserOptions);
26724  }
26725
26726  _createClass(Parser, [{
26727    key: "parse",
26728    value: function parse(line, hasMoreData) {
26729      var scanner = new Scanner_1.Scanner({
26730        line: Parser.removeBOM(line),
26731        parserOptions: this.parserOptions,
26732        hasMoreData: hasMoreData
26733      });
26734
26735      if (this.parserOptions.supportsComments) {
26736        return this.parseWithComments(scanner);
26737      }
26738
26739      return this.parseWithoutComments(scanner);
26740    }
26741  }, {
26742    key: "parseWithoutComments",
26743    value: function parseWithoutComments(scanner) {
26744      var rows = [];
26745      var shouldContinue = true;
26746
26747      while (shouldContinue) {
26748        shouldContinue = this.parseRow(scanner, rows);
26749      }
26750
26751      return {
26752        line: scanner.line,
26753        rows: rows
26754      };
26755    }
26756  }, {
26757    key: "parseWithComments",
26758    value: function parseWithComments(scanner) {
26759      var parserOptions = this.parserOptions;
26760      var rows = [];
26761
26762      for (var nextToken = scanner.nextCharacterToken; nextToken !== null; nextToken = scanner.nextCharacterToken) {
26763        if (Token_1.Token.isTokenComment(nextToken, parserOptions)) {
26764          var cursor = scanner.advancePastLine();
26765
26766          if (cursor === null) {
26767            return {
26768              line: scanner.lineFromCursor,
26769              rows: rows
26770            };
26771          }
26772
26773          if (!scanner.hasMoreCharacters) {
26774            return {
26775              line: scanner.lineFromCursor,
26776              rows: rows
26777            };
26778          }
26779
26780          scanner.truncateToCursor();
26781        } else if (!this.parseRow(scanner, rows)) {
26782          break;
26783        }
26784      }
26785
26786      return {
26787        line: scanner.line,
26788        rows: rows
26789      };
26790    }
26791  }, {
26792    key: "parseRow",
26793    value: function parseRow(scanner, rows) {
26794      var nextToken = scanner.nextNonSpaceToken;
26795
26796      if (!nextToken) {
26797        return false;
26798      }
26799
26800      var row = this.rowParser.parse(scanner);
26801
26802      if (row === null) {
26803        return false;
26804      }
26805
26806      if (this.parserOptions.ignoreEmpty && EMPTY_ROW_REGEXP.test(row.join(''))) {
26807        return true;
26808      }
26809
26810      rows.push(row);
26811      return true;
26812    }
26813  }], [{
26814    key: "removeBOM",
26815    value: function removeBOM(line) {
26816      // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
26817      // conversion translates it to FEFF (UTF-16 BOM)
26818      if (line && line.charCodeAt(0) === 0xfeff) {
26819        return line.slice(1);
26820      }
26821
26822      return line;
26823    }
26824  }]);
26825
26826  return Parser;
26827}();
26828
26829exports.Parser = Parser;
26830
26831},{"./RowParser":154,"./Scanner":155,"./Token":156}],154:[function(require,module,exports){
26832"use strict";
26833
26834function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26835
26836function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
26837
26838function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
26839
26840Object.defineProperty(exports, "__esModule", {
26841  value: true
26842});
26843exports.RowParser = void 0;
26844
26845var column_1 = require("./column");
26846
26847var Token_1 = require("./Token");
26848
26849var _Token_1$Token = Token_1.Token,
26850    isTokenRowDelimiter = _Token_1$Token.isTokenRowDelimiter,
26851    isTokenCarriageReturn = _Token_1$Token.isTokenCarriageReturn,
26852    isTokenDelimiter = _Token_1$Token.isTokenDelimiter;
26853
26854var RowParser = /*#__PURE__*/function () {
26855  function RowParser(parserOptions) {
26856    _classCallCheck(this, RowParser);
26857
26858    this.parserOptions = parserOptions;
26859    this.columnParser = new column_1.ColumnParser(parserOptions);
26860  }
26861
26862  _createClass(RowParser, [{
26863    key: "parse",
26864    value: function parse(scanner) {
26865      var parserOptions = this.parserOptions;
26866      var hasMoreData = scanner.hasMoreData;
26867      var currentScanner = scanner;
26868      var columns = [];
26869      var currentToken = this.getStartToken(currentScanner, columns);
26870
26871      while (currentToken) {
26872        if (isTokenRowDelimiter(currentToken)) {
26873          currentScanner.advancePastToken(currentToken); // if ends with CR and there is more data, keep unparsed due to possible
26874          // coming LF in CRLF
26875
26876          if (!currentScanner.hasMoreCharacters && isTokenCarriageReturn(currentToken, parserOptions) && hasMoreData) {
26877            return null;
26878          }
26879
26880          currentScanner.truncateToCursor();
26881          return columns;
26882        }
26883
26884        if (!this.shouldSkipColumnParse(currentScanner, currentToken, columns)) {
26885          var item = this.columnParser.parse(currentScanner);
26886
26887          if (item === null) {
26888            return null;
26889          }
26890
26891          columns.push(item);
26892        }
26893
26894        currentToken = currentScanner.nextNonSpaceToken;
26895      }
26896
26897      if (!hasMoreData) {
26898        currentScanner.truncateToCursor();
26899        return columns;
26900      }
26901
26902      return null;
26903    }
26904  }, {
26905    key: "getStartToken",
26906    value: function getStartToken(scanner, columns) {
26907      var currentToken = scanner.nextNonSpaceToken;
26908
26909      if (currentToken !== null && isTokenDelimiter(currentToken, this.parserOptions)) {
26910        columns.push('');
26911        return scanner.nextNonSpaceToken;
26912      }
26913
26914      return currentToken;
26915    }
26916  }, {
26917    key: "shouldSkipColumnParse",
26918    value: function shouldSkipColumnParse(scanner, currentToken, columns) {
26919      var parserOptions = this.parserOptions;
26920
26921      if (isTokenDelimiter(currentToken, parserOptions)) {
26922        scanner.advancePastToken(currentToken); // if the delimiter is at the end of a line
26923
26924        var nextToken = scanner.nextCharacterToken;
26925
26926        if (!scanner.hasMoreCharacters || nextToken !== null && isTokenRowDelimiter(nextToken)) {
26927          columns.push('');
26928          return true;
26929        }
26930
26931        if (nextToken !== null && isTokenDelimiter(nextToken, parserOptions)) {
26932          columns.push('');
26933          return true;
26934        }
26935      }
26936
26937      return false;
26938    }
26939  }]);
26940
26941  return RowParser;
26942}();
26943
26944exports.RowParser = RowParser;
26945
26946},{"./Token":156,"./column":161}],155:[function(require,module,exports){
26947"use strict";
26948
26949function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26950
26951function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
26952
26953function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
26954
26955Object.defineProperty(exports, "__esModule", {
26956  value: true
26957});
26958exports.Scanner = void 0;
26959
26960var Token_1 = require("./Token");
26961
26962var ROW_DELIMITER = /((?:\r\n)|\n|\r)/;
26963
26964var Scanner = /*#__PURE__*/function () {
26965  function Scanner(args) {
26966    _classCallCheck(this, Scanner);
26967
26968    this.cursor = 0;
26969    this.line = args.line;
26970    this.lineLength = this.line.length;
26971    this.parserOptions = args.parserOptions;
26972    this.hasMoreData = args.hasMoreData;
26973    this.cursor = args.cursor || 0;
26974  }
26975
26976  _createClass(Scanner, [{
26977    key: "advancePastLine",
26978    value: function advancePastLine() {
26979      var match = ROW_DELIMITER.exec(this.lineFromCursor);
26980
26981      if (!match) {
26982        if (this.hasMoreData) {
26983          return null;
26984        }
26985
26986        this.cursor = this.lineLength;
26987        return this;
26988      }
26989
26990      this.cursor += (match.index || 0) + match[0].length;
26991      return this;
26992    }
26993  }, {
26994    key: "advanceTo",
26995    value: function advanceTo(cursor) {
26996      this.cursor = cursor;
26997      return this;
26998    }
26999  }, {
27000    key: "advanceToToken",
27001    value: function advanceToToken(token) {
27002      this.cursor = token.startCursor;
27003      return this;
27004    }
27005  }, {
27006    key: "advancePastToken",
27007    value: function advancePastToken(token) {
27008      this.cursor = token.endCursor + 1;
27009      return this;
27010    }
27011  }, {
27012    key: "truncateToCursor",
27013    value: function truncateToCursor() {
27014      this.line = this.lineFromCursor;
27015      this.lineLength = this.line.length;
27016      this.cursor = 0;
27017      return this;
27018    }
27019  }, {
27020    key: "hasMoreCharacters",
27021    get: function get() {
27022      return this.lineLength > this.cursor;
27023    }
27024  }, {
27025    key: "nextNonSpaceToken",
27026    get: function get() {
27027      var lineFromCursor = this.lineFromCursor;
27028      var regex = this.parserOptions.NEXT_TOKEN_REGEXP;
27029
27030      if (lineFromCursor.search(regex) === -1) {
27031        return null;
27032      }
27033
27034      var match = regex.exec(lineFromCursor);
27035
27036      if (match == null) {
27037        return null;
27038      }
27039
27040      var token = match[1];
27041      var startCursor = this.cursor + (match.index || 0);
27042      return new Token_1.Token({
27043        token: token,
27044        startCursor: startCursor,
27045        endCursor: startCursor + token.length - 1
27046      });
27047    }
27048  }, {
27049    key: "nextCharacterToken",
27050    get: function get() {
27051      var cursor = this.cursor,
27052          lineLength = this.lineLength;
27053
27054      if (lineLength <= cursor) {
27055        return null;
27056      }
27057
27058      return new Token_1.Token({
27059        token: this.line[cursor],
27060        startCursor: cursor,
27061        endCursor: cursor
27062      });
27063    }
27064  }, {
27065    key: "lineFromCursor",
27066    get: function get() {
27067      return this.line.substr(this.cursor);
27068    }
27069  }]);
27070
27071  return Scanner;
27072}();
27073
27074exports.Scanner = Scanner;
27075
27076},{"./Token":156}],156:[function(require,module,exports){
27077"use strict";
27078
27079function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27080
27081function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27082
27083function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27084
27085Object.defineProperty(exports, "__esModule", {
27086  value: true
27087});
27088exports.Token = void 0;
27089
27090var Token = /*#__PURE__*/function () {
27091  function Token(tokenArgs) {
27092    _classCallCheck(this, Token);
27093
27094    this.token = tokenArgs.token;
27095    this.startCursor = tokenArgs.startCursor;
27096    this.endCursor = tokenArgs.endCursor;
27097  }
27098
27099  _createClass(Token, null, [{
27100    key: "isTokenRowDelimiter",
27101    value: function isTokenRowDelimiter(token) {
27102      var content = token.token;
27103      return content === '\r' || content === '\n' || content === '\r\n';
27104    }
27105  }, {
27106    key: "isTokenCarriageReturn",
27107    value: function isTokenCarriageReturn(token, parserOptions) {
27108      return token.token === parserOptions.carriageReturn;
27109    }
27110  }, {
27111    key: "isTokenComment",
27112    value: function isTokenComment(token, parserOptions) {
27113      return parserOptions.supportsComments && !!token && token.token === parserOptions.comment;
27114    }
27115  }, {
27116    key: "isTokenEscapeCharacter",
27117    value: function isTokenEscapeCharacter(token, parserOptions) {
27118      return token.token === parserOptions.escapeChar;
27119    }
27120  }, {
27121    key: "isTokenQuote",
27122    value: function isTokenQuote(token, parserOptions) {
27123      return token.token === parserOptions.quote;
27124    }
27125  }, {
27126    key: "isTokenDelimiter",
27127    value: function isTokenDelimiter(token, parserOptions) {
27128      return token.token === parserOptions.delimiter;
27129    }
27130  }]);
27131
27132  return Token;
27133}();
27134
27135exports.Token = Token;
27136
27137},{}],157:[function(require,module,exports){
27138"use strict";
27139
27140function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27141
27142Object.defineProperty(exports, "__esModule", {
27143  value: true
27144});
27145exports.ColumnFormatter = void 0;
27146
27147var ColumnFormatter = function ColumnFormatter(parserOptions) {
27148  _classCallCheck(this, ColumnFormatter);
27149
27150  if (parserOptions.trim) {
27151    this.format = function (col) {
27152      return col.trim();
27153    };
27154  } else if (parserOptions.ltrim) {
27155    this.format = function (col) {
27156      return col.trimLeft();
27157    };
27158  } else if (parserOptions.rtrim) {
27159    this.format = function (col) {
27160      return col.trimRight();
27161    };
27162  } else {
27163    this.format = function (col) {
27164      return col;
27165    };
27166  }
27167};
27168
27169exports.ColumnFormatter = ColumnFormatter;
27170
27171},{}],158:[function(require,module,exports){
27172"use strict";
27173
27174function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27175
27176function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27177
27178function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27179
27180Object.defineProperty(exports, "__esModule", {
27181  value: true
27182});
27183exports.ColumnParser = void 0;
27184
27185var NonQuotedColumnParser_1 = require("./NonQuotedColumnParser");
27186
27187var QuotedColumnParser_1 = require("./QuotedColumnParser");
27188
27189var Token_1 = require("../Token");
27190
27191var ColumnParser = /*#__PURE__*/function () {
27192  function ColumnParser(parserOptions) {
27193    _classCallCheck(this, ColumnParser);
27194
27195    this.parserOptions = parserOptions;
27196    this.quotedColumnParser = new QuotedColumnParser_1.QuotedColumnParser(parserOptions);
27197    this.nonQuotedColumnParser = new NonQuotedColumnParser_1.NonQuotedColumnParser(parserOptions);
27198  }
27199
27200  _createClass(ColumnParser, [{
27201    key: "parse",
27202    value: function parse(scanner) {
27203      var nextNonSpaceToken = scanner.nextNonSpaceToken;
27204
27205      if (nextNonSpaceToken !== null && Token_1.Token.isTokenQuote(nextNonSpaceToken, this.parserOptions)) {
27206        scanner.advanceToToken(nextNonSpaceToken);
27207        return this.quotedColumnParser.parse(scanner);
27208      }
27209
27210      return this.nonQuotedColumnParser.parse(scanner);
27211    }
27212  }]);
27213
27214  return ColumnParser;
27215}();
27216
27217exports.ColumnParser = ColumnParser;
27218
27219},{"../Token":156,"./NonQuotedColumnParser":159,"./QuotedColumnParser":160}],159:[function(require,module,exports){
27220"use strict";
27221
27222function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27223
27224function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27225
27226function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27227
27228Object.defineProperty(exports, "__esModule", {
27229  value: true
27230});
27231exports.NonQuotedColumnParser = void 0;
27232
27233var ColumnFormatter_1 = require("./ColumnFormatter");
27234
27235var Token_1 = require("../Token");
27236
27237var _Token_1$Token = Token_1.Token,
27238    isTokenDelimiter = _Token_1$Token.isTokenDelimiter,
27239    isTokenRowDelimiter = _Token_1$Token.isTokenRowDelimiter;
27240
27241var NonQuotedColumnParser = /*#__PURE__*/function () {
27242  function NonQuotedColumnParser(parserOptions) {
27243    _classCallCheck(this, NonQuotedColumnParser);
27244
27245    this.parserOptions = parserOptions;
27246    this.columnFormatter = new ColumnFormatter_1.ColumnFormatter(parserOptions);
27247  }
27248
27249  _createClass(NonQuotedColumnParser, [{
27250    key: "parse",
27251    value: function parse(scanner) {
27252      if (!scanner.hasMoreCharacters) {
27253        return null;
27254      }
27255
27256      var parserOptions = this.parserOptions;
27257      var characters = [];
27258      var nextToken = scanner.nextCharacterToken;
27259
27260      for (; nextToken; nextToken = scanner.nextCharacterToken) {
27261        if (isTokenDelimiter(nextToken, parserOptions) || isTokenRowDelimiter(nextToken)) {
27262          break;
27263        }
27264
27265        characters.push(nextToken.token);
27266        scanner.advancePastToken(nextToken);
27267      }
27268
27269      return this.columnFormatter.format(characters.join(''));
27270    }
27271  }]);
27272
27273  return NonQuotedColumnParser;
27274}();
27275
27276exports.NonQuotedColumnParser = NonQuotedColumnParser;
27277
27278},{"../Token":156,"./ColumnFormatter":157}],160:[function(require,module,exports){
27279"use strict";
27280
27281function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27282
27283function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27284
27285function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27286
27287Object.defineProperty(exports, "__esModule", {
27288  value: true
27289});
27290exports.QuotedColumnParser = void 0;
27291
27292var ColumnFormatter_1 = require("./ColumnFormatter");
27293
27294var Token_1 = require("../Token");
27295
27296var _Token_1$Token = Token_1.Token,
27297    isTokenDelimiter = _Token_1$Token.isTokenDelimiter,
27298    isTokenRowDelimiter = _Token_1$Token.isTokenRowDelimiter,
27299    isTokenEscapeCharacter = _Token_1$Token.isTokenEscapeCharacter,
27300    isTokenQuote = _Token_1$Token.isTokenQuote;
27301
27302var QuotedColumnParser = /*#__PURE__*/function () {
27303  function QuotedColumnParser(parserOptions) {
27304    _classCallCheck(this, QuotedColumnParser);
27305
27306    this.parserOptions = parserOptions;
27307    this.columnFormatter = new ColumnFormatter_1.ColumnFormatter(parserOptions);
27308  }
27309
27310  _createClass(QuotedColumnParser, [{
27311    key: "parse",
27312    value: function parse(scanner) {
27313      if (!scanner.hasMoreCharacters) {
27314        return null;
27315      }
27316
27317      var originalCursor = scanner.cursor;
27318
27319      var _this$gatherDataBetwe = this.gatherDataBetweenQuotes(scanner),
27320          foundClosingQuote = _this$gatherDataBetwe.foundClosingQuote,
27321          col = _this$gatherDataBetwe.col;
27322
27323      if (!foundClosingQuote) {
27324        // reset the cursor to the original
27325        scanner.advanceTo(originalCursor); // if we didnt find a closing quote but we potentially have more data then skip the parsing
27326        // and return the original scanner.
27327
27328        if (!scanner.hasMoreData) {
27329          throw new Error("Parse Error: missing closing: '".concat(this.parserOptions.quote || '', "' in line: at '").concat(scanner.lineFromCursor.replace(/[\r\n]/g, "\\n'"), "'"));
27330        }
27331
27332        return null;
27333      }
27334
27335      this.checkForMalformedColumn(scanner);
27336      return col;
27337    }
27338  }, {
27339    key: "gatherDataBetweenQuotes",
27340    value: function gatherDataBetweenQuotes(scanner) {
27341      var parserOptions = this.parserOptions;
27342      var foundStartingQuote = false;
27343      var foundClosingQuote = false;
27344      var characters = [];
27345      var nextToken = scanner.nextCharacterToken;
27346
27347      for (; !foundClosingQuote && nextToken !== null; nextToken = scanner.nextCharacterToken) {
27348        var isQuote = isTokenQuote(nextToken, parserOptions); // ignore first quote
27349
27350        if (!foundStartingQuote && isQuote) {
27351          foundStartingQuote = true;
27352        } else if (foundStartingQuote) {
27353          if (isTokenEscapeCharacter(nextToken, parserOptions)) {
27354            // advance past the escape character so we can get the next one in line
27355            scanner.advancePastToken(nextToken);
27356            var tokenFollowingEscape = scanner.nextCharacterToken; // if the character following the escape is a quote character then just add
27357            // the quote and advance to that character
27358
27359            if (tokenFollowingEscape !== null && (isTokenQuote(tokenFollowingEscape, parserOptions) || isTokenEscapeCharacter(tokenFollowingEscape, parserOptions))) {
27360              characters.push(tokenFollowingEscape.token);
27361              nextToken = tokenFollowingEscape;
27362            } else if (isQuote) {
27363              // if the escape is also a quote then we found our closing quote and finish early
27364              foundClosingQuote = true;
27365            } else {
27366              // other wise add the escape token to the characters since it wast escaping anything
27367              characters.push(nextToken.token);
27368            }
27369          } else if (isQuote) {
27370            // we found our closing quote!
27371            foundClosingQuote = true;
27372          } else {
27373            // add the token to the characters
27374            characters.push(nextToken.token);
27375          }
27376        }
27377
27378        scanner.advancePastToken(nextToken);
27379      }
27380
27381      return {
27382        col: this.columnFormatter.format(characters.join('')),
27383        foundClosingQuote: foundClosingQuote
27384      };
27385    }
27386  }, {
27387    key: "checkForMalformedColumn",
27388    value: function checkForMalformedColumn(scanner) {
27389      var parserOptions = this.parserOptions;
27390      var nextNonSpaceToken = scanner.nextNonSpaceToken;
27391
27392      if (nextNonSpaceToken) {
27393        var isNextTokenADelimiter = isTokenDelimiter(nextNonSpaceToken, parserOptions);
27394        var isNextTokenARowDelimiter = isTokenRowDelimiter(nextNonSpaceToken);
27395
27396        if (!(isNextTokenADelimiter || isNextTokenARowDelimiter)) {
27397          // if the final quote was NOT followed by a column (,) or row(\n) delimiter then its a bad column
27398          // tldr: only part of the column was quoted
27399          var linePreview = scanner.lineFromCursor.substr(0, 10).replace(/[\r\n]/g, "\\n'");
27400          throw new Error("Parse Error: expected: '".concat(parserOptions.escapedDelimiter, "' OR new line got: '").concat(nextNonSpaceToken.token, "'. at '").concat(linePreview));
27401        }
27402
27403        scanner.advanceToToken(nextNonSpaceToken);
27404      } else if (!scanner.hasMoreData) {
27405        scanner.advancePastLine();
27406      }
27407    }
27408  }]);
27409
27410  return QuotedColumnParser;
27411}();
27412
27413exports.QuotedColumnParser = QuotedColumnParser;
27414
27415},{"../Token":156,"./ColumnFormatter":157}],161:[function(require,module,exports){
27416"use strict";
27417
27418Object.defineProperty(exports, "__esModule", {
27419  value: true
27420});
27421
27422var ColumnParser_1 = require("./ColumnParser");
27423
27424Object.defineProperty(exports, "ColumnParser", {
27425  enumerable: true,
27426  get: function get() {
27427    return ColumnParser_1.ColumnParser;
27428  }
27429});
27430
27431var NonQuotedColumnParser_1 = require("./NonQuotedColumnParser");
27432
27433Object.defineProperty(exports, "NonQuotedColumnParser", {
27434  enumerable: true,
27435  get: function get() {
27436    return NonQuotedColumnParser_1.NonQuotedColumnParser;
27437  }
27438});
27439
27440var QuotedColumnParser_1 = require("./QuotedColumnParser");
27441
27442Object.defineProperty(exports, "QuotedColumnParser", {
27443  enumerable: true,
27444  get: function get() {
27445    return QuotedColumnParser_1.QuotedColumnParser;
27446  }
27447});
27448
27449var ColumnFormatter_1 = require("./ColumnFormatter");
27450
27451Object.defineProperty(exports, "ColumnFormatter", {
27452  enumerable: true,
27453  get: function get() {
27454    return ColumnFormatter_1.ColumnFormatter;
27455  }
27456});
27457
27458},{"./ColumnFormatter":157,"./ColumnParser":158,"./NonQuotedColumnParser":159,"./QuotedColumnParser":160}],162:[function(require,module,exports){
27459"use strict";
27460
27461Object.defineProperty(exports, "__esModule", {
27462  value: true
27463});
27464
27465var Parser_1 = require("./Parser");
27466
27467Object.defineProperty(exports, "Parser", {
27468  enumerable: true,
27469  get: function get() {
27470    return Parser_1.Parser;
27471  }
27472});
27473
27474var RowParser_1 = require("./RowParser");
27475
27476Object.defineProperty(exports, "RowParser", {
27477  enumerable: true,
27478  get: function get() {
27479    return RowParser_1.RowParser;
27480  }
27481});
27482
27483var Scanner_1 = require("./Scanner");
27484
27485Object.defineProperty(exports, "Scanner", {
27486  enumerable: true,
27487  get: function get() {
27488    return Scanner_1.Scanner;
27489  }
27490});
27491
27492var Token_1 = require("./Token");
27493
27494Object.defineProperty(exports, "Token", {
27495  enumerable: true,
27496  get: function get() {
27497    return Token_1.Token;
27498  }
27499});
27500
27501var column_1 = require("./column");
27502
27503Object.defineProperty(exports, "ColumnParser", {
27504  enumerable: true,
27505  get: function get() {
27506    return column_1.ColumnParser;
27507  }
27508});
27509Object.defineProperty(exports, "NonQuotedColumnParser", {
27510  enumerable: true,
27511  get: function get() {
27512    return column_1.NonQuotedColumnParser;
27513  }
27514});
27515Object.defineProperty(exports, "QuotedColumnParser", {
27516  enumerable: true,
27517  get: function get() {
27518    return column_1.QuotedColumnParser;
27519  }
27520});
27521
27522},{"./Parser":153,"./RowParser":154,"./Scanner":155,"./Token":156,"./column":161}],163:[function(require,module,exports){
27523"use strict";
27524
27525function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27526
27527function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27528
27529function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27530
27531var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
27532  return mod && mod.__esModule ? mod : {
27533    "default": mod
27534  };
27535};
27536
27537Object.defineProperty(exports, "__esModule", {
27538  value: true
27539});
27540exports.HeaderTransformer = void 0;
27541
27542var lodash_isundefined_1 = __importDefault(require("lodash.isundefined"));
27543
27544var lodash_isfunction_1 = __importDefault(require("lodash.isfunction"));
27545
27546var lodash_uniq_1 = __importDefault(require("lodash.uniq"));
27547
27548var lodash_groupby_1 = __importDefault(require("lodash.groupby"));
27549
27550var HeaderTransformer = /*#__PURE__*/function () {
27551  function HeaderTransformer(parserOptions) {
27552    _classCallCheck(this, HeaderTransformer);
27553
27554    this.headers = null;
27555    this.receivedHeaders = false;
27556    this.shouldUseFirstRow = false;
27557    this.processedFirstRow = false;
27558    this.headersLength = 0;
27559    this.parserOptions = parserOptions;
27560
27561    if (parserOptions.headers === true) {
27562      this.shouldUseFirstRow = true;
27563    } else if (Array.isArray(parserOptions.headers)) {
27564      this.setHeaders(parserOptions.headers);
27565    } else if (lodash_isfunction_1.default(parserOptions.headers)) {
27566      this.headersTransform = parserOptions.headers;
27567    }
27568  }
27569
27570  _createClass(HeaderTransformer, [{
27571    key: "transform",
27572    value: function transform(row, cb) {
27573      if (!this.shouldMapRow(row)) {
27574        return cb(null, {
27575          row: null,
27576          isValid: true
27577        });
27578      }
27579
27580      return cb(null, this.processRow(row));
27581    }
27582  }, {
27583    key: "shouldMapRow",
27584    value: function shouldMapRow(row) {
27585      var parserOptions = this.parserOptions;
27586
27587      if (!this.headersTransform && parserOptions.renameHeaders && !this.processedFirstRow) {
27588        if (!this.receivedHeaders) {
27589          throw new Error('Error renaming headers: new headers must be provided in an array');
27590        }
27591
27592        this.processedFirstRow = true;
27593        return false;
27594      }
27595
27596      if (!this.receivedHeaders && Array.isArray(row)) {
27597        if (this.headersTransform) {
27598          this.setHeaders(this.headersTransform(row));
27599        } else if (this.shouldUseFirstRow) {
27600          this.setHeaders(row);
27601        } else {
27602          // dont do anything with the headers if we didnt receive a transform or shouldnt use the first row.
27603          return true;
27604        }
27605
27606        return false;
27607      }
27608
27609      return true;
27610    }
27611  }, {
27612    key: "processRow",
27613    value: function processRow(row) {
27614      if (!this.headers) {
27615        return {
27616          row: row,
27617          isValid: true
27618        };
27619      }
27620
27621      var parserOptions = this.parserOptions;
27622
27623      if (!parserOptions.discardUnmappedColumns && row.length > this.headersLength) {
27624        if (!parserOptions.strictColumnHandling) {
27625          throw new Error("Unexpected Error: column header mismatch expected: ".concat(this.headersLength, " columns got: ").concat(row.length));
27626        }
27627
27628        return {
27629          row: row,
27630          isValid: false,
27631          reason: "Column header mismatch expected: ".concat(this.headersLength, " columns got: ").concat(row.length)
27632        };
27633      }
27634
27635      if (parserOptions.strictColumnHandling && row.length < this.headersLength) {
27636        return {
27637          row: row,
27638          isValid: false,
27639          reason: "Column header mismatch expected: ".concat(this.headersLength, " columns got: ").concat(row.length)
27640        };
27641      }
27642
27643      return {
27644        row: this.mapHeaders(row),
27645        isValid: true
27646      };
27647    }
27648  }, {
27649    key: "mapHeaders",
27650    value: function mapHeaders(row) {
27651      var rowMap = {};
27652      var headers = this.headers,
27653          headersLength = this.headersLength;
27654
27655      for (var i = 0; i < headersLength; i += 1) {
27656        var header = headers[i];
27657
27658        if (!lodash_isundefined_1.default(header)) {
27659          var val = row[i]; // eslint-disable-next-line no-param-reassign
27660
27661          if (lodash_isundefined_1.default(val)) {
27662            rowMap[header] = '';
27663          } else {
27664            rowMap[header] = val;
27665          }
27666        }
27667      }
27668
27669      return rowMap;
27670    }
27671  }, {
27672    key: "setHeaders",
27673    value: function setHeaders(headers) {
27674      var _a;
27675
27676      var filteredHeaders = headers.filter(function (h) {
27677        return !!h;
27678      });
27679
27680      if (lodash_uniq_1.default(filteredHeaders).length !== filteredHeaders.length) {
27681        var grouped = lodash_groupby_1.default(filteredHeaders);
27682        var duplicates = Object.keys(grouped).filter(function (dup) {
27683          return grouped[dup].length > 1;
27684        });
27685        throw new Error("Duplicate headers found ".concat(JSON.stringify(duplicates)));
27686      }
27687
27688      this.headers = headers;
27689      this.receivedHeaders = true;
27690      this.headersLength = ((_a = this.headers) === null || _a === void 0 ? void 0 : _a.length) || 0;
27691    }
27692  }]);
27693
27694  return HeaderTransformer;
27695}();
27696
27697exports.HeaderTransformer = HeaderTransformer;
27698
27699},{"lodash.groupby":427,"lodash.isfunction":430,"lodash.isundefined":432,"lodash.uniq":433}],164:[function(require,module,exports){
27700"use strict";
27701
27702function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27703
27704function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27705
27706function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27707
27708var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
27709  return mod && mod.__esModule ? mod : {
27710    "default": mod
27711  };
27712};
27713
27714Object.defineProperty(exports, "__esModule", {
27715  value: true
27716});
27717exports.RowTransformerValidator = void 0;
27718
27719var lodash_isfunction_1 = __importDefault(require("lodash.isfunction"));
27720
27721var types_1 = require("../types");
27722
27723var RowTransformerValidator = /*#__PURE__*/function () {
27724  function RowTransformerValidator() {
27725    _classCallCheck(this, RowTransformerValidator);
27726
27727    this._rowTransform = null;
27728    this._rowValidator = null;
27729  }
27730
27731  _createClass(RowTransformerValidator, [{
27732    key: "transformAndValidate",
27733    value: function transformAndValidate(row, cb) {
27734      var _this = this;
27735
27736      return this.callTransformer(row, function (transformErr, transformedRow) {
27737        if (transformErr) {
27738          return cb(transformErr);
27739        }
27740
27741        if (!transformedRow) {
27742          return cb(null, {
27743            row: null,
27744            isValid: true
27745          });
27746        }
27747
27748        return _this.callValidator(transformedRow, function (validateErr, validationResult) {
27749          if (validateErr) {
27750            return cb(validateErr);
27751          }
27752
27753          if (validationResult && !validationResult.isValid) {
27754            return cb(null, {
27755              row: transformedRow,
27756              isValid: false,
27757              reason: validationResult.reason
27758            });
27759          }
27760
27761          return cb(null, {
27762            row: transformedRow,
27763            isValid: true
27764          });
27765        });
27766      });
27767    }
27768  }, {
27769    key: "callTransformer",
27770    value: function callTransformer(row, cb) {
27771      if (!this._rowTransform) {
27772        return cb(null, row);
27773      }
27774
27775      return this._rowTransform(row, cb);
27776    }
27777  }, {
27778    key: "callValidator",
27779    value: function callValidator(row, cb) {
27780      if (!this._rowValidator) {
27781        return cb(null, {
27782          row: row,
27783          isValid: true
27784        });
27785      }
27786
27787      return this._rowValidator(row, cb);
27788    }
27789  }, {
27790    key: "rowTransform",
27791    set: function set(transformFunction) {
27792      if (!lodash_isfunction_1.default(transformFunction)) {
27793        throw new TypeError('The transform should be a function');
27794      }
27795
27796      this._rowTransform = RowTransformerValidator.createTransform(transformFunction);
27797    }
27798  }, {
27799    key: "rowValidator",
27800    set: function set(validateFunction) {
27801      if (!lodash_isfunction_1.default(validateFunction)) {
27802        throw new TypeError('The validate should be a function');
27803      }
27804
27805      this._rowValidator = RowTransformerValidator.createValidator(validateFunction);
27806    }
27807  }], [{
27808    key: "createTransform",
27809    value: function createTransform(transformFunction) {
27810      if (types_1.isSyncTransform(transformFunction)) {
27811        return function (row, cb) {
27812          var transformed = null;
27813
27814          try {
27815            transformed = transformFunction(row);
27816          } catch (e) {
27817            return cb(e);
27818          }
27819
27820          return cb(null, transformed);
27821        };
27822      }
27823
27824      return transformFunction;
27825    }
27826  }, {
27827    key: "createValidator",
27828    value: function createValidator(validateFunction) {
27829      if (types_1.isSyncValidate(validateFunction)) {
27830        return function (row, cb) {
27831          cb(null, {
27832            row: row,
27833            isValid: validateFunction(row)
27834          });
27835        };
27836      }
27837
27838      return function (row, cb) {
27839        validateFunction(row, function (err, isValid, reason) {
27840          if (err) {
27841            return cb(err);
27842          }
27843
27844          if (isValid) {
27845            return cb(null, {
27846              row: row,
27847              isValid: isValid,
27848              reason: reason
27849            });
27850          }
27851
27852          return cb(null, {
27853            row: row,
27854            isValid: false,
27855            reason: reason
27856          });
27857        });
27858      };
27859    }
27860  }]);
27861
27862  return RowTransformerValidator;
27863}();
27864
27865exports.RowTransformerValidator = RowTransformerValidator;
27866
27867},{"../types":166,"lodash.isfunction":430}],165:[function(require,module,exports){
27868"use strict";
27869
27870Object.defineProperty(exports, "__esModule", {
27871  value: true
27872});
27873
27874var RowTransformerValidator_1 = require("./RowTransformerValidator");
27875
27876Object.defineProperty(exports, "RowTransformerValidator", {
27877  enumerable: true,
27878  get: function get() {
27879    return RowTransformerValidator_1.RowTransformerValidator;
27880  }
27881});
27882
27883var HeaderTransformer_1 = require("./HeaderTransformer");
27884
27885Object.defineProperty(exports, "HeaderTransformer", {
27886  enumerable: true,
27887  get: function get() {
27888    return HeaderTransformer_1.HeaderTransformer;
27889  }
27890});
27891
27892},{"./HeaderTransformer":163,"./RowTransformerValidator":164}],166:[function(require,module,exports){
27893"use strict";
27894
27895Object.defineProperty(exports, "__esModule", {
27896  value: true
27897});
27898exports.isSyncValidate = exports.isSyncTransform = void 0;
27899
27900exports.isSyncTransform = function (transform) {
27901  return transform.length === 1;
27902};
27903
27904exports.isSyncValidate = function (validate) {
27905  return validate.length === 1;
27906};
27907
27908},{}],167:[function(require,module,exports){
27909'use strict';
27910
27911var asn1 = exports;
27912asn1.bignum = require('bn.js');
27913asn1.define = require('./asn1/api').define;
27914asn1.base = require('./asn1/base');
27915asn1.constants = require('./asn1/constants');
27916asn1.decoders = require('./asn1/decoders');
27917asn1.encoders = require('./asn1/encoders');
27918
27919},{"./asn1/api":168,"./asn1/base":170,"./asn1/constants":174,"./asn1/decoders":176,"./asn1/encoders":179,"bn.js":181}],168:[function(require,module,exports){
27920'use strict';
27921
27922var encoders = require('./encoders');
27923
27924var decoders = require('./decoders');
27925
27926var inherits = require('inherits');
27927
27928var api = exports;
27929
27930api.define = function define(name, body) {
27931  return new Entity(name, body);
27932};
27933
27934function Entity(name, body) {
27935  this.name = name;
27936  this.body = body;
27937  this.decoders = {};
27938  this.encoders = {};
27939}
27940
27941Entity.prototype._createNamed = function createNamed(Base) {
27942  var name = this.name;
27943
27944  function Generated(entity) {
27945    this._initNamed(entity, name);
27946  }
27947
27948  inherits(Generated, Base);
27949
27950  Generated.prototype._initNamed = function _initNamed(entity, name) {
27951    Base.call(this, entity, name);
27952  };
27953
27954  return new Generated(this);
27955};
27956
27957Entity.prototype._getDecoder = function _getDecoder(enc) {
27958  enc = enc || 'der'; // Lazily create decoder
27959
27960  if (!this.decoders.hasOwnProperty(enc)) this.decoders[enc] = this._createNamed(decoders[enc]);
27961  return this.decoders[enc];
27962};
27963
27964Entity.prototype.decode = function decode(data, enc, options) {
27965  return this._getDecoder(enc).decode(data, options);
27966};
27967
27968Entity.prototype._getEncoder = function _getEncoder(enc) {
27969  enc = enc || 'der'; // Lazily create encoder
27970
27971  if (!this.encoders.hasOwnProperty(enc)) this.encoders[enc] = this._createNamed(encoders[enc]);
27972  return this.encoders[enc];
27973};
27974
27975Entity.prototype.encode = function encode(data, enc,
27976/* internal */
27977reporter) {
27978  return this._getEncoder(enc).encode(data, reporter);
27979};
27980
27981},{"./decoders":176,"./encoders":179,"inherits":387}],169:[function(require,module,exports){
27982'use strict';
27983
27984function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
27985
27986var inherits = require('inherits');
27987
27988var Reporter = require('../base/reporter').Reporter;
27989
27990var Buffer = require('safer-buffer').Buffer;
27991
27992function DecoderBuffer(base, options) {
27993  Reporter.call(this, options);
27994
27995  if (!Buffer.isBuffer(base)) {
27996    this.error('Input not Buffer');
27997    return;
27998  }
27999
28000  this.base = base;
28001  this.offset = 0;
28002  this.length = base.length;
28003}
28004
28005inherits(DecoderBuffer, Reporter);
28006exports.DecoderBuffer = DecoderBuffer;
28007
28008DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) {
28009  if (data instanceof DecoderBuffer) {
28010    return true;
28011  } // Or accept compatible API
28012
28013
28014  var isCompatible = _typeof(data) === 'object' && Buffer.isBuffer(data.base) && data.constructor.name === 'DecoderBuffer' && typeof data.offset === 'number' && typeof data.length === 'number' && typeof data.save === 'function' && typeof data.restore === 'function' && typeof data.isEmpty === 'function' && typeof data.readUInt8 === 'function' && typeof data.skip === 'function' && typeof data.raw === 'function';
28015  return isCompatible;
28016};
28017
28018DecoderBuffer.prototype.save = function save() {
28019  return {
28020    offset: this.offset,
28021    reporter: Reporter.prototype.save.call(this)
28022  };
28023};
28024
28025DecoderBuffer.prototype.restore = function restore(save) {
28026  // Return skipped data
28027  var res = new DecoderBuffer(this.base);
28028  res.offset = save.offset;
28029  res.length = this.offset;
28030  this.offset = save.offset;
28031  Reporter.prototype.restore.call(this, save.reporter);
28032  return res;
28033};
28034
28035DecoderBuffer.prototype.isEmpty = function isEmpty() {
28036  return this.offset === this.length;
28037};
28038
28039DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
28040  if (this.offset + 1 <= this.length) return this.base.readUInt8(this.offset++, true);else return this.error(fail || 'DecoderBuffer overrun');
28041};
28042
28043DecoderBuffer.prototype.skip = function skip(bytes, fail) {
28044  if (!(this.offset + bytes <= this.length)) return this.error(fail || 'DecoderBuffer overrun');
28045  var res = new DecoderBuffer(this.base); // Share reporter state
28046
28047  res._reporterState = this._reporterState;
28048  res.offset = this.offset;
28049  res.length = this.offset + bytes;
28050  this.offset += bytes;
28051  return res;
28052};
28053
28054DecoderBuffer.prototype.raw = function raw(save) {
28055  return this.base.slice(save ? save.offset : this.offset, this.length);
28056};
28057
28058function EncoderBuffer(value, reporter) {
28059  if (Array.isArray(value)) {
28060    this.length = 0;
28061    this.value = value.map(function (item) {
28062      if (!EncoderBuffer.isEncoderBuffer(item)) item = new EncoderBuffer(item, reporter);
28063      this.length += item.length;
28064      return item;
28065    }, this);
28066  } else if (typeof value === 'number') {
28067    if (!(0 <= value && value <= 0xff)) return reporter.error('non-byte EncoderBuffer value');
28068    this.value = value;
28069    this.length = 1;
28070  } else if (typeof value === 'string') {
28071    this.value = value;
28072    this.length = Buffer.byteLength(value);
28073  } else if (Buffer.isBuffer(value)) {
28074    this.value = value;
28075    this.length = value.length;
28076  } else {
28077    return reporter.error('Unsupported type: ' + _typeof(value));
28078  }
28079}
28080
28081exports.EncoderBuffer = EncoderBuffer;
28082
28083EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) {
28084  if (data instanceof EncoderBuffer) {
28085    return true;
28086  } // Or accept compatible API
28087
28088
28089  var isCompatible = _typeof(data) === 'object' && data.constructor.name === 'EncoderBuffer' && typeof data.length === 'number' && typeof data.join === 'function';
28090  return isCompatible;
28091};
28092
28093EncoderBuffer.prototype.join = function join(out, offset) {
28094  if (!out) out = Buffer.alloc(this.length);
28095  if (!offset) offset = 0;
28096  if (this.length === 0) return out;
28097
28098  if (Array.isArray(this.value)) {
28099    this.value.forEach(function (item) {
28100      item.join(out, offset);
28101      offset += item.length;
28102    });
28103  } else {
28104    if (typeof this.value === 'number') out[offset] = this.value;else if (typeof this.value === 'string') out.write(this.value, offset);else if (Buffer.isBuffer(this.value)) this.value.copy(out, offset);
28105    offset += this.length;
28106  }
28107
28108  return out;
28109};
28110
28111},{"../base/reporter":172,"inherits":387,"safer-buffer":495}],170:[function(require,module,exports){
28112'use strict';
28113
28114var base = exports;
28115base.Reporter = require('./reporter').Reporter;
28116base.DecoderBuffer = require('./buffer').DecoderBuffer;
28117base.EncoderBuffer = require('./buffer').EncoderBuffer;
28118base.Node = require('./node');
28119
28120},{"./buffer":169,"./node":171,"./reporter":172}],171:[function(require,module,exports){
28121'use strict';
28122
28123function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
28124
28125var Reporter = require('../base/reporter').Reporter;
28126
28127var EncoderBuffer = require('../base/buffer').EncoderBuffer;
28128
28129var DecoderBuffer = require('../base/buffer').DecoderBuffer;
28130
28131var assert = require('minimalistic-assert'); // Supported tags
28132
28133
28134var tags = ['seq', 'seqof', 'set', 'setof', 'objid', 'bool', 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr']; // Public methods list
28135
28136var methods = ['key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', 'any', 'contains'].concat(tags); // Overrided methods list
28137
28138var overrided = ['_peekTag', '_decodeTag', '_use', '_decodeStr', '_decodeObjid', '_decodeTime', '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime', '_encodeNull', '_encodeInt', '_encodeBool'];
28139
28140function Node(enc, parent, name) {
28141  var state = {};
28142  this._baseState = state;
28143  state.name = name;
28144  state.enc = enc;
28145  state.parent = parent || null;
28146  state.children = null; // State
28147
28148  state.tag = null;
28149  state.args = null;
28150  state.reverseArgs = null;
28151  state.choice = null;
28152  state.optional = false;
28153  state.any = false;
28154  state.obj = false;
28155  state.use = null;
28156  state.useDecoder = null;
28157  state.key = null;
28158  state['default'] = null;
28159  state.explicit = null;
28160  state.implicit = null;
28161  state.contains = null; // Should create new instance on each method
28162
28163  if (!state.parent) {
28164    state.children = [];
28165
28166    this._wrap();
28167  }
28168}
28169
28170module.exports = Node;
28171var stateProps = ['enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', 'implicit', 'contains'];
28172
28173Node.prototype.clone = function clone() {
28174  var state = this._baseState;
28175  var cstate = {};
28176  stateProps.forEach(function (prop) {
28177    cstate[prop] = state[prop];
28178  });
28179  var res = new this.constructor(cstate.parent);
28180  res._baseState = cstate;
28181  return res;
28182};
28183
28184Node.prototype._wrap = function wrap() {
28185  var state = this._baseState;
28186  methods.forEach(function (method) {
28187    this[method] = function _wrappedMethod() {
28188      var clone = new this.constructor(this);
28189      state.children.push(clone);
28190      return clone[method].apply(clone, arguments);
28191    };
28192  }, this);
28193};
28194
28195Node.prototype._init = function init(body) {
28196  var state = this._baseState;
28197  assert(state.parent === null);
28198  body.call(this); // Filter children
28199
28200  state.children = state.children.filter(function (child) {
28201    return child._baseState.parent === this;
28202  }, this);
28203  assert.equal(state.children.length, 1, 'Root node can have only one child');
28204};
28205
28206Node.prototype._useArgs = function useArgs(args) {
28207  var state = this._baseState; // Filter children and args
28208
28209  var children = args.filter(function (arg) {
28210    return arg instanceof this.constructor;
28211  }, this);
28212  args = args.filter(function (arg) {
28213    return !(arg instanceof this.constructor);
28214  }, this);
28215
28216  if (children.length !== 0) {
28217    assert(state.children === null);
28218    state.children = children; // Replace parent to maintain backward link
28219
28220    children.forEach(function (child) {
28221      child._baseState.parent = this;
28222    }, this);
28223  }
28224
28225  if (args.length !== 0) {
28226    assert(state.args === null);
28227    state.args = args;
28228    state.reverseArgs = args.map(function (arg) {
28229      if (_typeof(arg) !== 'object' || arg.constructor !== Object) return arg;
28230      var res = {};
28231      Object.keys(arg).forEach(function (key) {
28232        if (key == (key | 0)) key |= 0;
28233        var value = arg[key];
28234        res[value] = key;
28235      });
28236      return res;
28237    });
28238  }
28239}; //
28240// Overrided methods
28241//
28242
28243
28244overrided.forEach(function (method) {
28245  Node.prototype[method] = function _overrided() {
28246    var state = this._baseState;
28247    throw new Error(method + ' not implemented for encoding: ' + state.enc);
28248  };
28249}); //
28250// Public methods
28251//
28252
28253tags.forEach(function (tag) {
28254  Node.prototype[tag] = function _tagMethod() {
28255    var state = this._baseState;
28256    var args = Array.prototype.slice.call(arguments);
28257    assert(state.tag === null);
28258    state.tag = tag;
28259
28260    this._useArgs(args);
28261
28262    return this;
28263  };
28264});
28265
28266Node.prototype.use = function use(item) {
28267  assert(item);
28268  var state = this._baseState;
28269  assert(state.use === null);
28270  state.use = item;
28271  return this;
28272};
28273
28274Node.prototype.optional = function optional() {
28275  var state = this._baseState;
28276  state.optional = true;
28277  return this;
28278};
28279
28280Node.prototype.def = function def(val) {
28281  var state = this._baseState;
28282  assert(state['default'] === null);
28283  state['default'] = val;
28284  state.optional = true;
28285  return this;
28286};
28287
28288Node.prototype.explicit = function explicit(num) {
28289  var state = this._baseState;
28290  assert(state.explicit === null && state.implicit === null);
28291  state.explicit = num;
28292  return this;
28293};
28294
28295Node.prototype.implicit = function implicit(num) {
28296  var state = this._baseState;
28297  assert(state.explicit === null && state.implicit === null);
28298  state.implicit = num;
28299  return this;
28300};
28301
28302Node.prototype.obj = function obj() {
28303  var state = this._baseState;
28304  var args = Array.prototype.slice.call(arguments);
28305  state.obj = true;
28306  if (args.length !== 0) this._useArgs(args);
28307  return this;
28308};
28309
28310Node.prototype.key = function key(newKey) {
28311  var state = this._baseState;
28312  assert(state.key === null);
28313  state.key = newKey;
28314  return this;
28315};
28316
28317Node.prototype.any = function any() {
28318  var state = this._baseState;
28319  state.any = true;
28320  return this;
28321};
28322
28323Node.prototype.choice = function choice(obj) {
28324  var state = this._baseState;
28325  assert(state.choice === null);
28326  state.choice = obj;
28327
28328  this._useArgs(Object.keys(obj).map(function (key) {
28329    return obj[key];
28330  }));
28331
28332  return this;
28333};
28334
28335Node.prototype.contains = function contains(item) {
28336  var state = this._baseState;
28337  assert(state.use === null);
28338  state.contains = item;
28339  return this;
28340}; //
28341// Decoding
28342//
28343
28344
28345Node.prototype._decode = function decode(input, options) {
28346  var state = this._baseState; // Decode root node
28347
28348  if (state.parent === null) return input.wrapResult(state.children[0]._decode(input, options));
28349  var result = state['default'];
28350  var present = true;
28351  var prevKey = null;
28352  if (state.key !== null) prevKey = input.enterKey(state.key); // Check if tag is there
28353
28354  if (state.optional) {
28355    var tag = null;
28356    if (state.explicit !== null) tag = state.explicit;else if (state.implicit !== null) tag = state.implicit;else if (state.tag !== null) tag = state.tag;
28357
28358    if (tag === null && !state.any) {
28359      // Trial and Error
28360      var save = input.save();
28361
28362      try {
28363        if (state.choice === null) this._decodeGeneric(state.tag, input, options);else this._decodeChoice(input, options);
28364        present = true;
28365      } catch (e) {
28366        present = false;
28367      }
28368
28369      input.restore(save);
28370    } else {
28371      present = this._peekTag(input, tag, state.any);
28372      if (input.isError(present)) return present;
28373    }
28374  } // Push object on stack
28375
28376
28377  var prevObj;
28378  if (state.obj && present) prevObj = input.enterObject();
28379
28380  if (present) {
28381    // Unwrap explicit values
28382    if (state.explicit !== null) {
28383      var explicit = this._decodeTag(input, state.explicit);
28384
28385      if (input.isError(explicit)) return explicit;
28386      input = explicit;
28387    }
28388
28389    var start = input.offset; // Unwrap implicit and normal values
28390
28391    if (state.use === null && state.choice === null) {
28392      var _save;
28393
28394      if (state.any) _save = input.save();
28395
28396      var body = this._decodeTag(input, state.implicit !== null ? state.implicit : state.tag, state.any);
28397
28398      if (input.isError(body)) return body;
28399      if (state.any) result = input.raw(_save);else input = body;
28400    }
28401
28402    if (options && options.track && state.tag !== null) options.track(input.path(), start, input.length, 'tagged');
28403    if (options && options.track && state.tag !== null) options.track(input.path(), input.offset, input.length, 'content'); // Select proper method for tag
28404
28405    if (state.any) {// no-op
28406    } else if (state.choice === null) {
28407      result = this._decodeGeneric(state.tag, input, options);
28408    } else {
28409      result = this._decodeChoice(input, options);
28410    }
28411
28412    if (input.isError(result)) return result; // Decode children
28413
28414    if (!state.any && state.choice === null && state.children !== null) {
28415      state.children.forEach(function decodeChildren(child) {
28416        // NOTE: We are ignoring errors here, to let parser continue with other
28417        // parts of encoded data
28418        child._decode(input, options);
28419      });
28420    } // Decode contained/encoded by schema, only in bit or octet strings
28421
28422
28423    if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
28424      var data = new DecoderBuffer(result);
28425      result = this._getUse(state.contains, input._reporterState.obj)._decode(data, options);
28426    }
28427  } // Pop object
28428
28429
28430  if (state.obj && present) result = input.leaveObject(prevObj); // Set key
28431
28432  if (state.key !== null && (result !== null || present === true)) input.leaveKey(prevKey, state.key, result);else if (prevKey !== null) input.exitKey(prevKey);
28433  return result;
28434};
28435
28436Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
28437  var state = this._baseState;
28438  if (tag === 'seq' || tag === 'set') return null;
28439  if (tag === 'seqof' || tag === 'setof') return this._decodeList(input, tag, state.args[0], options);else if (/str$/.test(tag)) return this._decodeStr(input, tag, options);else if (tag === 'objid' && state.args) return this._decodeObjid(input, state.args[0], state.args[1], options);else if (tag === 'objid') return this._decodeObjid(input, null, null, options);else if (tag === 'gentime' || tag === 'utctime') return this._decodeTime(input, tag, options);else if (tag === 'null_') return this._decodeNull(input, options);else if (tag === 'bool') return this._decodeBool(input, options);else if (tag === 'objDesc') return this._decodeStr(input, tag, options);else if (tag === 'int' || tag === 'enum') return this._decodeInt(input, state.args && state.args[0], options);
28440
28441  if (state.use !== null) {
28442    return this._getUse(state.use, input._reporterState.obj)._decode(input, options);
28443  } else {
28444    return input.error('unknown tag: ' + tag);
28445  }
28446};
28447
28448Node.prototype._getUse = function _getUse(entity, obj) {
28449  var state = this._baseState; // Create altered use decoder if implicit is set
28450
28451  state.useDecoder = this._use(entity, obj);
28452  assert(state.useDecoder._baseState.parent === null);
28453  state.useDecoder = state.useDecoder._baseState.children[0];
28454
28455  if (state.implicit !== state.useDecoder._baseState.implicit) {
28456    state.useDecoder = state.useDecoder.clone();
28457    state.useDecoder._baseState.implicit = state.implicit;
28458  }
28459
28460  return state.useDecoder;
28461};
28462
28463Node.prototype._decodeChoice = function decodeChoice(input, options) {
28464  var state = this._baseState;
28465  var result = null;
28466  var match = false;
28467  Object.keys(state.choice).some(function (key) {
28468    var save = input.save();
28469    var node = state.choice[key];
28470
28471    try {
28472      var value = node._decode(input, options);
28473
28474      if (input.isError(value)) return false;
28475      result = {
28476        type: key,
28477        value: value
28478      };
28479      match = true;
28480    } catch (e) {
28481      input.restore(save);
28482      return false;
28483    }
28484
28485    return true;
28486  }, this);
28487  if (!match) return input.error('Choice not matched');
28488  return result;
28489}; //
28490// Encoding
28491//
28492
28493
28494Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
28495  return new EncoderBuffer(data, this.reporter);
28496};
28497
28498Node.prototype._encode = function encode(data, reporter, parent) {
28499  var state = this._baseState;
28500  if (state['default'] !== null && state['default'] === data) return;
28501
28502  var result = this._encodeValue(data, reporter, parent);
28503
28504  if (result === undefined) return;
28505  if (this._skipDefault(result, reporter, parent)) return;
28506  return result;
28507};
28508
28509Node.prototype._encodeValue = function encode(data, reporter, parent) {
28510  var state = this._baseState; // Decode root node
28511
28512  if (state.parent === null) return state.children[0]._encode(data, reporter || new Reporter());
28513  var result = null; // Set reporter to share it with a child class
28514
28515  this.reporter = reporter; // Check if data is there
28516
28517  if (state.optional && data === undefined) {
28518    if (state['default'] !== null) data = state['default'];else return;
28519  } // Encode children first
28520
28521
28522  var content = null;
28523  var primitive = false;
28524
28525  if (state.any) {
28526    // Anything that was given is translated to buffer
28527    result = this._createEncoderBuffer(data);
28528  } else if (state.choice) {
28529    result = this._encodeChoice(data, reporter);
28530  } else if (state.contains) {
28531    content = this._getUse(state.contains, parent)._encode(data, reporter);
28532    primitive = true;
28533  } else if (state.children) {
28534    content = state.children.map(function (child) {
28535      if (child._baseState.tag === 'null_') return child._encode(null, reporter, data);
28536      if (child._baseState.key === null) return reporter.error('Child should have a key');
28537      var prevKey = reporter.enterKey(child._baseState.key);
28538      if (_typeof(data) !== 'object') return reporter.error('Child expected, but input is not object');
28539
28540      var res = child._encode(data[child._baseState.key], reporter, data);
28541
28542      reporter.leaveKey(prevKey);
28543      return res;
28544    }, this).filter(function (child) {
28545      return child;
28546    });
28547    content = this._createEncoderBuffer(content);
28548  } else {
28549    if (state.tag === 'seqof' || state.tag === 'setof') {
28550      // TODO(indutny): this should be thrown on DSL level
28551      if (!(state.args && state.args.length === 1)) return reporter.error('Too many args for : ' + state.tag);
28552      if (!Array.isArray(data)) return reporter.error('seqof/setof, but data is not Array');
28553      var child = this.clone();
28554      child._baseState.implicit = null;
28555      content = this._createEncoderBuffer(data.map(function (item) {
28556        var state = this._baseState;
28557        return this._getUse(state.args[0], data)._encode(item, reporter);
28558      }, child));
28559    } else if (state.use !== null) {
28560      result = this._getUse(state.use, parent)._encode(data, reporter);
28561    } else {
28562      content = this._encodePrimitive(state.tag, data);
28563      primitive = true;
28564    }
28565  } // Encode data itself
28566
28567
28568  if (!state.any && state.choice === null) {
28569    var tag = state.implicit !== null ? state.implicit : state.tag;
28570    var cls = state.implicit === null ? 'universal' : 'context';
28571
28572    if (tag === null) {
28573      if (state.use === null) reporter.error('Tag could be omitted only for .use()');
28574    } else {
28575      if (state.use === null) result = this._encodeComposite(tag, primitive, cls, content);
28576    }
28577  } // Wrap in explicit
28578
28579
28580  if (state.explicit !== null) result = this._encodeComposite(state.explicit, false, 'context', result);
28581  return result;
28582};
28583
28584Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
28585  var state = this._baseState;
28586  var node = state.choice[data.type];
28587
28588  if (!node) {
28589    assert(false, data.type + ' not found in ' + JSON.stringify(Object.keys(state.choice)));
28590  }
28591
28592  return node._encode(data.value, reporter);
28593};
28594
28595Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
28596  var state = this._baseState;
28597  if (/str$/.test(tag)) return this._encodeStr(data, tag);else if (tag === 'objid' && state.args) return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);else if (tag === 'objid') return this._encodeObjid(data, null, null);else if (tag === 'gentime' || tag === 'utctime') return this._encodeTime(data, tag);else if (tag === 'null_') return this._encodeNull();else if (tag === 'int' || tag === 'enum') return this._encodeInt(data, state.args && state.reverseArgs[0]);else if (tag === 'bool') return this._encodeBool(data);else if (tag === 'objDesc') return this._encodeStr(data, tag);else throw new Error('Unsupported tag: ' + tag);
28598};
28599
28600Node.prototype._isNumstr = function isNumstr(str) {
28601  return /^[0-9 ]*$/.test(str);
28602};
28603
28604Node.prototype._isPrintstr = function isPrintstr(str) {
28605  return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str);
28606};
28607
28608},{"../base/buffer":169,"../base/reporter":172,"minimalistic-assert":437}],172:[function(require,module,exports){
28609'use strict';
28610
28611var inherits = require('inherits');
28612
28613function Reporter(options) {
28614  this._reporterState = {
28615    obj: null,
28616    path: [],
28617    options: options || {},
28618    errors: []
28619  };
28620}
28621
28622exports.Reporter = Reporter;
28623
28624Reporter.prototype.isError = function isError(obj) {
28625  return obj instanceof ReporterError;
28626};
28627
28628Reporter.prototype.save = function save() {
28629  var state = this._reporterState;
28630  return {
28631    obj: state.obj,
28632    pathLen: state.path.length
28633  };
28634};
28635
28636Reporter.prototype.restore = function restore(data) {
28637  var state = this._reporterState;
28638  state.obj = data.obj;
28639  state.path = state.path.slice(0, data.pathLen);
28640};
28641
28642Reporter.prototype.enterKey = function enterKey(key) {
28643  return this._reporterState.path.push(key);
28644};
28645
28646Reporter.prototype.exitKey = function exitKey(index) {
28647  var state = this._reporterState;
28648  state.path = state.path.slice(0, index - 1);
28649};
28650
28651Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
28652  var state = this._reporterState;
28653  this.exitKey(index);
28654  if (state.obj !== null) state.obj[key] = value;
28655};
28656
28657Reporter.prototype.path = function path() {
28658  return this._reporterState.path.join('/');
28659};
28660
28661Reporter.prototype.enterObject = function enterObject() {
28662  var state = this._reporterState;
28663  var prev = state.obj;
28664  state.obj = {};
28665  return prev;
28666};
28667
28668Reporter.prototype.leaveObject = function leaveObject(prev) {
28669  var state = this._reporterState;
28670  var now = state.obj;
28671  state.obj = prev;
28672  return now;
28673};
28674
28675Reporter.prototype.error = function error(msg) {
28676  var err;
28677  var state = this._reporterState;
28678  var inherited = msg instanceof ReporterError;
28679
28680  if (inherited) {
28681    err = msg;
28682  } else {
28683    err = new ReporterError(state.path.map(function (elem) {
28684      return '[' + JSON.stringify(elem) + ']';
28685    }).join(''), msg.message || msg, msg.stack);
28686  }
28687
28688  if (!state.options.partial) throw err;
28689  if (!inherited) state.errors.push(err);
28690  return err;
28691};
28692
28693Reporter.prototype.wrapResult = function wrapResult(result) {
28694  var state = this._reporterState;
28695  if (!state.options.partial) return result;
28696  return {
28697    result: this.isError(result) ? null : result,
28698    errors: state.errors
28699  };
28700};
28701
28702function ReporterError(path, msg) {
28703  this.path = path;
28704  this.rethrow(msg);
28705}
28706
28707inherits(ReporterError, Error);
28708
28709ReporterError.prototype.rethrow = function rethrow(msg) {
28710  this.message = msg + ' at: ' + (this.path || '(shallow)');
28711  if (Error.captureStackTrace) Error.captureStackTrace(this, ReporterError);
28712
28713  if (!this.stack) {
28714    try {
28715      // IE only adds stack when thrown
28716      throw new Error(this.message);
28717    } catch (e) {
28718      this.stack = e.stack;
28719    }
28720  }
28721
28722  return this;
28723};
28724
28725},{"inherits":387}],173:[function(require,module,exports){
28726'use strict'; // Helper
28727
28728function reverse(map) {
28729  var res = {};
28730  Object.keys(map).forEach(function (key) {
28731    // Convert key to integer if it is stringified
28732    if ((key | 0) == key) key = key | 0;
28733    var value = map[key];
28734    res[value] = key;
28735  });
28736  return res;
28737}
28738
28739exports.tagClass = {
28740  0: 'universal',
28741  1: 'application',
28742  2: 'context',
28743  3: 'private'
28744};
28745exports.tagClassByName = reverse(exports.tagClass);
28746exports.tag = {
28747  0x00: 'end',
28748  0x01: 'bool',
28749  0x02: 'int',
28750  0x03: 'bitstr',
28751  0x04: 'octstr',
28752  0x05: 'null_',
28753  0x06: 'objid',
28754  0x07: 'objDesc',
28755  0x08: 'external',
28756  0x09: 'real',
28757  0x0a: 'enum',
28758  0x0b: 'embed',
28759  0x0c: 'utf8str',
28760  0x0d: 'relativeOid',
28761  0x10: 'seq',
28762  0x11: 'set',
28763  0x12: 'numstr',
28764  0x13: 'printstr',
28765  0x14: 't61str',
28766  0x15: 'videostr',
28767  0x16: 'ia5str',
28768  0x17: 'utctime',
28769  0x18: 'gentime',
28770  0x19: 'graphstr',
28771  0x1a: 'iso646str',
28772  0x1b: 'genstr',
28773  0x1c: 'unistr',
28774  0x1d: 'charstr',
28775  0x1e: 'bmpstr'
28776};
28777exports.tagByName = reverse(exports.tag);
28778
28779},{}],174:[function(require,module,exports){
28780'use strict';
28781
28782var constants = exports; // Helper
28783
28784constants._reverse = function reverse(map) {
28785  var res = {};
28786  Object.keys(map).forEach(function (key) {
28787    // Convert key to integer if it is stringified
28788    if ((key | 0) == key) key = key | 0;
28789    var value = map[key];
28790    res[value] = key;
28791  });
28792  return res;
28793};
28794
28795constants.der = require('./der');
28796
28797},{"./der":173}],175:[function(require,module,exports){
28798'use strict';
28799
28800var inherits = require('inherits');
28801
28802var bignum = require('bn.js');
28803
28804var DecoderBuffer = require('../base/buffer').DecoderBuffer;
28805
28806var Node = require('../base/node'); // Import DER constants
28807
28808
28809var der = require('../constants/der');
28810
28811function DERDecoder(entity) {
28812  this.enc = 'der';
28813  this.name = entity.name;
28814  this.entity = entity; // Construct base tree
28815
28816  this.tree = new DERNode();
28817
28818  this.tree._init(entity.body);
28819}
28820
28821module.exports = DERDecoder;
28822
28823DERDecoder.prototype.decode = function decode(data, options) {
28824  if (!DecoderBuffer.isDecoderBuffer(data)) {
28825    data = new DecoderBuffer(data, options);
28826  }
28827
28828  return this.tree._decode(data, options);
28829}; // Tree methods
28830
28831
28832function DERNode(parent) {
28833  Node.call(this, 'der', parent);
28834}
28835
28836inherits(DERNode, Node);
28837
28838DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
28839  if (buffer.isEmpty()) return false;
28840  var state = buffer.save();
28841  var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
28842  if (buffer.isError(decodedTag)) return decodedTag;
28843  buffer.restore(state);
28844  return decodedTag.tag === tag || decodedTag.tagStr === tag || decodedTag.tagStr + 'of' === tag || any;
28845};
28846
28847DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
28848  var decodedTag = derDecodeTag(buffer, 'Failed to decode tag of "' + tag + '"');
28849  if (buffer.isError(decodedTag)) return decodedTag;
28850  var len = derDecodeLen(buffer, decodedTag.primitive, 'Failed to get length of "' + tag + '"'); // Failure
28851
28852  if (buffer.isError(len)) return len;
28853
28854  if (!any && decodedTag.tag !== tag && decodedTag.tagStr !== tag && decodedTag.tagStr + 'of' !== tag) {
28855    return buffer.error('Failed to match tag: "' + tag + '"');
28856  }
28857
28858  if (decodedTag.primitive || len !== null) return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); // Indefinite length... find END tag
28859
28860  var state = buffer.save();
28861
28862  var res = this._skipUntilEnd(buffer, 'Failed to skip indefinite length body: "' + this.tag + '"');
28863
28864  if (buffer.isError(res)) return res;
28865  len = buffer.offset - state.offset;
28866  buffer.restore(state);
28867  return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
28868};
28869
28870DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
28871  for (;;) {
28872    var tag = derDecodeTag(buffer, fail);
28873    if (buffer.isError(tag)) return tag;
28874    var len = derDecodeLen(buffer, tag.primitive, fail);
28875    if (buffer.isError(len)) return len;
28876    var res = void 0;
28877    if (tag.primitive || len !== null) res = buffer.skip(len);else res = this._skipUntilEnd(buffer, fail); // Failure
28878
28879    if (buffer.isError(res)) return res;
28880    if (tag.tagStr === 'end') break;
28881  }
28882};
28883
28884DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, options) {
28885  var result = [];
28886
28887  while (!buffer.isEmpty()) {
28888    var possibleEnd = this._peekTag(buffer, 'end');
28889
28890    if (buffer.isError(possibleEnd)) return possibleEnd;
28891    var res = decoder.decode(buffer, 'der', options);
28892    if (buffer.isError(res) && possibleEnd) break;
28893    result.push(res);
28894  }
28895
28896  return result;
28897};
28898
28899DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
28900  if (tag === 'bitstr') {
28901    var unused = buffer.readUInt8();
28902    if (buffer.isError(unused)) return unused;
28903    return {
28904      unused: unused,
28905      data: buffer.raw()
28906    };
28907  } else if (tag === 'bmpstr') {
28908    var raw = buffer.raw();
28909    if (raw.length % 2 === 1) return buffer.error('Decoding of string type: bmpstr length mismatch');
28910    var str = '';
28911
28912    for (var i = 0; i < raw.length / 2; i++) {
28913      str += String.fromCharCode(raw.readUInt16BE(i * 2));
28914    }
28915
28916    return str;
28917  } else if (tag === 'numstr') {
28918    var numstr = buffer.raw().toString('ascii');
28919
28920    if (!this._isNumstr(numstr)) {
28921      return buffer.error('Decoding of string type: ' + 'numstr unsupported characters');
28922    }
28923
28924    return numstr;
28925  } else if (tag === 'octstr') {
28926    return buffer.raw();
28927  } else if (tag === 'objDesc') {
28928    return buffer.raw();
28929  } else if (tag === 'printstr') {
28930    var printstr = buffer.raw().toString('ascii');
28931
28932    if (!this._isPrintstr(printstr)) {
28933      return buffer.error('Decoding of string type: ' + 'printstr unsupported characters');
28934    }
28935
28936    return printstr;
28937  } else if (/str$/.test(tag)) {
28938    return buffer.raw().toString();
28939  } else {
28940    return buffer.error('Decoding of string type: ' + tag + ' unsupported');
28941  }
28942};
28943
28944DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
28945  var result;
28946  var identifiers = [];
28947  var ident = 0;
28948  var subident = 0;
28949
28950  while (!buffer.isEmpty()) {
28951    subident = buffer.readUInt8();
28952    ident <<= 7;
28953    ident |= subident & 0x7f;
28954
28955    if ((subident & 0x80) === 0) {
28956      identifiers.push(ident);
28957      ident = 0;
28958    }
28959  }
28960
28961  if (subident & 0x80) identifiers.push(ident);
28962  var first = identifiers[0] / 40 | 0;
28963  var second = identifiers[0] % 40;
28964  if (relative) result = identifiers;else result = [first, second].concat(identifiers.slice(1));
28965
28966  if (values) {
28967    var tmp = values[result.join(' ')];
28968    if (tmp === undefined) tmp = values[result.join('.')];
28969    if (tmp !== undefined) result = tmp;
28970  }
28971
28972  return result;
28973};
28974
28975DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
28976  var str = buffer.raw().toString();
28977  var year;
28978  var mon;
28979  var day;
28980  var hour;
28981  var min;
28982  var sec;
28983
28984  if (tag === 'gentime') {
28985    year = str.slice(0, 4) | 0;
28986    mon = str.slice(4, 6) | 0;
28987    day = str.slice(6, 8) | 0;
28988    hour = str.slice(8, 10) | 0;
28989    min = str.slice(10, 12) | 0;
28990    sec = str.slice(12, 14) | 0;
28991  } else if (tag === 'utctime') {
28992    year = str.slice(0, 2) | 0;
28993    mon = str.slice(2, 4) | 0;
28994    day = str.slice(4, 6) | 0;
28995    hour = str.slice(6, 8) | 0;
28996    min = str.slice(8, 10) | 0;
28997    sec = str.slice(10, 12) | 0;
28998    if (year < 70) year = 2000 + year;else year = 1900 + year;
28999  } else {
29000    return buffer.error('Decoding ' + tag + ' time is not supported yet');
29001  }
29002
29003  return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
29004};
29005
29006DERNode.prototype._decodeNull = function decodeNull() {
29007  return null;
29008};
29009
29010DERNode.prototype._decodeBool = function decodeBool(buffer) {
29011  var res = buffer.readUInt8();
29012  if (buffer.isError(res)) return res;else return res !== 0;
29013};
29014
29015DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
29016  // Bigint, return as it is (assume big endian)
29017  var raw = buffer.raw();
29018  var res = new bignum(raw);
29019  if (values) res = values[res.toString(10)] || res;
29020  return res;
29021};
29022
29023DERNode.prototype._use = function use(entity, obj) {
29024  if (typeof entity === 'function') entity = entity(obj);
29025  return entity._getDecoder('der').tree;
29026}; // Utility methods
29027
29028
29029function derDecodeTag(buf, fail) {
29030  var tag = buf.readUInt8(fail);
29031  if (buf.isError(tag)) return tag;
29032  var cls = der.tagClass[tag >> 6];
29033  var primitive = (tag & 0x20) === 0; // Multi-octet tag - load
29034
29035  if ((tag & 0x1f) === 0x1f) {
29036    var oct = tag;
29037    tag = 0;
29038
29039    while ((oct & 0x80) === 0x80) {
29040      oct = buf.readUInt8(fail);
29041      if (buf.isError(oct)) return oct;
29042      tag <<= 7;
29043      tag |= oct & 0x7f;
29044    }
29045  } else {
29046    tag &= 0x1f;
29047  }
29048
29049  var tagStr = der.tag[tag];
29050  return {
29051    cls: cls,
29052    primitive: primitive,
29053    tag: tag,
29054    tagStr: tagStr
29055  };
29056}
29057
29058function derDecodeLen(buf, primitive, fail) {
29059  var len = buf.readUInt8(fail);
29060  if (buf.isError(len)) return len; // Indefinite form
29061
29062  if (!primitive && len === 0x80) return null; // Definite form
29063
29064  if ((len & 0x80) === 0) {
29065    // Short form
29066    return len;
29067  } // Long form
29068
29069
29070  var num = len & 0x7f;
29071  if (num > 4) return buf.error('length octect is too long');
29072  len = 0;
29073
29074  for (var i = 0; i < num; i++) {
29075    len <<= 8;
29076    var j = buf.readUInt8(fail);
29077    if (buf.isError(j)) return j;
29078    len |= j;
29079  }
29080
29081  return len;
29082}
29083
29084},{"../base/buffer":169,"../base/node":171,"../constants/der":173,"bn.js":181,"inherits":387}],176:[function(require,module,exports){
29085'use strict';
29086
29087var decoders = exports;
29088decoders.der = require('./der');
29089decoders.pem = require('./pem');
29090
29091},{"./der":175,"./pem":177}],177:[function(require,module,exports){
29092'use strict';
29093
29094var inherits = require('inherits');
29095
29096var Buffer = require('safer-buffer').Buffer;
29097
29098var DERDecoder = require('./der');
29099
29100function PEMDecoder(entity) {
29101  DERDecoder.call(this, entity);
29102  this.enc = 'pem';
29103}
29104
29105inherits(PEMDecoder, DERDecoder);
29106module.exports = PEMDecoder;
29107
29108PEMDecoder.prototype.decode = function decode(data, options) {
29109  var lines = data.toString().split(/[\r\n]+/g);
29110  var label = options.label.toUpperCase();
29111  var re = /^-----(BEGIN|END) ([^-]+)-----$/;
29112  var start = -1;
29113  var end = -1;
29114
29115  for (var i = 0; i < lines.length; i++) {
29116    var match = lines[i].match(re);
29117    if (match === null) continue;
29118    if (match[2] !== label) continue;
29119
29120    if (start === -1) {
29121      if (match[1] !== 'BEGIN') break;
29122      start = i;
29123    } else {
29124      if (match[1] !== 'END') break;
29125      end = i;
29126      break;
29127    }
29128  }
29129
29130  if (start === -1 || end === -1) throw new Error('PEM section not found for: ' + label);
29131  var base64 = lines.slice(start + 1, end).join(''); // Remove excessive symbols
29132
29133  base64.replace(/[^a-z0-9+/=]+/gi, '');
29134  var input = Buffer.from(base64, 'base64');
29135  return DERDecoder.prototype.decode.call(this, input, options);
29136};
29137
29138},{"./der":175,"inherits":387,"safer-buffer":495}],178:[function(require,module,exports){
29139'use strict';
29140
29141var inherits = require('inherits');
29142
29143var Buffer = require('safer-buffer').Buffer;
29144
29145var Node = require('../base/node'); // Import DER constants
29146
29147
29148var der = require('../constants/der');
29149
29150function DEREncoder(entity) {
29151  this.enc = 'der';
29152  this.name = entity.name;
29153  this.entity = entity; // Construct base tree
29154
29155  this.tree = new DERNode();
29156
29157  this.tree._init(entity.body);
29158}
29159
29160module.exports = DEREncoder;
29161
29162DEREncoder.prototype.encode = function encode(data, reporter) {
29163  return this.tree._encode(data, reporter).join();
29164}; // Tree methods
29165
29166
29167function DERNode(parent) {
29168  Node.call(this, 'der', parent);
29169}
29170
29171inherits(DERNode, Node);
29172
29173DERNode.prototype._encodeComposite = function encodeComposite(tag, primitive, cls, content) {
29174  var encodedTag = encodeTag(tag, primitive, cls, this.reporter); // Short form
29175
29176  if (content.length < 0x80) {
29177    var _header = Buffer.alloc(2);
29178
29179    _header[0] = encodedTag;
29180    _header[1] = content.length;
29181    return this._createEncoderBuffer([_header, content]);
29182  } // Long form
29183  // Count octets required to store length
29184
29185
29186  var lenOctets = 1;
29187
29188  for (var i = content.length; i >= 0x100; i >>= 8) {
29189    lenOctets++;
29190  }
29191
29192  var header = Buffer.alloc(1 + 1 + lenOctets);
29193  header[0] = encodedTag;
29194  header[1] = 0x80 | lenOctets;
29195
29196  for (var _i = 1 + lenOctets, j = content.length; j > 0; _i--, j >>= 8) {
29197    header[_i] = j & 0xff;
29198  }
29199
29200  return this._createEncoderBuffer([header, content]);
29201};
29202
29203DERNode.prototype._encodeStr = function encodeStr(str, tag) {
29204  if (tag === 'bitstr') {
29205    return this._createEncoderBuffer([str.unused | 0, str.data]);
29206  } else if (tag === 'bmpstr') {
29207    var buf = Buffer.alloc(str.length * 2);
29208
29209    for (var i = 0; i < str.length; i++) {
29210      buf.writeUInt16BE(str.charCodeAt(i), i * 2);
29211    }
29212
29213    return this._createEncoderBuffer(buf);
29214  } else if (tag === 'numstr') {
29215    if (!this._isNumstr(str)) {
29216      return this.reporter.error('Encoding of string type: numstr supports ' + 'only digits and space');
29217    }
29218
29219    return this._createEncoderBuffer(str);
29220  } else if (tag === 'printstr') {
29221    if (!this._isPrintstr(str)) {
29222      return this.reporter.error('Encoding of string type: printstr supports ' + 'only latin upper and lower case letters, ' + 'digits, space, apostrophe, left and rigth ' + 'parenthesis, plus sign, comma, hyphen, ' + 'dot, slash, colon, equal sign, ' + 'question mark');
29223    }
29224
29225    return this._createEncoderBuffer(str);
29226  } else if (/str$/.test(tag)) {
29227    return this._createEncoderBuffer(str);
29228  } else if (tag === 'objDesc') {
29229    return this._createEncoderBuffer(str);
29230  } else {
29231    return this.reporter.error('Encoding of string type: ' + tag + ' unsupported');
29232  }
29233};
29234
29235DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
29236  if (typeof id === 'string') {
29237    if (!values) return this.reporter.error('string objid given, but no values map found');
29238    if (!values.hasOwnProperty(id)) return this.reporter.error('objid not found in values map');
29239    id = values[id].split(/[\s.]+/g);
29240
29241    for (var i = 0; i < id.length; i++) {
29242      id[i] |= 0;
29243    }
29244  } else if (Array.isArray(id)) {
29245    id = id.slice();
29246
29247    for (var _i2 = 0; _i2 < id.length; _i2++) {
29248      id[_i2] |= 0;
29249    }
29250  }
29251
29252  if (!Array.isArray(id)) {
29253    return this.reporter.error('objid() should be either array or string, ' + 'got: ' + JSON.stringify(id));
29254  }
29255
29256  if (!relative) {
29257    if (id[1] >= 40) return this.reporter.error('Second objid identifier OOB');
29258    id.splice(0, 2, id[0] * 40 + id[1]);
29259  } // Count number of octets
29260
29261
29262  var size = 0;
29263
29264  for (var _i3 = 0; _i3 < id.length; _i3++) {
29265    var ident = id[_i3];
29266
29267    for (size++; ident >= 0x80; ident >>= 7) {
29268      size++;
29269    }
29270  }
29271
29272  var objid = Buffer.alloc(size);
29273  var offset = objid.length - 1;
29274
29275  for (var _i4 = id.length - 1; _i4 >= 0; _i4--) {
29276    var _ident = id[_i4];
29277    objid[offset--] = _ident & 0x7f;
29278
29279    while ((_ident >>= 7) > 0) {
29280      objid[offset--] = 0x80 | _ident & 0x7f;
29281    }
29282  }
29283
29284  return this._createEncoderBuffer(objid);
29285};
29286
29287function two(num) {
29288  if (num < 10) return '0' + num;else return num;
29289}
29290
29291DERNode.prototype._encodeTime = function encodeTime(time, tag) {
29292  var str;
29293  var date = new Date(time);
29294
29295  if (tag === 'gentime') {
29296    str = [two(date.getUTCFullYear()), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), two(date.getUTCMinutes()), two(date.getUTCSeconds()), 'Z'].join('');
29297  } else if (tag === 'utctime') {
29298    str = [two(date.getUTCFullYear() % 100), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), two(date.getUTCMinutes()), two(date.getUTCSeconds()), 'Z'].join('');
29299  } else {
29300    this.reporter.error('Encoding ' + tag + ' time is not supported yet');
29301  }
29302
29303  return this._encodeStr(str, 'octstr');
29304};
29305
29306DERNode.prototype._encodeNull = function encodeNull() {
29307  return this._createEncoderBuffer('');
29308};
29309
29310DERNode.prototype._encodeInt = function encodeInt(num, values) {
29311  if (typeof num === 'string') {
29312    if (!values) return this.reporter.error('String int or enum given, but no values map');
29313
29314    if (!values.hasOwnProperty(num)) {
29315      return this.reporter.error('Values map doesn\'t contain: ' + JSON.stringify(num));
29316    }
29317
29318    num = values[num];
29319  } // Bignum, assume big endian
29320
29321
29322  if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
29323    var numArray = num.toArray();
29324
29325    if (!num.sign && numArray[0] & 0x80) {
29326      numArray.unshift(0);
29327    }
29328
29329    num = Buffer.from(numArray);
29330  }
29331
29332  if (Buffer.isBuffer(num)) {
29333    var _size = num.length;
29334    if (num.length === 0) _size++;
29335
29336    var _out = Buffer.alloc(_size);
29337
29338    num.copy(_out);
29339    if (num.length === 0) _out[0] = 0;
29340    return this._createEncoderBuffer(_out);
29341  }
29342
29343  if (num < 0x80) return this._createEncoderBuffer(num);
29344  if (num < 0x100) return this._createEncoderBuffer([0, num]);
29345  var size = 1;
29346
29347  for (var i = num; i >= 0x100; i >>= 8) {
29348    size++;
29349  }
29350
29351  var out = new Array(size);
29352
29353  for (var _i5 = out.length - 1; _i5 >= 0; _i5--) {
29354    out[_i5] = num & 0xff;
29355    num >>= 8;
29356  }
29357
29358  if (out[0] & 0x80) {
29359    out.unshift(0);
29360  }
29361
29362  return this._createEncoderBuffer(Buffer.from(out));
29363};
29364
29365DERNode.prototype._encodeBool = function encodeBool(value) {
29366  return this._createEncoderBuffer(value ? 0xff : 0);
29367};
29368
29369DERNode.prototype._use = function use(entity, obj) {
29370  if (typeof entity === 'function') entity = entity(obj);
29371  return entity._getEncoder('der').tree;
29372};
29373
29374DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
29375  var state = this._baseState;
29376  var i;
29377  if (state['default'] === null) return false;
29378  var data = dataBuffer.join();
29379  if (state.defaultBuffer === undefined) state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
29380  if (data.length !== state.defaultBuffer.length) return false;
29381
29382  for (i = 0; i < data.length; i++) {
29383    if (data[i] !== state.defaultBuffer[i]) return false;
29384  }
29385
29386  return true;
29387}; // Utility methods
29388
29389
29390function encodeTag(tag, primitive, cls, reporter) {
29391  var res;
29392  if (tag === 'seqof') tag = 'seq';else if (tag === 'setof') tag = 'set';
29393  if (der.tagByName.hasOwnProperty(tag)) res = der.tagByName[tag];else if (typeof tag === 'number' && (tag | 0) === tag) res = tag;else return reporter.error('Unknown tag: ' + tag);
29394  if (res >= 0x1f) return reporter.error('Multi-octet tag encoding unsupported');
29395  if (!primitive) res |= 0x20;
29396  res |= der.tagClassByName[cls || 'universal'] << 6;
29397  return res;
29398}
29399
29400},{"../base/node":171,"../constants/der":173,"inherits":387,"safer-buffer":495}],179:[function(require,module,exports){
29401'use strict';
29402
29403var encoders = exports;
29404encoders.der = require('./der');
29405encoders.pem = require('./pem');
29406
29407},{"./der":178,"./pem":180}],180:[function(require,module,exports){
29408'use strict';
29409
29410var inherits = require('inherits');
29411
29412var DEREncoder = require('./der');
29413
29414function PEMEncoder(entity) {
29415  DEREncoder.call(this, entity);
29416  this.enc = 'pem';
29417}
29418
29419inherits(PEMEncoder, DEREncoder);
29420module.exports = PEMEncoder;
29421
29422PEMEncoder.prototype.encode = function encode(data, options) {
29423  var buf = DEREncoder.prototype.encode.call(this, data);
29424  var p = buf.toString('base64');
29425  var out = ['-----BEGIN ' + options.label + '-----'];
29426
29427  for (var i = 0; i < p.length; i += 64) {
29428    out.push(p.slice(i, i + 64));
29429  }
29430
29431  out.push('-----END ' + options.label + '-----');
29432  return out.join('\n');
29433};
29434
29435},{"./der":178,"inherits":387}],181:[function(require,module,exports){
29436"use strict";
29437
29438function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
29439
29440(function (module, exports) {
29441  'use strict'; // Utils
29442
29443  function assert(val, msg) {
29444    if (!val) throw new Error(msg || 'Assertion failed');
29445  } // Could use `inherits` module, but don't want to move from single file
29446  // architecture yet.
29447
29448
29449  function inherits(ctor, superCtor) {
29450    ctor.super_ = superCtor;
29451
29452    var TempCtor = function TempCtor() {};
29453
29454    TempCtor.prototype = superCtor.prototype;
29455    ctor.prototype = new TempCtor();
29456    ctor.prototype.constructor = ctor;
29457  } // BN
29458
29459
29460  function BN(number, base, endian) {
29461    if (BN.isBN(number)) {
29462      return number;
29463    }
29464
29465    this.negative = 0;
29466    this.words = null;
29467    this.length = 0; // Reduction context
29468
29469    this.red = null;
29470
29471    if (number !== null) {
29472      if (base === 'le' || base === 'be') {
29473        endian = base;
29474        base = 10;
29475      }
29476
29477      this._init(number || 0, base || 10, endian || 'be');
29478    }
29479  }
29480
29481  if (_typeof(module) === 'object') {
29482    module.exports = BN;
29483  } else {
29484    exports.BN = BN;
29485  }
29486
29487  BN.BN = BN;
29488  BN.wordSize = 26;
29489  var Buffer;
29490
29491  try {
29492    Buffer = require('buffer').Buffer;
29493  } catch (e) {}
29494
29495  BN.isBN = function isBN(num) {
29496    if (num instanceof BN) {
29497      return true;
29498    }
29499
29500    return num !== null && _typeof(num) === 'object' && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
29501  };
29502
29503  BN.max = function max(left, right) {
29504    if (left.cmp(right) > 0) return left;
29505    return right;
29506  };
29507
29508  BN.min = function min(left, right) {
29509    if (left.cmp(right) < 0) return left;
29510    return right;
29511  };
29512
29513  BN.prototype._init = function init(number, base, endian) {
29514    if (typeof number === 'number') {
29515      return this._initNumber(number, base, endian);
29516    }
29517
29518    if (_typeof(number) === 'object') {
29519      return this._initArray(number, base, endian);
29520    }
29521
29522    if (base === 'hex') {
29523      base = 16;
29524    }
29525
29526    assert(base === (base | 0) && base >= 2 && base <= 36);
29527    number = number.toString().replace(/\s+/g, '');
29528    var start = 0;
29529
29530    if (number[0] === '-') {
29531      start++;
29532    }
29533
29534    if (base === 16) {
29535      this._parseHex(number, start);
29536    } else {
29537      this._parseBase(number, base, start);
29538    }
29539
29540    if (number[0] === '-') {
29541      this.negative = 1;
29542    }
29543
29544    this.strip();
29545    if (endian !== 'le') return;
29546
29547    this._initArray(this.toArray(), base, endian);
29548  };
29549
29550  BN.prototype._initNumber = function _initNumber(number, base, endian) {
29551    if (number < 0) {
29552      this.negative = 1;
29553      number = -number;
29554    }
29555
29556    if (number < 0x4000000) {
29557      this.words = [number & 0x3ffffff];
29558      this.length = 1;
29559    } else if (number < 0x10000000000000) {
29560      this.words = [number & 0x3ffffff, number / 0x4000000 & 0x3ffffff];
29561      this.length = 2;
29562    } else {
29563      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
29564
29565      this.words = [number & 0x3ffffff, number / 0x4000000 & 0x3ffffff, 1];
29566      this.length = 3;
29567    }
29568
29569    if (endian !== 'le') return; // Reverse the bytes
29570
29571    this._initArray(this.toArray(), base, endian);
29572  };
29573
29574  BN.prototype._initArray = function _initArray(number, base, endian) {
29575    // Perhaps a Uint8Array
29576    assert(typeof number.length === 'number');
29577
29578    if (number.length <= 0) {
29579      this.words = [0];
29580      this.length = 1;
29581      return this;
29582    }
29583
29584    this.length = Math.ceil(number.length / 3);
29585    this.words = new Array(this.length);
29586
29587    for (var i = 0; i < this.length; i++) {
29588      this.words[i] = 0;
29589    }
29590
29591    var j, w;
29592    var off = 0;
29593
29594    if (endian === 'be') {
29595      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
29596        w = number[i] | number[i - 1] << 8 | number[i - 2] << 16;
29597        this.words[j] |= w << off & 0x3ffffff;
29598        this.words[j + 1] = w >>> 26 - off & 0x3ffffff;
29599        off += 24;
29600
29601        if (off >= 26) {
29602          off -= 26;
29603          j++;
29604        }
29605      }
29606    } else if (endian === 'le') {
29607      for (i = 0, j = 0; i < number.length; i += 3) {
29608        w = number[i] | number[i + 1] << 8 | number[i + 2] << 16;
29609        this.words[j] |= w << off & 0x3ffffff;
29610        this.words[j + 1] = w >>> 26 - off & 0x3ffffff;
29611        off += 24;
29612
29613        if (off >= 26) {
29614          off -= 26;
29615          j++;
29616        }
29617      }
29618    }
29619
29620    return this.strip();
29621  };
29622
29623  function parseHex(str, start, end) {
29624    var r = 0;
29625    var len = Math.min(str.length, end);
29626
29627    for (var i = start; i < len; i++) {
29628      var c = str.charCodeAt(i) - 48;
29629      r <<= 4; // 'a' - 'f'
29630
29631      if (c >= 49 && c <= 54) {
29632        r |= c - 49 + 0xa; // 'A' - 'F'
29633      } else if (c >= 17 && c <= 22) {
29634        r |= c - 17 + 0xa; // '0' - '9'
29635      } else {
29636        r |= c & 0xf;
29637      }
29638    }
29639
29640    return r;
29641  }
29642
29643  BN.prototype._parseHex = function _parseHex(number, start) {
29644    // Create possibly bigger array to ensure that it fits the number
29645    this.length = Math.ceil((number.length - start) / 6);
29646    this.words = new Array(this.length);
29647
29648    for (var i = 0; i < this.length; i++) {
29649      this.words[i] = 0;
29650    }
29651
29652    var j, w; // Scan 24-bit chunks and add them to the number
29653
29654    var off = 0;
29655
29656    for (i = number.length - 6, j = 0; i >= start; i -= 6) {
29657      w = parseHex(number, i, i + 6);
29658      this.words[j] |= w << off & 0x3ffffff; // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
29659
29660      this.words[j + 1] |= w >>> 26 - off & 0x3fffff;
29661      off += 24;
29662
29663      if (off >= 26) {
29664        off -= 26;
29665        j++;
29666      }
29667    }
29668
29669    if (i + 6 !== start) {
29670      w = parseHex(number, start, i + 6);
29671      this.words[j] |= w << off & 0x3ffffff;
29672      this.words[j + 1] |= w >>> 26 - off & 0x3fffff;
29673    }
29674
29675    this.strip();
29676  };
29677
29678  function parseBase(str, start, end, mul) {
29679    var r = 0;
29680    var len = Math.min(str.length, end);
29681
29682    for (var i = start; i < len; i++) {
29683      var c = str.charCodeAt(i) - 48;
29684      r *= mul; // 'a'
29685
29686      if (c >= 49) {
29687        r += c - 49 + 0xa; // 'A'
29688      } else if (c >= 17) {
29689        r += c - 17 + 0xa; // '0' - '9'
29690      } else {
29691        r += c;
29692      }
29693    }
29694
29695    return r;
29696  }
29697
29698  BN.prototype._parseBase = function _parseBase(number, base, start) {
29699    // Initialize as zero
29700    this.words = [0];
29701    this.length = 1; // Find length of limb in base
29702
29703    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
29704      limbLen++;
29705    }
29706
29707    limbLen--;
29708    limbPow = limbPow / base | 0;
29709    var total = number.length - start;
29710    var mod = total % limbLen;
29711    var end = Math.min(total, total - mod) + start;
29712    var word = 0;
29713
29714    for (var i = start; i < end; i += limbLen) {
29715      word = parseBase(number, i, i + limbLen, base);
29716      this.imuln(limbPow);
29717
29718      if (this.words[0] + word < 0x4000000) {
29719        this.words[0] += word;
29720      } else {
29721        this._iaddn(word);
29722      }
29723    }
29724
29725    if (mod !== 0) {
29726      var pow = 1;
29727      word = parseBase(number, i, number.length, base);
29728
29729      for (i = 0; i < mod; i++) {
29730        pow *= base;
29731      }
29732
29733      this.imuln(pow);
29734
29735      if (this.words[0] + word < 0x4000000) {
29736        this.words[0] += word;
29737      } else {
29738        this._iaddn(word);
29739      }
29740    }
29741  };
29742
29743  BN.prototype.copy = function copy(dest) {
29744    dest.words = new Array(this.length);
29745
29746    for (var i = 0; i < this.length; i++) {
29747      dest.words[i] = this.words[i];
29748    }
29749
29750    dest.length = this.length;
29751    dest.negative = this.negative;
29752    dest.red = this.red;
29753  };
29754
29755  BN.prototype.clone = function clone() {
29756    var r = new BN(null);
29757    this.copy(r);
29758    return r;
29759  };
29760
29761  BN.prototype._expand = function _expand(size) {
29762    while (this.length < size) {
29763      this.words[this.length++] = 0;
29764    }
29765
29766    return this;
29767  }; // Remove leading `0` from `this`
29768
29769
29770  BN.prototype.strip = function strip() {
29771    while (this.length > 1 && this.words[this.length - 1] === 0) {
29772      this.length--;
29773    }
29774
29775    return this._normSign();
29776  };
29777
29778  BN.prototype._normSign = function _normSign() {
29779    // -0 = 0
29780    if (this.length === 1 && this.words[0] === 0) {
29781      this.negative = 0;
29782    }
29783
29784    return this;
29785  };
29786
29787  BN.prototype.inspect = function inspect() {
29788    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
29789  };
29790  /*
29791   var zeros = [];
29792  var groupSizes = [];
29793  var groupBases = [];
29794   var s = '';
29795  var i = -1;
29796  while (++i < BN.wordSize) {
29797    zeros[i] = s;
29798    s += '0';
29799  }
29800  groupSizes[0] = 0;
29801  groupSizes[1] = 0;
29802  groupBases[0] = 0;
29803  groupBases[1] = 0;
29804  var base = 2 - 1;
29805  while (++base < 36 + 1) {
29806    var groupSize = 0;
29807    var groupBase = 1;
29808    while (groupBase < (1 << BN.wordSize) / base) {
29809      groupBase *= base;
29810      groupSize += 1;
29811    }
29812    groupSizes[base] = groupSize;
29813    groupBases[base] = groupBase;
29814  }
29815   */
29816
29817
29818  var zeros = ['', '0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '000000000', '0000000000', '00000000000', '000000000000', '0000000000000', '00000000000000', '000000000000000', '0000000000000000', '00000000000000000', '000000000000000000', '0000000000000000000', '00000000000000000000', '000000000000000000000', '0000000000000000000000', '00000000000000000000000', '000000000000000000000000', '0000000000000000000000000'];
29819  var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5];
29820  var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176];
29821
29822  BN.prototype.toString = function toString(base, padding) {
29823    base = base || 10;
29824    padding = padding | 0 || 1;
29825    var out;
29826
29827    if (base === 16 || base === 'hex') {
29828      out = '';
29829      var off = 0;
29830      var carry = 0;
29831
29832      for (var i = 0; i < this.length; i++) {
29833        var w = this.words[i];
29834        var word = ((w << off | carry) & 0xffffff).toString(16);
29835        carry = w >>> 24 - off & 0xffffff;
29836
29837        if (carry !== 0 || i !== this.length - 1) {
29838          out = zeros[6 - word.length] + word + out;
29839        } else {
29840          out = word + out;
29841        }
29842
29843        off += 2;
29844
29845        if (off >= 26) {
29846          off -= 26;
29847          i--;
29848        }
29849      }
29850
29851      if (carry !== 0) {
29852        out = carry.toString(16) + out;
29853      }
29854
29855      while (out.length % padding !== 0) {
29856        out = '0' + out;
29857      }
29858
29859      if (this.negative !== 0) {
29860        out = '-' + out;
29861      }
29862
29863      return out;
29864    }
29865
29866    if (base === (base | 0) && base >= 2 && base <= 36) {
29867      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
29868      var groupSize = groupSizes[base]; // var groupBase = Math.pow(base, groupSize);
29869
29870      var groupBase = groupBases[base];
29871      out = '';
29872      var c = this.clone();
29873      c.negative = 0;
29874
29875      while (!c.isZero()) {
29876        var r = c.modn(groupBase).toString(base);
29877        c = c.idivn(groupBase);
29878
29879        if (!c.isZero()) {
29880          out = zeros[groupSize - r.length] + r + out;
29881        } else {
29882          out = r + out;
29883        }
29884      }
29885
29886      if (this.isZero()) {
29887        out = '0' + out;
29888      }
29889
29890      while (out.length % padding !== 0) {
29891        out = '0' + out;
29892      }
29893
29894      if (this.negative !== 0) {
29895        out = '-' + out;
29896      }
29897
29898      return out;
29899    }
29900
29901    assert(false, 'Base should be between 2 and 36');
29902  };
29903
29904  BN.prototype.toNumber = function toNumber() {
29905    var ret = this.words[0];
29906
29907    if (this.length === 2) {
29908      ret += this.words[1] * 0x4000000;
29909    } else if (this.length === 3 && this.words[2] === 0x01) {
29910      // NOTE: at this stage it is known that the top bit is set
29911      ret += 0x10000000000000 + this.words[1] * 0x4000000;
29912    } else if (this.length > 2) {
29913      assert(false, 'Number can only safely store up to 53 bits');
29914    }
29915
29916    return this.negative !== 0 ? -ret : ret;
29917  };
29918
29919  BN.prototype.toJSON = function toJSON() {
29920    return this.toString(16);
29921  };
29922
29923  BN.prototype.toBuffer = function toBuffer(endian, length) {
29924    assert(typeof Buffer !== 'undefined');
29925    return this.toArrayLike(Buffer, endian, length);
29926  };
29927
29928  BN.prototype.toArray = function toArray(endian, length) {
29929    return this.toArrayLike(Array, endian, length);
29930  };
29931
29932  BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
29933    var byteLength = this.byteLength();
29934    var reqLength = length || Math.max(1, byteLength);
29935    assert(byteLength <= reqLength, 'byte array longer than desired length');
29936    assert(reqLength > 0, 'Requested array length <= 0');
29937    this.strip();
29938    var littleEndian = endian === 'le';
29939    var res = new ArrayType(reqLength);
29940    var b, i;
29941    var q = this.clone();
29942
29943    if (!littleEndian) {
29944      // Assume big-endian
29945      for (i = 0; i < reqLength - byteLength; i++) {
29946        res[i] = 0;
29947      }
29948
29949      for (i = 0; !q.isZero(); i++) {
29950        b = q.andln(0xff);
29951        q.iushrn(8);
29952        res[reqLength - i - 1] = b;
29953      }
29954    } else {
29955      for (i = 0; !q.isZero(); i++) {
29956        b = q.andln(0xff);
29957        q.iushrn(8);
29958        res[i] = b;
29959      }
29960
29961      for (; i < reqLength; i++) {
29962        res[i] = 0;
29963      }
29964    }
29965
29966    return res;
29967  };
29968
29969  if (Math.clz32) {
29970    BN.prototype._countBits = function _countBits(w) {
29971      return 32 - Math.clz32(w);
29972    };
29973  } else {
29974    BN.prototype._countBits = function _countBits(w) {
29975      var t = w;
29976      var r = 0;
29977
29978      if (t >= 0x1000) {
29979        r += 13;
29980        t >>>= 13;
29981      }
29982
29983      if (t >= 0x40) {
29984        r += 7;
29985        t >>>= 7;
29986      }
29987
29988      if (t >= 0x8) {
29989        r += 4;
29990        t >>>= 4;
29991      }
29992
29993      if (t >= 0x02) {
29994        r += 2;
29995        t >>>= 2;
29996      }
29997
29998      return r + t;
29999    };
30000  }
30001
30002  BN.prototype._zeroBits = function _zeroBits(w) {
30003    // Short-cut
30004    if (w === 0) return 26;
30005    var t = w;
30006    var r = 0;
30007
30008    if ((t & 0x1fff) === 0) {
30009      r += 13;
30010      t >>>= 13;
30011    }
30012
30013    if ((t & 0x7f) === 0) {
30014      r += 7;
30015      t >>>= 7;
30016    }
30017
30018    if ((t & 0xf) === 0) {
30019      r += 4;
30020      t >>>= 4;
30021    }
30022
30023    if ((t & 0x3) === 0) {
30024      r += 2;
30025      t >>>= 2;
30026    }
30027
30028    if ((t & 0x1) === 0) {
30029      r++;
30030    }
30031
30032    return r;
30033  }; // Return number of used bits in a BN
30034
30035
30036  BN.prototype.bitLength = function bitLength() {
30037    var w = this.words[this.length - 1];
30038
30039    var hi = this._countBits(w);
30040
30041    return (this.length - 1) * 26 + hi;
30042  };
30043
30044  function toBitArray(num) {
30045    var w = new Array(num.bitLength());
30046
30047    for (var bit = 0; bit < w.length; bit++) {
30048      var off = bit / 26 | 0;
30049      var wbit = bit % 26;
30050      w[bit] = (num.words[off] & 1 << wbit) >>> wbit;
30051    }
30052
30053    return w;
30054  } // Number of trailing zero bits
30055
30056
30057  BN.prototype.zeroBits = function zeroBits() {
30058    if (this.isZero()) return 0;
30059    var r = 0;
30060
30061    for (var i = 0; i < this.length; i++) {
30062      var b = this._zeroBits(this.words[i]);
30063
30064      r += b;
30065      if (b !== 26) break;
30066    }
30067
30068    return r;
30069  };
30070
30071  BN.prototype.byteLength = function byteLength() {
30072    return Math.ceil(this.bitLength() / 8);
30073  };
30074
30075  BN.prototype.toTwos = function toTwos(width) {
30076    if (this.negative !== 0) {
30077      return this.abs().inotn(width).iaddn(1);
30078    }
30079
30080    return this.clone();
30081  };
30082
30083  BN.prototype.fromTwos = function fromTwos(width) {
30084    if (this.testn(width - 1)) {
30085      return this.notn(width).iaddn(1).ineg();
30086    }
30087
30088    return this.clone();
30089  };
30090
30091  BN.prototype.isNeg = function isNeg() {
30092    return this.negative !== 0;
30093  }; // Return negative clone of `this`
30094
30095
30096  BN.prototype.neg = function neg() {
30097    return this.clone().ineg();
30098  };
30099
30100  BN.prototype.ineg = function ineg() {
30101    if (!this.isZero()) {
30102      this.negative ^= 1;
30103    }
30104
30105    return this;
30106  }; // Or `num` with `this` in-place
30107
30108
30109  BN.prototype.iuor = function iuor(num) {
30110    while (this.length < num.length) {
30111      this.words[this.length++] = 0;
30112    }
30113
30114    for (var i = 0; i < num.length; i++) {
30115      this.words[i] = this.words[i] | num.words[i];
30116    }
30117
30118    return this.strip();
30119  };
30120
30121  BN.prototype.ior = function ior(num) {
30122    assert((this.negative | num.negative) === 0);
30123    return this.iuor(num);
30124  }; // Or `num` with `this`
30125
30126
30127  BN.prototype.or = function or(num) {
30128    if (this.length > num.length) return this.clone().ior(num);
30129    return num.clone().ior(this);
30130  };
30131
30132  BN.prototype.uor = function uor(num) {
30133    if (this.length > num.length) return this.clone().iuor(num);
30134    return num.clone().iuor(this);
30135  }; // And `num` with `this` in-place
30136
30137
30138  BN.prototype.iuand = function iuand(num) {
30139    // b = min-length(num, this)
30140    var b;
30141
30142    if (this.length > num.length) {
30143      b = num;
30144    } else {
30145      b = this;
30146    }
30147
30148    for (var i = 0; i < b.length; i++) {
30149      this.words[i] = this.words[i] & num.words[i];
30150    }
30151
30152    this.length = b.length;
30153    return this.strip();
30154  };
30155
30156  BN.prototype.iand = function iand(num) {
30157    assert((this.negative | num.negative) === 0);
30158    return this.iuand(num);
30159  }; // And `num` with `this`
30160
30161
30162  BN.prototype.and = function and(num) {
30163    if (this.length > num.length) return this.clone().iand(num);
30164    return num.clone().iand(this);
30165  };
30166
30167  BN.prototype.uand = function uand(num) {
30168    if (this.length > num.length) return this.clone().iuand(num);
30169    return num.clone().iuand(this);
30170  }; // Xor `num` with `this` in-place
30171
30172
30173  BN.prototype.iuxor = function iuxor(num) {
30174    // a.length > b.length
30175    var a;
30176    var b;
30177
30178    if (this.length > num.length) {
30179      a = this;
30180      b = num;
30181    } else {
30182      a = num;
30183      b = this;
30184    }
30185
30186    for (var i = 0; i < b.length; i++) {
30187      this.words[i] = a.words[i] ^ b.words[i];
30188    }
30189
30190    if (this !== a) {
30191      for (; i < a.length; i++) {
30192        this.words[i] = a.words[i];
30193      }
30194    }
30195
30196    this.length = a.length;
30197    return this.strip();
30198  };
30199
30200  BN.prototype.ixor = function ixor(num) {
30201    assert((this.negative | num.negative) === 0);
30202    return this.iuxor(num);
30203  }; // Xor `num` with `this`
30204
30205
30206  BN.prototype.xor = function xor(num) {
30207    if (this.length > num.length) return this.clone().ixor(num);
30208    return num.clone().ixor(this);
30209  };
30210
30211  BN.prototype.uxor = function uxor(num) {
30212    if (this.length > num.length) return this.clone().iuxor(num);
30213    return num.clone().iuxor(this);
30214  }; // Not ``this`` with ``width`` bitwidth
30215
30216
30217  BN.prototype.inotn = function inotn(width) {
30218    assert(typeof width === 'number' && width >= 0);
30219    var bytesNeeded = Math.ceil(width / 26) | 0;
30220    var bitsLeft = width % 26; // Extend the buffer with leading zeroes
30221
30222    this._expand(bytesNeeded);
30223
30224    if (bitsLeft > 0) {
30225      bytesNeeded--;
30226    } // Handle complete words
30227
30228
30229    for (var i = 0; i < bytesNeeded; i++) {
30230      this.words[i] = ~this.words[i] & 0x3ffffff;
30231    } // Handle the residue
30232
30233
30234    if (bitsLeft > 0) {
30235      this.words[i] = ~this.words[i] & 0x3ffffff >> 26 - bitsLeft;
30236    } // And remove leading zeroes
30237
30238
30239    return this.strip();
30240  };
30241
30242  BN.prototype.notn = function notn(width) {
30243    return this.clone().inotn(width);
30244  }; // Set `bit` of `this`
30245
30246
30247  BN.prototype.setn = function setn(bit, val) {
30248    assert(typeof bit === 'number' && bit >= 0);
30249    var off = bit / 26 | 0;
30250    var wbit = bit % 26;
30251
30252    this._expand(off + 1);
30253
30254    if (val) {
30255      this.words[off] = this.words[off] | 1 << wbit;
30256    } else {
30257      this.words[off] = this.words[off] & ~(1 << wbit);
30258    }
30259
30260    return this.strip();
30261  }; // Add `num` to `this` in-place
30262
30263
30264  BN.prototype.iadd = function iadd(num) {
30265    var r; // negative + positive
30266
30267    if (this.negative !== 0 && num.negative === 0) {
30268      this.negative = 0;
30269      r = this.isub(num);
30270      this.negative ^= 1;
30271      return this._normSign(); // positive + negative
30272    } else if (this.negative === 0 && num.negative !== 0) {
30273      num.negative = 0;
30274      r = this.isub(num);
30275      num.negative = 1;
30276      return r._normSign();
30277    } // a.length > b.length
30278
30279
30280    var a, b;
30281
30282    if (this.length > num.length) {
30283      a = this;
30284      b = num;
30285    } else {
30286      a = num;
30287      b = this;
30288    }
30289
30290    var carry = 0;
30291
30292    for (var i = 0; i < b.length; i++) {
30293      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
30294      this.words[i] = r & 0x3ffffff;
30295      carry = r >>> 26;
30296    }
30297
30298    for (; carry !== 0 && i < a.length; i++) {
30299      r = (a.words[i] | 0) + carry;
30300      this.words[i] = r & 0x3ffffff;
30301      carry = r >>> 26;
30302    }
30303
30304    this.length = a.length;
30305
30306    if (carry !== 0) {
30307      this.words[this.length] = carry;
30308      this.length++; // Copy the rest of the words
30309    } else if (a !== this) {
30310      for (; i < a.length; i++) {
30311        this.words[i] = a.words[i];
30312      }
30313    }
30314
30315    return this;
30316  }; // Add `num` to `this`
30317
30318
30319  BN.prototype.add = function add(num) {
30320    var res;
30321
30322    if (num.negative !== 0 && this.negative === 0) {
30323      num.negative = 0;
30324      res = this.sub(num);
30325      num.negative ^= 1;
30326      return res;
30327    } else if (num.negative === 0 && this.negative !== 0) {
30328      this.negative = 0;
30329      res = num.sub(this);
30330      this.negative = 1;
30331      return res;
30332    }
30333
30334    if (this.length > num.length) return this.clone().iadd(num);
30335    return num.clone().iadd(this);
30336  }; // Subtract `num` from `this` in-place
30337
30338
30339  BN.prototype.isub = function isub(num) {
30340    // this - (-num) = this + num
30341    if (num.negative !== 0) {
30342      num.negative = 0;
30343      var r = this.iadd(num);
30344      num.negative = 1;
30345      return r._normSign(); // -this - num = -(this + num)
30346    } else if (this.negative !== 0) {
30347      this.negative = 0;
30348      this.iadd(num);
30349      this.negative = 1;
30350      return this._normSign();
30351    } // At this point both numbers are positive
30352
30353
30354    var cmp = this.cmp(num); // Optimization - zeroify
30355
30356    if (cmp === 0) {
30357      this.negative = 0;
30358      this.length = 1;
30359      this.words[0] = 0;
30360      return this;
30361    } // a > b
30362
30363
30364    var a, b;
30365
30366    if (cmp > 0) {
30367      a = this;
30368      b = num;
30369    } else {
30370      a = num;
30371      b = this;
30372    }
30373
30374    var carry = 0;
30375
30376    for (var i = 0; i < b.length; i++) {
30377      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
30378      carry = r >> 26;
30379      this.words[i] = r & 0x3ffffff;
30380    }
30381
30382    for (; carry !== 0 && i < a.length; i++) {
30383      r = (a.words[i] | 0) + carry;
30384      carry = r >> 26;
30385      this.words[i] = r & 0x3ffffff;
30386    } // Copy rest of the words
30387
30388
30389    if (carry === 0 && i < a.length && a !== this) {
30390      for (; i < a.length; i++) {
30391        this.words[i] = a.words[i];
30392      }
30393    }
30394
30395    this.length = Math.max(this.length, i);
30396
30397    if (a !== this) {
30398      this.negative = 1;
30399    }
30400
30401    return this.strip();
30402  }; // Subtract `num` from `this`
30403
30404
30405  BN.prototype.sub = function sub(num) {
30406    return this.clone().isub(num);
30407  };
30408
30409  function smallMulTo(self, num, out) {
30410    out.negative = num.negative ^ self.negative;
30411    var len = self.length + num.length | 0;
30412    out.length = len;
30413    len = len - 1 | 0; // Peel one iteration (compiler can't do it, because of code complexity)
30414
30415    var a = self.words[0] | 0;
30416    var b = num.words[0] | 0;
30417    var r = a * b;
30418    var lo = r & 0x3ffffff;
30419    var carry = r / 0x4000000 | 0;
30420    out.words[0] = lo;
30421
30422    for (var k = 1; k < len; k++) {
30423      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
30424      // note that ncarry could be >= 0x3ffffff
30425      var ncarry = carry >>> 26;
30426      var rword = carry & 0x3ffffff;
30427      var maxJ = Math.min(k, num.length - 1);
30428
30429      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
30430        var i = k - j | 0;
30431        a = self.words[i] | 0;
30432        b = num.words[j] | 0;
30433        r = a * b + rword;
30434        ncarry += r / 0x4000000 | 0;
30435        rword = r & 0x3ffffff;
30436      }
30437
30438      out.words[k] = rword | 0;
30439      carry = ncarry | 0;
30440    }
30441
30442    if (carry !== 0) {
30443      out.words[k] = carry | 0;
30444    } else {
30445      out.length--;
30446    }
30447
30448    return out.strip();
30449  } // TODO(indutny): it may be reasonable to omit it for users who don't need
30450  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
30451  // multiplication (like elliptic secp256k1).
30452
30453
30454  var comb10MulTo = function comb10MulTo(self, num, out) {
30455    var a = self.words;
30456    var b = num.words;
30457    var o = out.words;
30458    var c = 0;
30459    var lo;
30460    var mid;
30461    var hi;
30462    var a0 = a[0] | 0;
30463    var al0 = a0 & 0x1fff;
30464    var ah0 = a0 >>> 13;
30465    var a1 = a[1] | 0;
30466    var al1 = a1 & 0x1fff;
30467    var ah1 = a1 >>> 13;
30468    var a2 = a[2] | 0;
30469    var al2 = a2 & 0x1fff;
30470    var ah2 = a2 >>> 13;
30471    var a3 = a[3] | 0;
30472    var al3 = a3 & 0x1fff;
30473    var ah3 = a3 >>> 13;
30474    var a4 = a[4] | 0;
30475    var al4 = a4 & 0x1fff;
30476    var ah4 = a4 >>> 13;
30477    var a5 = a[5] | 0;
30478    var al5 = a5 & 0x1fff;
30479    var ah5 = a5 >>> 13;
30480    var a6 = a[6] | 0;
30481    var al6 = a6 & 0x1fff;
30482    var ah6 = a6 >>> 13;
30483    var a7 = a[7] | 0;
30484    var al7 = a7 & 0x1fff;
30485    var ah7 = a7 >>> 13;
30486    var a8 = a[8] | 0;
30487    var al8 = a8 & 0x1fff;
30488    var ah8 = a8 >>> 13;
30489    var a9 = a[9] | 0;
30490    var al9 = a9 & 0x1fff;
30491    var ah9 = a9 >>> 13;
30492    var b0 = b[0] | 0;
30493    var bl0 = b0 & 0x1fff;
30494    var bh0 = b0 >>> 13;
30495    var b1 = b[1] | 0;
30496    var bl1 = b1 & 0x1fff;
30497    var bh1 = b1 >>> 13;
30498    var b2 = b[2] | 0;
30499    var bl2 = b2 & 0x1fff;
30500    var bh2 = b2 >>> 13;
30501    var b3 = b[3] | 0;
30502    var bl3 = b3 & 0x1fff;
30503    var bh3 = b3 >>> 13;
30504    var b4 = b[4] | 0;
30505    var bl4 = b4 & 0x1fff;
30506    var bh4 = b4 >>> 13;
30507    var b5 = b[5] | 0;
30508    var bl5 = b5 & 0x1fff;
30509    var bh5 = b5 >>> 13;
30510    var b6 = b[6] | 0;
30511    var bl6 = b6 & 0x1fff;
30512    var bh6 = b6 >>> 13;
30513    var b7 = b[7] | 0;
30514    var bl7 = b7 & 0x1fff;
30515    var bh7 = b7 >>> 13;
30516    var b8 = b[8] | 0;
30517    var bl8 = b8 & 0x1fff;
30518    var bh8 = b8 >>> 13;
30519    var b9 = b[9] | 0;
30520    var bl9 = b9 & 0x1fff;
30521    var bh9 = b9 >>> 13;
30522    out.negative = self.negative ^ num.negative;
30523    out.length = 19;
30524    /* k = 0 */
30525
30526    lo = Math.imul(al0, bl0);
30527    mid = Math.imul(al0, bh0);
30528    mid = mid + Math.imul(ah0, bl0) | 0;
30529    hi = Math.imul(ah0, bh0);
30530    var w0 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30531    c = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0;
30532    w0 &= 0x3ffffff;
30533    /* k = 1 */
30534
30535    lo = Math.imul(al1, bl0);
30536    mid = Math.imul(al1, bh0);
30537    mid = mid + Math.imul(ah1, bl0) | 0;
30538    hi = Math.imul(ah1, bh0);
30539    lo = lo + Math.imul(al0, bl1) | 0;
30540    mid = mid + Math.imul(al0, bh1) | 0;
30541    mid = mid + Math.imul(ah0, bl1) | 0;
30542    hi = hi + Math.imul(ah0, bh1) | 0;
30543    var w1 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30544    c = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0;
30545    w1 &= 0x3ffffff;
30546    /* k = 2 */
30547
30548    lo = Math.imul(al2, bl0);
30549    mid = Math.imul(al2, bh0);
30550    mid = mid + Math.imul(ah2, bl0) | 0;
30551    hi = Math.imul(ah2, bh0);
30552    lo = lo + Math.imul(al1, bl1) | 0;
30553    mid = mid + Math.imul(al1, bh1) | 0;
30554    mid = mid + Math.imul(ah1, bl1) | 0;
30555    hi = hi + Math.imul(ah1, bh1) | 0;
30556    lo = lo + Math.imul(al0, bl2) | 0;
30557    mid = mid + Math.imul(al0, bh2) | 0;
30558    mid = mid + Math.imul(ah0, bl2) | 0;
30559    hi = hi + Math.imul(ah0, bh2) | 0;
30560    var w2 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30561    c = (hi + (mid >>> 13) | 0) + (w2 >>> 26) | 0;
30562    w2 &= 0x3ffffff;
30563    /* k = 3 */
30564
30565    lo = Math.imul(al3, bl0);
30566    mid = Math.imul(al3, bh0);
30567    mid = mid + Math.imul(ah3, bl0) | 0;
30568    hi = Math.imul(ah3, bh0);
30569    lo = lo + Math.imul(al2, bl1) | 0;
30570    mid = mid + Math.imul(al2, bh1) | 0;
30571    mid = mid + Math.imul(ah2, bl1) | 0;
30572    hi = hi + Math.imul(ah2, bh1) | 0;
30573    lo = lo + Math.imul(al1, bl2) | 0;
30574    mid = mid + Math.imul(al1, bh2) | 0;
30575    mid = mid + Math.imul(ah1, bl2) | 0;
30576    hi = hi + Math.imul(ah1, bh2) | 0;
30577    lo = lo + Math.imul(al0, bl3) | 0;
30578    mid = mid + Math.imul(al0, bh3) | 0;
30579    mid = mid + Math.imul(ah0, bl3) | 0;
30580    hi = hi + Math.imul(ah0, bh3) | 0;
30581    var w3 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30582    c = (hi + (mid >>> 13) | 0) + (w3 >>> 26) | 0;
30583    w3 &= 0x3ffffff;
30584    /* k = 4 */
30585
30586    lo = Math.imul(al4, bl0);
30587    mid = Math.imul(al4, bh0);
30588    mid = mid + Math.imul(ah4, bl0) | 0;
30589    hi = Math.imul(ah4, bh0);
30590    lo = lo + Math.imul(al3, bl1) | 0;
30591    mid = mid + Math.imul(al3, bh1) | 0;
30592    mid = mid + Math.imul(ah3, bl1) | 0;
30593    hi = hi + Math.imul(ah3, bh1) | 0;
30594    lo = lo + Math.imul(al2, bl2) | 0;
30595    mid = mid + Math.imul(al2, bh2) | 0;
30596    mid = mid + Math.imul(ah2, bl2) | 0;
30597    hi = hi + Math.imul(ah2, bh2) | 0;
30598    lo = lo + Math.imul(al1, bl3) | 0;
30599    mid = mid + Math.imul(al1, bh3) | 0;
30600    mid = mid + Math.imul(ah1, bl3) | 0;
30601    hi = hi + Math.imul(ah1, bh3) | 0;
30602    lo = lo + Math.imul(al0, bl4) | 0;
30603    mid = mid + Math.imul(al0, bh4) | 0;
30604    mid = mid + Math.imul(ah0, bl4) | 0;
30605    hi = hi + Math.imul(ah0, bh4) | 0;
30606    var w4 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30607    c = (hi + (mid >>> 13) | 0) + (w4 >>> 26) | 0;
30608    w4 &= 0x3ffffff;
30609    /* k = 5 */
30610
30611    lo = Math.imul(al5, bl0);
30612    mid = Math.imul(al5, bh0);
30613    mid = mid + Math.imul(ah5, bl0) | 0;
30614    hi = Math.imul(ah5, bh0);
30615    lo = lo + Math.imul(al4, bl1) | 0;
30616    mid = mid + Math.imul(al4, bh1) | 0;
30617    mid = mid + Math.imul(ah4, bl1) | 0;
30618    hi = hi + Math.imul(ah4, bh1) | 0;
30619    lo = lo + Math.imul(al3, bl2) | 0;
30620    mid = mid + Math.imul(al3, bh2) | 0;
30621    mid = mid + Math.imul(ah3, bl2) | 0;
30622    hi = hi + Math.imul(ah3, bh2) | 0;
30623    lo = lo + Math.imul(al2, bl3) | 0;
30624    mid = mid + Math.imul(al2, bh3) | 0;
30625    mid = mid + Math.imul(ah2, bl3) | 0;
30626    hi = hi + Math.imul(ah2, bh3) | 0;
30627    lo = lo + Math.imul(al1, bl4) | 0;
30628    mid = mid + Math.imul(al1, bh4) | 0;
30629    mid = mid + Math.imul(ah1, bl4) | 0;
30630    hi = hi + Math.imul(ah1, bh4) | 0;
30631    lo = lo + Math.imul(al0, bl5) | 0;
30632    mid = mid + Math.imul(al0, bh5) | 0;
30633    mid = mid + Math.imul(ah0, bl5) | 0;
30634    hi = hi + Math.imul(ah0, bh5) | 0;
30635    var w5 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30636    c = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0;
30637    w5 &= 0x3ffffff;
30638    /* k = 6 */
30639
30640    lo = Math.imul(al6, bl0);
30641    mid = Math.imul(al6, bh0);
30642    mid = mid + Math.imul(ah6, bl0) | 0;
30643    hi = Math.imul(ah6, bh0);
30644    lo = lo + Math.imul(al5, bl1) | 0;
30645    mid = mid + Math.imul(al5, bh1) | 0;
30646    mid = mid + Math.imul(ah5, bl1) | 0;
30647    hi = hi + Math.imul(ah5, bh1) | 0;
30648    lo = lo + Math.imul(al4, bl2) | 0;
30649    mid = mid + Math.imul(al4, bh2) | 0;
30650    mid = mid + Math.imul(ah4, bl2) | 0;
30651    hi = hi + Math.imul(ah4, bh2) | 0;
30652    lo = lo + Math.imul(al3, bl3) | 0;
30653    mid = mid + Math.imul(al3, bh3) | 0;
30654    mid = mid + Math.imul(ah3, bl3) | 0;
30655    hi = hi + Math.imul(ah3, bh3) | 0;
30656    lo = lo + Math.imul(al2, bl4) | 0;
30657    mid = mid + Math.imul(al2, bh4) | 0;
30658    mid = mid + Math.imul(ah2, bl4) | 0;
30659    hi = hi + Math.imul(ah2, bh4) | 0;
30660    lo = lo + Math.imul(al1, bl5) | 0;
30661    mid = mid + Math.imul(al1, bh5) | 0;
30662    mid = mid + Math.imul(ah1, bl5) | 0;
30663    hi = hi + Math.imul(ah1, bh5) | 0;
30664    lo = lo + Math.imul(al0, bl6) | 0;
30665    mid = mid + Math.imul(al0, bh6) | 0;
30666    mid = mid + Math.imul(ah0, bl6) | 0;
30667    hi = hi + Math.imul(ah0, bh6) | 0;
30668    var w6 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30669    c = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0;
30670    w6 &= 0x3ffffff;
30671    /* k = 7 */
30672
30673    lo = Math.imul(al7, bl0);
30674    mid = Math.imul(al7, bh0);
30675    mid = mid + Math.imul(ah7, bl0) | 0;
30676    hi = Math.imul(ah7, bh0);
30677    lo = lo + Math.imul(al6, bl1) | 0;
30678    mid = mid + Math.imul(al6, bh1) | 0;
30679    mid = mid + Math.imul(ah6, bl1) | 0;
30680    hi = hi + Math.imul(ah6, bh1) | 0;
30681    lo = lo + Math.imul(al5, bl2) | 0;
30682    mid = mid + Math.imul(al5, bh2) | 0;
30683    mid = mid + Math.imul(ah5, bl2) | 0;
30684    hi = hi + Math.imul(ah5, bh2) | 0;
30685    lo = lo + Math.imul(al4, bl3) | 0;
30686    mid = mid + Math.imul(al4, bh3) | 0;
30687    mid = mid + Math.imul(ah4, bl3) | 0;
30688    hi = hi + Math.imul(ah4, bh3) | 0;
30689    lo = lo + Math.imul(al3, bl4) | 0;
30690    mid = mid + Math.imul(al3, bh4) | 0;
30691    mid = mid + Math.imul(ah3, bl4) | 0;
30692    hi = hi + Math.imul(ah3, bh4) | 0;
30693    lo = lo + Math.imul(al2, bl5) | 0;
30694    mid = mid + Math.imul(al2, bh5) | 0;
30695    mid = mid + Math.imul(ah2, bl5) | 0;
30696    hi = hi + Math.imul(ah2, bh5) | 0;
30697    lo = lo + Math.imul(al1, bl6) | 0;
30698    mid = mid + Math.imul(al1, bh6) | 0;
30699    mid = mid + Math.imul(ah1, bl6) | 0;
30700    hi = hi + Math.imul(ah1, bh6) | 0;
30701    lo = lo + Math.imul(al0, bl7) | 0;
30702    mid = mid + Math.imul(al0, bh7) | 0;
30703    mid = mid + Math.imul(ah0, bl7) | 0;
30704    hi = hi + Math.imul(ah0, bh7) | 0;
30705    var w7 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30706    c = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0;
30707    w7 &= 0x3ffffff;
30708    /* k = 8 */
30709
30710    lo = Math.imul(al8, bl0);
30711    mid = Math.imul(al8, bh0);
30712    mid = mid + Math.imul(ah8, bl0) | 0;
30713    hi = Math.imul(ah8, bh0);
30714    lo = lo + Math.imul(al7, bl1) | 0;
30715    mid = mid + Math.imul(al7, bh1) | 0;
30716    mid = mid + Math.imul(ah7, bl1) | 0;
30717    hi = hi + Math.imul(ah7, bh1) | 0;
30718    lo = lo + Math.imul(al6, bl2) | 0;
30719    mid = mid + Math.imul(al6, bh2) | 0;
30720    mid = mid + Math.imul(ah6, bl2) | 0;
30721    hi = hi + Math.imul(ah6, bh2) | 0;
30722    lo = lo + Math.imul(al5, bl3) | 0;
30723    mid = mid + Math.imul(al5, bh3) | 0;
30724    mid = mid + Math.imul(ah5, bl3) | 0;
30725    hi = hi + Math.imul(ah5, bh3) | 0;
30726    lo = lo + Math.imul(al4, bl4) | 0;
30727    mid = mid + Math.imul(al4, bh4) | 0;
30728    mid = mid + Math.imul(ah4, bl4) | 0;
30729    hi = hi + Math.imul(ah4, bh4) | 0;
30730    lo = lo + Math.imul(al3, bl5) | 0;
30731    mid = mid + Math.imul(al3, bh5) | 0;
30732    mid = mid + Math.imul(ah3, bl5) | 0;
30733    hi = hi + Math.imul(ah3, bh5) | 0;
30734    lo = lo + Math.imul(al2, bl6) | 0;
30735    mid = mid + Math.imul(al2, bh6) | 0;
30736    mid = mid + Math.imul(ah2, bl6) | 0;
30737    hi = hi + Math.imul(ah2, bh6) | 0;
30738    lo = lo + Math.imul(al1, bl7) | 0;
30739    mid = mid + Math.imul(al1, bh7) | 0;
30740    mid = mid + Math.imul(ah1, bl7) | 0;
30741    hi = hi + Math.imul(ah1, bh7) | 0;
30742    lo = lo + Math.imul(al0, bl8) | 0;
30743    mid = mid + Math.imul(al0, bh8) | 0;
30744    mid = mid + Math.imul(ah0, bl8) | 0;
30745    hi = hi + Math.imul(ah0, bh8) | 0;
30746    var w8 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30747    c = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0;
30748    w8 &= 0x3ffffff;
30749    /* k = 9 */
30750
30751    lo = Math.imul(al9, bl0);
30752    mid = Math.imul(al9, bh0);
30753    mid = mid + Math.imul(ah9, bl0) | 0;
30754    hi = Math.imul(ah9, bh0);
30755    lo = lo + Math.imul(al8, bl1) | 0;
30756    mid = mid + Math.imul(al8, bh1) | 0;
30757    mid = mid + Math.imul(ah8, bl1) | 0;
30758    hi = hi + Math.imul(ah8, bh1) | 0;
30759    lo = lo + Math.imul(al7, bl2) | 0;
30760    mid = mid + Math.imul(al7, bh2) | 0;
30761    mid = mid + Math.imul(ah7, bl2) | 0;
30762    hi = hi + Math.imul(ah7, bh2) | 0;
30763    lo = lo + Math.imul(al6, bl3) | 0;
30764    mid = mid + Math.imul(al6, bh3) | 0;
30765    mid = mid + Math.imul(ah6, bl3) | 0;
30766    hi = hi + Math.imul(ah6, bh3) | 0;
30767    lo = lo + Math.imul(al5, bl4) | 0;
30768    mid = mid + Math.imul(al5, bh4) | 0;
30769    mid = mid + Math.imul(ah5, bl4) | 0;
30770    hi = hi + Math.imul(ah5, bh4) | 0;
30771    lo = lo + Math.imul(al4, bl5) | 0;
30772    mid = mid + Math.imul(al4, bh5) | 0;
30773    mid = mid + Math.imul(ah4, bl5) | 0;
30774    hi = hi + Math.imul(ah4, bh5) | 0;
30775    lo = lo + Math.imul(al3, bl6) | 0;
30776    mid = mid + Math.imul(al3, bh6) | 0;
30777    mid = mid + Math.imul(ah3, bl6) | 0;
30778    hi = hi + Math.imul(ah3, bh6) | 0;
30779    lo = lo + Math.imul(al2, bl7) | 0;
30780    mid = mid + Math.imul(al2, bh7) | 0;
30781    mid = mid + Math.imul(ah2, bl7) | 0;
30782    hi = hi + Math.imul(ah2, bh7) | 0;
30783    lo = lo + Math.imul(al1, bl8) | 0;
30784    mid = mid + Math.imul(al1, bh8) | 0;
30785    mid = mid + Math.imul(ah1, bl8) | 0;
30786    hi = hi + Math.imul(ah1, bh8) | 0;
30787    lo = lo + Math.imul(al0, bl9) | 0;
30788    mid = mid + Math.imul(al0, bh9) | 0;
30789    mid = mid + Math.imul(ah0, bl9) | 0;
30790    hi = hi + Math.imul(ah0, bh9) | 0;
30791    var w9 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30792    c = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0;
30793    w9 &= 0x3ffffff;
30794    /* k = 10 */
30795
30796    lo = Math.imul(al9, bl1);
30797    mid = Math.imul(al9, bh1);
30798    mid = mid + Math.imul(ah9, bl1) | 0;
30799    hi = Math.imul(ah9, bh1);
30800    lo = lo + Math.imul(al8, bl2) | 0;
30801    mid = mid + Math.imul(al8, bh2) | 0;
30802    mid = mid + Math.imul(ah8, bl2) | 0;
30803    hi = hi + Math.imul(ah8, bh2) | 0;
30804    lo = lo + Math.imul(al7, bl3) | 0;
30805    mid = mid + Math.imul(al7, bh3) | 0;
30806    mid = mid + Math.imul(ah7, bl3) | 0;
30807    hi = hi + Math.imul(ah7, bh3) | 0;
30808    lo = lo + Math.imul(al6, bl4) | 0;
30809    mid = mid + Math.imul(al6, bh4) | 0;
30810    mid = mid + Math.imul(ah6, bl4) | 0;
30811    hi = hi + Math.imul(ah6, bh4) | 0;
30812    lo = lo + Math.imul(al5, bl5) | 0;
30813    mid = mid + Math.imul(al5, bh5) | 0;
30814    mid = mid + Math.imul(ah5, bl5) | 0;
30815    hi = hi + Math.imul(ah5, bh5) | 0;
30816    lo = lo + Math.imul(al4, bl6) | 0;
30817    mid = mid + Math.imul(al4, bh6) | 0;
30818    mid = mid + Math.imul(ah4, bl6) | 0;
30819    hi = hi + Math.imul(ah4, bh6) | 0;
30820    lo = lo + Math.imul(al3, bl7) | 0;
30821    mid = mid + Math.imul(al3, bh7) | 0;
30822    mid = mid + Math.imul(ah3, bl7) | 0;
30823    hi = hi + Math.imul(ah3, bh7) | 0;
30824    lo = lo + Math.imul(al2, bl8) | 0;
30825    mid = mid + Math.imul(al2, bh8) | 0;
30826    mid = mid + Math.imul(ah2, bl8) | 0;
30827    hi = hi + Math.imul(ah2, bh8) | 0;
30828    lo = lo + Math.imul(al1, bl9) | 0;
30829    mid = mid + Math.imul(al1, bh9) | 0;
30830    mid = mid + Math.imul(ah1, bl9) | 0;
30831    hi = hi + Math.imul(ah1, bh9) | 0;
30832    var w10 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30833    c = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0;
30834    w10 &= 0x3ffffff;
30835    /* k = 11 */
30836
30837    lo = Math.imul(al9, bl2);
30838    mid = Math.imul(al9, bh2);
30839    mid = mid + Math.imul(ah9, bl2) | 0;
30840    hi = Math.imul(ah9, bh2);
30841    lo = lo + Math.imul(al8, bl3) | 0;
30842    mid = mid + Math.imul(al8, bh3) | 0;
30843    mid = mid + Math.imul(ah8, bl3) | 0;
30844    hi = hi + Math.imul(ah8, bh3) | 0;
30845    lo = lo + Math.imul(al7, bl4) | 0;
30846    mid = mid + Math.imul(al7, bh4) | 0;
30847    mid = mid + Math.imul(ah7, bl4) | 0;
30848    hi = hi + Math.imul(ah7, bh4) | 0;
30849    lo = lo + Math.imul(al6, bl5) | 0;
30850    mid = mid + Math.imul(al6, bh5) | 0;
30851    mid = mid + Math.imul(ah6, bl5) | 0;
30852    hi = hi + Math.imul(ah6, bh5) | 0;
30853    lo = lo + Math.imul(al5, bl6) | 0;
30854    mid = mid + Math.imul(al5, bh6) | 0;
30855    mid = mid + Math.imul(ah5, bl6) | 0;
30856    hi = hi + Math.imul(ah5, bh6) | 0;
30857    lo = lo + Math.imul(al4, bl7) | 0;
30858    mid = mid + Math.imul(al4, bh7) | 0;
30859    mid = mid + Math.imul(ah4, bl7) | 0;
30860    hi = hi + Math.imul(ah4, bh7) | 0;
30861    lo = lo + Math.imul(al3, bl8) | 0;
30862    mid = mid + Math.imul(al3, bh8) | 0;
30863    mid = mid + Math.imul(ah3, bl8) | 0;
30864    hi = hi + Math.imul(ah3, bh8) | 0;
30865    lo = lo + Math.imul(al2, bl9) | 0;
30866    mid = mid + Math.imul(al2, bh9) | 0;
30867    mid = mid + Math.imul(ah2, bl9) | 0;
30868    hi = hi + Math.imul(ah2, bh9) | 0;
30869    var w11 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30870    c = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0;
30871    w11 &= 0x3ffffff;
30872    /* k = 12 */
30873
30874    lo = Math.imul(al9, bl3);
30875    mid = Math.imul(al9, bh3);
30876    mid = mid + Math.imul(ah9, bl3) | 0;
30877    hi = Math.imul(ah9, bh3);
30878    lo = lo + Math.imul(al8, bl4) | 0;
30879    mid = mid + Math.imul(al8, bh4) | 0;
30880    mid = mid + Math.imul(ah8, bl4) | 0;
30881    hi = hi + Math.imul(ah8, bh4) | 0;
30882    lo = lo + Math.imul(al7, bl5) | 0;
30883    mid = mid + Math.imul(al7, bh5) | 0;
30884    mid = mid + Math.imul(ah7, bl5) | 0;
30885    hi = hi + Math.imul(ah7, bh5) | 0;
30886    lo = lo + Math.imul(al6, bl6) | 0;
30887    mid = mid + Math.imul(al6, bh6) | 0;
30888    mid = mid + Math.imul(ah6, bl6) | 0;
30889    hi = hi + Math.imul(ah6, bh6) | 0;
30890    lo = lo + Math.imul(al5, bl7) | 0;
30891    mid = mid + Math.imul(al5, bh7) | 0;
30892    mid = mid + Math.imul(ah5, bl7) | 0;
30893    hi = hi + Math.imul(ah5, bh7) | 0;
30894    lo = lo + Math.imul(al4, bl8) | 0;
30895    mid = mid + Math.imul(al4, bh8) | 0;
30896    mid = mid + Math.imul(ah4, bl8) | 0;
30897    hi = hi + Math.imul(ah4, bh8) | 0;
30898    lo = lo + Math.imul(al3, bl9) | 0;
30899    mid = mid + Math.imul(al3, bh9) | 0;
30900    mid = mid + Math.imul(ah3, bl9) | 0;
30901    hi = hi + Math.imul(ah3, bh9) | 0;
30902    var w12 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30903    c = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0;
30904    w12 &= 0x3ffffff;
30905    /* k = 13 */
30906
30907    lo = Math.imul(al9, bl4);
30908    mid = Math.imul(al9, bh4);
30909    mid = mid + Math.imul(ah9, bl4) | 0;
30910    hi = Math.imul(ah9, bh4);
30911    lo = lo + Math.imul(al8, bl5) | 0;
30912    mid = mid + Math.imul(al8, bh5) | 0;
30913    mid = mid + Math.imul(ah8, bl5) | 0;
30914    hi = hi + Math.imul(ah8, bh5) | 0;
30915    lo = lo + Math.imul(al7, bl6) | 0;
30916    mid = mid + Math.imul(al7, bh6) | 0;
30917    mid = mid + Math.imul(ah7, bl6) | 0;
30918    hi = hi + Math.imul(ah7, bh6) | 0;
30919    lo = lo + Math.imul(al6, bl7) | 0;
30920    mid = mid + Math.imul(al6, bh7) | 0;
30921    mid = mid + Math.imul(ah6, bl7) | 0;
30922    hi = hi + Math.imul(ah6, bh7) | 0;
30923    lo = lo + Math.imul(al5, bl8) | 0;
30924    mid = mid + Math.imul(al5, bh8) | 0;
30925    mid = mid + Math.imul(ah5, bl8) | 0;
30926    hi = hi + Math.imul(ah5, bh8) | 0;
30927    lo = lo + Math.imul(al4, bl9) | 0;
30928    mid = mid + Math.imul(al4, bh9) | 0;
30929    mid = mid + Math.imul(ah4, bl9) | 0;
30930    hi = hi + Math.imul(ah4, bh9) | 0;
30931    var w13 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30932    c = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0;
30933    w13 &= 0x3ffffff;
30934    /* k = 14 */
30935
30936    lo = Math.imul(al9, bl5);
30937    mid = Math.imul(al9, bh5);
30938    mid = mid + Math.imul(ah9, bl5) | 0;
30939    hi = Math.imul(ah9, bh5);
30940    lo = lo + Math.imul(al8, bl6) | 0;
30941    mid = mid + Math.imul(al8, bh6) | 0;
30942    mid = mid + Math.imul(ah8, bl6) | 0;
30943    hi = hi + Math.imul(ah8, bh6) | 0;
30944    lo = lo + Math.imul(al7, bl7) | 0;
30945    mid = mid + Math.imul(al7, bh7) | 0;
30946    mid = mid + Math.imul(ah7, bl7) | 0;
30947    hi = hi + Math.imul(ah7, bh7) | 0;
30948    lo = lo + Math.imul(al6, bl8) | 0;
30949    mid = mid + Math.imul(al6, bh8) | 0;
30950    mid = mid + Math.imul(ah6, bl8) | 0;
30951    hi = hi + Math.imul(ah6, bh8) | 0;
30952    lo = lo + Math.imul(al5, bl9) | 0;
30953    mid = mid + Math.imul(al5, bh9) | 0;
30954    mid = mid + Math.imul(ah5, bl9) | 0;
30955    hi = hi + Math.imul(ah5, bh9) | 0;
30956    var w14 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30957    c = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0;
30958    w14 &= 0x3ffffff;
30959    /* k = 15 */
30960
30961    lo = Math.imul(al9, bl6);
30962    mid = Math.imul(al9, bh6);
30963    mid = mid + Math.imul(ah9, bl6) | 0;
30964    hi = Math.imul(ah9, bh6);
30965    lo = lo + Math.imul(al8, bl7) | 0;
30966    mid = mid + Math.imul(al8, bh7) | 0;
30967    mid = mid + Math.imul(ah8, bl7) | 0;
30968    hi = hi + Math.imul(ah8, bh7) | 0;
30969    lo = lo + Math.imul(al7, bl8) | 0;
30970    mid = mid + Math.imul(al7, bh8) | 0;
30971    mid = mid + Math.imul(ah7, bl8) | 0;
30972    hi = hi + Math.imul(ah7, bh8) | 0;
30973    lo = lo + Math.imul(al6, bl9) | 0;
30974    mid = mid + Math.imul(al6, bh9) | 0;
30975    mid = mid + Math.imul(ah6, bl9) | 0;
30976    hi = hi + Math.imul(ah6, bh9) | 0;
30977    var w15 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30978    c = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0;
30979    w15 &= 0x3ffffff;
30980    /* k = 16 */
30981
30982    lo = Math.imul(al9, bl7);
30983    mid = Math.imul(al9, bh7);
30984    mid = mid + Math.imul(ah9, bl7) | 0;
30985    hi = Math.imul(ah9, bh7);
30986    lo = lo + Math.imul(al8, bl8) | 0;
30987    mid = mid + Math.imul(al8, bh8) | 0;
30988    mid = mid + Math.imul(ah8, bl8) | 0;
30989    hi = hi + Math.imul(ah8, bh8) | 0;
30990    lo = lo + Math.imul(al7, bl9) | 0;
30991    mid = mid + Math.imul(al7, bh9) | 0;
30992    mid = mid + Math.imul(ah7, bl9) | 0;
30993    hi = hi + Math.imul(ah7, bh9) | 0;
30994    var w16 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
30995    c = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0;
30996    w16 &= 0x3ffffff;
30997    /* k = 17 */
30998
30999    lo = Math.imul(al9, bl8);
31000    mid = Math.imul(al9, bh8);
31001    mid = mid + Math.imul(ah9, bl8) | 0;
31002    hi = Math.imul(ah9, bh8);
31003    lo = lo + Math.imul(al8, bl9) | 0;
31004    mid = mid + Math.imul(al8, bh9) | 0;
31005    mid = mid + Math.imul(ah8, bl9) | 0;
31006    hi = hi + Math.imul(ah8, bh9) | 0;
31007    var w17 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
31008    c = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0;
31009    w17 &= 0x3ffffff;
31010    /* k = 18 */
31011
31012    lo = Math.imul(al9, bl9);
31013    mid = Math.imul(al9, bh9);
31014    mid = mid + Math.imul(ah9, bl9) | 0;
31015    hi = Math.imul(ah9, bh9);
31016    var w18 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
31017    c = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0;
31018    w18 &= 0x3ffffff;
31019    o[0] = w0;
31020    o[1] = w1;
31021    o[2] = w2;
31022    o[3] = w3;
31023    o[4] = w4;
31024    o[5] = w5;
31025    o[6] = w6;
31026    o[7] = w7;
31027    o[8] = w8;
31028    o[9] = w9;
31029    o[10] = w10;
31030    o[11] = w11;
31031    o[12] = w12;
31032    o[13] = w13;
31033    o[14] = w14;
31034    o[15] = w15;
31035    o[16] = w16;
31036    o[17] = w17;
31037    o[18] = w18;
31038
31039    if (c !== 0) {
31040      o[19] = c;
31041      out.length++;
31042    }
31043
31044    return out;
31045  }; // Polyfill comb
31046
31047
31048  if (!Math.imul) {
31049    comb10MulTo = smallMulTo;
31050  }
31051
31052  function bigMulTo(self, num, out) {
31053    out.negative = num.negative ^ self.negative;
31054    out.length = self.length + num.length;
31055    var carry = 0;
31056    var hncarry = 0;
31057
31058    for (var k = 0; k < out.length - 1; k++) {
31059      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
31060      // note that ncarry could be >= 0x3ffffff
31061      var ncarry = hncarry;
31062      hncarry = 0;
31063      var rword = carry & 0x3ffffff;
31064      var maxJ = Math.min(k, num.length - 1);
31065
31066      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
31067        var i = k - j;
31068        var a = self.words[i] | 0;
31069        var b = num.words[j] | 0;
31070        var r = a * b;
31071        var lo = r & 0x3ffffff;
31072        ncarry = ncarry + (r / 0x4000000 | 0) | 0;
31073        lo = lo + rword | 0;
31074        rword = lo & 0x3ffffff;
31075        ncarry = ncarry + (lo >>> 26) | 0;
31076        hncarry += ncarry >>> 26;
31077        ncarry &= 0x3ffffff;
31078      }
31079
31080      out.words[k] = rword;
31081      carry = ncarry;
31082      ncarry = hncarry;
31083    }
31084
31085    if (carry !== 0) {
31086      out.words[k] = carry;
31087    } else {
31088      out.length--;
31089    }
31090
31091    return out.strip();
31092  }
31093
31094  function jumboMulTo(self, num, out) {
31095    var fftm = new FFTM();
31096    return fftm.mulp(self, num, out);
31097  }
31098
31099  BN.prototype.mulTo = function mulTo(num, out) {
31100    var res;
31101    var len = this.length + num.length;
31102
31103    if (this.length === 10 && num.length === 10) {
31104      res = comb10MulTo(this, num, out);
31105    } else if (len < 63) {
31106      res = smallMulTo(this, num, out);
31107    } else if (len < 1024) {
31108      res = bigMulTo(this, num, out);
31109    } else {
31110      res = jumboMulTo(this, num, out);
31111    }
31112
31113    return res;
31114  }; // Cooley-Tukey algorithm for FFT
31115  // slightly revisited to rely on looping instead of recursion
31116
31117
31118  function FFTM(x, y) {
31119    this.x = x;
31120    this.y = y;
31121  }
31122
31123  FFTM.prototype.makeRBT = function makeRBT(N) {
31124    var t = new Array(N);
31125    var l = BN.prototype._countBits(N) - 1;
31126
31127    for (var i = 0; i < N; i++) {
31128      t[i] = this.revBin(i, l, N);
31129    }
31130
31131    return t;
31132  }; // Returns binary-reversed representation of `x`
31133
31134
31135  FFTM.prototype.revBin = function revBin(x, l, N) {
31136    if (x === 0 || x === N - 1) return x;
31137    var rb = 0;
31138
31139    for (var i = 0; i < l; i++) {
31140      rb |= (x & 1) << l - i - 1;
31141      x >>= 1;
31142    }
31143
31144    return rb;
31145  }; // Performs "tweedling" phase, therefore 'emulating'
31146  // behaviour of the recursive algorithm
31147
31148
31149  FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N) {
31150    for (var i = 0; i < N; i++) {
31151      rtws[i] = rws[rbt[i]];
31152      itws[i] = iws[rbt[i]];
31153    }
31154  };
31155
31156  FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N, rbt) {
31157    this.permute(rbt, rws, iws, rtws, itws, N);
31158
31159    for (var s = 1; s < N; s <<= 1) {
31160      var l = s << 1;
31161      var rtwdf = Math.cos(2 * Math.PI / l);
31162      var itwdf = Math.sin(2 * Math.PI / l);
31163
31164      for (var p = 0; p < N; p += l) {
31165        var rtwdf_ = rtwdf;
31166        var itwdf_ = itwdf;
31167
31168        for (var j = 0; j < s; j++) {
31169          var re = rtws[p + j];
31170          var ie = itws[p + j];
31171          var ro = rtws[p + j + s];
31172          var io = itws[p + j + s];
31173          var rx = rtwdf_ * ro - itwdf_ * io;
31174          io = rtwdf_ * io + itwdf_ * ro;
31175          ro = rx;
31176          rtws[p + j] = re + ro;
31177          itws[p + j] = ie + io;
31178          rtws[p + j + s] = re - ro;
31179          itws[p + j + s] = ie - io;
31180          /* jshint maxdepth : false */
31181
31182          if (j !== l) {
31183            rx = rtwdf * rtwdf_ - itwdf * itwdf_;
31184            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
31185            rtwdf_ = rx;
31186          }
31187        }
31188      }
31189    }
31190  };
31191
31192  FFTM.prototype.guessLen13b = function guessLen13b(n, m) {
31193    var N = Math.max(m, n) | 1;
31194    var odd = N & 1;
31195    var i = 0;
31196
31197    for (N = N / 2 | 0; N; N = N >>> 1) {
31198      i++;
31199    }
31200
31201    return 1 << i + 1 + odd;
31202  };
31203
31204  FFTM.prototype.conjugate = function conjugate(rws, iws, N) {
31205    if (N <= 1) return;
31206
31207    for (var i = 0; i < N / 2; i++) {
31208      var t = rws[i];
31209      rws[i] = rws[N - i - 1];
31210      rws[N - i - 1] = t;
31211      t = iws[i];
31212      iws[i] = -iws[N - i - 1];
31213      iws[N - i - 1] = -t;
31214    }
31215  };
31216
31217  FFTM.prototype.normalize13b = function normalize13b(ws, N) {
31218    var carry = 0;
31219
31220    for (var i = 0; i < N / 2; i++) {
31221      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + Math.round(ws[2 * i] / N) + carry;
31222      ws[i] = w & 0x3ffffff;
31223
31224      if (w < 0x4000000) {
31225        carry = 0;
31226      } else {
31227        carry = w / 0x4000000 | 0;
31228      }
31229    }
31230
31231    return ws;
31232  };
31233
31234  FFTM.prototype.convert13b = function convert13b(ws, len, rws, N) {
31235    var carry = 0;
31236
31237    for (var i = 0; i < len; i++) {
31238      carry = carry + (ws[i] | 0);
31239      rws[2 * i] = carry & 0x1fff;
31240      carry = carry >>> 13;
31241      rws[2 * i + 1] = carry & 0x1fff;
31242      carry = carry >>> 13;
31243    } // Pad with zeroes
31244
31245
31246    for (i = 2 * len; i < N; ++i) {
31247      rws[i] = 0;
31248    }
31249
31250    assert(carry === 0);
31251    assert((carry & ~0x1fff) === 0);
31252  };
31253
31254  FFTM.prototype.stub = function stub(N) {
31255    var ph = new Array(N);
31256
31257    for (var i = 0; i < N; i++) {
31258      ph[i] = 0;
31259    }
31260
31261    return ph;
31262  };
31263
31264  FFTM.prototype.mulp = function mulp(x, y, out) {
31265    var N = 2 * this.guessLen13b(x.length, y.length);
31266    var rbt = this.makeRBT(N);
31267
31268    var _ = this.stub(N);
31269
31270    var rws = new Array(N);
31271    var rwst = new Array(N);
31272    var iwst = new Array(N);
31273    var nrws = new Array(N);
31274    var nrwst = new Array(N);
31275    var niwst = new Array(N);
31276    var rmws = out.words;
31277    rmws.length = N;
31278    this.convert13b(x.words, x.length, rws, N);
31279    this.convert13b(y.words, y.length, nrws, N);
31280    this.transform(rws, _, rwst, iwst, N, rbt);
31281    this.transform(nrws, _, nrwst, niwst, N, rbt);
31282
31283    for (var i = 0; i < N; i++) {
31284      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
31285      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
31286      rwst[i] = rx;
31287    }
31288
31289    this.conjugate(rwst, iwst, N);
31290    this.transform(rwst, iwst, rmws, _, N, rbt);
31291    this.conjugate(rmws, _, N);
31292    this.normalize13b(rmws, N);
31293    out.negative = x.negative ^ y.negative;
31294    out.length = x.length + y.length;
31295    return out.strip();
31296  }; // Multiply `this` by `num`
31297
31298
31299  BN.prototype.mul = function mul(num) {
31300    var out = new BN(null);
31301    out.words = new Array(this.length + num.length);
31302    return this.mulTo(num, out);
31303  }; // Multiply employing FFT
31304
31305
31306  BN.prototype.mulf = function mulf(num) {
31307    var out = new BN(null);
31308    out.words = new Array(this.length + num.length);
31309    return jumboMulTo(this, num, out);
31310  }; // In-place Multiplication
31311
31312
31313  BN.prototype.imul = function imul(num) {
31314    return this.clone().mulTo(num, this);
31315  };
31316
31317  BN.prototype.imuln = function imuln(num) {
31318    assert(typeof num === 'number');
31319    assert(num < 0x4000000); // Carry
31320
31321    var carry = 0;
31322
31323    for (var i = 0; i < this.length; i++) {
31324      var w = (this.words[i] | 0) * num;
31325      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
31326      carry >>= 26;
31327      carry += w / 0x4000000 | 0; // NOTE: lo is 27bit maximum
31328
31329      carry += lo >>> 26;
31330      this.words[i] = lo & 0x3ffffff;
31331    }
31332
31333    if (carry !== 0) {
31334      this.words[i] = carry;
31335      this.length++;
31336    }
31337
31338    return this;
31339  };
31340
31341  BN.prototype.muln = function muln(num) {
31342    return this.clone().imuln(num);
31343  }; // `this` * `this`
31344
31345
31346  BN.prototype.sqr = function sqr() {
31347    return this.mul(this);
31348  }; // `this` * `this` in-place
31349
31350
31351  BN.prototype.isqr = function isqr() {
31352    return this.imul(this.clone());
31353  }; // Math.pow(`this`, `num`)
31354
31355
31356  BN.prototype.pow = function pow(num) {
31357    var w = toBitArray(num);
31358    if (w.length === 0) return new BN(1); // Skip leading zeroes
31359
31360    var res = this;
31361
31362    for (var i = 0; i < w.length; i++, res = res.sqr()) {
31363      if (w[i] !== 0) break;
31364    }
31365
31366    if (++i < w.length) {
31367      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
31368        if (w[i] === 0) continue;
31369        res = res.mul(q);
31370      }
31371    }
31372
31373    return res;
31374  }; // Shift-left in-place
31375
31376
31377  BN.prototype.iushln = function iushln(bits) {
31378    assert(typeof bits === 'number' && bits >= 0);
31379    var r = bits % 26;
31380    var s = (bits - r) / 26;
31381    var carryMask = 0x3ffffff >>> 26 - r << 26 - r;
31382    var i;
31383
31384    if (r !== 0) {
31385      var carry = 0;
31386
31387      for (i = 0; i < this.length; i++) {
31388        var newCarry = this.words[i] & carryMask;
31389        var c = (this.words[i] | 0) - newCarry << r;
31390        this.words[i] = c | carry;
31391        carry = newCarry >>> 26 - r;
31392      }
31393
31394      if (carry) {
31395        this.words[i] = carry;
31396        this.length++;
31397      }
31398    }
31399
31400    if (s !== 0) {
31401      for (i = this.length - 1; i >= 0; i--) {
31402        this.words[i + s] = this.words[i];
31403      }
31404
31405      for (i = 0; i < s; i++) {
31406        this.words[i] = 0;
31407      }
31408
31409      this.length += s;
31410    }
31411
31412    return this.strip();
31413  };
31414
31415  BN.prototype.ishln = function ishln(bits) {
31416    // TODO(indutny): implement me
31417    assert(this.negative === 0);
31418    return this.iushln(bits);
31419  }; // Shift-right in-place
31420  // NOTE: `hint` is a lowest bit before trailing zeroes
31421  // NOTE: if `extended` is present - it will be filled with destroyed bits
31422
31423
31424  BN.prototype.iushrn = function iushrn(bits, hint, extended) {
31425    assert(typeof bits === 'number' && bits >= 0);
31426    var h;
31427
31428    if (hint) {
31429      h = (hint - hint % 26) / 26;
31430    } else {
31431      h = 0;
31432    }
31433
31434    var r = bits % 26;
31435    var s = Math.min((bits - r) / 26, this.length);
31436    var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
31437    var maskedWords = extended;
31438    h -= s;
31439    h = Math.max(0, h); // Extended mode, copy masked part
31440
31441    if (maskedWords) {
31442      for (var i = 0; i < s; i++) {
31443        maskedWords.words[i] = this.words[i];
31444      }
31445
31446      maskedWords.length = s;
31447    }
31448
31449    if (s === 0) {// No-op, we should not move anything at all
31450    } else if (this.length > s) {
31451      this.length -= s;
31452
31453      for (i = 0; i < this.length; i++) {
31454        this.words[i] = this.words[i + s];
31455      }
31456    } else {
31457      this.words[0] = 0;
31458      this.length = 1;
31459    }
31460
31461    var carry = 0;
31462
31463    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
31464      var word = this.words[i] | 0;
31465      this.words[i] = carry << 26 - r | word >>> r;
31466      carry = word & mask;
31467    } // Push carried bits as a mask
31468
31469
31470    if (maskedWords && carry !== 0) {
31471      maskedWords.words[maskedWords.length++] = carry;
31472    }
31473
31474    if (this.length === 0) {
31475      this.words[0] = 0;
31476      this.length = 1;
31477    }
31478
31479    return this.strip();
31480  };
31481
31482  BN.prototype.ishrn = function ishrn(bits, hint, extended) {
31483    // TODO(indutny): implement me
31484    assert(this.negative === 0);
31485    return this.iushrn(bits, hint, extended);
31486  }; // Shift-left
31487
31488
31489  BN.prototype.shln = function shln(bits) {
31490    return this.clone().ishln(bits);
31491  };
31492
31493  BN.prototype.ushln = function ushln(bits) {
31494    return this.clone().iushln(bits);
31495  }; // Shift-right
31496
31497
31498  BN.prototype.shrn = function shrn(bits) {
31499    return this.clone().ishrn(bits);
31500  };
31501
31502  BN.prototype.ushrn = function ushrn(bits) {
31503    return this.clone().iushrn(bits);
31504  }; // Test if n bit is set
31505
31506
31507  BN.prototype.testn = function testn(bit) {
31508    assert(typeof bit === 'number' && bit >= 0);
31509    var r = bit % 26;
31510    var s = (bit - r) / 26;
31511    var q = 1 << r; // Fast case: bit is much higher than all existing words
31512
31513    if (this.length <= s) return false; // Check bit and return
31514
31515    var w = this.words[s];
31516    return !!(w & q);
31517  }; // Return only lowers bits of number (in-place)
31518
31519
31520  BN.prototype.imaskn = function imaskn(bits) {
31521    assert(typeof bits === 'number' && bits >= 0);
31522    var r = bits % 26;
31523    var s = (bits - r) / 26;
31524    assert(this.negative === 0, 'imaskn works only with positive numbers');
31525
31526    if (this.length <= s) {
31527      return this;
31528    }
31529
31530    if (r !== 0) {
31531      s++;
31532    }
31533
31534    this.length = Math.min(s, this.length);
31535
31536    if (r !== 0) {
31537      var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
31538      this.words[this.length - 1] &= mask;
31539    }
31540
31541    return this.strip();
31542  }; // Return only lowers bits of number
31543
31544
31545  BN.prototype.maskn = function maskn(bits) {
31546    return this.clone().imaskn(bits);
31547  }; // Add plain number `num` to `this`
31548
31549
31550  BN.prototype.iaddn = function iaddn(num) {
31551    assert(typeof num === 'number');
31552    assert(num < 0x4000000);
31553    if (num < 0) return this.isubn(-num); // Possible sign change
31554
31555    if (this.negative !== 0) {
31556      if (this.length === 1 && (this.words[0] | 0) < num) {
31557        this.words[0] = num - (this.words[0] | 0);
31558        this.negative = 0;
31559        return this;
31560      }
31561
31562      this.negative = 0;
31563      this.isubn(num);
31564      this.negative = 1;
31565      return this;
31566    } // Add without checks
31567
31568
31569    return this._iaddn(num);
31570  };
31571
31572  BN.prototype._iaddn = function _iaddn(num) {
31573    this.words[0] += num; // Carry
31574
31575    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
31576      this.words[i] -= 0x4000000;
31577
31578      if (i === this.length - 1) {
31579        this.words[i + 1] = 1;
31580      } else {
31581        this.words[i + 1]++;
31582      }
31583    }
31584
31585    this.length = Math.max(this.length, i + 1);
31586    return this;
31587  }; // Subtract plain number `num` from `this`
31588
31589
31590  BN.prototype.isubn = function isubn(num) {
31591    assert(typeof num === 'number');
31592    assert(num < 0x4000000);
31593    if (num < 0) return this.iaddn(-num);
31594
31595    if (this.negative !== 0) {
31596      this.negative = 0;
31597      this.iaddn(num);
31598      this.negative = 1;
31599      return this;
31600    }
31601
31602    this.words[0] -= num;
31603
31604    if (this.length === 1 && this.words[0] < 0) {
31605      this.words[0] = -this.words[0];
31606      this.negative = 1;
31607    } else {
31608      // Carry
31609      for (var i = 0; i < this.length && this.words[i] < 0; i++) {
31610        this.words[i] += 0x4000000;
31611        this.words[i + 1] -= 1;
31612      }
31613    }
31614
31615    return this.strip();
31616  };
31617
31618  BN.prototype.addn = function addn(num) {
31619    return this.clone().iaddn(num);
31620  };
31621
31622  BN.prototype.subn = function subn(num) {
31623    return this.clone().isubn(num);
31624  };
31625
31626  BN.prototype.iabs = function iabs() {
31627    this.negative = 0;
31628    return this;
31629  };
31630
31631  BN.prototype.abs = function abs() {
31632    return this.clone().iabs();
31633  };
31634
31635  BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
31636    var len = num.length + shift;
31637    var i;
31638
31639    this._expand(len);
31640
31641    var w;
31642    var carry = 0;
31643
31644    for (i = 0; i < num.length; i++) {
31645      w = (this.words[i + shift] | 0) + carry;
31646      var right = (num.words[i] | 0) * mul;
31647      w -= right & 0x3ffffff;
31648      carry = (w >> 26) - (right / 0x4000000 | 0);
31649      this.words[i + shift] = w & 0x3ffffff;
31650    }
31651
31652    for (; i < this.length - shift; i++) {
31653      w = (this.words[i + shift] | 0) + carry;
31654      carry = w >> 26;
31655      this.words[i + shift] = w & 0x3ffffff;
31656    }
31657
31658    if (carry === 0) return this.strip(); // Subtraction overflow
31659
31660    assert(carry === -1);
31661    carry = 0;
31662
31663    for (i = 0; i < this.length; i++) {
31664      w = -(this.words[i] | 0) + carry;
31665      carry = w >> 26;
31666      this.words[i] = w & 0x3ffffff;
31667    }
31668
31669    this.negative = 1;
31670    return this.strip();
31671  };
31672
31673  BN.prototype._wordDiv = function _wordDiv(num, mode) {
31674    var shift = this.length - num.length;
31675    var a = this.clone();
31676    var b = num; // Normalize
31677
31678    var bhi = b.words[b.length - 1] | 0;
31679
31680    var bhiBits = this._countBits(bhi);
31681
31682    shift = 26 - bhiBits;
31683
31684    if (shift !== 0) {
31685      b = b.ushln(shift);
31686      a.iushln(shift);
31687      bhi = b.words[b.length - 1] | 0;
31688    } // Initialize quotient
31689
31690
31691    var m = a.length - b.length;
31692    var q;
31693
31694    if (mode !== 'mod') {
31695      q = new BN(null);
31696      q.length = m + 1;
31697      q.words = new Array(q.length);
31698
31699      for (var i = 0; i < q.length; i++) {
31700        q.words[i] = 0;
31701      }
31702    }
31703
31704    var diff = a.clone()._ishlnsubmul(b, 1, m);
31705
31706    if (diff.negative === 0) {
31707      a = diff;
31708
31709      if (q) {
31710        q.words[m] = 1;
31711      }
31712    }
31713
31714    for (var j = m - 1; j >= 0; j--) {
31715      var qj = (a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j - 1] | 0); // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
31716      // (0x7ffffff)
31717
31718      qj = Math.min(qj / bhi | 0, 0x3ffffff);
31719
31720      a._ishlnsubmul(b, qj, j);
31721
31722      while (a.negative !== 0) {
31723        qj--;
31724        a.negative = 0;
31725
31726        a._ishlnsubmul(b, 1, j);
31727
31728        if (!a.isZero()) {
31729          a.negative ^= 1;
31730        }
31731      }
31732
31733      if (q) {
31734        q.words[j] = qj;
31735      }
31736    }
31737
31738    if (q) {
31739      q.strip();
31740    }
31741
31742    a.strip(); // Denormalize
31743
31744    if (mode !== 'div' && shift !== 0) {
31745      a.iushrn(shift);
31746    }
31747
31748    return {
31749      div: q || null,
31750      mod: a
31751    };
31752  }; // NOTE: 1) `mode` can be set to `mod` to request mod only,
31753  //       to `div` to request div only, or be absent to
31754  //       request both div & mod
31755  //       2) `positive` is true if unsigned mod is requested
31756
31757
31758  BN.prototype.divmod = function divmod(num, mode, positive) {
31759    assert(!num.isZero());
31760
31761    if (this.isZero()) {
31762      return {
31763        div: new BN(0),
31764        mod: new BN(0)
31765      };
31766    }
31767
31768    var div, mod, res;
31769
31770    if (this.negative !== 0 && num.negative === 0) {
31771      res = this.neg().divmod(num, mode);
31772
31773      if (mode !== 'mod') {
31774        div = res.div.neg();
31775      }
31776
31777      if (mode !== 'div') {
31778        mod = res.mod.neg();
31779
31780        if (positive && mod.negative !== 0) {
31781          mod.iadd(num);
31782        }
31783      }
31784
31785      return {
31786        div: div,
31787        mod: mod
31788      };
31789    }
31790
31791    if (this.negative === 0 && num.negative !== 0) {
31792      res = this.divmod(num.neg(), mode);
31793
31794      if (mode !== 'mod') {
31795        div = res.div.neg();
31796      }
31797
31798      return {
31799        div: div,
31800        mod: res.mod
31801      };
31802    }
31803
31804    if ((this.negative & num.negative) !== 0) {
31805      res = this.neg().divmod(num.neg(), mode);
31806
31807      if (mode !== 'div') {
31808        mod = res.mod.neg();
31809
31810        if (positive && mod.negative !== 0) {
31811          mod.isub(num);
31812        }
31813      }
31814
31815      return {
31816        div: res.div,
31817        mod: mod
31818      };
31819    } // Both numbers are positive at this point
31820    // Strip both numbers to approximate shift value
31821
31822
31823    if (num.length > this.length || this.cmp(num) < 0) {
31824      return {
31825        div: new BN(0),
31826        mod: this
31827      };
31828    } // Very short reduction
31829
31830
31831    if (num.length === 1) {
31832      if (mode === 'div') {
31833        return {
31834          div: this.divn(num.words[0]),
31835          mod: null
31836        };
31837      }
31838
31839      if (mode === 'mod') {
31840        return {
31841          div: null,
31842          mod: new BN(this.modn(num.words[0]))
31843        };
31844      }
31845
31846      return {
31847        div: this.divn(num.words[0]),
31848        mod: new BN(this.modn(num.words[0]))
31849      };
31850    }
31851
31852    return this._wordDiv(num, mode);
31853  }; // Find `this` / `num`
31854
31855
31856  BN.prototype.div = function div(num) {
31857    return this.divmod(num, 'div', false).div;
31858  }; // Find `this` % `num`
31859
31860
31861  BN.prototype.mod = function mod(num) {
31862    return this.divmod(num, 'mod', false).mod;
31863  };
31864
31865  BN.prototype.umod = function umod(num) {
31866    return this.divmod(num, 'mod', true).mod;
31867  }; // Find Round(`this` / `num`)
31868
31869
31870  BN.prototype.divRound = function divRound(num) {
31871    var dm = this.divmod(num); // Fast case - exact division
31872
31873    if (dm.mod.isZero()) return dm.div;
31874    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
31875    var half = num.ushrn(1);
31876    var r2 = num.andln(1);
31877    var cmp = mod.cmp(half); // Round down
31878
31879    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; // Round up
31880
31881    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
31882  };
31883
31884  BN.prototype.modn = function modn(num) {
31885    assert(num <= 0x3ffffff);
31886    var p = (1 << 26) % num;
31887    var acc = 0;
31888
31889    for (var i = this.length - 1; i >= 0; i--) {
31890      acc = (p * acc + (this.words[i] | 0)) % num;
31891    }
31892
31893    return acc;
31894  }; // In-place division by number
31895
31896
31897  BN.prototype.idivn = function idivn(num) {
31898    assert(num <= 0x3ffffff);
31899    var carry = 0;
31900
31901    for (var i = this.length - 1; i >= 0; i--) {
31902      var w = (this.words[i] | 0) + carry * 0x4000000;
31903      this.words[i] = w / num | 0;
31904      carry = w % num;
31905    }
31906
31907    return this.strip();
31908  };
31909
31910  BN.prototype.divn = function divn(num) {
31911    return this.clone().idivn(num);
31912  };
31913
31914  BN.prototype.egcd = function egcd(p) {
31915    assert(p.negative === 0);
31916    assert(!p.isZero());
31917    var x = this;
31918    var y = p.clone();
31919
31920    if (x.negative !== 0) {
31921      x = x.umod(p);
31922    } else {
31923      x = x.clone();
31924    } // A * x + B * y = x
31925
31926
31927    var A = new BN(1);
31928    var B = new BN(0); // C * x + D * y = y
31929
31930    var C = new BN(0);
31931    var D = new BN(1);
31932    var g = 0;
31933
31934    while (x.isEven() && y.isEven()) {
31935      x.iushrn(1);
31936      y.iushrn(1);
31937      ++g;
31938    }
31939
31940    var yp = y.clone();
31941    var xp = x.clone();
31942
31943    while (!x.isZero()) {
31944      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1) {
31945        ;
31946      }
31947
31948      if (i > 0) {
31949        x.iushrn(i);
31950
31951        while (i-- > 0) {
31952          if (A.isOdd() || B.isOdd()) {
31953            A.iadd(yp);
31954            B.isub(xp);
31955          }
31956
31957          A.iushrn(1);
31958          B.iushrn(1);
31959        }
31960      }
31961
31962      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1) {
31963        ;
31964      }
31965
31966      if (j > 0) {
31967        y.iushrn(j);
31968
31969        while (j-- > 0) {
31970          if (C.isOdd() || D.isOdd()) {
31971            C.iadd(yp);
31972            D.isub(xp);
31973          }
31974
31975          C.iushrn(1);
31976          D.iushrn(1);
31977        }
31978      }
31979
31980      if (x.cmp(y) >= 0) {
31981        x.isub(y);
31982        A.isub(C);
31983        B.isub(D);
31984      } else {
31985        y.isub(x);
31986        C.isub(A);
31987        D.isub(B);
31988      }
31989    }
31990
31991    return {
31992      a: C,
31993      b: D,
31994      gcd: y.iushln(g)
31995    };
31996  }; // This is reduced incarnation of the binary EEA
31997  // above, designated to invert members of the
31998  // _prime_ fields F(p) at a maximal speed
31999
32000
32001  BN.prototype._invmp = function _invmp(p) {
32002    assert(p.negative === 0);
32003    assert(!p.isZero());
32004    var a = this;
32005    var b = p.clone();
32006
32007    if (a.negative !== 0) {
32008      a = a.umod(p);
32009    } else {
32010      a = a.clone();
32011    }
32012
32013    var x1 = new BN(1);
32014    var x2 = new BN(0);
32015    var delta = b.clone();
32016
32017    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
32018      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) {
32019        ;
32020      }
32021
32022      if (i > 0) {
32023        a.iushrn(i);
32024
32025        while (i-- > 0) {
32026          if (x1.isOdd()) {
32027            x1.iadd(delta);
32028          }
32029
32030          x1.iushrn(1);
32031        }
32032      }
32033
32034      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1) {
32035        ;
32036      }
32037
32038      if (j > 0) {
32039        b.iushrn(j);
32040
32041        while (j-- > 0) {
32042          if (x2.isOdd()) {
32043            x2.iadd(delta);
32044          }
32045
32046          x2.iushrn(1);
32047        }
32048      }
32049
32050      if (a.cmp(b) >= 0) {
32051        a.isub(b);
32052        x1.isub(x2);
32053      } else {
32054        b.isub(a);
32055        x2.isub(x1);
32056      }
32057    }
32058
32059    var res;
32060
32061    if (a.cmpn(1) === 0) {
32062      res = x1;
32063    } else {
32064      res = x2;
32065    }
32066
32067    if (res.cmpn(0) < 0) {
32068      res.iadd(p);
32069    }
32070
32071    return res;
32072  };
32073
32074  BN.prototype.gcd = function gcd(num) {
32075    if (this.isZero()) return num.abs();
32076    if (num.isZero()) return this.abs();
32077    var a = this.clone();
32078    var b = num.clone();
32079    a.negative = 0;
32080    b.negative = 0; // Remove common factor of two
32081
32082    for (var shift = 0; a.isEven() && b.isEven(); shift++) {
32083      a.iushrn(1);
32084      b.iushrn(1);
32085    }
32086
32087    do {
32088      while (a.isEven()) {
32089        a.iushrn(1);
32090      }
32091
32092      while (b.isEven()) {
32093        b.iushrn(1);
32094      }
32095
32096      var r = a.cmp(b);
32097
32098      if (r < 0) {
32099        // Swap `a` and `b` to make `a` always bigger than `b`
32100        var t = a;
32101        a = b;
32102        b = t;
32103      } else if (r === 0 || b.cmpn(1) === 0) {
32104        break;
32105      }
32106
32107      a.isub(b);
32108    } while (true);
32109
32110    return b.iushln(shift);
32111  }; // Invert number in the field F(num)
32112
32113
32114  BN.prototype.invm = function invm(num) {
32115    return this.egcd(num).a.umod(num);
32116  };
32117
32118  BN.prototype.isEven = function isEven() {
32119    return (this.words[0] & 1) === 0;
32120  };
32121
32122  BN.prototype.isOdd = function isOdd() {
32123    return (this.words[0] & 1) === 1;
32124  }; // And first word and num
32125
32126
32127  BN.prototype.andln = function andln(num) {
32128    return this.words[0] & num;
32129  }; // Increment at the bit position in-line
32130
32131
32132  BN.prototype.bincn = function bincn(bit) {
32133    assert(typeof bit === 'number');
32134    var r = bit % 26;
32135    var s = (bit - r) / 26;
32136    var q = 1 << r; // Fast case: bit is much higher than all existing words
32137
32138    if (this.length <= s) {
32139      this._expand(s + 1);
32140
32141      this.words[s] |= q;
32142      return this;
32143    } // Add bit and propagate, if needed
32144
32145
32146    var carry = q;
32147
32148    for (var i = s; carry !== 0 && i < this.length; i++) {
32149      var w = this.words[i] | 0;
32150      w += carry;
32151      carry = w >>> 26;
32152      w &= 0x3ffffff;
32153      this.words[i] = w;
32154    }
32155
32156    if (carry !== 0) {
32157      this.words[i] = carry;
32158      this.length++;
32159    }
32160
32161    return this;
32162  };
32163
32164  BN.prototype.isZero = function isZero() {
32165    return this.length === 1 && this.words[0] === 0;
32166  };
32167
32168  BN.prototype.cmpn = function cmpn(num) {
32169    var negative = num < 0;
32170    if (this.negative !== 0 && !negative) return -1;
32171    if (this.negative === 0 && negative) return 1;
32172    this.strip();
32173    var res;
32174
32175    if (this.length > 1) {
32176      res = 1;
32177    } else {
32178      if (negative) {
32179        num = -num;
32180      }
32181
32182      assert(num <= 0x3ffffff, 'Number is too big');
32183      var w = this.words[0] | 0;
32184      res = w === num ? 0 : w < num ? -1 : 1;
32185    }
32186
32187    if (this.negative !== 0) return -res | 0;
32188    return res;
32189  }; // Compare two numbers and return:
32190  // 1 - if `this` > `num`
32191  // 0 - if `this` == `num`
32192  // -1 - if `this` < `num`
32193
32194
32195  BN.prototype.cmp = function cmp(num) {
32196    if (this.negative !== 0 && num.negative === 0) return -1;
32197    if (this.negative === 0 && num.negative !== 0) return 1;
32198    var res = this.ucmp(num);
32199    if (this.negative !== 0) return -res | 0;
32200    return res;
32201  }; // Unsigned comparison
32202
32203
32204  BN.prototype.ucmp = function ucmp(num) {
32205    // At this point both numbers have the same sign
32206    if (this.length > num.length) return 1;
32207    if (this.length < num.length) return -1;
32208    var res = 0;
32209
32210    for (var i = this.length - 1; i >= 0; i--) {
32211      var a = this.words[i] | 0;
32212      var b = num.words[i] | 0;
32213      if (a === b) continue;
32214
32215      if (a < b) {
32216        res = -1;
32217      } else if (a > b) {
32218        res = 1;
32219      }
32220
32221      break;
32222    }
32223
32224    return res;
32225  };
32226
32227  BN.prototype.gtn = function gtn(num) {
32228    return this.cmpn(num) === 1;
32229  };
32230
32231  BN.prototype.gt = function gt(num) {
32232    return this.cmp(num) === 1;
32233  };
32234
32235  BN.prototype.gten = function gten(num) {
32236    return this.cmpn(num) >= 0;
32237  };
32238
32239  BN.prototype.gte = function gte(num) {
32240    return this.cmp(num) >= 0;
32241  };
32242
32243  BN.prototype.ltn = function ltn(num) {
32244    return this.cmpn(num) === -1;
32245  };
32246
32247  BN.prototype.lt = function lt(num) {
32248    return this.cmp(num) === -1;
32249  };
32250
32251  BN.prototype.lten = function lten(num) {
32252    return this.cmpn(num) <= 0;
32253  };
32254
32255  BN.prototype.lte = function lte(num) {
32256    return this.cmp(num) <= 0;
32257  };
32258
32259  BN.prototype.eqn = function eqn(num) {
32260    return this.cmpn(num) === 0;
32261  };
32262
32263  BN.prototype.eq = function eq(num) {
32264    return this.cmp(num) === 0;
32265  }; //
32266  // A reduce context, could be using montgomery or something better, depending
32267  // on the `m` itself.
32268  //
32269
32270
32271  BN.red = function red(num) {
32272    return new Red(num);
32273  };
32274
32275  BN.prototype.toRed = function toRed(ctx) {
32276    assert(!this.red, 'Already a number in reduction context');
32277    assert(this.negative === 0, 'red works only with positives');
32278    return ctx.convertTo(this)._forceRed(ctx);
32279  };
32280
32281  BN.prototype.fromRed = function fromRed() {
32282    assert(this.red, 'fromRed works only with numbers in reduction context');
32283    return this.red.convertFrom(this);
32284  };
32285
32286  BN.prototype._forceRed = function _forceRed(ctx) {
32287    this.red = ctx;
32288    return this;
32289  };
32290
32291  BN.prototype.forceRed = function forceRed(ctx) {
32292    assert(!this.red, 'Already a number in reduction context');
32293    return this._forceRed(ctx);
32294  };
32295
32296  BN.prototype.redAdd = function redAdd(num) {
32297    assert(this.red, 'redAdd works only with red numbers');
32298    return this.red.add(this, num);
32299  };
32300
32301  BN.prototype.redIAdd = function redIAdd(num) {
32302    assert(this.red, 'redIAdd works only with red numbers');
32303    return this.red.iadd(this, num);
32304  };
32305
32306  BN.prototype.redSub = function redSub(num) {
32307    assert(this.red, 'redSub works only with red numbers');
32308    return this.red.sub(this, num);
32309  };
32310
32311  BN.prototype.redISub = function redISub(num) {
32312    assert(this.red, 'redISub works only with red numbers');
32313    return this.red.isub(this, num);
32314  };
32315
32316  BN.prototype.redShl = function redShl(num) {
32317    assert(this.red, 'redShl works only with red numbers');
32318    return this.red.shl(this, num);
32319  };
32320
32321  BN.prototype.redMul = function redMul(num) {
32322    assert(this.red, 'redMul works only with red numbers');
32323
32324    this.red._verify2(this, num);
32325
32326    return this.red.mul(this, num);
32327  };
32328
32329  BN.prototype.redIMul = function redIMul(num) {
32330    assert(this.red, 'redMul works only with red numbers');
32331
32332    this.red._verify2(this, num);
32333
32334    return this.red.imul(this, num);
32335  };
32336
32337  BN.prototype.redSqr = function redSqr() {
32338    assert(this.red, 'redSqr works only with red numbers');
32339
32340    this.red._verify1(this);
32341
32342    return this.red.sqr(this);
32343  };
32344
32345  BN.prototype.redISqr = function redISqr() {
32346    assert(this.red, 'redISqr works only with red numbers');
32347
32348    this.red._verify1(this);
32349
32350    return this.red.isqr(this);
32351  }; // Square root over p
32352
32353
32354  BN.prototype.redSqrt = function redSqrt() {
32355    assert(this.red, 'redSqrt works only with red numbers');
32356
32357    this.red._verify1(this);
32358
32359    return this.red.sqrt(this);
32360  };
32361
32362  BN.prototype.redInvm = function redInvm() {
32363    assert(this.red, 'redInvm works only with red numbers');
32364
32365    this.red._verify1(this);
32366
32367    return this.red.invm(this);
32368  }; // Return negative clone of `this` % `red modulo`
32369
32370
32371  BN.prototype.redNeg = function redNeg() {
32372    assert(this.red, 'redNeg works only with red numbers');
32373
32374    this.red._verify1(this);
32375
32376    return this.red.neg(this);
32377  };
32378
32379  BN.prototype.redPow = function redPow(num) {
32380    assert(this.red && !num.red, 'redPow(normalNum)');
32381
32382    this.red._verify1(this);
32383
32384    return this.red.pow(this, num);
32385  }; // Prime numbers with efficient reduction
32386
32387
32388  var primes = {
32389    k256: null,
32390    p224: null,
32391    p192: null,
32392    p25519: null
32393  }; // Pseudo-Mersenne prime
32394
32395  function MPrime(name, p) {
32396    // P = 2 ^ N - K
32397    this.name = name;
32398    this.p = new BN(p, 16);
32399    this.n = this.p.bitLength();
32400    this.k = new BN(1).iushln(this.n).isub(this.p);
32401    this.tmp = this._tmp();
32402  }
32403
32404  MPrime.prototype._tmp = function _tmp() {
32405    var tmp = new BN(null);
32406    tmp.words = new Array(Math.ceil(this.n / 13));
32407    return tmp;
32408  };
32409
32410  MPrime.prototype.ireduce = function ireduce(num) {
32411    // Assumes that `num` is less than `P^2`
32412    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
32413    var r = num;
32414    var rlen;
32415
32416    do {
32417      this.split(r, this.tmp);
32418      r = this.imulK(r);
32419      r = r.iadd(this.tmp);
32420      rlen = r.bitLength();
32421    } while (rlen > this.n);
32422
32423    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
32424
32425    if (cmp === 0) {
32426      r.words[0] = 0;
32427      r.length = 1;
32428    } else if (cmp > 0) {
32429      r.isub(this.p);
32430    } else {
32431      if (r.strip !== undefined) {
32432        // r is BN v4 instance
32433        r.strip();
32434      } else {
32435        // r is BN v5 instance
32436        r._strip();
32437      }
32438    }
32439
32440    return r;
32441  };
32442
32443  MPrime.prototype.split = function split(input, out) {
32444    input.iushrn(this.n, 0, out);
32445  };
32446
32447  MPrime.prototype.imulK = function imulK(num) {
32448    return num.imul(this.k);
32449  };
32450
32451  function K256() {
32452    MPrime.call(this, 'k256', 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
32453  }
32454
32455  inherits(K256, MPrime);
32456
32457  K256.prototype.split = function split(input, output) {
32458    // 256 = 9 * 26 + 22
32459    var mask = 0x3fffff;
32460    var outLen = Math.min(input.length, 9);
32461
32462    for (var i = 0; i < outLen; i++) {
32463      output.words[i] = input.words[i];
32464    }
32465
32466    output.length = outLen;
32467
32468    if (input.length <= 9) {
32469      input.words[0] = 0;
32470      input.length = 1;
32471      return;
32472    } // Shift by 9 limbs
32473
32474
32475    var prev = input.words[9];
32476    output.words[output.length++] = prev & mask;
32477
32478    for (i = 10; i < input.length; i++) {
32479      var next = input.words[i] | 0;
32480      input.words[i - 10] = (next & mask) << 4 | prev >>> 22;
32481      prev = next;
32482    }
32483
32484    prev >>>= 22;
32485    input.words[i - 10] = prev;
32486
32487    if (prev === 0 && input.length > 10) {
32488      input.length -= 10;
32489    } else {
32490      input.length -= 9;
32491    }
32492  };
32493
32494  K256.prototype.imulK = function imulK(num) {
32495    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
32496    num.words[num.length] = 0;
32497    num.words[num.length + 1] = 0;
32498    num.length += 2; // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
32499
32500    var lo = 0;
32501
32502    for (var i = 0; i < num.length; i++) {
32503      var w = num.words[i] | 0;
32504      lo += w * 0x3d1;
32505      num.words[i] = lo & 0x3ffffff;
32506      lo = w * 0x40 + (lo / 0x4000000 | 0);
32507    } // Fast length reduction
32508
32509
32510    if (num.words[num.length - 1] === 0) {
32511      num.length--;
32512
32513      if (num.words[num.length - 1] === 0) {
32514        num.length--;
32515      }
32516    }
32517
32518    return num;
32519  };
32520
32521  function P224() {
32522    MPrime.call(this, 'p224', 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
32523  }
32524
32525  inherits(P224, MPrime);
32526
32527  function P192() {
32528    MPrime.call(this, 'p192', 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
32529  }
32530
32531  inherits(P192, MPrime);
32532
32533  function P25519() {
32534    // 2 ^ 255 - 19
32535    MPrime.call(this, '25519', '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
32536  }
32537
32538  inherits(P25519, MPrime);
32539
32540  P25519.prototype.imulK = function imulK(num) {
32541    // K = 0x13
32542    var carry = 0;
32543
32544    for (var i = 0; i < num.length; i++) {
32545      var hi = (num.words[i] | 0) * 0x13 + carry;
32546      var lo = hi & 0x3ffffff;
32547      hi >>>= 26;
32548      num.words[i] = lo;
32549      carry = hi;
32550    }
32551
32552    if (carry !== 0) {
32553      num.words[num.length++] = carry;
32554    }
32555
32556    return num;
32557  }; // Exported mostly for testing purposes, use plain name instead
32558
32559
32560  BN._prime = function prime(name) {
32561    // Cached version of prime
32562    if (primes[name]) return primes[name];
32563    var prime;
32564
32565    if (name === 'k256') {
32566      prime = new K256();
32567    } else if (name === 'p224') {
32568      prime = new P224();
32569    } else if (name === 'p192') {
32570      prime = new P192();
32571    } else if (name === 'p25519') {
32572      prime = new P25519();
32573    } else {
32574      throw new Error('Unknown prime ' + name);
32575    }
32576
32577    primes[name] = prime;
32578    return prime;
32579  }; //
32580  // Base reduction engine
32581  //
32582
32583
32584  function Red(m) {
32585    if (typeof m === 'string') {
32586      var prime = BN._prime(m);
32587
32588      this.m = prime.p;
32589      this.prime = prime;
32590    } else {
32591      assert(m.gtn(1), 'modulus must be greater than 1');
32592      this.m = m;
32593      this.prime = null;
32594    }
32595  }
32596
32597  Red.prototype._verify1 = function _verify1(a) {
32598    assert(a.negative === 0, 'red works only with positives');
32599    assert(a.red, 'red works only with red numbers');
32600  };
32601
32602  Red.prototype._verify2 = function _verify2(a, b) {
32603    assert((a.negative | b.negative) === 0, 'red works only with positives');
32604    assert(a.red && a.red === b.red, 'red works only with red numbers');
32605  };
32606
32607  Red.prototype.imod = function imod(a) {
32608    if (this.prime) return this.prime.ireduce(a)._forceRed(this);
32609    return a.umod(this.m)._forceRed(this);
32610  };
32611
32612  Red.prototype.neg = function neg(a) {
32613    if (a.isZero()) {
32614      return a.clone();
32615    }
32616
32617    return this.m.sub(a)._forceRed(this);
32618  };
32619
32620  Red.prototype.add = function add(a, b) {
32621    this._verify2(a, b);
32622
32623    var res = a.add(b);
32624
32625    if (res.cmp(this.m) >= 0) {
32626      res.isub(this.m);
32627    }
32628
32629    return res._forceRed(this);
32630  };
32631
32632  Red.prototype.iadd = function iadd(a, b) {
32633    this._verify2(a, b);
32634
32635    var res = a.iadd(b);
32636
32637    if (res.cmp(this.m) >= 0) {
32638      res.isub(this.m);
32639    }
32640
32641    return res;
32642  };
32643
32644  Red.prototype.sub = function sub(a, b) {
32645    this._verify2(a, b);
32646
32647    var res = a.sub(b);
32648
32649    if (res.cmpn(0) < 0) {
32650      res.iadd(this.m);
32651    }
32652
32653    return res._forceRed(this);
32654  };
32655
32656  Red.prototype.isub = function isub(a, b) {
32657    this._verify2(a, b);
32658
32659    var res = a.isub(b);
32660
32661    if (res.cmpn(0) < 0) {
32662      res.iadd(this.m);
32663    }
32664
32665    return res;
32666  };
32667
32668  Red.prototype.shl = function shl(a, num) {
32669    this._verify1(a);
32670
32671    return this.imod(a.ushln(num));
32672  };
32673
32674  Red.prototype.imul = function imul(a, b) {
32675    this._verify2(a, b);
32676
32677    return this.imod(a.imul(b));
32678  };
32679
32680  Red.prototype.mul = function mul(a, b) {
32681    this._verify2(a, b);
32682
32683    return this.imod(a.mul(b));
32684  };
32685
32686  Red.prototype.isqr = function isqr(a) {
32687    return this.imul(a, a.clone());
32688  };
32689
32690  Red.prototype.sqr = function sqr(a) {
32691    return this.mul(a, a);
32692  };
32693
32694  Red.prototype.sqrt = function sqrt(a) {
32695    if (a.isZero()) return a.clone();
32696    var mod3 = this.m.andln(3);
32697    assert(mod3 % 2 === 1); // Fast case
32698
32699    if (mod3 === 3) {
32700      var pow = this.m.add(new BN(1)).iushrn(2);
32701      return this.pow(a, pow);
32702    } // Tonelli-Shanks algorithm (Totally unoptimized and slow)
32703    //
32704    // Find Q and S, that Q * 2 ^ S = (P - 1)
32705
32706
32707    var q = this.m.subn(1);
32708    var s = 0;
32709
32710    while (!q.isZero() && q.andln(1) === 0) {
32711      s++;
32712      q.iushrn(1);
32713    }
32714
32715    assert(!q.isZero());
32716    var one = new BN(1).toRed(this);
32717    var nOne = one.redNeg(); // Find quadratic non-residue
32718    // NOTE: Max is such because of generalized Riemann hypothesis.
32719
32720    var lpow = this.m.subn(1).iushrn(1);
32721    var z = this.m.bitLength();
32722    z = new BN(2 * z * z).toRed(this);
32723
32724    while (this.pow(z, lpow).cmp(nOne) !== 0) {
32725      z.redIAdd(nOne);
32726    }
32727
32728    var c = this.pow(z, q);
32729    var r = this.pow(a, q.addn(1).iushrn(1));
32730    var t = this.pow(a, q);
32731    var m = s;
32732
32733    while (t.cmp(one) !== 0) {
32734      var tmp = t;
32735
32736      for (var i = 0; tmp.cmp(one) !== 0; i++) {
32737        tmp = tmp.redSqr();
32738      }
32739
32740      assert(i < m);
32741      var b = this.pow(c, new BN(1).iushln(m - i - 1));
32742      r = r.redMul(b);
32743      c = b.redSqr();
32744      t = t.redMul(c);
32745      m = i;
32746    }
32747
32748    return r;
32749  };
32750
32751  Red.prototype.invm = function invm(a) {
32752    var inv = a._invmp(this.m);
32753
32754    if (inv.negative !== 0) {
32755      inv.negative = 0;
32756      return this.imod(inv).redNeg();
32757    } else {
32758      return this.imod(inv);
32759    }
32760  };
32761
32762  Red.prototype.pow = function pow(a, num) {
32763    if (num.isZero()) return new BN(1).toRed(this);
32764    if (num.cmpn(1) === 0) return a.clone();
32765    var windowSize = 4;
32766    var wnd = new Array(1 << windowSize);
32767    wnd[0] = new BN(1).toRed(this);
32768    wnd[1] = a;
32769
32770    for (var i = 2; i < wnd.length; i++) {
32771      wnd[i] = this.mul(wnd[i - 1], a);
32772    }
32773
32774    var res = wnd[0];
32775    var current = 0;
32776    var currentLen = 0;
32777    var start = num.bitLength() % 26;
32778
32779    if (start === 0) {
32780      start = 26;
32781    }
32782
32783    for (i = num.length - 1; i >= 0; i--) {
32784      var word = num.words[i];
32785
32786      for (var j = start - 1; j >= 0; j--) {
32787        var bit = word >> j & 1;
32788
32789        if (res !== wnd[0]) {
32790          res = this.sqr(res);
32791        }
32792
32793        if (bit === 0 && current === 0) {
32794          currentLen = 0;
32795          continue;
32796        }
32797
32798        current <<= 1;
32799        current |= bit;
32800        currentLen++;
32801        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
32802        res = this.mul(res, wnd[current]);
32803        currentLen = 0;
32804        current = 0;
32805      }
32806
32807      start = 26;
32808    }
32809
32810    return res;
32811  };
32812
32813  Red.prototype.convertTo = function convertTo(num) {
32814    var r = num.umod(this.m);
32815    return r === num ? r.clone() : r;
32816  };
32817
32818  Red.prototype.convertFrom = function convertFrom(num) {
32819    var res = num.clone();
32820    res.red = null;
32821    return res;
32822  }; //
32823  // Montgomery method engine
32824  //
32825
32826
32827  BN.mont = function mont(num) {
32828    return new Mont(num);
32829  };
32830
32831  function Mont(m) {
32832    Red.call(this, m);
32833    this.shift = this.m.bitLength();
32834
32835    if (this.shift % 26 !== 0) {
32836      this.shift += 26 - this.shift % 26;
32837    }
32838
32839    this.r = new BN(1).iushln(this.shift);
32840    this.r2 = this.imod(this.r.sqr());
32841    this.rinv = this.r._invmp(this.m);
32842    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
32843    this.minv = this.minv.umod(this.r);
32844    this.minv = this.r.sub(this.minv);
32845  }
32846
32847  inherits(Mont, Red);
32848
32849  Mont.prototype.convertTo = function convertTo(num) {
32850    return this.imod(num.ushln(this.shift));
32851  };
32852
32853  Mont.prototype.convertFrom = function convertFrom(num) {
32854    var r = this.imod(num.mul(this.rinv));
32855    r.red = null;
32856    return r;
32857  };
32858
32859  Mont.prototype.imul = function imul(a, b) {
32860    if (a.isZero() || b.isZero()) {
32861      a.words[0] = 0;
32862      a.length = 1;
32863      return a;
32864    }
32865
32866    var t = a.imul(b);
32867    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
32868    var u = t.isub(c).iushrn(this.shift);
32869    var res = u;
32870
32871    if (u.cmp(this.m) >= 0) {
32872      res = u.isub(this.m);
32873    } else if (u.cmpn(0) < 0) {
32874      res = u.iadd(this.m);
32875    }
32876
32877    return res._forceRed(this);
32878  };
32879
32880  Mont.prototype.mul = function mul(a, b) {
32881    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
32882    var t = a.mul(b);
32883    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
32884    var u = t.isub(c).iushrn(this.shift);
32885    var res = u;
32886
32887    if (u.cmp(this.m) >= 0) {
32888      res = u.isub(this.m);
32889    } else if (u.cmpn(0) < 0) {
32890      res = u.iadd(this.m);
32891    }
32892
32893    return res._forceRed(this);
32894  };
32895
32896  Mont.prototype.invm = function invm(a) {
32897    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
32898    var res = this.imod(a._invmp(this.m).mul(this.r2));
32899    return res._forceRed(this);
32900  };
32901})(typeof module === 'undefined' || module, void 0);
32902
32903},{"buffer":185}],182:[function(require,module,exports){
32904'use strict';
32905
32906exports.byteLength = byteLength;
32907exports.toByteArray = toByteArray;
32908exports.fromByteArray = fromByteArray;
32909var lookup = [];
32910var revLookup = [];
32911var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
32912var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
32913
32914for (var i = 0, len = code.length; i < len; ++i) {
32915  lookup[i] = code[i];
32916  revLookup[code.charCodeAt(i)] = i;
32917} // Support decoding URL-safe base64 strings, as Node.js does.
32918// See: https://en.wikipedia.org/wiki/Base64#URL_applications
32919
32920
32921revLookup['-'.charCodeAt(0)] = 62;
32922revLookup['_'.charCodeAt(0)] = 63;
32923
32924function getLens(b64) {
32925  var len = b64.length;
32926
32927  if (len % 4 > 0) {
32928    throw new Error('Invalid string. Length must be a multiple of 4');
32929  } // Trim off extra bytes after placeholder bytes are found
32930  // See: https://github.com/beatgammit/base64-js/issues/42
32931
32932
32933  var validLen = b64.indexOf('=');
32934  if (validLen === -1) validLen = len;
32935  var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
32936  return [validLen, placeHoldersLen];
32937} // base64 is 4/3 + up to two characters of the original data
32938
32939
32940function byteLength(b64) {
32941  var lens = getLens(b64);
32942  var validLen = lens[0];
32943  var placeHoldersLen = lens[1];
32944  return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
32945}
32946
32947function _byteLength(b64, validLen, placeHoldersLen) {
32948  return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
32949}
32950
32951function toByteArray(b64) {
32952  var tmp;
32953  var lens = getLens(b64);
32954  var validLen = lens[0];
32955  var placeHoldersLen = lens[1];
32956  var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
32957  var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars
32958
32959  var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
32960  var i;
32961
32962  for (i = 0; i < len; i += 4) {
32963    tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
32964    arr[curByte++] = tmp >> 16 & 0xFF;
32965    arr[curByte++] = tmp >> 8 & 0xFF;
32966    arr[curByte++] = tmp & 0xFF;
32967  }
32968
32969  if (placeHoldersLen === 2) {
32970    tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
32971    arr[curByte++] = tmp & 0xFF;
32972  }
32973
32974  if (placeHoldersLen === 1) {
32975    tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
32976    arr[curByte++] = tmp >> 8 & 0xFF;
32977    arr[curByte++] = tmp & 0xFF;
32978  }
32979
32980  return arr;
32981}
32982
32983function tripletToBase64(num) {
32984  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
32985}
32986
32987function encodeChunk(uint8, start, end) {
32988  var tmp;
32989  var output = [];
32990
32991  for (var i = start; i < end; i += 3) {
32992    tmp = (uint8[i] << 16 & 0xFF0000) + (uint8[i + 1] << 8 & 0xFF00) + (uint8[i + 2] & 0xFF);
32993    output.push(tripletToBase64(tmp));
32994  }
32995
32996  return output.join('');
32997}
32998
32999function fromByteArray(uint8) {
33000  var tmp;
33001  var len = uint8.length;
33002  var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
33003
33004  var parts = [];
33005  var maxChunkLength = 16383; // must be multiple of 3
33006  // go through the array every three bytes, we'll deal with trailing stuff later
33007
33008  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
33009    parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
33010  } // pad the end with zeros, but make sure to not forget the extra bytes
33011
33012
33013  if (extraBytes === 1) {
33014    tmp = uint8[len - 1];
33015    parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 0x3F] + '==');
33016  } else if (extraBytes === 2) {
33017    tmp = (uint8[len - 2] << 8) + uint8[len - 1];
33018    parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 0x3F] + lookup[tmp << 2 & 0x3F] + '=');
33019  }
33020
33021  return parts.join('');
33022}
33023
33024},{}],183:[function(require,module,exports){
33025"use strict";
33026
33027function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
33028
33029(function (module, exports) {
33030  'use strict'; // Utils
33031
33032  function assert(val, msg) {
33033    if (!val) throw new Error(msg || 'Assertion failed');
33034  } // Could use `inherits` module, but don't want to move from single file
33035  // architecture yet.
33036
33037
33038  function inherits(ctor, superCtor) {
33039    ctor.super_ = superCtor;
33040
33041    var TempCtor = function TempCtor() {};
33042
33043    TempCtor.prototype = superCtor.prototype;
33044    ctor.prototype = new TempCtor();
33045    ctor.prototype.constructor = ctor;
33046  } // BN
33047
33048
33049  function BN(number, base, endian) {
33050    if (BN.isBN(number)) {
33051      return number;
33052    }
33053
33054    this.negative = 0;
33055    this.words = null;
33056    this.length = 0; // Reduction context
33057
33058    this.red = null;
33059
33060    if (number !== null) {
33061      if (base === 'le' || base === 'be') {
33062        endian = base;
33063        base = 10;
33064      }
33065
33066      this._init(number || 0, base || 10, endian || 'be');
33067    }
33068  }
33069
33070  if (_typeof(module) === 'object') {
33071    module.exports = BN;
33072  } else {
33073    exports.BN = BN;
33074  }
33075
33076  BN.BN = BN;
33077  BN.wordSize = 26;
33078  var Buffer;
33079
33080  try {
33081    Buffer = require('buffer').Buffer;
33082  } catch (e) {}
33083
33084  BN.isBN = function isBN(num) {
33085    if (num instanceof BN) {
33086      return true;
33087    }
33088
33089    return num !== null && _typeof(num) === 'object' && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
33090  };
33091
33092  BN.max = function max(left, right) {
33093    if (left.cmp(right) > 0) return left;
33094    return right;
33095  };
33096
33097  BN.min = function min(left, right) {
33098    if (left.cmp(right) < 0) return left;
33099    return right;
33100  };
33101
33102  BN.prototype._init = function init(number, base, endian) {
33103    if (typeof number === 'number') {
33104      return this._initNumber(number, base, endian);
33105    }
33106
33107    if (_typeof(number) === 'object') {
33108      return this._initArray(number, base, endian);
33109    }
33110
33111    if (base === 'hex') {
33112      base = 16;
33113    }
33114
33115    assert(base === (base | 0) && base >= 2 && base <= 36);
33116    number = number.toString().replace(/\s+/g, '');
33117    var start = 0;
33118
33119    if (number[0] === '-') {
33120      start++;
33121    }
33122
33123    if (base === 16) {
33124      this._parseHex(number, start);
33125    } else {
33126      this._parseBase(number, base, start);
33127    }
33128
33129    if (number[0] === '-') {
33130      this.negative = 1;
33131    }
33132
33133    this._strip();
33134
33135    if (endian !== 'le') return;
33136
33137    this._initArray(this.toArray(), base, endian);
33138  };
33139
33140  BN.prototype._initNumber = function _initNumber(number, base, endian) {
33141    if (number < 0) {
33142      this.negative = 1;
33143      number = -number;
33144    }
33145
33146    if (number < 0x4000000) {
33147      this.words = [number & 0x3ffffff];
33148      this.length = 1;
33149    } else if (number < 0x10000000000000) {
33150      this.words = [number & 0x3ffffff, number / 0x4000000 & 0x3ffffff];
33151      this.length = 2;
33152    } else {
33153      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
33154
33155      this.words = [number & 0x3ffffff, number / 0x4000000 & 0x3ffffff, 1];
33156      this.length = 3;
33157    }
33158
33159    if (endian !== 'le') return; // Reverse the bytes
33160
33161    this._initArray(this.toArray(), base, endian);
33162  };
33163
33164  BN.prototype._initArray = function _initArray(number, base, endian) {
33165    // Perhaps a Uint8Array
33166    assert(typeof number.length === 'number');
33167
33168    if (number.length <= 0) {
33169      this.words = [0];
33170      this.length = 1;
33171      return this;
33172    }
33173
33174    this.length = Math.ceil(number.length / 3);
33175    this.words = new Array(this.length);
33176
33177    for (var i = 0; i < this.length; i++) {
33178      this.words[i] = 0;
33179    }
33180
33181    var j, w;
33182    var off = 0;
33183
33184    if (endian === 'be') {
33185      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
33186        w = number[i] | number[i - 1] << 8 | number[i - 2] << 16;
33187        this.words[j] |= w << off & 0x3ffffff;
33188        this.words[j + 1] = w >>> 26 - off & 0x3ffffff;
33189        off += 24;
33190
33191        if (off >= 26) {
33192          off -= 26;
33193          j++;
33194        }
33195      }
33196    } else if (endian === 'le') {
33197      for (i = 0, j = 0; i < number.length; i += 3) {
33198        w = number[i] | number[i + 1] << 8 | number[i + 2] << 16;
33199        this.words[j] |= w << off & 0x3ffffff;
33200        this.words[j + 1] = w >>> 26 - off & 0x3ffffff;
33201        off += 24;
33202
33203        if (off >= 26) {
33204          off -= 26;
33205          j++;
33206        }
33207      }
33208    }
33209
33210    return this._strip();
33211  };
33212
33213  function parseHex(str, start, end) {
33214    var r = 0;
33215    var len = Math.min(str.length, end);
33216    var z = 0;
33217
33218    for (var i = start; i < len; i++) {
33219      var c = str.charCodeAt(i) - 48;
33220      r <<= 4;
33221      var b; // 'a' - 'f'
33222
33223      if (c >= 49 && c <= 54) {
33224        b = c - 49 + 0xa; // 'A' - 'F'
33225      } else if (c >= 17 && c <= 22) {
33226        b = c - 17 + 0xa; // '0' - '9'
33227      } else {
33228        b = c;
33229      }
33230
33231      r |= b;
33232      z |= b;
33233    }
33234
33235    assert(!(z & 0xf0), 'Invalid character in ' + str);
33236    return r;
33237  }
33238
33239  BN.prototype._parseHex = function _parseHex(number, start) {
33240    // Create possibly bigger array to ensure that it fits the number
33241    this.length = Math.ceil((number.length - start) / 6);
33242    this.words = new Array(this.length);
33243
33244    for (var i = 0; i < this.length; i++) {
33245      this.words[i] = 0;
33246    }
33247
33248    var j, w; // Scan 24-bit chunks and add them to the number
33249
33250    var off = 0;
33251
33252    for (i = number.length - 6, j = 0; i >= start; i -= 6) {
33253      w = parseHex(number, i, i + 6);
33254      this.words[j] |= w << off & 0x3ffffff; // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
33255
33256      this.words[j + 1] |= w >>> 26 - off & 0x3fffff;
33257      off += 24;
33258
33259      if (off >= 26) {
33260        off -= 26;
33261        j++;
33262      }
33263    }
33264
33265    if (i + 6 !== start) {
33266      w = parseHex(number, start, i + 6);
33267      this.words[j] |= w << off & 0x3ffffff;
33268      this.words[j + 1] |= w >>> 26 - off & 0x3fffff;
33269    }
33270
33271    this._strip();
33272  };
33273
33274  function parseBase(str, start, end, mul) {
33275    var r = 0;
33276    var b = 0;
33277    var len = Math.min(str.length, end);
33278
33279    for (var i = start; i < len; i++) {
33280      var c = str.charCodeAt(i) - 48;
33281      r *= mul; // 'a'
33282
33283      if (c >= 49) {
33284        b = c - 49 + 0xa; // 'A'
33285      } else if (c >= 17) {
33286        b = c - 17 + 0xa; // '0' - '9'
33287      } else {
33288        b = c;
33289      }
33290
33291      assert(c >= 0 && b < mul, 'Invalid character');
33292      r += b;
33293    }
33294
33295    return r;
33296  }
33297
33298  BN.prototype._parseBase = function _parseBase(number, base, start) {
33299    // Initialize as zero
33300    this.words = [0];
33301    this.length = 1; // Find length of limb in base
33302
33303    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
33304      limbLen++;
33305    }
33306
33307    limbLen--;
33308    limbPow = limbPow / base | 0;
33309    var total = number.length - start;
33310    var mod = total % limbLen;
33311    var end = Math.min(total, total - mod) + start;
33312    var word = 0;
33313
33314    for (var i = start; i < end; i += limbLen) {
33315      word = parseBase(number, i, i + limbLen, base);
33316      this.imuln(limbPow);
33317
33318      if (this.words[0] + word < 0x4000000) {
33319        this.words[0] += word;
33320      } else {
33321        this._iaddn(word);
33322      }
33323    }
33324
33325    if (mod !== 0) {
33326      var pow = 1;
33327      word = parseBase(number, i, number.length, base);
33328
33329      for (i = 0; i < mod; i++) {
33330        pow *= base;
33331      }
33332
33333      this.imuln(pow);
33334
33335      if (this.words[0] + word < 0x4000000) {
33336        this.words[0] += word;
33337      } else {
33338        this._iaddn(word);
33339      }
33340    }
33341  };
33342
33343  BN.prototype.copy = function copy(dest) {
33344    dest.words = new Array(this.length);
33345
33346    for (var i = 0; i < this.length; i++) {
33347      dest.words[i] = this.words[i];
33348    }
33349
33350    dest.length = this.length;
33351    dest.negative = this.negative;
33352    dest.red = this.red;
33353  };
33354
33355  function move(dest, src) {
33356    dest.words = src.words;
33357    dest.length = src.length;
33358    dest.negative = src.negative;
33359    dest.red = src.red;
33360  }
33361
33362  BN.prototype._move = function _move(dest) {
33363    move(dest, this);
33364  };
33365
33366  BN.prototype.clone = function clone() {
33367    var r = new BN(null);
33368    this.copy(r);
33369    return r;
33370  };
33371
33372  BN.prototype._expand = function _expand(size) {
33373    while (this.length < size) {
33374      this.words[this.length++] = 0;
33375    }
33376
33377    return this;
33378  }; // Remove leading `0` from `this`
33379
33380
33381  BN.prototype._strip = function strip() {
33382    while (this.length > 1 && this.words[this.length - 1] === 0) {
33383      this.length--;
33384    }
33385
33386    return this._normSign();
33387  };
33388
33389  BN.prototype._normSign = function _normSign() {
33390    // -0 = 0
33391    if (this.length === 1 && this.words[0] === 0) {
33392      this.negative = 0;
33393    }
33394
33395    return this;
33396  }; // Check Symbol.for because not everywhere where Symbol defined
33397  // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility
33398
33399
33400  if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') {
33401    try {
33402      BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;
33403    } catch (e) {
33404      BN.prototype.inspect = inspect;
33405    }
33406  } else {
33407    BN.prototype.inspect = inspect;
33408  }
33409
33410  function inspect() {
33411    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
33412  }
33413  /*
33414   var zeros = [];
33415  var groupSizes = [];
33416  var groupBases = [];
33417   var s = '';
33418  var i = -1;
33419  while (++i < BN.wordSize) {
33420    zeros[i] = s;
33421    s += '0';
33422  }
33423  groupSizes[0] = 0;
33424  groupSizes[1] = 0;
33425  groupBases[0] = 0;
33426  groupBases[1] = 0;
33427  var base = 2 - 1;
33428  while (++base < 36 + 1) {
33429    var groupSize = 0;
33430    var groupBase = 1;
33431    while (groupBase < (1 << BN.wordSize) / base) {
33432      groupBase *= base;
33433      groupSize += 1;
33434    }
33435    groupSizes[base] = groupSize;
33436    groupBases[base] = groupBase;
33437  }
33438   */
33439
33440
33441  var zeros = ['', '0', '00', '000', '0000', '00000', '000000', '0000000', '00000000', '000000000', '0000000000', '00000000000', '000000000000', '0000000000000', '00000000000000', '000000000000000', '0000000000000000', '00000000000000000', '000000000000000000', '0000000000000000000', '00000000000000000000', '000000000000000000000', '0000000000000000000000', '00000000000000000000000', '000000000000000000000000', '0000000000000000000000000'];
33442  var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5];
33443  var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176];
33444
33445  BN.prototype.toString = function toString(base, padding) {
33446    base = base || 10;
33447    padding = padding | 0 || 1;
33448    var out;
33449
33450    if (base === 16 || base === 'hex') {
33451      out = '';
33452      var off = 0;
33453      var carry = 0;
33454
33455      for (var i = 0; i < this.length; i++) {
33456        var w = this.words[i];
33457        var word = ((w << off | carry) & 0xffffff).toString(16);
33458        carry = w >>> 24 - off & 0xffffff;
33459
33460        if (carry !== 0 || i !== this.length - 1) {
33461          out = zeros[6 - word.length] + word + out;
33462        } else {
33463          out = word + out;
33464        }
33465
33466        off += 2;
33467
33468        if (off >= 26) {
33469          off -= 26;
33470          i--;
33471        }
33472      }
33473
33474      if (carry !== 0) {
33475        out = carry.toString(16) + out;
33476      }
33477
33478      while (out.length % padding !== 0) {
33479        out = '0' + out;
33480      }
33481
33482      if (this.negative !== 0) {
33483        out = '-' + out;
33484      }
33485
33486      return out;
33487    }
33488
33489    if (base === (base | 0) && base >= 2 && base <= 36) {
33490      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
33491      var groupSize = groupSizes[base]; // var groupBase = Math.pow(base, groupSize);
33492
33493      var groupBase = groupBases[base];
33494      out = '';
33495      var c = this.clone();
33496      c.negative = 0;
33497
33498      while (!c.isZero()) {
33499        var r = c.modrn(groupBase).toString(base);
33500        c = c.idivn(groupBase);
33501
33502        if (!c.isZero()) {
33503          out = zeros[groupSize - r.length] + r + out;
33504        } else {
33505          out = r + out;
33506        }
33507      }
33508
33509      if (this.isZero()) {
33510        out = '0' + out;
33511      }
33512
33513      while (out.length % padding !== 0) {
33514        out = '0' + out;
33515      }
33516
33517      if (this.negative !== 0) {
33518        out = '-' + out;
33519      }
33520
33521      return out;
33522    }
33523
33524    assert(false, 'Base should be between 2 and 36');
33525  };
33526
33527  BN.prototype.toNumber = function toNumber() {
33528    var ret = this.words[0];
33529
33530    if (this.length === 2) {
33531      ret += this.words[1] * 0x4000000;
33532    } else if (this.length === 3 && this.words[2] === 0x01) {
33533      // NOTE: at this stage it is known that the top bit is set
33534      ret += 0x10000000000000 + this.words[1] * 0x4000000;
33535    } else if (this.length > 2) {
33536      assert(false, 'Number can only safely store up to 53 bits');
33537    }
33538
33539    return this.negative !== 0 ? -ret : ret;
33540  };
33541
33542  BN.prototype.toJSON = function toJSON() {
33543    return this.toString(16, 2);
33544  };
33545
33546  if (Buffer) {
33547    BN.prototype.toBuffer = function toBuffer(endian, length) {
33548      return this.toArrayLike(Buffer, endian, length);
33549    };
33550  }
33551
33552  BN.prototype.toArray = function toArray(endian, length) {
33553    return this.toArrayLike(Array, endian, length);
33554  };
33555
33556  var allocate = function allocate(ArrayType, size) {
33557    if (ArrayType.allocUnsafe) {
33558      return ArrayType.allocUnsafe(size);
33559    }
33560
33561    return new ArrayType(size);
33562  };
33563
33564  BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
33565    this._strip();
33566
33567    var byteLength = this.byteLength();
33568    var reqLength = length || Math.max(1, byteLength);
33569    assert(byteLength <= reqLength, 'byte array longer than desired length');
33570    assert(reqLength > 0, 'Requested array length <= 0');
33571    var res = allocate(ArrayType, reqLength);
33572    var postfix = endian === 'le' ? 'LE' : 'BE';
33573    this['_toArrayLike' + postfix](res, byteLength);
33574    return res;
33575  };
33576
33577  BN.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
33578    var position = 0;
33579    var carry = 0;
33580
33581    for (var i = 0, shift = 0; i < this.length; i++) {
33582      var word = this.words[i] << shift | carry;
33583      res[position++] = word & 0xff;
33584
33585      if (position < res.length) {
33586        res[position++] = word >> 8 & 0xff;
33587      }
33588
33589      if (position < res.length) {
33590        res[position++] = word >> 16 & 0xff;
33591      }
33592
33593      if (shift === 6) {
33594        if (position < res.length) {
33595          res[position++] = word >> 24 & 0xff;
33596        }
33597
33598        carry = 0;
33599        shift = 0;
33600      } else {
33601        carry = word >>> 24;
33602        shift += 2;
33603      }
33604    }
33605
33606    if (position < res.length) {
33607      res[position++] = carry;
33608
33609      while (position < res.length) {
33610        res[position++] = 0;
33611      }
33612    }
33613  };
33614
33615  BN.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
33616    var position = res.length - 1;
33617    var carry = 0;
33618
33619    for (var i = 0, shift = 0; i < this.length; i++) {
33620      var word = this.words[i] << shift | carry;
33621      res[position--] = word & 0xff;
33622
33623      if (position >= 0) {
33624        res[position--] = word >> 8 & 0xff;
33625      }
33626
33627      if (position >= 0) {
33628        res[position--] = word >> 16 & 0xff;
33629      }
33630
33631      if (shift === 6) {
33632        if (position >= 0) {
33633          res[position--] = word >> 24 & 0xff;
33634        }
33635
33636        carry = 0;
33637        shift = 0;
33638      } else {
33639        carry = word >>> 24;
33640        shift += 2;
33641      }
33642    }
33643
33644    if (position >= 0) {
33645      res[position--] = carry;
33646
33647      while (position >= 0) {
33648        res[position--] = 0;
33649      }
33650    }
33651  };
33652
33653  if (Math.clz32) {
33654    BN.prototype._countBits = function _countBits(w) {
33655      return 32 - Math.clz32(w);
33656    };
33657  } else {
33658    BN.prototype._countBits = function _countBits(w) {
33659      var t = w;
33660      var r = 0;
33661
33662      if (t >= 0x1000) {
33663        r += 13;
33664        t >>>= 13;
33665      }
33666
33667      if (t >= 0x40) {
33668        r += 7;
33669        t >>>= 7;
33670      }
33671
33672      if (t >= 0x8) {
33673        r += 4;
33674        t >>>= 4;
33675      }
33676
33677      if (t >= 0x02) {
33678        r += 2;
33679        t >>>= 2;
33680      }
33681
33682      return r + t;
33683    };
33684  }
33685
33686  BN.prototype._zeroBits = function _zeroBits(w) {
33687    // Short-cut
33688    if (w === 0) return 26;
33689    var t = w;
33690    var r = 0;
33691
33692    if ((t & 0x1fff) === 0) {
33693      r += 13;
33694      t >>>= 13;
33695    }
33696
33697    if ((t & 0x7f) === 0) {
33698      r += 7;
33699      t >>>= 7;
33700    }
33701
33702    if ((t & 0xf) === 0) {
33703      r += 4;
33704      t >>>= 4;
33705    }
33706
33707    if ((t & 0x3) === 0) {
33708      r += 2;
33709      t >>>= 2;
33710    }
33711
33712    if ((t & 0x1) === 0) {
33713      r++;
33714    }
33715
33716    return r;
33717  }; // Return number of used bits in a BN
33718
33719
33720  BN.prototype.bitLength = function bitLength() {
33721    var w = this.words[this.length - 1];
33722
33723    var hi = this._countBits(w);
33724
33725    return (this.length - 1) * 26 + hi;
33726  };
33727
33728  function toBitArray(num) {
33729    var w = new Array(num.bitLength());
33730
33731    for (var bit = 0; bit < w.length; bit++) {
33732      var off = bit / 26 | 0;
33733      var wbit = bit % 26;
33734      w[bit] = num.words[off] >>> wbit & 0x01;
33735    }
33736
33737    return w;
33738  } // Number of trailing zero bits
33739
33740
33741  BN.prototype.zeroBits = function zeroBits() {
33742    if (this.isZero()) return 0;
33743    var r = 0;
33744
33745    for (var i = 0; i < this.length; i++) {
33746      var b = this._zeroBits(this.words[i]);
33747
33748      r += b;
33749      if (b !== 26) break;
33750    }
33751
33752    return r;
33753  };
33754
33755  BN.prototype.byteLength = function byteLength() {
33756    return Math.ceil(this.bitLength() / 8);
33757  };
33758
33759  BN.prototype.toTwos = function toTwos(width) {
33760    if (this.negative !== 0) {
33761      return this.abs().inotn(width).iaddn(1);
33762    }
33763
33764    return this.clone();
33765  };
33766
33767  BN.prototype.fromTwos = function fromTwos(width) {
33768    if (this.testn(width - 1)) {
33769      return this.notn(width).iaddn(1).ineg();
33770    }
33771
33772    return this.clone();
33773  };
33774
33775  BN.prototype.isNeg = function isNeg() {
33776    return this.negative !== 0;
33777  }; // Return negative clone of `this`
33778
33779
33780  BN.prototype.neg = function neg() {
33781    return this.clone().ineg();
33782  };
33783
33784  BN.prototype.ineg = function ineg() {
33785    if (!this.isZero()) {
33786      this.negative ^= 1;
33787    }
33788
33789    return this;
33790  }; // Or `num` with `this` in-place
33791
33792
33793  BN.prototype.iuor = function iuor(num) {
33794    while (this.length < num.length) {
33795      this.words[this.length++] = 0;
33796    }
33797
33798    for (var i = 0; i < num.length; i++) {
33799      this.words[i] = this.words[i] | num.words[i];
33800    }
33801
33802    return this._strip();
33803  };
33804
33805  BN.prototype.ior = function ior(num) {
33806    assert((this.negative | num.negative) === 0);
33807    return this.iuor(num);
33808  }; // Or `num` with `this`
33809
33810
33811  BN.prototype.or = function or(num) {
33812    if (this.length > num.length) return this.clone().ior(num);
33813    return num.clone().ior(this);
33814  };
33815
33816  BN.prototype.uor = function uor(num) {
33817    if (this.length > num.length) return this.clone().iuor(num);
33818    return num.clone().iuor(this);
33819  }; // And `num` with `this` in-place
33820
33821
33822  BN.prototype.iuand = function iuand(num) {
33823    // b = min-length(num, this)
33824    var b;
33825
33826    if (this.length > num.length) {
33827      b = num;
33828    } else {
33829      b = this;
33830    }
33831
33832    for (var i = 0; i < b.length; i++) {
33833      this.words[i] = this.words[i] & num.words[i];
33834    }
33835
33836    this.length = b.length;
33837    return this._strip();
33838  };
33839
33840  BN.prototype.iand = function iand(num) {
33841    assert((this.negative | num.negative) === 0);
33842    return this.iuand(num);
33843  }; // And `num` with `this`
33844
33845
33846  BN.prototype.and = function and(num) {
33847    if (this.length > num.length) return this.clone().iand(num);
33848    return num.clone().iand(this);
33849  };
33850
33851  BN.prototype.uand = function uand(num) {
33852    if (this.length > num.length) return this.clone().iuand(num);
33853    return num.clone().iuand(this);
33854  }; // Xor `num` with `this` in-place
33855
33856
33857  BN.prototype.iuxor = function iuxor(num) {
33858    // a.length > b.length
33859    var a;
33860    var b;
33861
33862    if (this.length > num.length) {
33863      a = this;
33864      b = num;
33865    } else {
33866      a = num;
33867      b = this;
33868    }
33869
33870    for (var i = 0; i < b.length; i++) {
33871      this.words[i] = a.words[i] ^ b.words[i];
33872    }
33873
33874    if (this !== a) {
33875      for (; i < a.length; i++) {
33876        this.words[i] = a.words[i];
33877      }
33878    }
33879
33880    this.length = a.length;
33881    return this._strip();
33882  };
33883
33884  BN.prototype.ixor = function ixor(num) {
33885    assert((this.negative | num.negative) === 0);
33886    return this.iuxor(num);
33887  }; // Xor `num` with `this`
33888
33889
33890  BN.prototype.xor = function xor(num) {
33891    if (this.length > num.length) return this.clone().ixor(num);
33892    return num.clone().ixor(this);
33893  };
33894
33895  BN.prototype.uxor = function uxor(num) {
33896    if (this.length > num.length) return this.clone().iuxor(num);
33897    return num.clone().iuxor(this);
33898  }; // Not ``this`` with ``width`` bitwidth
33899
33900
33901  BN.prototype.inotn = function inotn(width) {
33902    assert(typeof width === 'number' && width >= 0);
33903    var bytesNeeded = Math.ceil(width / 26) | 0;
33904    var bitsLeft = width % 26; // Extend the buffer with leading zeroes
33905
33906    this._expand(bytesNeeded);
33907
33908    if (bitsLeft > 0) {
33909      bytesNeeded--;
33910    } // Handle complete words
33911
33912
33913    for (var i = 0; i < bytesNeeded; i++) {
33914      this.words[i] = ~this.words[i] & 0x3ffffff;
33915    } // Handle the residue
33916
33917
33918    if (bitsLeft > 0) {
33919      this.words[i] = ~this.words[i] & 0x3ffffff >> 26 - bitsLeft;
33920    } // And remove leading zeroes
33921
33922
33923    return this._strip();
33924  };
33925
33926  BN.prototype.notn = function notn(width) {
33927    return this.clone().inotn(width);
33928  }; // Set `bit` of `this`
33929
33930
33931  BN.prototype.setn = function setn(bit, val) {
33932    assert(typeof bit === 'number' && bit >= 0);
33933    var off = bit / 26 | 0;
33934    var wbit = bit % 26;
33935
33936    this._expand(off + 1);
33937
33938    if (val) {
33939      this.words[off] = this.words[off] | 1 << wbit;
33940    } else {
33941      this.words[off] = this.words[off] & ~(1 << wbit);
33942    }
33943
33944    return this._strip();
33945  }; // Add `num` to `this` in-place
33946
33947
33948  BN.prototype.iadd = function iadd(num) {
33949    var r; // negative + positive
33950
33951    if (this.negative !== 0 && num.negative === 0) {
33952      this.negative = 0;
33953      r = this.isub(num);
33954      this.negative ^= 1;
33955      return this._normSign(); // positive + negative
33956    } else if (this.negative === 0 && num.negative !== 0) {
33957      num.negative = 0;
33958      r = this.isub(num);
33959      num.negative = 1;
33960      return r._normSign();
33961    } // a.length > b.length
33962
33963
33964    var a, b;
33965
33966    if (this.length > num.length) {
33967      a = this;
33968      b = num;
33969    } else {
33970      a = num;
33971      b = this;
33972    }
33973
33974    var carry = 0;
33975
33976    for (var i = 0; i < b.length; i++) {
33977      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
33978      this.words[i] = r & 0x3ffffff;
33979      carry = r >>> 26;
33980    }
33981
33982    for (; carry !== 0 && i < a.length; i++) {
33983      r = (a.words[i] | 0) + carry;
33984      this.words[i] = r & 0x3ffffff;
33985      carry = r >>> 26;
33986    }
33987
33988    this.length = a.length;
33989
33990    if (carry !== 0) {
33991      this.words[this.length] = carry;
33992      this.length++; // Copy the rest of the words
33993    } else if (a !== this) {
33994      for (; i < a.length; i++) {
33995        this.words[i] = a.words[i];
33996      }
33997    }
33998
33999    return this;
34000  }; // Add `num` to `this`
34001
34002
34003  BN.prototype.add = function add(num) {
34004    var res;
34005
34006    if (num.negative !== 0 && this.negative === 0) {
34007      num.negative = 0;
34008      res = this.sub(num);
34009      num.negative ^= 1;
34010      return res;
34011    } else if (num.negative === 0 && this.negative !== 0) {
34012      this.negative = 0;
34013      res = num.sub(this);
34014      this.negative = 1;
34015      return res;
34016    }
34017
34018    if (this.length > num.length) return this.clone().iadd(num);
34019    return num.clone().iadd(this);
34020  }; // Subtract `num` from `this` in-place
34021
34022
34023  BN.prototype.isub = function isub(num) {
34024    // this - (-num) = this + num
34025    if (num.negative !== 0) {
34026      num.negative = 0;
34027      var r = this.iadd(num);
34028      num.negative = 1;
34029      return r._normSign(); // -this - num = -(this + num)
34030    } else if (this.negative !== 0) {
34031      this.negative = 0;
34032      this.iadd(num);
34033      this.negative = 1;
34034      return this._normSign();
34035    } // At this point both numbers are positive
34036
34037
34038    var cmp = this.cmp(num); // Optimization - zeroify
34039
34040    if (cmp === 0) {
34041      this.negative = 0;
34042      this.length = 1;
34043      this.words[0] = 0;
34044      return this;
34045    } // a > b
34046
34047
34048    var a, b;
34049
34050    if (cmp > 0) {
34051      a = this;
34052      b = num;
34053    } else {
34054      a = num;
34055      b = this;
34056    }
34057
34058    var carry = 0;
34059
34060    for (var i = 0; i < b.length; i++) {
34061      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
34062      carry = r >> 26;
34063      this.words[i] = r & 0x3ffffff;
34064    }
34065
34066    for (; carry !== 0 && i < a.length; i++) {
34067      r = (a.words[i] | 0) + carry;
34068      carry = r >> 26;
34069      this.words[i] = r & 0x3ffffff;
34070    } // Copy rest of the words
34071
34072
34073    if (carry === 0 && i < a.length && a !== this) {
34074      for (; i < a.length; i++) {
34075        this.words[i] = a.words[i];
34076      }
34077    }
34078
34079    this.length = Math.max(this.length, i);
34080
34081    if (a !== this) {
34082      this.negative = 1;
34083    }
34084
34085    return this._strip();
34086  }; // Subtract `num` from `this`
34087
34088
34089  BN.prototype.sub = function sub(num) {
34090    return this.clone().isub(num);
34091  };
34092
34093  function smallMulTo(self, num, out) {
34094    out.negative = num.negative ^ self.negative;
34095    var len = self.length + num.length | 0;
34096    out.length = len;
34097    len = len - 1 | 0; // Peel one iteration (compiler can't do it, because of code complexity)
34098
34099    var a = self.words[0] | 0;
34100    var b = num.words[0] | 0;
34101    var r = a * b;
34102    var lo = r & 0x3ffffff;
34103    var carry = r / 0x4000000 | 0;
34104    out.words[0] = lo;
34105
34106    for (var k = 1; k < len; k++) {
34107      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
34108      // note that ncarry could be >= 0x3ffffff
34109      var ncarry = carry >>> 26;
34110      var rword = carry & 0x3ffffff;
34111      var maxJ = Math.min(k, num.length - 1);
34112
34113      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
34114        var i = k - j | 0;
34115        a = self.words[i] | 0;
34116        b = num.words[j] | 0;
34117        r = a * b + rword;
34118        ncarry += r / 0x4000000 | 0;
34119        rword = r & 0x3ffffff;
34120      }
34121
34122      out.words[k] = rword | 0;
34123      carry = ncarry | 0;
34124    }
34125
34126    if (carry !== 0) {
34127      out.words[k] = carry | 0;
34128    } else {
34129      out.length--;
34130    }
34131
34132    return out._strip();
34133  } // TODO(indutny): it may be reasonable to omit it for users who don't need
34134  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
34135  // multiplication (like elliptic secp256k1).
34136
34137
34138  var comb10MulTo = function comb10MulTo(self, num, out) {
34139    var a = self.words;
34140    var b = num.words;
34141    var o = out.words;
34142    var c = 0;
34143    var lo;
34144    var mid;
34145    var hi;
34146    var a0 = a[0] | 0;
34147    var al0 = a0 & 0x1fff;
34148    var ah0 = a0 >>> 13;
34149    var a1 = a[1] | 0;
34150    var al1 = a1 & 0x1fff;
34151    var ah1 = a1 >>> 13;
34152    var a2 = a[2] | 0;
34153    var al2 = a2 & 0x1fff;
34154    var ah2 = a2 >>> 13;
34155    var a3 = a[3] | 0;
34156    var al3 = a3 & 0x1fff;
34157    var ah3 = a3 >>> 13;
34158    var a4 = a[4] | 0;
34159    var al4 = a4 & 0x1fff;
34160    var ah4 = a4 >>> 13;
34161    var a5 = a[5] | 0;
34162    var al5 = a5 & 0x1fff;
34163    var ah5 = a5 >>> 13;
34164    var a6 = a[6] | 0;
34165    var al6 = a6 & 0x1fff;
34166    var ah6 = a6 >>> 13;
34167    var a7 = a[7] | 0;
34168    var al7 = a7 & 0x1fff;
34169    var ah7 = a7 >>> 13;
34170    var a8 = a[8] | 0;
34171    var al8 = a8 & 0x1fff;
34172    var ah8 = a8 >>> 13;
34173    var a9 = a[9] | 0;
34174    var al9 = a9 & 0x1fff;
34175    var ah9 = a9 >>> 13;
34176    var b0 = b[0] | 0;
34177    var bl0 = b0 & 0x1fff;
34178    var bh0 = b0 >>> 13;
34179    var b1 = b[1] | 0;
34180    var bl1 = b1 & 0x1fff;
34181    var bh1 = b1 >>> 13;
34182    var b2 = b[2] | 0;
34183    var bl2 = b2 & 0x1fff;
34184    var bh2 = b2 >>> 13;
34185    var b3 = b[3] | 0;
34186    var bl3 = b3 & 0x1fff;
34187    var bh3 = b3 >>> 13;
34188    var b4 = b[4] | 0;
34189    var bl4 = b4 & 0x1fff;
34190    var bh4 = b4 >>> 13;
34191    var b5 = b[5] | 0;
34192    var bl5 = b5 & 0x1fff;
34193    var bh5 = b5 >>> 13;
34194    var b6 = b[6] | 0;
34195    var bl6 = b6 & 0x1fff;
34196    var bh6 = b6 >>> 13;
34197    var b7 = b[7] | 0;
34198    var bl7 = b7 & 0x1fff;
34199    var bh7 = b7 >>> 13;
34200    var b8 = b[8] | 0;
34201    var bl8 = b8 & 0x1fff;
34202    var bh8 = b8 >>> 13;
34203    var b9 = b[9] | 0;
34204    var bl9 = b9 & 0x1fff;
34205    var bh9 = b9 >>> 13;
34206    out.negative = self.negative ^ num.negative;
34207    out.length = 19;
34208    /* k = 0 */
34209
34210    lo = Math.imul(al0, bl0);
34211    mid = Math.imul(al0, bh0);
34212    mid = mid + Math.imul(ah0, bl0) | 0;
34213    hi = Math.imul(ah0, bh0);
34214    var w0 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34215    c = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0;
34216    w0 &= 0x3ffffff;
34217    /* k = 1 */
34218
34219    lo = Math.imul(al1, bl0);
34220    mid = Math.imul(al1, bh0);
34221    mid = mid + Math.imul(ah1, bl0) | 0;
34222    hi = Math.imul(ah1, bh0);
34223    lo = lo + Math.imul(al0, bl1) | 0;
34224    mid = mid + Math.imul(al0, bh1) | 0;
34225    mid = mid + Math.imul(ah0, bl1) | 0;
34226    hi = hi + Math.imul(ah0, bh1) | 0;
34227    var w1 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34228    c = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0;
34229    w1 &= 0x3ffffff;
34230    /* k = 2 */
34231
34232    lo = Math.imul(al2, bl0);
34233    mid = Math.imul(al2, bh0);
34234    mid = mid + Math.imul(ah2, bl0) | 0;
34235    hi = Math.imul(ah2, bh0);
34236    lo = lo + Math.imul(al1, bl1) | 0;
34237    mid = mid + Math.imul(al1, bh1) | 0;
34238    mid = mid + Math.imul(ah1, bl1) | 0;
34239    hi = hi + Math.imul(ah1, bh1) | 0;
34240    lo = lo + Math.imul(al0, bl2) | 0;
34241    mid = mid + Math.imul(al0, bh2) | 0;
34242    mid = mid + Math.imul(ah0, bl2) | 0;
34243    hi = hi + Math.imul(ah0, bh2) | 0;
34244    var w2 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34245    c = (hi + (mid >>> 13) | 0) + (w2 >>> 26) | 0;
34246    w2 &= 0x3ffffff;
34247    /* k = 3 */
34248
34249    lo = Math.imul(al3, bl0);
34250    mid = Math.imul(al3, bh0);
34251    mid = mid + Math.imul(ah3, bl0) | 0;
34252    hi = Math.imul(ah3, bh0);
34253    lo = lo + Math.imul(al2, bl1) | 0;
34254    mid = mid + Math.imul(al2, bh1) | 0;
34255    mid = mid + Math.imul(ah2, bl1) | 0;
34256    hi = hi + Math.imul(ah2, bh1) | 0;
34257    lo = lo + Math.imul(al1, bl2) | 0;
34258    mid = mid + Math.imul(al1, bh2) | 0;
34259    mid = mid + Math.imul(ah1, bl2) | 0;
34260    hi = hi + Math.imul(ah1, bh2) | 0;
34261    lo = lo + Math.imul(al0, bl3) | 0;
34262    mid = mid + Math.imul(al0, bh3) | 0;
34263    mid = mid + Math.imul(ah0, bl3) | 0;
34264    hi = hi + Math.imul(ah0, bh3) | 0;
34265    var w3 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34266    c = (hi + (mid >>> 13) | 0) + (w3 >>> 26) | 0;
34267    w3 &= 0x3ffffff;
34268    /* k = 4 */
34269
34270    lo = Math.imul(al4, bl0);
34271    mid = Math.imul(al4, bh0);
34272    mid = mid + Math.imul(ah4, bl0) | 0;
34273    hi = Math.imul(ah4, bh0);
34274    lo = lo + Math.imul(al3, bl1) | 0;
34275    mid = mid + Math.imul(al3, bh1) | 0;
34276    mid = mid + Math.imul(ah3, bl1) | 0;
34277    hi = hi + Math.imul(ah3, bh1) | 0;
34278    lo = lo + Math.imul(al2, bl2) | 0;
34279    mid = mid + Math.imul(al2, bh2) | 0;
34280    mid = mid + Math.imul(ah2, bl2) | 0;
34281    hi = hi + Math.imul(ah2, bh2) | 0;
34282    lo = lo + Math.imul(al1, bl3) | 0;
34283    mid = mid + Math.imul(al1, bh3) | 0;
34284    mid = mid + Math.imul(ah1, bl3) | 0;
34285    hi = hi + Math.imul(ah1, bh3) | 0;
34286    lo = lo + Math.imul(al0, bl4) | 0;
34287    mid = mid + Math.imul(al0, bh4) | 0;
34288    mid = mid + Math.imul(ah0, bl4) | 0;
34289    hi = hi + Math.imul(ah0, bh4) | 0;
34290    var w4 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34291    c = (hi + (mid >>> 13) | 0) + (w4 >>> 26) | 0;
34292    w4 &= 0x3ffffff;
34293    /* k = 5 */
34294
34295    lo = Math.imul(al5, bl0);
34296    mid = Math.imul(al5, bh0);
34297    mid = mid + Math.imul(ah5, bl0) | 0;
34298    hi = Math.imul(ah5, bh0);
34299    lo = lo + Math.imul(al4, bl1) | 0;
34300    mid = mid + Math.imul(al4, bh1) | 0;
34301    mid = mid + Math.imul(ah4, bl1) | 0;
34302    hi = hi + Math.imul(ah4, bh1) | 0;
34303    lo = lo + Math.imul(al3, bl2) | 0;
34304    mid = mid + Math.imul(al3, bh2) | 0;
34305    mid = mid + Math.imul(ah3, bl2) | 0;
34306    hi = hi + Math.imul(ah3, bh2) | 0;
34307    lo = lo + Math.imul(al2, bl3) | 0;
34308    mid = mid + Math.imul(al2, bh3) | 0;
34309    mid = mid + Math.imul(ah2, bl3) | 0;
34310    hi = hi + Math.imul(ah2, bh3) | 0;
34311    lo = lo + Math.imul(al1, bl4) | 0;
34312    mid = mid + Math.imul(al1, bh4) | 0;
34313    mid = mid + Math.imul(ah1, bl4) | 0;
34314    hi = hi + Math.imul(ah1, bh4) | 0;
34315    lo = lo + Math.imul(al0, bl5) | 0;
34316    mid = mid + Math.imul(al0, bh5) | 0;
34317    mid = mid + Math.imul(ah0, bl5) | 0;
34318    hi = hi + Math.imul(ah0, bh5) | 0;
34319    var w5 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34320    c = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0;
34321    w5 &= 0x3ffffff;
34322    /* k = 6 */
34323
34324    lo = Math.imul(al6, bl0);
34325    mid = Math.imul(al6, bh0);
34326    mid = mid + Math.imul(ah6, bl0) | 0;
34327    hi = Math.imul(ah6, bh0);
34328    lo = lo + Math.imul(al5, bl1) | 0;
34329    mid = mid + Math.imul(al5, bh1) | 0;
34330    mid = mid + Math.imul(ah5, bl1) | 0;
34331    hi = hi + Math.imul(ah5, bh1) | 0;
34332    lo = lo + Math.imul(al4, bl2) | 0;
34333    mid = mid + Math.imul(al4, bh2) | 0;
34334    mid = mid + Math.imul(ah4, bl2) | 0;
34335    hi = hi + Math.imul(ah4, bh2) | 0;
34336    lo = lo + Math.imul(al3, bl3) | 0;
34337    mid = mid + Math.imul(al3, bh3) | 0;
34338    mid = mid + Math.imul(ah3, bl3) | 0;
34339    hi = hi + Math.imul(ah3, bh3) | 0;
34340    lo = lo + Math.imul(al2, bl4) | 0;
34341    mid = mid + Math.imul(al2, bh4) | 0;
34342    mid = mid + Math.imul(ah2, bl4) | 0;
34343    hi = hi + Math.imul(ah2, bh4) | 0;
34344    lo = lo + Math.imul(al1, bl5) | 0;
34345    mid = mid + Math.imul(al1, bh5) | 0;
34346    mid = mid + Math.imul(ah1, bl5) | 0;
34347    hi = hi + Math.imul(ah1, bh5) | 0;
34348    lo = lo + Math.imul(al0, bl6) | 0;
34349    mid = mid + Math.imul(al0, bh6) | 0;
34350    mid = mid + Math.imul(ah0, bl6) | 0;
34351    hi = hi + Math.imul(ah0, bh6) | 0;
34352    var w6 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34353    c = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0;
34354    w6 &= 0x3ffffff;
34355    /* k = 7 */
34356
34357    lo = Math.imul(al7, bl0);
34358    mid = Math.imul(al7, bh0);
34359    mid = mid + Math.imul(ah7, bl0) | 0;
34360    hi = Math.imul(ah7, bh0);
34361    lo = lo + Math.imul(al6, bl1) | 0;
34362    mid = mid + Math.imul(al6, bh1) | 0;
34363    mid = mid + Math.imul(ah6, bl1) | 0;
34364    hi = hi + Math.imul(ah6, bh1) | 0;
34365    lo = lo + Math.imul(al5, bl2) | 0;
34366    mid = mid + Math.imul(al5, bh2) | 0;
34367    mid = mid + Math.imul(ah5, bl2) | 0;
34368    hi = hi + Math.imul(ah5, bh2) | 0;
34369    lo = lo + Math.imul(al4, bl3) | 0;
34370    mid = mid + Math.imul(al4, bh3) | 0;
34371    mid = mid + Math.imul(ah4, bl3) | 0;
34372    hi = hi + Math.imul(ah4, bh3) | 0;
34373    lo = lo + Math.imul(al3, bl4) | 0;
34374    mid = mid + Math.imul(al3, bh4) | 0;
34375    mid = mid + Math.imul(ah3, bl4) | 0;
34376    hi = hi + Math.imul(ah3, bh4) | 0;
34377    lo = lo + Math.imul(al2, bl5) | 0;
34378    mid = mid + Math.imul(al2, bh5) | 0;
34379    mid = mid + Math.imul(ah2, bl5) | 0;
34380    hi = hi + Math.imul(ah2, bh5) | 0;
34381    lo = lo + Math.imul(al1, bl6) | 0;
34382    mid = mid + Math.imul(al1, bh6) | 0;
34383    mid = mid + Math.imul(ah1, bl6) | 0;
34384    hi = hi + Math.imul(ah1, bh6) | 0;
34385    lo = lo + Math.imul(al0, bl7) | 0;
34386    mid = mid + Math.imul(al0, bh7) | 0;
34387    mid = mid + Math.imul(ah0, bl7) | 0;
34388    hi = hi + Math.imul(ah0, bh7) | 0;
34389    var w7 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34390    c = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0;
34391    w7 &= 0x3ffffff;
34392    /* k = 8 */
34393
34394    lo = Math.imul(al8, bl0);
34395    mid = Math.imul(al8, bh0);
34396    mid = mid + Math.imul(ah8, bl0) | 0;
34397    hi = Math.imul(ah8, bh0);
34398    lo = lo + Math.imul(al7, bl1) | 0;
34399    mid = mid + Math.imul(al7, bh1) | 0;
34400    mid = mid + Math.imul(ah7, bl1) | 0;
34401    hi = hi + Math.imul(ah7, bh1) | 0;
34402    lo = lo + Math.imul(al6, bl2) | 0;
34403    mid = mid + Math.imul(al6, bh2) | 0;
34404    mid = mid + Math.imul(ah6, bl2) | 0;
34405    hi = hi + Math.imul(ah6, bh2) | 0;
34406    lo = lo + Math.imul(al5, bl3) | 0;
34407    mid = mid + Math.imul(al5, bh3) | 0;
34408    mid = mid + Math.imul(ah5, bl3) | 0;
34409    hi = hi + Math.imul(ah5, bh3) | 0;
34410    lo = lo + Math.imul(al4, bl4) | 0;
34411    mid = mid + Math.imul(al4, bh4) | 0;
34412    mid = mid + Math.imul(ah4, bl4) | 0;
34413    hi = hi + Math.imul(ah4, bh4) | 0;
34414    lo = lo + Math.imul(al3, bl5) | 0;
34415    mid = mid + Math.imul(al3, bh5) | 0;
34416    mid = mid + Math.imul(ah3, bl5) | 0;
34417    hi = hi + Math.imul(ah3, bh5) | 0;
34418    lo = lo + Math.imul(al2, bl6) | 0;
34419    mid = mid + Math.imul(al2, bh6) | 0;
34420    mid = mid + Math.imul(ah2, bl6) | 0;
34421    hi = hi + Math.imul(ah2, bh6) | 0;
34422    lo = lo + Math.imul(al1, bl7) | 0;
34423    mid = mid + Math.imul(al1, bh7) | 0;
34424    mid = mid + Math.imul(ah1, bl7) | 0;
34425    hi = hi + Math.imul(ah1, bh7) | 0;
34426    lo = lo + Math.imul(al0, bl8) | 0;
34427    mid = mid + Math.imul(al0, bh8) | 0;
34428    mid = mid + Math.imul(ah0, bl8) | 0;
34429    hi = hi + Math.imul(ah0, bh8) | 0;
34430    var w8 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34431    c = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0;
34432    w8 &= 0x3ffffff;
34433    /* k = 9 */
34434
34435    lo = Math.imul(al9, bl0);
34436    mid = Math.imul(al9, bh0);
34437    mid = mid + Math.imul(ah9, bl0) | 0;
34438    hi = Math.imul(ah9, bh0);
34439    lo = lo + Math.imul(al8, bl1) | 0;
34440    mid = mid + Math.imul(al8, bh1) | 0;
34441    mid = mid + Math.imul(ah8, bl1) | 0;
34442    hi = hi + Math.imul(ah8, bh1) | 0;
34443    lo = lo + Math.imul(al7, bl2) | 0;
34444    mid = mid + Math.imul(al7, bh2) | 0;
34445    mid = mid + Math.imul(ah7, bl2) | 0;
34446    hi = hi + Math.imul(ah7, bh2) | 0;
34447    lo = lo + Math.imul(al6, bl3) | 0;
34448    mid = mid + Math.imul(al6, bh3) | 0;
34449    mid = mid + Math.imul(ah6, bl3) | 0;
34450    hi = hi + Math.imul(ah6, bh3) | 0;
34451    lo = lo + Math.imul(al5, bl4) | 0;
34452    mid = mid + Math.imul(al5, bh4) | 0;
34453    mid = mid + Math.imul(ah5, bl4) | 0;
34454    hi = hi + Math.imul(ah5, bh4) | 0;
34455    lo = lo + Math.imul(al4, bl5) | 0;
34456    mid = mid + Math.imul(al4, bh5) | 0;
34457    mid = mid + Math.imul(ah4, bl5) | 0;
34458    hi = hi + Math.imul(ah4, bh5) | 0;
34459    lo = lo + Math.imul(al3, bl6) | 0;
34460    mid = mid + Math.imul(al3, bh6) | 0;
34461    mid = mid + Math.imul(ah3, bl6) | 0;
34462    hi = hi + Math.imul(ah3, bh6) | 0;
34463    lo = lo + Math.imul(al2, bl7) | 0;
34464    mid = mid + Math.imul(al2, bh7) | 0;
34465    mid = mid + Math.imul(ah2, bl7) | 0;
34466    hi = hi + Math.imul(ah2, bh7) | 0;
34467    lo = lo + Math.imul(al1, bl8) | 0;
34468    mid = mid + Math.imul(al1, bh8) | 0;
34469    mid = mid + Math.imul(ah1, bl8) | 0;
34470    hi = hi + Math.imul(ah1, bh8) | 0;
34471    lo = lo + Math.imul(al0, bl9) | 0;
34472    mid = mid + Math.imul(al0, bh9) | 0;
34473    mid = mid + Math.imul(ah0, bl9) | 0;
34474    hi = hi + Math.imul(ah0, bh9) | 0;
34475    var w9 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34476    c = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0;
34477    w9 &= 0x3ffffff;
34478    /* k = 10 */
34479
34480    lo = Math.imul(al9, bl1);
34481    mid = Math.imul(al9, bh1);
34482    mid = mid + Math.imul(ah9, bl1) | 0;
34483    hi = Math.imul(ah9, bh1);
34484    lo = lo + Math.imul(al8, bl2) | 0;
34485    mid = mid + Math.imul(al8, bh2) | 0;
34486    mid = mid + Math.imul(ah8, bl2) | 0;
34487    hi = hi + Math.imul(ah8, bh2) | 0;
34488    lo = lo + Math.imul(al7, bl3) | 0;
34489    mid = mid + Math.imul(al7, bh3) | 0;
34490    mid = mid + Math.imul(ah7, bl3) | 0;
34491    hi = hi + Math.imul(ah7, bh3) | 0;
34492    lo = lo + Math.imul(al6, bl4) | 0;
34493    mid = mid + Math.imul(al6, bh4) | 0;
34494    mid = mid + Math.imul(ah6, bl4) | 0;
34495    hi = hi + Math.imul(ah6, bh4) | 0;
34496    lo = lo + Math.imul(al5, bl5) | 0;
34497    mid = mid + Math.imul(al5, bh5) | 0;
34498    mid = mid + Math.imul(ah5, bl5) | 0;
34499    hi = hi + Math.imul(ah5, bh5) | 0;
34500    lo = lo + Math.imul(al4, bl6) | 0;
34501    mid = mid + Math.imul(al4, bh6) | 0;
34502    mid = mid + Math.imul(ah4, bl6) | 0;
34503    hi = hi + Math.imul(ah4, bh6) | 0;
34504    lo = lo + Math.imul(al3, bl7) | 0;
34505    mid = mid + Math.imul(al3, bh7) | 0;
34506    mid = mid + Math.imul(ah3, bl7) | 0;
34507    hi = hi + Math.imul(ah3, bh7) | 0;
34508    lo = lo + Math.imul(al2, bl8) | 0;
34509    mid = mid + Math.imul(al2, bh8) | 0;
34510    mid = mid + Math.imul(ah2, bl8) | 0;
34511    hi = hi + Math.imul(ah2, bh8) | 0;
34512    lo = lo + Math.imul(al1, bl9) | 0;
34513    mid = mid + Math.imul(al1, bh9) | 0;
34514    mid = mid + Math.imul(ah1, bl9) | 0;
34515    hi = hi + Math.imul(ah1, bh9) | 0;
34516    var w10 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34517    c = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0;
34518    w10 &= 0x3ffffff;
34519    /* k = 11 */
34520
34521    lo = Math.imul(al9, bl2);
34522    mid = Math.imul(al9, bh2);
34523    mid = mid + Math.imul(ah9, bl2) | 0;
34524    hi = Math.imul(ah9, bh2);
34525    lo = lo + Math.imul(al8, bl3) | 0;
34526    mid = mid + Math.imul(al8, bh3) | 0;
34527    mid = mid + Math.imul(ah8, bl3) | 0;
34528    hi = hi + Math.imul(ah8, bh3) | 0;
34529    lo = lo + Math.imul(al7, bl4) | 0;
34530    mid = mid + Math.imul(al7, bh4) | 0;
34531    mid = mid + Math.imul(ah7, bl4) | 0;
34532    hi = hi + Math.imul(ah7, bh4) | 0;
34533    lo = lo + Math.imul(al6, bl5) | 0;
34534    mid = mid + Math.imul(al6, bh5) | 0;
34535    mid = mid + Math.imul(ah6, bl5) | 0;
34536    hi = hi + Math.imul(ah6, bh5) | 0;
34537    lo = lo + Math.imul(al5, bl6) | 0;
34538    mid = mid + Math.imul(al5, bh6) | 0;
34539    mid = mid + Math.imul(ah5, bl6) | 0;
34540    hi = hi + Math.imul(ah5, bh6) | 0;
34541    lo = lo + Math.imul(al4, bl7) | 0;
34542    mid = mid + Math.imul(al4, bh7) | 0;
34543    mid = mid + Math.imul(ah4, bl7) | 0;
34544    hi = hi + Math.imul(ah4, bh7) | 0;
34545    lo = lo + Math.imul(al3, bl8) | 0;
34546    mid = mid + Math.imul(al3, bh8) | 0;
34547    mid = mid + Math.imul(ah3, bl8) | 0;
34548    hi = hi + Math.imul(ah3, bh8) | 0;
34549    lo = lo + Math.imul(al2, bl9) | 0;
34550    mid = mid + Math.imul(al2, bh9) | 0;
34551    mid = mid + Math.imul(ah2, bl9) | 0;
34552    hi = hi + Math.imul(ah2, bh9) | 0;
34553    var w11 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34554    c = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0;
34555    w11 &= 0x3ffffff;
34556    /* k = 12 */
34557
34558    lo = Math.imul(al9, bl3);
34559    mid = Math.imul(al9, bh3);
34560    mid = mid + Math.imul(ah9, bl3) | 0;
34561    hi = Math.imul(ah9, bh3);
34562    lo = lo + Math.imul(al8, bl4) | 0;
34563    mid = mid + Math.imul(al8, bh4) | 0;
34564    mid = mid + Math.imul(ah8, bl4) | 0;
34565    hi = hi + Math.imul(ah8, bh4) | 0;
34566    lo = lo + Math.imul(al7, bl5) | 0;
34567    mid = mid + Math.imul(al7, bh5) | 0;
34568    mid = mid + Math.imul(ah7, bl5) | 0;
34569    hi = hi + Math.imul(ah7, bh5) | 0;
34570    lo = lo + Math.imul(al6, bl6) | 0;
34571    mid = mid + Math.imul(al6, bh6) | 0;
34572    mid = mid + Math.imul(ah6, bl6) | 0;
34573    hi = hi + Math.imul(ah6, bh6) | 0;
34574    lo = lo + Math.imul(al5, bl7) | 0;
34575    mid = mid + Math.imul(al5, bh7) | 0;
34576    mid = mid + Math.imul(ah5, bl7) | 0;
34577    hi = hi + Math.imul(ah5, bh7) | 0;
34578    lo = lo + Math.imul(al4, bl8) | 0;
34579    mid = mid + Math.imul(al4, bh8) | 0;
34580    mid = mid + Math.imul(ah4, bl8) | 0;
34581    hi = hi + Math.imul(ah4, bh8) | 0;
34582    lo = lo + Math.imul(al3, bl9) | 0;
34583    mid = mid + Math.imul(al3, bh9) | 0;
34584    mid = mid + Math.imul(ah3, bl9) | 0;
34585    hi = hi + Math.imul(ah3, bh9) | 0;
34586    var w12 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34587    c = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0;
34588    w12 &= 0x3ffffff;
34589    /* k = 13 */
34590
34591    lo = Math.imul(al9, bl4);
34592    mid = Math.imul(al9, bh4);
34593    mid = mid + Math.imul(ah9, bl4) | 0;
34594    hi = Math.imul(ah9, bh4);
34595    lo = lo + Math.imul(al8, bl5) | 0;
34596    mid = mid + Math.imul(al8, bh5) | 0;
34597    mid = mid + Math.imul(ah8, bl5) | 0;
34598    hi = hi + Math.imul(ah8, bh5) | 0;
34599    lo = lo + Math.imul(al7, bl6) | 0;
34600    mid = mid + Math.imul(al7, bh6) | 0;
34601    mid = mid + Math.imul(ah7, bl6) | 0;
34602    hi = hi + Math.imul(ah7, bh6) | 0;
34603    lo = lo + Math.imul(al6, bl7) | 0;
34604    mid = mid + Math.imul(al6, bh7) | 0;
34605    mid = mid + Math.imul(ah6, bl7) | 0;
34606    hi = hi + Math.imul(ah6, bh7) | 0;
34607    lo = lo + Math.imul(al5, bl8) | 0;
34608    mid = mid + Math.imul(al5, bh8) | 0;
34609    mid = mid + Math.imul(ah5, bl8) | 0;
34610    hi = hi + Math.imul(ah5, bh8) | 0;
34611    lo = lo + Math.imul(al4, bl9) | 0;
34612    mid = mid + Math.imul(al4, bh9) | 0;
34613    mid = mid + Math.imul(ah4, bl9) | 0;
34614    hi = hi + Math.imul(ah4, bh9) | 0;
34615    var w13 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34616    c = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0;
34617    w13 &= 0x3ffffff;
34618    /* k = 14 */
34619
34620    lo = Math.imul(al9, bl5);
34621    mid = Math.imul(al9, bh5);
34622    mid = mid + Math.imul(ah9, bl5) | 0;
34623    hi = Math.imul(ah9, bh5);
34624    lo = lo + Math.imul(al8, bl6) | 0;
34625    mid = mid + Math.imul(al8, bh6) | 0;
34626    mid = mid + Math.imul(ah8, bl6) | 0;
34627    hi = hi + Math.imul(ah8, bh6) | 0;
34628    lo = lo + Math.imul(al7, bl7) | 0;
34629    mid = mid + Math.imul(al7, bh7) | 0;
34630    mid = mid + Math.imul(ah7, bl7) | 0;
34631    hi = hi + Math.imul(ah7, bh7) | 0;
34632    lo = lo + Math.imul(al6, bl8) | 0;
34633    mid = mid + Math.imul(al6, bh8) | 0;
34634    mid = mid + Math.imul(ah6, bl8) | 0;
34635    hi = hi + Math.imul(ah6, bh8) | 0;
34636    lo = lo + Math.imul(al5, bl9) | 0;
34637    mid = mid + Math.imul(al5, bh9) | 0;
34638    mid = mid + Math.imul(ah5, bl9) | 0;
34639    hi = hi + Math.imul(ah5, bh9) | 0;
34640    var w14 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34641    c = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0;
34642    w14 &= 0x3ffffff;
34643    /* k = 15 */
34644
34645    lo = Math.imul(al9, bl6);
34646    mid = Math.imul(al9, bh6);
34647    mid = mid + Math.imul(ah9, bl6) | 0;
34648    hi = Math.imul(ah9, bh6);
34649    lo = lo + Math.imul(al8, bl7) | 0;
34650    mid = mid + Math.imul(al8, bh7) | 0;
34651    mid = mid + Math.imul(ah8, bl7) | 0;
34652    hi = hi + Math.imul(ah8, bh7) | 0;
34653    lo = lo + Math.imul(al7, bl8) | 0;
34654    mid = mid + Math.imul(al7, bh8) | 0;
34655    mid = mid + Math.imul(ah7, bl8) | 0;
34656    hi = hi + Math.imul(ah7, bh8) | 0;
34657    lo = lo + Math.imul(al6, bl9) | 0;
34658    mid = mid + Math.imul(al6, bh9) | 0;
34659    mid = mid + Math.imul(ah6, bl9) | 0;
34660    hi = hi + Math.imul(ah6, bh9) | 0;
34661    var w15 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34662    c = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0;
34663    w15 &= 0x3ffffff;
34664    /* k = 16 */
34665
34666    lo = Math.imul(al9, bl7);
34667    mid = Math.imul(al9, bh7);
34668    mid = mid + Math.imul(ah9, bl7) | 0;
34669    hi = Math.imul(ah9, bh7);
34670    lo = lo + Math.imul(al8, bl8) | 0;
34671    mid = mid + Math.imul(al8, bh8) | 0;
34672    mid = mid + Math.imul(ah8, bl8) | 0;
34673    hi = hi + Math.imul(ah8, bh8) | 0;
34674    lo = lo + Math.imul(al7, bl9) | 0;
34675    mid = mid + Math.imul(al7, bh9) | 0;
34676    mid = mid + Math.imul(ah7, bl9) | 0;
34677    hi = hi + Math.imul(ah7, bh9) | 0;
34678    var w16 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34679    c = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0;
34680    w16 &= 0x3ffffff;
34681    /* k = 17 */
34682
34683    lo = Math.imul(al9, bl8);
34684    mid = Math.imul(al9, bh8);
34685    mid = mid + Math.imul(ah9, bl8) | 0;
34686    hi = Math.imul(ah9, bh8);
34687    lo = lo + Math.imul(al8, bl9) | 0;
34688    mid = mid + Math.imul(al8, bh9) | 0;
34689    mid = mid + Math.imul(ah8, bl9) | 0;
34690    hi = hi + Math.imul(ah8, bh9) | 0;
34691    var w17 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34692    c = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0;
34693    w17 &= 0x3ffffff;
34694    /* k = 18 */
34695
34696    lo = Math.imul(al9, bl9);
34697    mid = Math.imul(al9, bh9);
34698    mid = mid + Math.imul(ah9, bl9) | 0;
34699    hi = Math.imul(ah9, bh9);
34700    var w18 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;
34701    c = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0;
34702    w18 &= 0x3ffffff;
34703    o[0] = w0;
34704    o[1] = w1;
34705    o[2] = w2;
34706    o[3] = w3;
34707    o[4] = w4;
34708    o[5] = w5;
34709    o[6] = w6;
34710    o[7] = w7;
34711    o[8] = w8;
34712    o[9] = w9;
34713    o[10] = w10;
34714    o[11] = w11;
34715    o[12] = w12;
34716    o[13] = w13;
34717    o[14] = w14;
34718    o[15] = w15;
34719    o[16] = w16;
34720    o[17] = w17;
34721    o[18] = w18;
34722
34723    if (c !== 0) {
34724      o[19] = c;
34725      out.length++;
34726    }
34727
34728    return out;
34729  }; // Polyfill comb
34730
34731
34732  if (!Math.imul) {
34733    comb10MulTo = smallMulTo;
34734  }
34735
34736  function bigMulTo(self, num, out) {
34737    out.negative = num.negative ^ self.negative;
34738    out.length = self.length + num.length;
34739    var carry = 0;
34740    var hncarry = 0;
34741
34742    for (var k = 0; k < out.length - 1; k++) {
34743      // Sum all words with the same `i + j = k` and accumulate `ncarry`,
34744      // note that ncarry could be >= 0x3ffffff
34745      var ncarry = hncarry;
34746      hncarry = 0;
34747      var rword = carry & 0x3ffffff;
34748      var maxJ = Math.min(k, num.length - 1);
34749
34750      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
34751        var i = k - j;
34752        var a = self.words[i] | 0;
34753        var b = num.words[j] | 0;
34754        var r = a * b;
34755        var lo = r & 0x3ffffff;
34756        ncarry = ncarry + (r / 0x4000000 | 0) | 0;
34757        lo = lo + rword | 0;
34758        rword = lo & 0x3ffffff;
34759        ncarry = ncarry + (lo >>> 26) | 0;
34760        hncarry += ncarry >>> 26;
34761        ncarry &= 0x3ffffff;
34762      }
34763
34764      out.words[k] = rword;
34765      carry = ncarry;
34766      ncarry = hncarry;
34767    }
34768
34769    if (carry !== 0) {
34770      out.words[k] = carry;
34771    } else {
34772      out.length--;
34773    }
34774
34775    return out._strip();
34776  }
34777
34778  function jumboMulTo(self, num, out) {
34779    // Temporary disable, see https://github.com/indutny/bn.js/issues/211
34780    // var fftm = new FFTM();
34781    // return fftm.mulp(self, num, out);
34782    return bigMulTo(self, num, out);
34783  }
34784
34785  BN.prototype.mulTo = function mulTo(num, out) {
34786    var res;
34787    var len = this.length + num.length;
34788
34789    if (this.length === 10 && num.length === 10) {
34790      res = comb10MulTo(this, num, out);
34791    } else if (len < 63) {
34792      res = smallMulTo(this, num, out);
34793    } else if (len < 1024) {
34794      res = bigMulTo(this, num, out);
34795    } else {
34796      res = jumboMulTo(this, num, out);
34797    }
34798
34799    return res;
34800  }; // Cooley-Tukey algorithm for FFT
34801  // slightly revisited to rely on looping instead of recursion
34802
34803
34804  function FFTM(x, y) {
34805    this.x = x;
34806    this.y = y;
34807  }
34808
34809  FFTM.prototype.makeRBT = function makeRBT(N) {
34810    var t = new Array(N);
34811    var l = BN.prototype._countBits(N) - 1;
34812
34813    for (var i = 0; i < N; i++) {
34814      t[i] = this.revBin(i, l, N);
34815    }
34816
34817    return t;
34818  }; // Returns binary-reversed representation of `x`
34819
34820
34821  FFTM.prototype.revBin = function revBin(x, l, N) {
34822    if (x === 0 || x === N - 1) return x;
34823    var rb = 0;
34824
34825    for (var i = 0; i < l; i++) {
34826      rb |= (x & 1) << l - i - 1;
34827      x >>= 1;
34828    }
34829
34830    return rb;
34831  }; // Performs "tweedling" phase, therefore 'emulating'
34832  // behaviour of the recursive algorithm
34833
34834
34835  FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N) {
34836    for (var i = 0; i < N; i++) {
34837      rtws[i] = rws[rbt[i]];
34838      itws[i] = iws[rbt[i]];
34839    }
34840  };
34841
34842  FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N, rbt) {
34843    this.permute(rbt, rws, iws, rtws, itws, N);
34844
34845    for (var s = 1; s < N; s <<= 1) {
34846      var l = s << 1;
34847      var rtwdf = Math.cos(2 * Math.PI / l);
34848      var itwdf = Math.sin(2 * Math.PI / l);
34849
34850      for (var p = 0; p < N; p += l) {
34851        var rtwdf_ = rtwdf;
34852        var itwdf_ = itwdf;
34853
34854        for (var j = 0; j < s; j++) {
34855          var re = rtws[p + j];
34856          var ie = itws[p + j];
34857          var ro = rtws[p + j + s];
34858          var io = itws[p + j + s];
34859          var rx = rtwdf_ * ro - itwdf_ * io;
34860          io = rtwdf_ * io + itwdf_ * ro;
34861          ro = rx;
34862          rtws[p + j] = re + ro;
34863          itws[p + j] = ie + io;
34864          rtws[p + j + s] = re - ro;
34865          itws[p + j + s] = ie - io;
34866          /* jshint maxdepth : false */
34867
34868          if (j !== l) {
34869            rx = rtwdf * rtwdf_ - itwdf * itwdf_;
34870            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
34871            rtwdf_ = rx;
34872          }
34873        }
34874      }
34875    }
34876  };
34877
34878  FFTM.prototype.guessLen13b = function guessLen13b(n, m) {
34879    var N = Math.max(m, n) | 1;
34880    var odd = N & 1;
34881    var i = 0;
34882
34883    for (N = N / 2 | 0; N; N = N >>> 1) {
34884      i++;
34885    }
34886
34887    return 1 << i + 1 + odd;
34888  };
34889
34890  FFTM.prototype.conjugate = function conjugate(rws, iws, N) {
34891    if (N <= 1) return;
34892
34893    for (var i = 0; i < N / 2; i++) {
34894      var t = rws[i];
34895      rws[i] = rws[N - i - 1];
34896      rws[N - i - 1] = t;
34897      t = iws[i];
34898      iws[i] = -iws[N - i - 1];
34899      iws[N - i - 1] = -t;
34900    }
34901  };
34902
34903  FFTM.prototype.normalize13b = function normalize13b(ws, N) {
34904    var carry = 0;
34905
34906    for (var i = 0; i < N / 2; i++) {
34907      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + Math.round(ws[2 * i] / N) + carry;
34908      ws[i] = w & 0x3ffffff;
34909
34910      if (w < 0x4000000) {
34911        carry = 0;
34912      } else {
34913        carry = w / 0x4000000 | 0;
34914      }
34915    }
34916
34917    return ws;
34918  };
34919
34920  FFTM.prototype.convert13b = function convert13b(ws, len, rws, N) {
34921    var carry = 0;
34922
34923    for (var i = 0; i < len; i++) {
34924      carry = carry + (ws[i] | 0);
34925      rws[2 * i] = carry & 0x1fff;
34926      carry = carry >>> 13;
34927      rws[2 * i + 1] = carry & 0x1fff;
34928      carry = carry >>> 13;
34929    } // Pad with zeroes
34930
34931
34932    for (i = 2 * len; i < N; ++i) {
34933      rws[i] = 0;
34934    }
34935
34936    assert(carry === 0);
34937    assert((carry & ~0x1fff) === 0);
34938  };
34939
34940  FFTM.prototype.stub = function stub(N) {
34941    var ph = new Array(N);
34942
34943    for (var i = 0; i < N; i++) {
34944      ph[i] = 0;
34945    }
34946
34947    return ph;
34948  };
34949
34950  FFTM.prototype.mulp = function mulp(x, y, out) {
34951    var N = 2 * this.guessLen13b(x.length, y.length);
34952    var rbt = this.makeRBT(N);
34953
34954    var _ = this.stub(N);
34955
34956    var rws = new Array(N);
34957    var rwst = new Array(N);
34958    var iwst = new Array(N);
34959    var nrws = new Array(N);
34960    var nrwst = new Array(N);
34961    var niwst = new Array(N);
34962    var rmws = out.words;
34963    rmws.length = N;
34964    this.convert13b(x.words, x.length, rws, N);
34965    this.convert13b(y.words, y.length, nrws, N);
34966    this.transform(rws, _, rwst, iwst, N, rbt);
34967    this.transform(nrws, _, nrwst, niwst, N, rbt);
34968
34969    for (var i = 0; i < N; i++) {
34970      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
34971      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
34972      rwst[i] = rx;
34973    }
34974
34975    this.conjugate(rwst, iwst, N);
34976    this.transform(rwst, iwst, rmws, _, N, rbt);
34977    this.conjugate(rmws, _, N);
34978    this.normalize13b(rmws, N);
34979    out.negative = x.negative ^ y.negative;
34980    out.length = x.length + y.length;
34981    return out._strip();
34982  }; // Multiply `this` by `num`
34983
34984
34985  BN.prototype.mul = function mul(num) {
34986    var out = new BN(null);
34987    out.words = new Array(this.length + num.length);
34988    return this.mulTo(num, out);
34989  }; // Multiply employing FFT
34990
34991
34992  BN.prototype.mulf = function mulf(num) {
34993    var out = new BN(null);
34994    out.words = new Array(this.length + num.length);
34995    return jumboMulTo(this, num, out);
34996  }; // In-place Multiplication
34997
34998
34999  BN.prototype.imul = function imul(num) {
35000    return this.clone().mulTo(num, this);
35001  };
35002
35003  BN.prototype.imuln = function imuln(num) {
35004    var isNegNum = num < 0;
35005    if (isNegNum) num = -num;
35006    assert(typeof num === 'number');
35007    assert(num < 0x4000000); // Carry
35008
35009    var carry = 0;
35010
35011    for (var i = 0; i < this.length; i++) {
35012      var w = (this.words[i] | 0) * num;
35013      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
35014      carry >>= 26;
35015      carry += w / 0x4000000 | 0; // NOTE: lo is 27bit maximum
35016
35017      carry += lo >>> 26;
35018      this.words[i] = lo & 0x3ffffff;
35019    }
35020
35021    if (carry !== 0) {
35022      this.words[i] = carry;
35023      this.length++;
35024    }
35025
35026    return isNegNum ? this.ineg() : this;
35027  };
35028
35029  BN.prototype.muln = function muln(num) {
35030    return this.clone().imuln(num);
35031  }; // `this` * `this`
35032
35033
35034  BN.prototype.sqr = function sqr() {
35035    return this.mul(this);
35036  }; // `this` * `this` in-place
35037
35038
35039  BN.prototype.isqr = function isqr() {
35040    return this.imul(this.clone());
35041  }; // Math.pow(`this`, `num`)
35042
35043
35044  BN.prototype.pow = function pow(num) {
35045    var w = toBitArray(num);
35046    if (w.length === 0) return new BN(1); // Skip leading zeroes
35047
35048    var res = this;
35049
35050    for (var i = 0; i < w.length; i++, res = res.sqr()) {
35051      if (w[i] !== 0) break;
35052    }
35053
35054    if (++i < w.length) {
35055      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
35056        if (w[i] === 0) continue;
35057        res = res.mul(q);
35058      }
35059    }
35060
35061    return res;
35062  }; // Shift-left in-place
35063
35064
35065  BN.prototype.iushln = function iushln(bits) {
35066    assert(typeof bits === 'number' && bits >= 0);
35067    var r = bits % 26;
35068    var s = (bits - r) / 26;
35069    var carryMask = 0x3ffffff >>> 26 - r << 26 - r;
35070    var i;
35071
35072    if (r !== 0) {
35073      var carry = 0;
35074
35075      for (i = 0; i < this.length; i++) {
35076        var newCarry = this.words[i] & carryMask;
35077        var c = (this.words[i] | 0) - newCarry << r;
35078        this.words[i] = c | carry;
35079        carry = newCarry >>> 26 - r;
35080      }
35081
35082      if (carry) {
35083        this.words[i] = carry;
35084        this.length++;
35085      }
35086    }
35087
35088    if (s !== 0) {
35089      for (i = this.length - 1; i >= 0; i--) {
35090        this.words[i + s] = this.words[i];
35091      }
35092
35093      for (i = 0; i < s; i++) {
35094        this.words[i] = 0;
35095      }
35096
35097      this.length += s;
35098    }
35099
35100    return this._strip();
35101  };
35102
35103  BN.prototype.ishln = function ishln(bits) {
35104    // TODO(indutny): implement me
35105    assert(this.negative === 0);
35106    return this.iushln(bits);
35107  }; // Shift-right in-place
35108  // NOTE: `hint` is a lowest bit before trailing zeroes
35109  // NOTE: if `extended` is present - it will be filled with destroyed bits
35110
35111
35112  BN.prototype.iushrn = function iushrn(bits, hint, extended) {
35113    assert(typeof bits === 'number' && bits >= 0);
35114    var h;
35115
35116    if (hint) {
35117      h = (hint - hint % 26) / 26;
35118    } else {
35119      h = 0;
35120    }
35121
35122    var r = bits % 26;
35123    var s = Math.min((bits - r) / 26, this.length);
35124    var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
35125    var maskedWords = extended;
35126    h -= s;
35127    h = Math.max(0, h); // Extended mode, copy masked part
35128
35129    if (maskedWords) {
35130      for (var i = 0; i < s; i++) {
35131        maskedWords.words[i] = this.words[i];
35132      }
35133
35134      maskedWords.length = s;
35135    }
35136
35137    if (s === 0) {// No-op, we should not move anything at all
35138    } else if (this.length > s) {
35139      this.length -= s;
35140
35141      for (i = 0; i < this.length; i++) {
35142        this.words[i] = this.words[i + s];
35143      }
35144    } else {
35145      this.words[0] = 0;
35146      this.length = 1;
35147    }
35148
35149    var carry = 0;
35150
35151    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
35152      var word = this.words[i] | 0;
35153      this.words[i] = carry << 26 - r | word >>> r;
35154      carry = word & mask;
35155    } // Push carried bits as a mask
35156
35157
35158    if (maskedWords && carry !== 0) {
35159      maskedWords.words[maskedWords.length++] = carry;
35160    }
35161
35162    if (this.length === 0) {
35163      this.words[0] = 0;
35164      this.length = 1;
35165    }
35166
35167    return this._strip();
35168  };
35169
35170  BN.prototype.ishrn = function ishrn(bits, hint, extended) {
35171    // TODO(indutny): implement me
35172    assert(this.negative === 0);
35173    return this.iushrn(bits, hint, extended);
35174  }; // Shift-left
35175
35176
35177  BN.prototype.shln = function shln(bits) {
35178    return this.clone().ishln(bits);
35179  };
35180
35181  BN.prototype.ushln = function ushln(bits) {
35182    return this.clone().iushln(bits);
35183  }; // Shift-right
35184
35185
35186  BN.prototype.shrn = function shrn(bits) {
35187    return this.clone().ishrn(bits);
35188  };
35189
35190  BN.prototype.ushrn = function ushrn(bits) {
35191    return this.clone().iushrn(bits);
35192  }; // Test if n bit is set
35193
35194
35195  BN.prototype.testn = function testn(bit) {
35196    assert(typeof bit === 'number' && bit >= 0);
35197    var r = bit % 26;
35198    var s = (bit - r) / 26;
35199    var q = 1 << r; // Fast case: bit is much higher than all existing words
35200
35201    if (this.length <= s) return false; // Check bit and return
35202
35203    var w = this.words[s];
35204    return !!(w & q);
35205  }; // Return only lowers bits of number (in-place)
35206
35207
35208  BN.prototype.imaskn = function imaskn(bits) {
35209    assert(typeof bits === 'number' && bits >= 0);
35210    var r = bits % 26;
35211    var s = (bits - r) / 26;
35212    assert(this.negative === 0, 'imaskn works only with positive numbers');
35213
35214    if (this.length <= s) {
35215      return this;
35216    }
35217
35218    if (r !== 0) {
35219      s++;
35220    }
35221
35222    this.length = Math.min(s, this.length);
35223
35224    if (r !== 0) {
35225      var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;
35226      this.words[this.length - 1] &= mask;
35227    }
35228
35229    return this._strip();
35230  }; // Return only lowers bits of number
35231
35232
35233  BN.prototype.maskn = function maskn(bits) {
35234    return this.clone().imaskn(bits);
35235  }; // Add plain number `num` to `this`
35236
35237
35238  BN.prototype.iaddn = function iaddn(num) {
35239    assert(typeof num === 'number');
35240    assert(num < 0x4000000);
35241    if (num < 0) return this.isubn(-num); // Possible sign change
35242
35243    if (this.negative !== 0) {
35244      if (this.length === 1 && (this.words[0] | 0) <= num) {
35245        this.words[0] = num - (this.words[0] | 0);
35246        this.negative = 0;
35247        return this;
35248      }
35249
35250      this.negative = 0;
35251      this.isubn(num);
35252      this.negative = 1;
35253      return this;
35254    } // Add without checks
35255
35256
35257    return this._iaddn(num);
35258  };
35259
35260  BN.prototype._iaddn = function _iaddn(num) {
35261    this.words[0] += num; // Carry
35262
35263    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
35264      this.words[i] -= 0x4000000;
35265
35266      if (i === this.length - 1) {
35267        this.words[i + 1] = 1;
35268      } else {
35269        this.words[i + 1]++;
35270      }
35271    }
35272
35273    this.length = Math.max(this.length, i + 1);
35274    return this;
35275  }; // Subtract plain number `num` from `this`
35276
35277
35278  BN.prototype.isubn = function isubn(num) {
35279    assert(typeof num === 'number');
35280    assert(num < 0x4000000);
35281    if (num < 0) return this.iaddn(-num);
35282
35283    if (this.negative !== 0) {
35284      this.negative = 0;
35285      this.iaddn(num);
35286      this.negative = 1;
35287      return this;
35288    }
35289
35290    this.words[0] -= num;
35291
35292    if (this.length === 1 && this.words[0] < 0) {
35293      this.words[0] = -this.words[0];
35294      this.negative = 1;
35295    } else {
35296      // Carry
35297      for (var i = 0; i < this.length && this.words[i] < 0; i++) {
35298        this.words[i] += 0x4000000;
35299        this.words[i + 1] -= 1;
35300      }
35301    }
35302
35303    return this._strip();
35304  };
35305
35306  BN.prototype.addn = function addn(num) {
35307    return this.clone().iaddn(num);
35308  };
35309
35310  BN.prototype.subn = function subn(num) {
35311    return this.clone().isubn(num);
35312  };
35313
35314  BN.prototype.iabs = function iabs() {
35315    this.negative = 0;
35316    return this;
35317  };
35318
35319  BN.prototype.abs = function abs() {
35320    return this.clone().iabs();
35321  };
35322
35323  BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {
35324    var len = num.length + shift;
35325    var i;
35326
35327    this._expand(len);
35328
35329    var w;
35330    var carry = 0;
35331
35332    for (i = 0; i < num.length; i++) {
35333      w = (this.words[i + shift] | 0) + carry;
35334      var right = (num.words[i] | 0) * mul;
35335      w -= right & 0x3ffffff;
35336      carry = (w >> 26) - (right / 0x4000000 | 0);
35337      this.words[i + shift] = w & 0x3ffffff;
35338    }
35339
35340    for (; i < this.length - shift; i++) {
35341      w = (this.words[i + shift] | 0) + carry;
35342      carry = w >> 26;
35343      this.words[i + shift] = w & 0x3ffffff;
35344    }
35345
35346    if (carry === 0) return this._strip(); // Subtraction overflow
35347
35348    assert(carry === -1);
35349    carry = 0;
35350
35351    for (i = 0; i < this.length; i++) {
35352      w = -(this.words[i] | 0) + carry;
35353      carry = w >> 26;
35354      this.words[i] = w & 0x3ffffff;
35355    }
35356
35357    this.negative = 1;
35358    return this._strip();
35359  };
35360
35361  BN.prototype._wordDiv = function _wordDiv(num, mode) {
35362    var shift = this.length - num.length;
35363    var a = this.clone();
35364    var b = num; // Normalize
35365
35366    var bhi = b.words[b.length - 1] | 0;
35367
35368    var bhiBits = this._countBits(bhi);
35369
35370    shift = 26 - bhiBits;
35371
35372    if (shift !== 0) {
35373      b = b.ushln(shift);
35374      a.iushln(shift);
35375      bhi = b.words[b.length - 1] | 0;
35376    } // Initialize quotient
35377
35378
35379    var m = a.length - b.length;
35380    var q;
35381
35382    if (mode !== 'mod') {
35383      q = new BN(null);
35384      q.length = m + 1;
35385      q.words = new Array(q.length);
35386
35387      for (var i = 0; i < q.length; i++) {
35388        q.words[i] = 0;
35389      }
35390    }
35391
35392    var diff = a.clone()._ishlnsubmul(b, 1, m);
35393
35394    if (diff.negative === 0) {
35395      a = diff;
35396
35397      if (q) {
35398        q.words[m] = 1;
35399      }
35400    }
35401
35402    for (var j = m - 1; j >= 0; j--) {
35403      var qj = (a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j - 1] | 0); // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
35404      // (0x7ffffff)
35405
35406      qj = Math.min(qj / bhi | 0, 0x3ffffff);
35407
35408      a._ishlnsubmul(b, qj, j);
35409
35410      while (a.negative !== 0) {
35411        qj--;
35412        a.negative = 0;
35413
35414        a._ishlnsubmul(b, 1, j);
35415
35416        if (!a.isZero()) {
35417          a.negative ^= 1;
35418        }
35419      }
35420
35421      if (q) {
35422        q.words[j] = qj;
35423      }
35424    }
35425
35426    if (q) {
35427      q._strip();
35428    }
35429
35430    a._strip(); // Denormalize
35431
35432
35433    if (mode !== 'div' && shift !== 0) {
35434      a.iushrn(shift);
35435    }
35436
35437    return {
35438      div: q || null,
35439      mod: a
35440    };
35441  }; // NOTE: 1) `mode` can be set to `mod` to request mod only,
35442  //       to `div` to request div only, or be absent to
35443  //       request both div & mod
35444  //       2) `positive` is true if unsigned mod is requested
35445
35446
35447  BN.prototype.divmod = function divmod(num, mode, positive) {
35448    assert(!num.isZero());
35449
35450    if (this.isZero()) {
35451      return {
35452        div: new BN(0),
35453        mod: new BN(0)
35454      };
35455    }
35456
35457    var div, mod, res;
35458
35459    if (this.negative !== 0 && num.negative === 0) {
35460      res = this.neg().divmod(num, mode);
35461
35462      if (mode !== 'mod') {
35463        div = res.div.neg();
35464      }
35465
35466      if (mode !== 'div') {
35467        mod = res.mod.neg();
35468
35469        if (positive && mod.negative !== 0) {
35470          mod.iadd(num);
35471        }
35472      }
35473
35474      return {
35475        div: div,
35476        mod: mod
35477      };
35478    }
35479
35480    if (this.negative === 0 && num.negative !== 0) {
35481      res = this.divmod(num.neg(), mode);
35482
35483      if (mode !== 'mod') {
35484        div = res.div.neg();
35485      }
35486
35487      return {
35488        div: div,
35489        mod: res.mod
35490      };
35491    }
35492
35493    if ((this.negative & num.negative) !== 0) {
35494      res = this.neg().divmod(num.neg(), mode);
35495
35496      if (mode !== 'div') {
35497        mod = res.mod.neg();
35498
35499        if (positive && mod.negative !== 0) {
35500          mod.isub(num);
35501        }
35502      }
35503
35504      return {
35505        div: res.div,
35506        mod: mod
35507      };
35508    } // Both numbers are positive at this point
35509    // Strip both numbers to approximate shift value
35510
35511
35512    if (num.length > this.length || this.cmp(num) < 0) {
35513      return {
35514        div: new BN(0),
35515        mod: this
35516      };
35517    } // Very short reduction
35518
35519
35520    if (num.length === 1) {
35521      if (mode === 'div') {
35522        return {
35523          div: this.divn(num.words[0]),
35524          mod: null
35525        };
35526      }
35527
35528      if (mode === 'mod') {
35529        return {
35530          div: null,
35531          mod: new BN(this.modrn(num.words[0]))
35532        };
35533      }
35534
35535      return {
35536        div: this.divn(num.words[0]),
35537        mod: new BN(this.modrn(num.words[0]))
35538      };
35539    }
35540
35541    return this._wordDiv(num, mode);
35542  }; // Find `this` / `num`
35543
35544
35545  BN.prototype.div = function div(num) {
35546    return this.divmod(num, 'div', false).div;
35547  }; // Find `this` % `num`
35548
35549
35550  BN.prototype.mod = function mod(num) {
35551    return this.divmod(num, 'mod', false).mod;
35552  };
35553
35554  BN.prototype.umod = function umod(num) {
35555    return this.divmod(num, 'mod', true).mod;
35556  }; // Find Round(`this` / `num`)
35557
35558
35559  BN.prototype.divRound = function divRound(num) {
35560    var dm = this.divmod(num); // Fast case - exact division
35561
35562    if (dm.mod.isZero()) return dm.div;
35563    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
35564    var half = num.ushrn(1);
35565    var r2 = num.andln(1);
35566    var cmp = mod.cmp(half); // Round down
35567
35568    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; // Round up
35569
35570    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
35571  };
35572
35573  BN.prototype.modrn = function modrn(num) {
35574    var isNegNum = num < 0;
35575    if (isNegNum) num = -num;
35576    assert(num <= 0x3ffffff);
35577    var p = (1 << 26) % num;
35578    var acc = 0;
35579
35580    for (var i = this.length - 1; i >= 0; i--) {
35581      acc = (p * acc + (this.words[i] | 0)) % num;
35582    }
35583
35584    return isNegNum ? -acc : acc;
35585  }; // WARNING: DEPRECATED
35586
35587
35588  BN.prototype.modn = function modn(num) {
35589    return this.modrn(num);
35590  }; // In-place division by number
35591
35592
35593  BN.prototype.idivn = function idivn(num) {
35594    var isNegNum = num < 0;
35595    if (isNegNum) num = -num;
35596    assert(num <= 0x3ffffff);
35597    var carry = 0;
35598
35599    for (var i = this.length - 1; i >= 0; i--) {
35600      var w = (this.words[i] | 0) + carry * 0x4000000;
35601      this.words[i] = w / num | 0;
35602      carry = w % num;
35603    }
35604
35605    this._strip();
35606
35607    return isNegNum ? this.ineg() : this;
35608  };
35609
35610  BN.prototype.divn = function divn(num) {
35611    return this.clone().idivn(num);
35612  };
35613
35614  BN.prototype.egcd = function egcd(p) {
35615    assert(p.negative === 0);
35616    assert(!p.isZero());
35617    var x = this;
35618    var y = p.clone();
35619
35620    if (x.negative !== 0) {
35621      x = x.umod(p);
35622    } else {
35623      x = x.clone();
35624    } // A * x + B * y = x
35625
35626
35627    var A = new BN(1);
35628    var B = new BN(0); // C * x + D * y = y
35629
35630    var C = new BN(0);
35631    var D = new BN(1);
35632    var g = 0;
35633
35634    while (x.isEven() && y.isEven()) {
35635      x.iushrn(1);
35636      y.iushrn(1);
35637      ++g;
35638    }
35639
35640    var yp = y.clone();
35641    var xp = x.clone();
35642
35643    while (!x.isZero()) {
35644      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1) {
35645        ;
35646      }
35647
35648      if (i > 0) {
35649        x.iushrn(i);
35650
35651        while (i-- > 0) {
35652          if (A.isOdd() || B.isOdd()) {
35653            A.iadd(yp);
35654            B.isub(xp);
35655          }
35656
35657          A.iushrn(1);
35658          B.iushrn(1);
35659        }
35660      }
35661
35662      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1) {
35663        ;
35664      }
35665
35666      if (j > 0) {
35667        y.iushrn(j);
35668
35669        while (j-- > 0) {
35670          if (C.isOdd() || D.isOdd()) {
35671            C.iadd(yp);
35672            D.isub(xp);
35673          }
35674
35675          C.iushrn(1);
35676          D.iushrn(1);
35677        }
35678      }
35679
35680      if (x.cmp(y) >= 0) {
35681        x.isub(y);
35682        A.isub(C);
35683        B.isub(D);
35684      } else {
35685        y.isub(x);
35686        C.isub(A);
35687        D.isub(B);
35688      }
35689    }
35690
35691    return {
35692      a: C,
35693      b: D,
35694      gcd: y.iushln(g)
35695    };
35696  }; // This is reduced incarnation of the binary EEA
35697  // above, designated to invert members of the
35698  // _prime_ fields F(p) at a maximal speed
35699
35700
35701  BN.prototype._invmp = function _invmp(p) {
35702    assert(p.negative === 0);
35703    assert(!p.isZero());
35704    var a = this;
35705    var b = p.clone();
35706
35707    if (a.negative !== 0) {
35708      a = a.umod(p);
35709    } else {
35710      a = a.clone();
35711    }
35712
35713    var x1 = new BN(1);
35714    var x2 = new BN(0);
35715    var delta = b.clone();
35716
35717    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
35718      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) {
35719        ;
35720      }
35721
35722      if (i > 0) {
35723        a.iushrn(i);
35724
35725        while (i-- > 0) {
35726          if (x1.isOdd()) {
35727            x1.iadd(delta);
35728          }
35729
35730          x1.iushrn(1);
35731        }
35732      }
35733
35734      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1) {
35735        ;
35736      }
35737
35738      if (j > 0) {
35739        b.iushrn(j);
35740
35741        while (j-- > 0) {
35742          if (x2.isOdd()) {
35743            x2.iadd(delta);
35744          }
35745
35746          x2.iushrn(1);
35747        }
35748      }
35749
35750      if (a.cmp(b) >= 0) {
35751        a.isub(b);
35752        x1.isub(x2);
35753      } else {
35754        b.isub(a);
35755        x2.isub(x1);
35756      }
35757    }
35758
35759    var res;
35760
35761    if (a.cmpn(1) === 0) {
35762      res = x1;
35763    } else {
35764      res = x2;
35765    }
35766
35767    if (res.cmpn(0) < 0) {
35768      res.iadd(p);
35769    }
35770
35771    return res;
35772  };
35773
35774  BN.prototype.gcd = function gcd(num) {
35775    if (this.isZero()) return num.abs();
35776    if (num.isZero()) return this.abs();
35777    var a = this.clone();
35778    var b = num.clone();
35779    a.negative = 0;
35780    b.negative = 0; // Remove common factor of two
35781
35782    for (var shift = 0; a.isEven() && b.isEven(); shift++) {
35783      a.iushrn(1);
35784      b.iushrn(1);
35785    }
35786
35787    do {
35788      while (a.isEven()) {
35789        a.iushrn(1);
35790      }
35791
35792      while (b.isEven()) {
35793        b.iushrn(1);
35794      }
35795
35796      var r = a.cmp(b);
35797
35798      if (r < 0) {
35799        // Swap `a` and `b` to make `a` always bigger than `b`
35800        var t = a;
35801        a = b;
35802        b = t;
35803      } else if (r === 0 || b.cmpn(1) === 0) {
35804        break;
35805      }
35806
35807      a.isub(b);
35808    } while (true);
35809
35810    return b.iushln(shift);
35811  }; // Invert number in the field F(num)
35812
35813
35814  BN.prototype.invm = function invm(num) {
35815    return this.egcd(num).a.umod(num);
35816  };
35817
35818  BN.prototype.isEven = function isEven() {
35819    return (this.words[0] & 1) === 0;
35820  };
35821
35822  BN.prototype.isOdd = function isOdd() {
35823    return (this.words[0] & 1) === 1;
35824  }; // And first word and num
35825
35826
35827  BN.prototype.andln = function andln(num) {
35828    return this.words[0] & num;
35829  }; // Increment at the bit position in-line
35830
35831
35832  BN.prototype.bincn = function bincn(bit) {
35833    assert(typeof bit === 'number');
35834    var r = bit % 26;
35835    var s = (bit - r) / 26;
35836    var q = 1 << r; // Fast case: bit is much higher than all existing words
35837
35838    if (this.length <= s) {
35839      this._expand(s + 1);
35840
35841      this.words[s] |= q;
35842      return this;
35843    } // Add bit and propagate, if needed
35844
35845
35846    var carry = q;
35847
35848    for (var i = s; carry !== 0 && i < this.length; i++) {
35849      var w = this.words[i] | 0;
35850      w += carry;
35851      carry = w >>> 26;
35852      w &= 0x3ffffff;
35853      this.words[i] = w;
35854    }
35855
35856    if (carry !== 0) {
35857      this.words[i] = carry;
35858      this.length++;
35859    }
35860
35861    return this;
35862  };
35863
35864  BN.prototype.isZero = function isZero() {
35865    return this.length === 1 && this.words[0] === 0;
35866  };
35867
35868  BN.prototype.cmpn = function cmpn(num) {
35869    var negative = num < 0;
35870    if (this.negative !== 0 && !negative) return -1;
35871    if (this.negative === 0 && negative) return 1;
35872
35873    this._strip();
35874
35875    var res;
35876
35877    if (this.length > 1) {
35878      res = 1;
35879    } else {
35880      if (negative) {
35881        num = -num;
35882      }
35883
35884      assert(num <= 0x3ffffff, 'Number is too big');
35885      var w = this.words[0] | 0;
35886      res = w === num ? 0 : w < num ? -1 : 1;
35887    }
35888
35889    if (this.negative !== 0) return -res | 0;
35890    return res;
35891  }; // Compare two numbers and return:
35892  // 1 - if `this` > `num`
35893  // 0 - if `this` == `num`
35894  // -1 - if `this` < `num`
35895
35896
35897  BN.prototype.cmp = function cmp(num) {
35898    if (this.negative !== 0 && num.negative === 0) return -1;
35899    if (this.negative === 0 && num.negative !== 0) return 1;
35900    var res = this.ucmp(num);
35901    if (this.negative !== 0) return -res | 0;
35902    return res;
35903  }; // Unsigned comparison
35904
35905
35906  BN.prototype.ucmp = function ucmp(num) {
35907    // At this point both numbers have the same sign
35908    if (this.length > num.length) return 1;
35909    if (this.length < num.length) return -1;
35910    var res = 0;
35911
35912    for (var i = this.length - 1; i >= 0; i--) {
35913      var a = this.words[i] | 0;
35914      var b = num.words[i] | 0;
35915      if (a === b) continue;
35916
35917      if (a < b) {
35918        res = -1;
35919      } else if (a > b) {
35920        res = 1;
35921      }
35922
35923      break;
35924    }
35925
35926    return res;
35927  };
35928
35929  BN.prototype.gtn = function gtn(num) {
35930    return this.cmpn(num) === 1;
35931  };
35932
35933  BN.prototype.gt = function gt(num) {
35934    return this.cmp(num) === 1;
35935  };
35936
35937  BN.prototype.gten = function gten(num) {
35938    return this.cmpn(num) >= 0;
35939  };
35940
35941  BN.prototype.gte = function gte(num) {
35942    return this.cmp(num) >= 0;
35943  };
35944
35945  BN.prototype.ltn = function ltn(num) {
35946    return this.cmpn(num) === -1;
35947  };
35948
35949  BN.prototype.lt = function lt(num) {
35950    return this.cmp(num) === -1;
35951  };
35952
35953  BN.prototype.lten = function lten(num) {
35954    return this.cmpn(num) <= 0;
35955  };
35956
35957  BN.prototype.lte = function lte(num) {
35958    return this.cmp(num) <= 0;
35959  };
35960
35961  BN.prototype.eqn = function eqn(num) {
35962    return this.cmpn(num) === 0;
35963  };
35964
35965  BN.prototype.eq = function eq(num) {
35966    return this.cmp(num) === 0;
35967  }; //
35968  // A reduce context, could be using montgomery or something better, depending
35969  // on the `m` itself.
35970  //
35971
35972
35973  BN.red = function red(num) {
35974    return new Red(num);
35975  };
35976
35977  BN.prototype.toRed = function toRed(ctx) {
35978    assert(!this.red, 'Already a number in reduction context');
35979    assert(this.negative === 0, 'red works only with positives');
35980    return ctx.convertTo(this)._forceRed(ctx);
35981  };
35982
35983  BN.prototype.fromRed = function fromRed() {
35984    assert(this.red, 'fromRed works only with numbers in reduction context');
35985    return this.red.convertFrom(this);
35986  };
35987
35988  BN.prototype._forceRed = function _forceRed(ctx) {
35989    this.red = ctx;
35990    return this;
35991  };
35992
35993  BN.prototype.forceRed = function forceRed(ctx) {
35994    assert(!this.red, 'Already a number in reduction context');
35995    return this._forceRed(ctx);
35996  };
35997
35998  BN.prototype.redAdd = function redAdd(num) {
35999    assert(this.red, 'redAdd works only with red numbers');
36000    return this.red.add(this, num);
36001  };
36002
36003  BN.prototype.redIAdd = function redIAdd(num) {
36004    assert(this.red, 'redIAdd works only with red numbers');
36005    return this.red.iadd(this, num);
36006  };
36007
36008  BN.prototype.redSub = function redSub(num) {
36009    assert(this.red, 'redSub works only with red numbers');
36010    return this.red.sub(this, num);
36011  };
36012
36013  BN.prototype.redISub = function redISub(num) {
36014    assert(this.red, 'redISub works only with red numbers');
36015    return this.red.isub(this, num);
36016  };
36017
36018  BN.prototype.redShl = function redShl(num) {
36019    assert(this.red, 'redShl works only with red numbers');
36020    return this.red.shl(this, num);
36021  };
36022
36023  BN.prototype.redMul = function redMul(num) {
36024    assert(this.red, 'redMul works only with red numbers');
36025
36026    this.red._verify2(this, num);
36027
36028    return this.red.mul(this, num);
36029  };
36030
36031  BN.prototype.redIMul = function redIMul(num) {
36032    assert(this.red, 'redMul works only with red numbers');
36033
36034    this.red._verify2(this, num);
36035
36036    return this.red.imul(this, num);
36037  };
36038
36039  BN.prototype.redSqr = function redSqr() {
36040    assert(this.red, 'redSqr works only with red numbers');
36041
36042    this.red._verify1(this);
36043
36044    return this.red.sqr(this);
36045  };
36046
36047  BN.prototype.redISqr = function redISqr() {
36048    assert(this.red, 'redISqr works only with red numbers');
36049
36050    this.red._verify1(this);
36051
36052    return this.red.isqr(this);
36053  }; // Square root over p
36054
36055
36056  BN.prototype.redSqrt = function redSqrt() {
36057    assert(this.red, 'redSqrt works only with red numbers');
36058
36059    this.red._verify1(this);
36060
36061    return this.red.sqrt(this);
36062  };
36063
36064  BN.prototype.redInvm = function redInvm() {
36065    assert(this.red, 'redInvm works only with red numbers');
36066
36067    this.red._verify1(this);
36068
36069    return this.red.invm(this);
36070  }; // Return negative clone of `this` % `red modulo`
36071
36072
36073  BN.prototype.redNeg = function redNeg() {
36074    assert(this.red, 'redNeg works only with red numbers');
36075
36076    this.red._verify1(this);
36077
36078    return this.red.neg(this);
36079  };
36080
36081  BN.prototype.redPow = function redPow(num) {
36082    assert(this.red && !num.red, 'redPow(normalNum)');
36083
36084    this.red._verify1(this);
36085
36086    return this.red.pow(this, num);
36087  }; // Prime numbers with efficient reduction
36088
36089
36090  var primes = {
36091    k256: null,
36092    p224: null,
36093    p192: null,
36094    p25519: null
36095  }; // Pseudo-Mersenne prime
36096
36097  function MPrime(name, p) {
36098    // P = 2 ^ N - K
36099    this.name = name;
36100    this.p = new BN(p, 16);
36101    this.n = this.p.bitLength();
36102    this.k = new BN(1).iushln(this.n).isub(this.p);
36103    this.tmp = this._tmp();
36104  }
36105
36106  MPrime.prototype._tmp = function _tmp() {
36107    var tmp = new BN(null);
36108    tmp.words = new Array(Math.ceil(this.n / 13));
36109    return tmp;
36110  };
36111
36112  MPrime.prototype.ireduce = function ireduce(num) {
36113    // Assumes that `num` is less than `P^2`
36114    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
36115    var r = num;
36116    var rlen;
36117
36118    do {
36119      this.split(r, this.tmp);
36120      r = this.imulK(r);
36121      r = r.iadd(this.tmp);
36122      rlen = r.bitLength();
36123    } while (rlen > this.n);
36124
36125    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
36126
36127    if (cmp === 0) {
36128      r.words[0] = 0;
36129      r.length = 1;
36130    } else if (cmp > 0) {
36131      r.isub(this.p);
36132    } else {
36133      if (r.strip !== undefined) {
36134        // r is a BN v4 instance
36135        r.strip();
36136      } else {
36137        // r is a BN v5 instance
36138        r._strip();
36139      }
36140    }
36141
36142    return r;
36143  };
36144
36145  MPrime.prototype.split = function split(input, out) {
36146    input.iushrn(this.n, 0, out);
36147  };
36148
36149  MPrime.prototype.imulK = function imulK(num) {
36150    return num.imul(this.k);
36151  };
36152
36153  function K256() {
36154    MPrime.call(this, 'k256', 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
36155  }
36156
36157  inherits(K256, MPrime);
36158
36159  K256.prototype.split = function split(input, output) {
36160    // 256 = 9 * 26 + 22
36161    var mask = 0x3fffff;
36162    var outLen = Math.min(input.length, 9);
36163
36164    for (var i = 0; i < outLen; i++) {
36165      output.words[i] = input.words[i];
36166    }
36167
36168    output.length = outLen;
36169
36170    if (input.length <= 9) {
36171      input.words[0] = 0;
36172      input.length = 1;
36173      return;
36174    } // Shift by 9 limbs
36175
36176
36177    var prev = input.words[9];
36178    output.words[output.length++] = prev & mask;
36179
36180    for (i = 10; i < input.length; i++) {
36181      var next = input.words[i] | 0;
36182      input.words[i - 10] = (next & mask) << 4 | prev >>> 22;
36183      prev = next;
36184    }
36185
36186    prev >>>= 22;
36187    input.words[i - 10] = prev;
36188
36189    if (prev === 0 && input.length > 10) {
36190      input.length -= 10;
36191    } else {
36192      input.length -= 9;
36193    }
36194  };
36195
36196  K256.prototype.imulK = function imulK(num) {
36197    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
36198    num.words[num.length] = 0;
36199    num.words[num.length + 1] = 0;
36200    num.length += 2; // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
36201
36202    var lo = 0;
36203
36204    for (var i = 0; i < num.length; i++) {
36205      var w = num.words[i] | 0;
36206      lo += w * 0x3d1;
36207      num.words[i] = lo & 0x3ffffff;
36208      lo = w * 0x40 + (lo / 0x4000000 | 0);
36209    } // Fast length reduction
36210
36211
36212    if (num.words[num.length - 1] === 0) {
36213      num.length--;
36214
36215      if (num.words[num.length - 1] === 0) {
36216        num.length--;
36217      }
36218    }
36219
36220    return num;
36221  };
36222
36223  function P224() {
36224    MPrime.call(this, 'p224', 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
36225  }
36226
36227  inherits(P224, MPrime);
36228
36229  function P192() {
36230    MPrime.call(this, 'p192', 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
36231  }
36232
36233  inherits(P192, MPrime);
36234
36235  function P25519() {
36236    // 2 ^ 255 - 19
36237    MPrime.call(this, '25519', '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
36238  }
36239
36240  inherits(P25519, MPrime);
36241
36242  P25519.prototype.imulK = function imulK(num) {
36243    // K = 0x13
36244    var carry = 0;
36245
36246    for (var i = 0; i < num.length; i++) {
36247      var hi = (num.words[i] | 0) * 0x13 + carry;
36248      var lo = hi & 0x3ffffff;
36249      hi >>>= 26;
36250      num.words[i] = lo;
36251      carry = hi;
36252    }
36253
36254    if (carry !== 0) {
36255      num.words[num.length++] = carry;
36256    }
36257
36258    return num;
36259  }; // Exported mostly for testing purposes, use plain name instead
36260
36261
36262  BN._prime = function prime(name) {
36263    // Cached version of prime
36264    if (primes[name]) return primes[name];
36265    var prime;
36266
36267    if (name === 'k256') {
36268      prime = new K256();
36269    } else if (name === 'p224') {
36270      prime = new P224();
36271    } else if (name === 'p192') {
36272      prime = new P192();
36273    } else if (name === 'p25519') {
36274      prime = new P25519();
36275    } else {
36276      throw new Error('Unknown prime ' + name);
36277    }
36278
36279    primes[name] = prime;
36280    return prime;
36281  }; //
36282  // Base reduction engine
36283  //
36284
36285
36286  function Red(m) {
36287    if (typeof m === 'string') {
36288      var prime = BN._prime(m);
36289
36290      this.m = prime.p;
36291      this.prime = prime;
36292    } else {
36293      assert(m.gtn(1), 'modulus must be greater than 1');
36294      this.m = m;
36295      this.prime = null;
36296    }
36297  }
36298
36299  Red.prototype._verify1 = function _verify1(a) {
36300    assert(a.negative === 0, 'red works only with positives');
36301    assert(a.red, 'red works only with red numbers');
36302  };
36303
36304  Red.prototype._verify2 = function _verify2(a, b) {
36305    assert((a.negative | b.negative) === 0, 'red works only with positives');
36306    assert(a.red && a.red === b.red, 'red works only with red numbers');
36307  };
36308
36309  Red.prototype.imod = function imod(a) {
36310    if (this.prime) return this.prime.ireduce(a)._forceRed(this);
36311    move(a, a.umod(this.m)._forceRed(this));
36312    return a;
36313  };
36314
36315  Red.prototype.neg = function neg(a) {
36316    if (a.isZero()) {
36317      return a.clone();
36318    }
36319
36320    return this.m.sub(a)._forceRed(this);
36321  };
36322
36323  Red.prototype.add = function add(a, b) {
36324    this._verify2(a, b);
36325
36326    var res = a.add(b);
36327
36328    if (res.cmp(this.m) >= 0) {
36329      res.isub(this.m);
36330    }
36331
36332    return res._forceRed(this);
36333  };
36334
36335  Red.prototype.iadd = function iadd(a, b) {
36336    this._verify2(a, b);
36337
36338    var res = a.iadd(b);
36339
36340    if (res.cmp(this.m) >= 0) {
36341      res.isub(this.m);
36342    }
36343
36344    return res;
36345  };
36346
36347  Red.prototype.sub = function sub(a, b) {
36348    this._verify2(a, b);
36349
36350    var res = a.sub(b);
36351
36352    if (res.cmpn(0) < 0) {
36353      res.iadd(this.m);
36354    }
36355
36356    return res._forceRed(this);
36357  };
36358
36359  Red.prototype.isub = function isub(a, b) {
36360    this._verify2(a, b);
36361
36362    var res = a.isub(b);
36363
36364    if (res.cmpn(0) < 0) {
36365      res.iadd(this.m);
36366    }
36367
36368    return res;
36369  };
36370
36371  Red.prototype.shl = function shl(a, num) {
36372    this._verify1(a);
36373
36374    return this.imod(a.ushln(num));
36375  };
36376
36377  Red.prototype.imul = function imul(a, b) {
36378    this._verify2(a, b);
36379
36380    return this.imod(a.imul(b));
36381  };
36382
36383  Red.prototype.mul = function mul(a, b) {
36384    this._verify2(a, b);
36385
36386    return this.imod(a.mul(b));
36387  };
36388
36389  Red.prototype.isqr = function isqr(a) {
36390    return this.imul(a, a.clone());
36391  };
36392
36393  Red.prototype.sqr = function sqr(a) {
36394    return this.mul(a, a);
36395  };
36396
36397  Red.prototype.sqrt = function sqrt(a) {
36398    if (a.isZero()) return a.clone();
36399    var mod3 = this.m.andln(3);
36400    assert(mod3 % 2 === 1); // Fast case
36401
36402    if (mod3 === 3) {
36403      var pow = this.m.add(new BN(1)).iushrn(2);
36404      return this.pow(a, pow);
36405    } // Tonelli-Shanks algorithm (Totally unoptimized and slow)
36406    //
36407    // Find Q and S, that Q * 2 ^ S = (P - 1)
36408
36409
36410    var q = this.m.subn(1);
36411    var s = 0;
36412
36413    while (!q.isZero() && q.andln(1) === 0) {
36414      s++;
36415      q.iushrn(1);
36416    }
36417
36418    assert(!q.isZero());
36419    var one = new BN(1).toRed(this);
36420    var nOne = one.redNeg(); // Find quadratic non-residue
36421    // NOTE: Max is such because of generalized Riemann hypothesis.
36422
36423    var lpow = this.m.subn(1).iushrn(1);
36424    var z = this.m.bitLength();
36425    z = new BN(2 * z * z).toRed(this);
36426
36427    while (this.pow(z, lpow).cmp(nOne) !== 0) {
36428      z.redIAdd(nOne);
36429    }
36430
36431    var c = this.pow(z, q);
36432    var r = this.pow(a, q.addn(1).iushrn(1));
36433    var t = this.pow(a, q);
36434    var m = s;
36435
36436    while (t.cmp(one) !== 0) {
36437      var tmp = t;
36438
36439      for (var i = 0; tmp.cmp(one) !== 0; i++) {
36440        tmp = tmp.redSqr();
36441      }
36442
36443      assert(i < m);
36444      var b = this.pow(c, new BN(1).iushln(m - i - 1));
36445      r = r.redMul(b);
36446      c = b.redSqr();
36447      t = t.redMul(c);
36448      m = i;
36449    }
36450
36451    return r;
36452  };
36453
36454  Red.prototype.invm = function invm(a) {
36455    var inv = a._invmp(this.m);
36456
36457    if (inv.negative !== 0) {
36458      inv.negative = 0;
36459      return this.imod(inv).redNeg();
36460    } else {
36461      return this.imod(inv);
36462    }
36463  };
36464
36465  Red.prototype.pow = function pow(a, num) {
36466    if (num.isZero()) return new BN(1).toRed(this);
36467    if (num.cmpn(1) === 0) return a.clone();
36468    var windowSize = 4;
36469    var wnd = new Array(1 << windowSize);
36470    wnd[0] = new BN(1).toRed(this);
36471    wnd[1] = a;
36472
36473    for (var i = 2; i < wnd.length; i++) {
36474      wnd[i] = this.mul(wnd[i - 1], a);
36475    }
36476
36477    var res = wnd[0];
36478    var current = 0;
36479    var currentLen = 0;
36480    var start = num.bitLength() % 26;
36481
36482    if (start === 0) {
36483      start = 26;
36484    }
36485
36486    for (i = num.length - 1; i >= 0; i--) {
36487      var word = num.words[i];
36488
36489      for (var j = start - 1; j >= 0; j--) {
36490        var bit = word >> j & 1;
36491
36492        if (res !== wnd[0]) {
36493          res = this.sqr(res);
36494        }
36495
36496        if (bit === 0 && current === 0) {
36497          currentLen = 0;
36498          continue;
36499        }
36500
36501        current <<= 1;
36502        current |= bit;
36503        currentLen++;
36504        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
36505        res = this.mul(res, wnd[current]);
36506        currentLen = 0;
36507        current = 0;
36508      }
36509
36510      start = 26;
36511    }
36512
36513    return res;
36514  };
36515
36516  Red.prototype.convertTo = function convertTo(num) {
36517    var r = num.umod(this.m);
36518    return r === num ? r.clone() : r;
36519  };
36520
36521  Red.prototype.convertFrom = function convertFrom(num) {
36522    var res = num.clone();
36523    res.red = null;
36524    return res;
36525  }; //
36526  // Montgomery method engine
36527  //
36528
36529
36530  BN.mont = function mont(num) {
36531    return new Mont(num);
36532  };
36533
36534  function Mont(m) {
36535    Red.call(this, m);
36536    this.shift = this.m.bitLength();
36537
36538    if (this.shift % 26 !== 0) {
36539      this.shift += 26 - this.shift % 26;
36540    }
36541
36542    this.r = new BN(1).iushln(this.shift);
36543    this.r2 = this.imod(this.r.sqr());
36544    this.rinv = this.r._invmp(this.m);
36545    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
36546    this.minv = this.minv.umod(this.r);
36547    this.minv = this.r.sub(this.minv);
36548  }
36549
36550  inherits(Mont, Red);
36551
36552  Mont.prototype.convertTo = function convertTo(num) {
36553    return this.imod(num.ushln(this.shift));
36554  };
36555
36556  Mont.prototype.convertFrom = function convertFrom(num) {
36557    var r = this.imod(num.mul(this.rinv));
36558    r.red = null;
36559    return r;
36560  };
36561
36562  Mont.prototype.imul = function imul(a, b) {
36563    if (a.isZero() || b.isZero()) {
36564      a.words[0] = 0;
36565      a.length = 1;
36566      return a;
36567    }
36568
36569    var t = a.imul(b);
36570    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
36571    var u = t.isub(c).iushrn(this.shift);
36572    var res = u;
36573
36574    if (u.cmp(this.m) >= 0) {
36575      res = u.isub(this.m);
36576    } else if (u.cmpn(0) < 0) {
36577      res = u.iadd(this.m);
36578    }
36579
36580    return res._forceRed(this);
36581  };
36582
36583  Mont.prototype.mul = function mul(a, b) {
36584    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
36585    var t = a.mul(b);
36586    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
36587    var u = t.isub(c).iushrn(this.shift);
36588    var res = u;
36589
36590    if (u.cmp(this.m) >= 0) {
36591      res = u.isub(this.m);
36592    } else if (u.cmpn(0) < 0) {
36593      res = u.iadd(this.m);
36594    }
36595
36596    return res._forceRed(this);
36597  };
36598
36599  Mont.prototype.invm = function invm(a) {
36600    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
36601    var res = this.imod(a._invmp(this.m).mul(this.r2));
36602    return res._forceRed(this);
36603  };
36604})(typeof module === 'undefined' || module, void 0);
36605
36606},{"buffer":185}],184:[function(require,module,exports){
36607"use strict";
36608
36609function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
36610
36611var r;
36612
36613module.exports = function rand(len) {
36614  if (!r) r = new Rand(null);
36615  return r.generate(len);
36616};
36617
36618function Rand(rand) {
36619  this.rand = rand;
36620}
36621
36622module.exports.Rand = Rand;
36623
36624Rand.prototype.generate = function generate(len) {
36625  return this._rand(len);
36626}; // Emulate crypto API using randy
36627
36628
36629Rand.prototype._rand = function _rand(n) {
36630  if (this.rand.getBytes) return this.rand.getBytes(n);
36631  var res = new Uint8Array(n);
36632
36633  for (var i = 0; i < res.length; i++) {
36634    res[i] = this.rand.getByte();
36635  }
36636
36637  return res;
36638};
36639
36640if ((typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object') {
36641  if (self.crypto && self.crypto.getRandomValues) {
36642    // Modern browsers
36643    Rand.prototype._rand = function _rand(n) {
36644      var arr = new Uint8Array(n);
36645      self.crypto.getRandomValues(arr);
36646      return arr;
36647    };
36648  } else if (self.msCrypto && self.msCrypto.getRandomValues) {
36649    // IE
36650    Rand.prototype._rand = function _rand(n) {
36651      var arr = new Uint8Array(n);
36652      self.msCrypto.getRandomValues(arr);
36653      return arr;
36654    }; // Safari's WebWorkers do not have `crypto`
36655
36656  } else if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
36657    // Old junk
36658    Rand.prototype._rand = function () {
36659      throw new Error('Not implemented yet');
36660    };
36661  }
36662} else {
36663  // Node.js or Web worker with no crypto support
36664  try {
36665    var crypto = require('crypto');
36666
36667    if (typeof crypto.randomBytes !== 'function') throw new Error('Not supported');
36668
36669    Rand.prototype._rand = function _rand(n) {
36670      return crypto.randomBytes(n);
36671    };
36672  } catch (e) {}
36673}
36674
36675},{"crypto":185}],185:[function(require,module,exports){
36676"use strict";
36677
36678},{}],186:[function(require,module,exports){
36679"use strict";
36680
36681// based on the aes implimentation in triple sec
36682// https://github.com/keybase/triplesec
36683// which is in turn based on the one from crypto-js
36684// https://code.google.com/p/crypto-js/
36685var Buffer = require('safe-buffer').Buffer;
36686
36687function asUInt32Array(buf) {
36688  if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
36689  var len = buf.length / 4 | 0;
36690  var out = new Array(len);
36691
36692  for (var i = 0; i < len; i++) {
36693    out[i] = buf.readUInt32BE(i * 4);
36694  }
36695
36696  return out;
36697}
36698
36699function scrubVec(v) {
36700  for (var i = 0; i < v.length; v++) {
36701    v[i] = 0;
36702  }
36703}
36704
36705function cryptBlock(M, keySchedule, SUB_MIX, SBOX, nRounds) {
36706  var SUB_MIX0 = SUB_MIX[0];
36707  var SUB_MIX1 = SUB_MIX[1];
36708  var SUB_MIX2 = SUB_MIX[2];
36709  var SUB_MIX3 = SUB_MIX[3];
36710  var s0 = M[0] ^ keySchedule[0];
36711  var s1 = M[1] ^ keySchedule[1];
36712  var s2 = M[2] ^ keySchedule[2];
36713  var s3 = M[3] ^ keySchedule[3];
36714  var t0, t1, t2, t3;
36715  var ksRow = 4;
36716
36717  for (var round = 1; round < nRounds; round++) {
36718    t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[s1 >>> 16 & 0xff] ^ SUB_MIX2[s2 >>> 8 & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++];
36719    t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[s2 >>> 16 & 0xff] ^ SUB_MIX2[s3 >>> 8 & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++];
36720    t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[s3 >>> 16 & 0xff] ^ SUB_MIX2[s0 >>> 8 & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++];
36721    t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[s0 >>> 16 & 0xff] ^ SUB_MIX2[s1 >>> 8 & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++];
36722    s0 = t0;
36723    s1 = t1;
36724    s2 = t2;
36725    s3 = t3;
36726  }
36727
36728  t0 = (SBOX[s0 >>> 24] << 24 | SBOX[s1 >>> 16 & 0xff] << 16 | SBOX[s2 >>> 8 & 0xff] << 8 | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
36729  t1 = (SBOX[s1 >>> 24] << 24 | SBOX[s2 >>> 16 & 0xff] << 16 | SBOX[s3 >>> 8 & 0xff] << 8 | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
36730  t2 = (SBOX[s2 >>> 24] << 24 | SBOX[s3 >>> 16 & 0xff] << 16 | SBOX[s0 >>> 8 & 0xff] << 8 | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
36731  t3 = (SBOX[s3 >>> 24] << 24 | SBOX[s0 >>> 16 & 0xff] << 16 | SBOX[s1 >>> 8 & 0xff] << 8 | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
36732  t0 = t0 >>> 0;
36733  t1 = t1 >>> 0;
36734  t2 = t2 >>> 0;
36735  t3 = t3 >>> 0;
36736  return [t0, t1, t2, t3];
36737} // AES constants
36738
36739
36740var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
36741
36742var G = function () {
36743  // Compute double table
36744  var d = new Array(256);
36745
36746  for (var j = 0; j < 256; j++) {
36747    if (j < 128) {
36748      d[j] = j << 1;
36749    } else {
36750      d[j] = j << 1 ^ 0x11b;
36751    }
36752  }
36753
36754  var SBOX = [];
36755  var INV_SBOX = [];
36756  var SUB_MIX = [[], [], [], []];
36757  var INV_SUB_MIX = [[], [], [], []]; // Walk GF(2^8)
36758
36759  var x = 0;
36760  var xi = 0;
36761
36762  for (var i = 0; i < 256; ++i) {
36763    // Compute sbox
36764    var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4;
36765    sx = sx >>> 8 ^ sx & 0xff ^ 0x63;
36766    SBOX[x] = sx;
36767    INV_SBOX[sx] = x; // Compute multiplication
36768
36769    var x2 = d[x];
36770    var x4 = d[x2];
36771    var x8 = d[x4]; // Compute sub bytes, mix columns tables
36772
36773    var t = d[sx] * 0x101 ^ sx * 0x1010100;
36774    SUB_MIX[0][x] = t << 24 | t >>> 8;
36775    SUB_MIX[1][x] = t << 16 | t >>> 16;
36776    SUB_MIX[2][x] = t << 8 | t >>> 24;
36777    SUB_MIX[3][x] = t; // Compute inv sub bytes, inv mix columns tables
36778
36779    t = x8 * 0x1010101 ^ x4 * 0x10001 ^ x2 * 0x101 ^ x * 0x1010100;
36780    INV_SUB_MIX[0][sx] = t << 24 | t >>> 8;
36781    INV_SUB_MIX[1][sx] = t << 16 | t >>> 16;
36782    INV_SUB_MIX[2][sx] = t << 8 | t >>> 24;
36783    INV_SUB_MIX[3][sx] = t;
36784
36785    if (x === 0) {
36786      x = xi = 1;
36787    } else {
36788      x = x2 ^ d[d[d[x8 ^ x2]]];
36789      xi ^= d[d[xi]];
36790    }
36791  }
36792
36793  return {
36794    SBOX: SBOX,
36795    INV_SBOX: INV_SBOX,
36796    SUB_MIX: SUB_MIX,
36797    INV_SUB_MIX: INV_SUB_MIX
36798  };
36799}();
36800
36801function AES(key) {
36802  this._key = asUInt32Array(key);
36803
36804  this._reset();
36805}
36806
36807AES.blockSize = 4 * 4;
36808AES.keySize = 256 / 8;
36809AES.prototype.blockSize = AES.blockSize;
36810AES.prototype.keySize = AES.keySize;
36811
36812AES.prototype._reset = function () {
36813  var keyWords = this._key;
36814  var keySize = keyWords.length;
36815  var nRounds = keySize + 6;
36816  var ksRows = (nRounds + 1) * 4;
36817  var keySchedule = [];
36818
36819  for (var k = 0; k < keySize; k++) {
36820    keySchedule[k] = keyWords[k];
36821  }
36822
36823  for (k = keySize; k < ksRows; k++) {
36824    var t = keySchedule[k - 1];
36825
36826    if (k % keySize === 0) {
36827      t = t << 8 | t >>> 24;
36828      t = G.SBOX[t >>> 24] << 24 | G.SBOX[t >>> 16 & 0xff] << 16 | G.SBOX[t >>> 8 & 0xff] << 8 | G.SBOX[t & 0xff];
36829      t ^= RCON[k / keySize | 0] << 24;
36830    } else if (keySize > 6 && k % keySize === 4) {
36831      t = G.SBOX[t >>> 24] << 24 | G.SBOX[t >>> 16 & 0xff] << 16 | G.SBOX[t >>> 8 & 0xff] << 8 | G.SBOX[t & 0xff];
36832    }
36833
36834    keySchedule[k] = keySchedule[k - keySize] ^ t;
36835  }
36836
36837  var invKeySchedule = [];
36838
36839  for (var ik = 0; ik < ksRows; ik++) {
36840    var ksR = ksRows - ik;
36841    var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)];
36842
36843    if (ik < 4 || ksR <= 4) {
36844      invKeySchedule[ik] = tt;
36845    } else {
36846      invKeySchedule[ik] = G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^ G.INV_SUB_MIX[1][G.SBOX[tt >>> 16 & 0xff]] ^ G.INV_SUB_MIX[2][G.SBOX[tt >>> 8 & 0xff]] ^ G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]];
36847    }
36848  }
36849
36850  this._nRounds = nRounds;
36851  this._keySchedule = keySchedule;
36852  this._invKeySchedule = invKeySchedule;
36853};
36854
36855AES.prototype.encryptBlockRaw = function (M) {
36856  M = asUInt32Array(M);
36857  return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds);
36858};
36859
36860AES.prototype.encryptBlock = function (M) {
36861  var out = this.encryptBlockRaw(M);
36862  var buf = Buffer.allocUnsafe(16);
36863  buf.writeUInt32BE(out[0], 0);
36864  buf.writeUInt32BE(out[1], 4);
36865  buf.writeUInt32BE(out[2], 8);
36866  buf.writeUInt32BE(out[3], 12);
36867  return buf;
36868};
36869
36870AES.prototype.decryptBlock = function (M) {
36871  M = asUInt32Array(M); // swap
36872
36873  var m1 = M[1];
36874  M[1] = M[3];
36875  M[3] = m1;
36876  var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds);
36877  var buf = Buffer.allocUnsafe(16);
36878  buf.writeUInt32BE(out[0], 0);
36879  buf.writeUInt32BE(out[3], 4);
36880  buf.writeUInt32BE(out[2], 8);
36881  buf.writeUInt32BE(out[1], 12);
36882  return buf;
36883};
36884
36885AES.prototype.scrub = function () {
36886  scrubVec(this._keySchedule);
36887  scrubVec(this._invKeySchedule);
36888  scrubVec(this._key);
36889};
36890
36891module.exports.AES = AES;
36892
36893},{"safe-buffer":494}],187:[function(require,module,exports){
36894"use strict";
36895
36896var aes = require('./aes');
36897
36898var Buffer = require('safe-buffer').Buffer;
36899
36900var Transform = require('cipher-base');
36901
36902var inherits = require('inherits');
36903
36904var GHASH = require('./ghash');
36905
36906var xor = require('buffer-xor');
36907
36908var incr32 = require('./incr32');
36909
36910function xorTest(a, b) {
36911  var out = 0;
36912  if (a.length !== b.length) out++;
36913  var len = Math.min(a.length, b.length);
36914
36915  for (var i = 0; i < len; ++i) {
36916    out += a[i] ^ b[i];
36917  }
36918
36919  return out;
36920}
36921
36922function calcIv(self, iv, ck) {
36923  if (iv.length === 12) {
36924    self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])]);
36925    return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])]);
36926  }
36927
36928  var ghash = new GHASH(ck);
36929  var len = iv.length;
36930  var toPad = len % 16;
36931  ghash.update(iv);
36932
36933  if (toPad) {
36934    toPad = 16 - toPad;
36935    ghash.update(Buffer.alloc(toPad, 0));
36936  }
36937
36938  ghash.update(Buffer.alloc(8, 0));
36939  var ivBits = len * 8;
36940  var tail = Buffer.alloc(8);
36941  tail.writeUIntBE(ivBits, 0, 8);
36942  ghash.update(tail);
36943  self._finID = ghash.state;
36944  var out = Buffer.from(self._finID);
36945  incr32(out);
36946  return out;
36947}
36948
36949function StreamCipher(mode, key, iv, decrypt) {
36950  Transform.call(this);
36951  var h = Buffer.alloc(4, 0);
36952  this._cipher = new aes.AES(key);
36953
36954  var ck = this._cipher.encryptBlock(h);
36955
36956  this._ghash = new GHASH(ck);
36957  iv = calcIv(this, iv, ck);
36958  this._prev = Buffer.from(iv);
36959  this._cache = Buffer.allocUnsafe(0);
36960  this._secCache = Buffer.allocUnsafe(0);
36961  this._decrypt = decrypt;
36962  this._alen = 0;
36963  this._len = 0;
36964  this._mode = mode;
36965  this._authTag = null;
36966  this._called = false;
36967}
36968
36969inherits(StreamCipher, Transform);
36970
36971StreamCipher.prototype._update = function (chunk) {
36972  if (!this._called && this._alen) {
36973    var rump = 16 - this._alen % 16;
36974
36975    if (rump < 16) {
36976      rump = Buffer.alloc(rump, 0);
36977
36978      this._ghash.update(rump);
36979    }
36980  }
36981
36982  this._called = true;
36983
36984  var out = this._mode.encrypt(this, chunk);
36985
36986  if (this._decrypt) {
36987    this._ghash.update(chunk);
36988  } else {
36989    this._ghash.update(out);
36990  }
36991
36992  this._len += chunk.length;
36993  return out;
36994};
36995
36996StreamCipher.prototype._final = function () {
36997  if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data');
36998  var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID));
36999  if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data');
37000  this._authTag = tag;
37001
37002  this._cipher.scrub();
37003};
37004
37005StreamCipher.prototype.getAuthTag = function getAuthTag() {
37006  if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state');
37007  return this._authTag;
37008};
37009
37010StreamCipher.prototype.setAuthTag = function setAuthTag(tag) {
37011  if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state');
37012  this._authTag = tag;
37013};
37014
37015StreamCipher.prototype.setAAD = function setAAD(buf) {
37016  if (this._called) throw new Error('Attempting to set AAD in unsupported state');
37017
37018  this._ghash.update(buf);
37019
37020  this._alen += buf.length;
37021};
37022
37023module.exports = StreamCipher;
37024
37025},{"./aes":186,"./ghash":191,"./incr32":192,"buffer-xor":217,"cipher-base":218,"inherits":387,"safe-buffer":494}],188:[function(require,module,exports){
37026"use strict";
37027
37028var ciphers = require('./encrypter');
37029
37030var deciphers = require('./decrypter');
37031
37032var modes = require('./modes/list.json');
37033
37034function getCiphers() {
37035  return Object.keys(modes);
37036}
37037
37038exports.createCipher = exports.Cipher = ciphers.createCipher;
37039exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv;
37040exports.createDecipher = exports.Decipher = deciphers.createDecipher;
37041exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv;
37042exports.listCiphers = exports.getCiphers = getCiphers;
37043
37044},{"./decrypter":189,"./encrypter":190,"./modes/list.json":200}],189:[function(require,module,exports){
37045"use strict";
37046
37047var AuthCipher = require('./authCipher');
37048
37049var Buffer = require('safe-buffer').Buffer;
37050
37051var MODES = require('./modes');
37052
37053var StreamCipher = require('./streamCipher');
37054
37055var Transform = require('cipher-base');
37056
37057var aes = require('./aes');
37058
37059var ebtk = require('evp_bytestokey');
37060
37061var inherits = require('inherits');
37062
37063function Decipher(mode, key, iv) {
37064  Transform.call(this);
37065  this._cache = new Splitter();
37066  this._last = void 0;
37067  this._cipher = new aes.AES(key);
37068  this._prev = Buffer.from(iv);
37069  this._mode = mode;
37070  this._autopadding = true;
37071}
37072
37073inherits(Decipher, Transform);
37074
37075Decipher.prototype._update = function (data) {
37076  this._cache.add(data);
37077
37078  var chunk;
37079  var thing;
37080  var out = [];
37081
37082  while (chunk = this._cache.get(this._autopadding)) {
37083    thing = this._mode.decrypt(this, chunk);
37084    out.push(thing);
37085  }
37086
37087  return Buffer.concat(out);
37088};
37089
37090Decipher.prototype._final = function () {
37091  var chunk = this._cache.flush();
37092
37093  if (this._autopadding) {
37094    return unpad(this._mode.decrypt(this, chunk));
37095  } else if (chunk) {
37096    throw new Error('data not multiple of block length');
37097  }
37098};
37099
37100Decipher.prototype.setAutoPadding = function (setTo) {
37101  this._autopadding = !!setTo;
37102  return this;
37103};
37104
37105function Splitter() {
37106  this.cache = Buffer.allocUnsafe(0);
37107}
37108
37109Splitter.prototype.add = function (data) {
37110  this.cache = Buffer.concat([this.cache, data]);
37111};
37112
37113Splitter.prototype.get = function (autoPadding) {
37114  var out;
37115
37116  if (autoPadding) {
37117    if (this.cache.length > 16) {
37118      out = this.cache.slice(0, 16);
37119      this.cache = this.cache.slice(16);
37120      return out;
37121    }
37122  } else {
37123    if (this.cache.length >= 16) {
37124      out = this.cache.slice(0, 16);
37125      this.cache = this.cache.slice(16);
37126      return out;
37127    }
37128  }
37129
37130  return null;
37131};
37132
37133Splitter.prototype.flush = function () {
37134  if (this.cache.length) return this.cache;
37135};
37136
37137function unpad(last) {
37138  var padded = last[15];
37139
37140  if (padded < 1 || padded > 16) {
37141    throw new Error('unable to decrypt data');
37142  }
37143
37144  var i = -1;
37145
37146  while (++i < padded) {
37147    if (last[i + (16 - padded)] !== padded) {
37148      throw new Error('unable to decrypt data');
37149    }
37150  }
37151
37152  if (padded === 16) return;
37153  return last.slice(0, 16 - padded);
37154}
37155
37156function createDecipheriv(suite, password, iv) {
37157  var config = MODES[suite.toLowerCase()];
37158  if (!config) throw new TypeError('invalid suite type');
37159  if (typeof iv === 'string') iv = Buffer.from(iv);
37160  if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length);
37161  if (typeof password === 'string') password = Buffer.from(password);
37162  if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length);
37163
37164  if (config.type === 'stream') {
37165    return new StreamCipher(config.module, password, iv, true);
37166  } else if (config.type === 'auth') {
37167    return new AuthCipher(config.module, password, iv, true);
37168  }
37169
37170  return new Decipher(config.module, password, iv);
37171}
37172
37173function createDecipher(suite, password) {
37174  var config = MODES[suite.toLowerCase()];
37175  if (!config) throw new TypeError('invalid suite type');
37176  var keys = ebtk(password, false, config.key, config.iv);
37177  return createDecipheriv(suite, keys.key, keys.iv);
37178}
37179
37180exports.createDecipher = createDecipher;
37181exports.createDecipheriv = createDecipheriv;
37182
37183},{"./aes":186,"./authCipher":187,"./modes":199,"./streamCipher":202,"cipher-base":218,"evp_bytestokey":368,"inherits":387,"safe-buffer":494}],190:[function(require,module,exports){
37184"use strict";
37185
37186var MODES = require('./modes');
37187
37188var AuthCipher = require('./authCipher');
37189
37190var Buffer = require('safe-buffer').Buffer;
37191
37192var StreamCipher = require('./streamCipher');
37193
37194var Transform = require('cipher-base');
37195
37196var aes = require('./aes');
37197
37198var ebtk = require('evp_bytestokey');
37199
37200var inherits = require('inherits');
37201
37202function Cipher(mode, key, iv) {
37203  Transform.call(this);
37204  this._cache = new Splitter();
37205  this._cipher = new aes.AES(key);
37206  this._prev = Buffer.from(iv);
37207  this._mode = mode;
37208  this._autopadding = true;
37209}
37210
37211inherits(Cipher, Transform);
37212
37213Cipher.prototype._update = function (data) {
37214  this._cache.add(data);
37215
37216  var chunk;
37217  var thing;
37218  var out = [];
37219
37220  while (chunk = this._cache.get()) {
37221    thing = this._mode.encrypt(this, chunk);
37222    out.push(thing);
37223  }
37224
37225  return Buffer.concat(out);
37226};
37227
37228var PADDING = Buffer.alloc(16, 0x10);
37229
37230Cipher.prototype._final = function () {
37231  var chunk = this._cache.flush();
37232
37233  if (this._autopadding) {
37234    chunk = this._mode.encrypt(this, chunk);
37235
37236    this._cipher.scrub();
37237
37238    return chunk;
37239  }
37240
37241  if (!chunk.equals(PADDING)) {
37242    this._cipher.scrub();
37243
37244    throw new Error('data not multiple of block length');
37245  }
37246};
37247
37248Cipher.prototype.setAutoPadding = function (setTo) {
37249  this._autopadding = !!setTo;
37250  return this;
37251};
37252
37253function Splitter() {
37254  this.cache = Buffer.allocUnsafe(0);
37255}
37256
37257Splitter.prototype.add = function (data) {
37258  this.cache = Buffer.concat([this.cache, data]);
37259};
37260
37261Splitter.prototype.get = function () {
37262  if (this.cache.length > 15) {
37263    var out = this.cache.slice(0, 16);
37264    this.cache = this.cache.slice(16);
37265    return out;
37266  }
37267
37268  return null;
37269};
37270
37271Splitter.prototype.flush = function () {
37272  var len = 16 - this.cache.length;
37273  var padBuff = Buffer.allocUnsafe(len);
37274  var i = -1;
37275
37276  while (++i < len) {
37277    padBuff.writeUInt8(len, i);
37278  }
37279
37280  return Buffer.concat([this.cache, padBuff]);
37281};
37282
37283function createCipheriv(suite, password, iv) {
37284  var config = MODES[suite.toLowerCase()];
37285  if (!config) throw new TypeError('invalid suite type');
37286  if (typeof password === 'string') password = Buffer.from(password);
37287  if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length);
37288  if (typeof iv === 'string') iv = Buffer.from(iv);
37289  if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length);
37290
37291  if (config.type === 'stream') {
37292    return new StreamCipher(config.module, password, iv);
37293  } else if (config.type === 'auth') {
37294    return new AuthCipher(config.module, password, iv);
37295  }
37296
37297  return new Cipher(config.module, password, iv);
37298}
37299
37300function createCipher(suite, password) {
37301  var config = MODES[suite.toLowerCase()];
37302  if (!config) throw new TypeError('invalid suite type');
37303  var keys = ebtk(password, false, config.key, config.iv);
37304  return createCipheriv(suite, keys.key, keys.iv);
37305}
37306
37307exports.createCipheriv = createCipheriv;
37308exports.createCipher = createCipher;
37309
37310},{"./aes":186,"./authCipher":187,"./modes":199,"./streamCipher":202,"cipher-base":218,"evp_bytestokey":368,"inherits":387,"safe-buffer":494}],191:[function(require,module,exports){
37311"use strict";
37312
37313var Buffer = require('safe-buffer').Buffer;
37314
37315var ZEROES = Buffer.alloc(16, 0);
37316
37317function toArray(buf) {
37318  return [buf.readUInt32BE(0), buf.readUInt32BE(4), buf.readUInt32BE(8), buf.readUInt32BE(12)];
37319}
37320
37321function fromArray(out) {
37322  var buf = Buffer.allocUnsafe(16);
37323  buf.writeUInt32BE(out[0] >>> 0, 0);
37324  buf.writeUInt32BE(out[1] >>> 0, 4);
37325  buf.writeUInt32BE(out[2] >>> 0, 8);
37326  buf.writeUInt32BE(out[3] >>> 0, 12);
37327  return buf;
37328}
37329
37330function GHASH(key) {
37331  this.h = key;
37332  this.state = Buffer.alloc(16, 0);
37333  this.cache = Buffer.allocUnsafe(0);
37334} // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
37335// by Juho Vähä-Herttua
37336
37337
37338GHASH.prototype.ghash = function (block) {
37339  var i = -1;
37340
37341  while (++i < block.length) {
37342    this.state[i] ^= block[i];
37343  }
37344
37345  this._multiply();
37346};
37347
37348GHASH.prototype._multiply = function () {
37349  var Vi = toArray(this.h);
37350  var Zi = [0, 0, 0, 0];
37351  var j, xi, lsbVi;
37352  var i = -1;
37353
37354  while (++i < 128) {
37355    xi = (this.state[~~(i / 8)] & 1 << 7 - i % 8) !== 0;
37356
37357    if (xi) {
37358      // Z_i+1 = Z_i ^ V_i
37359      Zi[0] ^= Vi[0];
37360      Zi[1] ^= Vi[1];
37361      Zi[2] ^= Vi[2];
37362      Zi[3] ^= Vi[3];
37363    } // Store the value of LSB(V_i)
37364
37365
37366    lsbVi = (Vi[3] & 1) !== 0; // V_i+1 = V_i >> 1
37367
37368    for (j = 3; j > 0; j--) {
37369      Vi[j] = Vi[j] >>> 1 | (Vi[j - 1] & 1) << 31;
37370    }
37371
37372    Vi[0] = Vi[0] >>> 1; // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
37373
37374    if (lsbVi) {
37375      Vi[0] = Vi[0] ^ 0xe1 << 24;
37376    }
37377  }
37378
37379  this.state = fromArray(Zi);
37380};
37381
37382GHASH.prototype.update = function (buf) {
37383  this.cache = Buffer.concat([this.cache, buf]);
37384  var chunk;
37385
37386  while (this.cache.length >= 16) {
37387    chunk = this.cache.slice(0, 16);
37388    this.cache = this.cache.slice(16);
37389    this.ghash(chunk);
37390  }
37391};
37392
37393GHASH.prototype.final = function (abl, bl) {
37394  if (this.cache.length) {
37395    this.ghash(Buffer.concat([this.cache, ZEROES], 16));
37396  }
37397
37398  this.ghash(fromArray([0, abl, 0, bl]));
37399  return this.state;
37400};
37401
37402module.exports = GHASH;
37403
37404},{"safe-buffer":494}],192:[function(require,module,exports){
37405"use strict";
37406
37407function incr32(iv) {
37408  var len = iv.length;
37409  var item;
37410
37411  while (len--) {
37412    item = iv.readUInt8(len);
37413
37414    if (item === 255) {
37415      iv.writeUInt8(0, len);
37416    } else {
37417      item++;
37418      iv.writeUInt8(item, len);
37419      break;
37420    }
37421  }
37422}
37423
37424module.exports = incr32;
37425
37426},{}],193:[function(require,module,exports){
37427"use strict";
37428
37429var xor = require('buffer-xor');
37430
37431exports.encrypt = function (self, block) {
37432  var data = xor(block, self._prev);
37433  self._prev = self._cipher.encryptBlock(data);
37434  return self._prev;
37435};
37436
37437exports.decrypt = function (self, block) {
37438  var pad = self._prev;
37439  self._prev = block;
37440
37441  var out = self._cipher.decryptBlock(block);
37442
37443  return xor(out, pad);
37444};
37445
37446},{"buffer-xor":217}],194:[function(require,module,exports){
37447"use strict";
37448
37449var Buffer = require('safe-buffer').Buffer;
37450
37451var xor = require('buffer-xor');
37452
37453function encryptStart(self, data, decrypt) {
37454  var len = data.length;
37455  var out = xor(data, self._cache);
37456  self._cache = self._cache.slice(len);
37457  self._prev = Buffer.concat([self._prev, decrypt ? data : out]);
37458  return out;
37459}
37460
37461exports.encrypt = function (self, data, decrypt) {
37462  var out = Buffer.allocUnsafe(0);
37463  var len;
37464
37465  while (data.length) {
37466    if (self._cache.length === 0) {
37467      self._cache = self._cipher.encryptBlock(self._prev);
37468      self._prev = Buffer.allocUnsafe(0);
37469    }
37470
37471    if (self._cache.length <= data.length) {
37472      len = self._cache.length;
37473      out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)]);
37474      data = data.slice(len);
37475    } else {
37476      out = Buffer.concat([out, encryptStart(self, data, decrypt)]);
37477      break;
37478    }
37479  }
37480
37481  return out;
37482};
37483
37484},{"buffer-xor":217,"safe-buffer":494}],195:[function(require,module,exports){
37485"use strict";
37486
37487var Buffer = require('safe-buffer').Buffer;
37488
37489function encryptByte(self, byteParam, decrypt) {
37490  var pad;
37491  var i = -1;
37492  var len = 8;
37493  var out = 0;
37494  var bit, value;
37495
37496  while (++i < len) {
37497    pad = self._cipher.encryptBlock(self._prev);
37498    bit = byteParam & 1 << 7 - i ? 0x80 : 0;
37499    value = pad[0] ^ bit;
37500    out += (value & 0x80) >> i % 8;
37501    self._prev = shiftIn(self._prev, decrypt ? bit : value);
37502  }
37503
37504  return out;
37505}
37506
37507function shiftIn(buffer, value) {
37508  var len = buffer.length;
37509  var i = -1;
37510  var out = Buffer.allocUnsafe(buffer.length);
37511  buffer = Buffer.concat([buffer, Buffer.from([value])]);
37512
37513  while (++i < len) {
37514    out[i] = buffer[i] << 1 | buffer[i + 1] >> 7;
37515  }
37516
37517  return out;
37518}
37519
37520exports.encrypt = function (self, chunk, decrypt) {
37521  var len = chunk.length;
37522  var out = Buffer.allocUnsafe(len);
37523  var i = -1;
37524
37525  while (++i < len) {
37526    out[i] = encryptByte(self, chunk[i], decrypt);
37527  }
37528
37529  return out;
37530};
37531
37532},{"safe-buffer":494}],196:[function(require,module,exports){
37533"use strict";
37534
37535var Buffer = require('safe-buffer').Buffer;
37536
37537function encryptByte(self, byteParam, decrypt) {
37538  var pad = self._cipher.encryptBlock(self._prev);
37539
37540  var out = pad[0] ^ byteParam;
37541  self._prev = Buffer.concat([self._prev.slice(1), Buffer.from([decrypt ? byteParam : out])]);
37542  return out;
37543}
37544
37545exports.encrypt = function (self, chunk, decrypt) {
37546  var len = chunk.length;
37547  var out = Buffer.allocUnsafe(len);
37548  var i = -1;
37549
37550  while (++i < len) {
37551    out[i] = encryptByte(self, chunk[i], decrypt);
37552  }
37553
37554  return out;
37555};
37556
37557},{"safe-buffer":494}],197:[function(require,module,exports){
37558"use strict";
37559
37560var xor = require('buffer-xor');
37561
37562var Buffer = require('safe-buffer').Buffer;
37563
37564var incr32 = require('../incr32');
37565
37566function getBlock(self) {
37567  var out = self._cipher.encryptBlockRaw(self._prev);
37568
37569  incr32(self._prev);
37570  return out;
37571}
37572
37573var blockSize = 16;
37574
37575exports.encrypt = function (self, chunk) {
37576  var chunkNum = Math.ceil(chunk.length / blockSize);
37577  var start = self._cache.length;
37578  self._cache = Buffer.concat([self._cache, Buffer.allocUnsafe(chunkNum * blockSize)]);
37579
37580  for (var i = 0; i < chunkNum; i++) {
37581    var out = getBlock(self);
37582    var offset = start + i * blockSize;
37583
37584    self._cache.writeUInt32BE(out[0], offset + 0);
37585
37586    self._cache.writeUInt32BE(out[1], offset + 4);
37587
37588    self._cache.writeUInt32BE(out[2], offset + 8);
37589
37590    self._cache.writeUInt32BE(out[3], offset + 12);
37591  }
37592
37593  var pad = self._cache.slice(0, chunk.length);
37594
37595  self._cache = self._cache.slice(chunk.length);
37596  return xor(chunk, pad);
37597};
37598
37599},{"../incr32":192,"buffer-xor":217,"safe-buffer":494}],198:[function(require,module,exports){
37600"use strict";
37601
37602exports.encrypt = function (self, block) {
37603  return self._cipher.encryptBlock(block);
37604};
37605
37606exports.decrypt = function (self, block) {
37607  return self._cipher.decryptBlock(block);
37608};
37609
37610},{}],199:[function(require,module,exports){
37611"use strict";
37612
37613var modeModules = {
37614  ECB: require('./ecb'),
37615  CBC: require('./cbc'),
37616  CFB: require('./cfb'),
37617  CFB8: require('./cfb8'),
37618  CFB1: require('./cfb1'),
37619  OFB: require('./ofb'),
37620  CTR: require('./ctr'),
37621  GCM: require('./ctr')
37622};
37623
37624var modes = require('./list.json');
37625
37626for (var key in modes) {
37627  modes[key].module = modeModules[modes[key].mode];
37628}
37629
37630module.exports = modes;
37631
37632},{"./cbc":193,"./cfb":194,"./cfb1":195,"./cfb8":196,"./ctr":197,"./ecb":198,"./list.json":200,"./ofb":201}],200:[function(require,module,exports){
37633module.exports={
37634  "aes-128-ecb": {
37635    "cipher": "AES",
37636    "key": 128,
37637    "iv": 0,
37638    "mode": "ECB",
37639    "type": "block"
37640  },
37641  "aes-192-ecb": {
37642    "cipher": "AES",
37643    "key": 192,
37644    "iv": 0,
37645    "mode": "ECB",
37646    "type": "block"
37647  },
37648  "aes-256-ecb": {
37649    "cipher": "AES",
37650    "key": 256,
37651    "iv": 0,
37652    "mode": "ECB",
37653    "type": "block"
37654  },
37655  "aes-128-cbc": {
37656    "cipher": "AES",
37657    "key": 128,
37658    "iv": 16,
37659    "mode": "CBC",
37660    "type": "block"
37661  },
37662  "aes-192-cbc": {
37663    "cipher": "AES",
37664    "key": 192,
37665    "iv": 16,
37666    "mode": "CBC",
37667    "type": "block"
37668  },
37669  "aes-256-cbc": {
37670    "cipher": "AES",
37671    "key": 256,
37672    "iv": 16,
37673    "mode": "CBC",
37674    "type": "block"
37675  },
37676  "aes128": {
37677    "cipher": "AES",
37678    "key": 128,
37679    "iv": 16,
37680    "mode": "CBC",
37681    "type": "block"
37682  },
37683  "aes192": {
37684    "cipher": "AES",
37685    "key": 192,
37686    "iv": 16,
37687    "mode": "CBC",
37688    "type": "block"
37689  },
37690  "aes256": {
37691    "cipher": "AES",
37692    "key": 256,
37693    "iv": 16,
37694    "mode": "CBC",
37695    "type": "block"
37696  },
37697  "aes-128-cfb": {
37698    "cipher": "AES",
37699    "key": 128,
37700    "iv": 16,
37701    "mode": "CFB",
37702    "type": "stream"
37703  },
37704  "aes-192-cfb": {
37705    "cipher": "AES",
37706    "key": 192,
37707    "iv": 16,
37708    "mode": "CFB",
37709    "type": "stream"
37710  },
37711  "aes-256-cfb": {
37712    "cipher": "AES",
37713    "key": 256,
37714    "iv": 16,
37715    "mode": "CFB",
37716    "type": "stream"
37717  },
37718  "aes-128-cfb8": {
37719    "cipher": "AES",
37720    "key": 128,
37721    "iv": 16,
37722    "mode": "CFB8",
37723    "type": "stream"
37724  },
37725  "aes-192-cfb8": {
37726    "cipher": "AES",
37727    "key": 192,
37728    "iv": 16,
37729    "mode": "CFB8",
37730    "type": "stream"
37731  },
37732  "aes-256-cfb8": {
37733    "cipher": "AES",
37734    "key": 256,
37735    "iv": 16,
37736    "mode": "CFB8",
37737    "type": "stream"
37738  },
37739  "aes-128-cfb1": {
37740    "cipher": "AES",
37741    "key": 128,
37742    "iv": 16,
37743    "mode": "CFB1",
37744    "type": "stream"
37745  },
37746  "aes-192-cfb1": {
37747    "cipher": "AES",
37748    "key": 192,
37749    "iv": 16,
37750    "mode": "CFB1",
37751    "type": "stream"
37752  },
37753  "aes-256-cfb1": {
37754    "cipher": "AES",
37755    "key": 256,
37756    "iv": 16,
37757    "mode": "CFB1",
37758    "type": "stream"
37759  },
37760  "aes-128-ofb": {
37761    "cipher": "AES",
37762    "key": 128,
37763    "iv": 16,
37764    "mode": "OFB",
37765    "type": "stream"
37766  },
37767  "aes-192-ofb": {
37768    "cipher": "AES",
37769    "key": 192,
37770    "iv": 16,
37771    "mode": "OFB",
37772    "type": "stream"
37773  },
37774  "aes-256-ofb": {
37775    "cipher": "AES",
37776    "key": 256,
37777    "iv": 16,
37778    "mode": "OFB",
37779    "type": "stream"
37780  },
37781  "aes-128-ctr": {
37782    "cipher": "AES",
37783    "key": 128,
37784    "iv": 16,
37785    "mode": "CTR",
37786    "type": "stream"
37787  },
37788  "aes-192-ctr": {
37789    "cipher": "AES",
37790    "key": 192,
37791    "iv": 16,
37792    "mode": "CTR",
37793    "type": "stream"
37794  },
37795  "aes-256-ctr": {
37796    "cipher": "AES",
37797    "key": 256,
37798    "iv": 16,
37799    "mode": "CTR",
37800    "type": "stream"
37801  },
37802  "aes-128-gcm": {
37803    "cipher": "AES",
37804    "key": 128,
37805    "iv": 12,
37806    "mode": "GCM",
37807    "type": "auth"
37808  },
37809  "aes-192-gcm": {
37810    "cipher": "AES",
37811    "key": 192,
37812    "iv": 12,
37813    "mode": "GCM",
37814    "type": "auth"
37815  },
37816  "aes-256-gcm": {
37817    "cipher": "AES",
37818    "key": 256,
37819    "iv": 12,
37820    "mode": "GCM",
37821    "type": "auth"
37822  }
37823}
37824
37825},{}],201:[function(require,module,exports){
37826(function (Buffer){
37827"use strict";
37828
37829var xor = require('buffer-xor');
37830
37831function getBlock(self) {
37832  self._prev = self._cipher.encryptBlock(self._prev);
37833  return self._prev;
37834}
37835
37836exports.encrypt = function (self, chunk) {
37837  while (self._cache.length < chunk.length) {
37838    self._cache = Buffer.concat([self._cache, getBlock(self)]);
37839  }
37840
37841  var pad = self._cache.slice(0, chunk.length);
37842
37843  self._cache = self._cache.slice(chunk.length);
37844  return xor(chunk, pad);
37845};
37846
37847}).call(this,require("buffer").Buffer)
37848
37849},{"buffer":216,"buffer-xor":217}],202:[function(require,module,exports){
37850"use strict";
37851
37852var aes = require('./aes');
37853
37854var Buffer = require('safe-buffer').Buffer;
37855
37856var Transform = require('cipher-base');
37857
37858var inherits = require('inherits');
37859
37860function StreamCipher(mode, key, iv, decrypt) {
37861  Transform.call(this);
37862  this._cipher = new aes.AES(key);
37863  this._prev = Buffer.from(iv);
37864  this._cache = Buffer.allocUnsafe(0);
37865  this._secCache = Buffer.allocUnsafe(0);
37866  this._decrypt = decrypt;
37867  this._mode = mode;
37868}
37869
37870inherits(StreamCipher, Transform);
37871
37872StreamCipher.prototype._update = function (chunk) {
37873  return this._mode.encrypt(this, chunk, this._decrypt);
37874};
37875
37876StreamCipher.prototype._final = function () {
37877  this._cipher.scrub();
37878};
37879
37880module.exports = StreamCipher;
37881
37882},{"./aes":186,"cipher-base":218,"inherits":387,"safe-buffer":494}],203:[function(require,module,exports){
37883"use strict";
37884
37885var DES = require('browserify-des');
37886
37887var aes = require('browserify-aes/browser');
37888
37889var aesModes = require('browserify-aes/modes');
37890
37891var desModes = require('browserify-des/modes');
37892
37893var ebtk = require('evp_bytestokey');
37894
37895function createCipher(suite, password) {
37896  suite = suite.toLowerCase();
37897  var keyLen, ivLen;
37898
37899  if (aesModes[suite]) {
37900    keyLen = aesModes[suite].key;
37901    ivLen = aesModes[suite].iv;
37902  } else if (desModes[suite]) {
37903    keyLen = desModes[suite].key * 8;
37904    ivLen = desModes[suite].iv;
37905  } else {
37906    throw new TypeError('invalid suite type');
37907  }
37908
37909  var keys = ebtk(password, false, keyLen, ivLen);
37910  return createCipheriv(suite, keys.key, keys.iv);
37911}
37912
37913function createDecipher(suite, password) {
37914  suite = suite.toLowerCase();
37915  var keyLen, ivLen;
37916
37917  if (aesModes[suite]) {
37918    keyLen = aesModes[suite].key;
37919    ivLen = aesModes[suite].iv;
37920  } else if (desModes[suite]) {
37921    keyLen = desModes[suite].key * 8;
37922    ivLen = desModes[suite].iv;
37923  } else {
37924    throw new TypeError('invalid suite type');
37925  }
37926
37927  var keys = ebtk(password, false, keyLen, ivLen);
37928  return createDecipheriv(suite, keys.key, keys.iv);
37929}
37930
37931function createCipheriv(suite, key, iv) {
37932  suite = suite.toLowerCase();
37933  if (aesModes[suite]) return aes.createCipheriv(suite, key, iv);
37934  if (desModes[suite]) return new DES({
37935    key: key,
37936    iv: iv,
37937    mode: suite
37938  });
37939  throw new TypeError('invalid suite type');
37940}
37941
37942function createDecipheriv(suite, key, iv) {
37943  suite = suite.toLowerCase();
37944  if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv);
37945  if (desModes[suite]) return new DES({
37946    key: key,
37947    iv: iv,
37948    mode: suite,
37949    decrypt: true
37950  });
37951  throw new TypeError('invalid suite type');
37952}
37953
37954function getCiphers() {
37955  return Object.keys(desModes).concat(aes.getCiphers());
37956}
37957
37958exports.createCipher = exports.Cipher = createCipher;
37959exports.createCipheriv = exports.Cipheriv = createCipheriv;
37960exports.createDecipher = exports.Decipher = createDecipher;
37961exports.createDecipheriv = exports.Decipheriv = createDecipheriv;
37962exports.listCiphers = exports.getCiphers = getCiphers;
37963
37964},{"browserify-aes/browser":188,"browserify-aes/modes":199,"browserify-des":204,"browserify-des/modes":205,"evp_bytestokey":368}],204:[function(require,module,exports){
37965"use strict";
37966
37967var CipherBase = require('cipher-base');
37968
37969var des = require('des.js');
37970
37971var inherits = require('inherits');
37972
37973var Buffer = require('safe-buffer').Buffer;
37974
37975var modes = {
37976  'des-ede3-cbc': des.CBC.instantiate(des.EDE),
37977  'des-ede3': des.EDE,
37978  'des-ede-cbc': des.CBC.instantiate(des.EDE),
37979  'des-ede': des.EDE,
37980  'des-cbc': des.CBC.instantiate(des.DES),
37981  'des-ecb': des.DES
37982};
37983modes.des = modes['des-cbc'];
37984modes.des3 = modes['des-ede3-cbc'];
37985module.exports = DES;
37986inherits(DES, CipherBase);
37987
37988function DES(opts) {
37989  CipherBase.call(this);
37990  var modeName = opts.mode.toLowerCase();
37991  var mode = modes[modeName];
37992  var type;
37993
37994  if (opts.decrypt) {
37995    type = 'decrypt';
37996  } else {
37997    type = 'encrypt';
37998  }
37999
38000  var key = opts.key;
38001
38002  if (!Buffer.isBuffer(key)) {
38003    key = Buffer.from(key);
38004  }
38005
38006  if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
38007    key = Buffer.concat([key, key.slice(0, 8)]);
38008  }
38009
38010  var iv = opts.iv;
38011
38012  if (!Buffer.isBuffer(iv)) {
38013    iv = Buffer.from(iv);
38014  }
38015
38016  this._des = mode.create({
38017    key: key,
38018    iv: iv,
38019    type: type
38020  });
38021}
38022
38023DES.prototype._update = function (data) {
38024  return Buffer.from(this._des.update(data));
38025};
38026
38027DES.prototype._final = function () {
38028  return Buffer.from(this._des.final());
38029};
38030
38031},{"cipher-base":218,"des.js":339,"inherits":387,"safe-buffer":494}],205:[function(require,module,exports){
38032"use strict";
38033
38034exports['des-ecb'] = {
38035  key: 8,
38036  iv: 0
38037};
38038exports['des-cbc'] = exports.des = {
38039  key: 8,
38040  iv: 8
38041};
38042exports['des-ede3-cbc'] = exports.des3 = {
38043  key: 24,
38044  iv: 8
38045};
38046exports['des-ede3'] = {
38047  key: 24,
38048  iv: 0
38049};
38050exports['des-ede-cbc'] = {
38051  key: 16,
38052  iv: 8
38053};
38054exports['des-ede'] = {
38055  key: 16,
38056  iv: 0
38057};
38058
38059},{}],206:[function(require,module,exports){
38060(function (Buffer){
38061"use strict";
38062
38063var bn = require('bn.js');
38064
38065var randomBytes = require('randombytes');
38066
38067module.exports = crt;
38068
38069function blind(priv) {
38070  var r = getr(priv);
38071  var blinder = r.toRed(bn.mont(priv.modulus)).redPow(new bn(priv.publicExponent)).fromRed();
38072  return {
38073    blinder: blinder,
38074    unblinder: r.invm(priv.modulus)
38075  };
38076}
38077
38078function crt(msg, priv) {
38079  var blinds = blind(priv);
38080  var len = priv.modulus.byteLength();
38081  var mod = bn.mont(priv.modulus);
38082  var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
38083  var c1 = blinded.toRed(bn.mont(priv.prime1));
38084  var c2 = blinded.toRed(bn.mont(priv.prime2));
38085  var qinv = priv.coefficient;
38086  var p = priv.prime1;
38087  var q = priv.prime2;
38088  var m1 = c1.redPow(priv.exponent1);
38089  var m2 = c2.redPow(priv.exponent2);
38090  m1 = m1.fromRed();
38091  m2 = m2.fromRed();
38092  var h = m1.isub(m2).imul(qinv).umod(p);
38093  h.imul(q);
38094  m2.iadd(h);
38095  return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
38096}
38097
38098crt.getr = getr;
38099
38100function getr(priv) {
38101  var len = priv.modulus.byteLength();
38102  var r = new bn(randomBytes(len));
38103
38104  while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
38105    r = new bn(randomBytes(len));
38106  }
38107
38108  return r;
38109}
38110
38111}).call(this,require("buffer").Buffer)
38112
38113},{"bn.js":207,"buffer":216,"randombytes":475}],207:[function(require,module,exports){
38114arguments[4][181][0].apply(exports,arguments)
38115},{"buffer":185,"dup":181}],208:[function(require,module,exports){
38116"use strict";
38117
38118module.exports = require('./browser/algorithms.json');
38119
38120},{"./browser/algorithms.json":209}],209:[function(require,module,exports){
38121module.exports={
38122  "sha224WithRSAEncryption": {
38123    "sign": "rsa",
38124    "hash": "sha224",
38125    "id": "302d300d06096086480165030402040500041c"
38126  },
38127  "RSA-SHA224": {
38128    "sign": "ecdsa/rsa",
38129    "hash": "sha224",
38130    "id": "302d300d06096086480165030402040500041c"
38131  },
38132  "sha256WithRSAEncryption": {
38133    "sign": "rsa",
38134    "hash": "sha256",
38135    "id": "3031300d060960864801650304020105000420"
38136  },
38137  "RSA-SHA256": {
38138    "sign": "ecdsa/rsa",
38139    "hash": "sha256",
38140    "id": "3031300d060960864801650304020105000420"
38141  },
38142  "sha384WithRSAEncryption": {
38143    "sign": "rsa",
38144    "hash": "sha384",
38145    "id": "3041300d060960864801650304020205000430"
38146  },
38147  "RSA-SHA384": {
38148    "sign": "ecdsa/rsa",
38149    "hash": "sha384",
38150    "id": "3041300d060960864801650304020205000430"
38151  },
38152  "sha512WithRSAEncryption": {
38153    "sign": "rsa",
38154    "hash": "sha512",
38155    "id": "3051300d060960864801650304020305000440"
38156  },
38157  "RSA-SHA512": {
38158    "sign": "ecdsa/rsa",
38159    "hash": "sha512",
38160    "id": "3051300d060960864801650304020305000440"
38161  },
38162  "RSA-SHA1": {
38163    "sign": "rsa",
38164    "hash": "sha1",
38165    "id": "3021300906052b0e03021a05000414"
38166  },
38167  "ecdsa-with-SHA1": {
38168    "sign": "ecdsa",
38169    "hash": "sha1",
38170    "id": ""
38171  },
38172  "sha256": {
38173    "sign": "ecdsa",
38174    "hash": "sha256",
38175    "id": ""
38176  },
38177  "sha224": {
38178    "sign": "ecdsa",
38179    "hash": "sha224",
38180    "id": ""
38181  },
38182  "sha384": {
38183    "sign": "ecdsa",
38184    "hash": "sha384",
38185    "id": ""
38186  },
38187  "sha512": {
38188    "sign": "ecdsa",
38189    "hash": "sha512",
38190    "id": ""
38191  },
38192  "DSA-SHA": {
38193    "sign": "dsa",
38194    "hash": "sha1",
38195    "id": ""
38196  },
38197  "DSA-SHA1": {
38198    "sign": "dsa",
38199    "hash": "sha1",
38200    "id": ""
38201  },
38202  "DSA": {
38203    "sign": "dsa",
38204    "hash": "sha1",
38205    "id": ""
38206  },
38207  "DSA-WITH-SHA224": {
38208    "sign": "dsa",
38209    "hash": "sha224",
38210    "id": ""
38211  },
38212  "DSA-SHA224": {
38213    "sign": "dsa",
38214    "hash": "sha224",
38215    "id": ""
38216  },
38217  "DSA-WITH-SHA256": {
38218    "sign": "dsa",
38219    "hash": "sha256",
38220    "id": ""
38221  },
38222  "DSA-SHA256": {
38223    "sign": "dsa",
38224    "hash": "sha256",
38225    "id": ""
38226  },
38227  "DSA-WITH-SHA384": {
38228    "sign": "dsa",
38229    "hash": "sha384",
38230    "id": ""
38231  },
38232  "DSA-SHA384": {
38233    "sign": "dsa",
38234    "hash": "sha384",
38235    "id": ""
38236  },
38237  "DSA-WITH-SHA512": {
38238    "sign": "dsa",
38239    "hash": "sha512",
38240    "id": ""
38241  },
38242  "DSA-SHA512": {
38243    "sign": "dsa",
38244    "hash": "sha512",
38245    "id": ""
38246  },
38247  "DSA-RIPEMD160": {
38248    "sign": "dsa",
38249    "hash": "rmd160",
38250    "id": ""
38251  },
38252  "ripemd160WithRSA": {
38253    "sign": "rsa",
38254    "hash": "rmd160",
38255    "id": "3021300906052b2403020105000414"
38256  },
38257  "RSA-RIPEMD160": {
38258    "sign": "rsa",
38259    "hash": "rmd160",
38260    "id": "3021300906052b2403020105000414"
38261  },
38262  "md5WithRSAEncryption": {
38263    "sign": "rsa",
38264    "hash": "md5",
38265    "id": "3020300c06082a864886f70d020505000410"
38266  },
38267  "RSA-MD5": {
38268    "sign": "rsa",
38269    "hash": "md5",
38270    "id": "3020300c06082a864886f70d020505000410"
38271  }
38272}
38273
38274},{}],210:[function(require,module,exports){
38275module.exports={
38276  "1.3.132.0.10": "secp256k1",
38277  "1.3.132.0.33": "p224",
38278  "1.2.840.10045.3.1.1": "p192",
38279  "1.2.840.10045.3.1.7": "p256",
38280  "1.3.132.0.34": "p384",
38281  "1.3.132.0.35": "p521"
38282}
38283
38284},{}],211:[function(require,module,exports){
38285"use strict";
38286
38287var Buffer = require('safe-buffer').Buffer;
38288
38289var createHash = require('create-hash');
38290
38291var stream = require('readable-stream');
38292
38293var inherits = require('inherits');
38294
38295var sign = require('./sign');
38296
38297var verify = require('./verify');
38298
38299var algorithms = require('./algorithms.json');
38300
38301Object.keys(algorithms).forEach(function (key) {
38302  algorithms[key].id = Buffer.from(algorithms[key].id, 'hex');
38303  algorithms[key.toLowerCase()] = algorithms[key];
38304});
38305
38306function Sign(algorithm) {
38307  stream.Writable.call(this);
38308  var data = algorithms[algorithm];
38309  if (!data) throw new Error('Unknown message digest');
38310  this._hashType = data.hash;
38311  this._hash = createHash(data.hash);
38312  this._tag = data.id;
38313  this._signType = data.sign;
38314}
38315
38316inherits(Sign, stream.Writable);
38317
38318Sign.prototype._write = function _write(data, _, done) {
38319  this._hash.update(data);
38320
38321  done();
38322};
38323
38324Sign.prototype.update = function update(data, enc) {
38325  if (typeof data === 'string') data = Buffer.from(data, enc);
38326
38327  this._hash.update(data);
38328
38329  return this;
38330};
38331
38332Sign.prototype.sign = function signMethod(key, enc) {
38333  this.end();
38334
38335  var hash = this._hash.digest();
38336
38337  var sig = sign(hash, key, this._hashType, this._signType, this._tag);
38338  return enc ? sig.toString(enc) : sig;
38339};
38340
38341function Verify(algorithm) {
38342  stream.Writable.call(this);
38343  var data = algorithms[algorithm];
38344  if (!data) throw new Error('Unknown message digest');
38345  this._hash = createHash(data.hash);
38346  this._tag = data.id;
38347  this._signType = data.sign;
38348}
38349
38350inherits(Verify, stream.Writable);
38351
38352Verify.prototype._write = function _write(data, _, done) {
38353  this._hash.update(data);
38354
38355  done();
38356};
38357
38358Verify.prototype.update = function update(data, enc) {
38359  if (typeof data === 'string') data = Buffer.from(data, enc);
38360
38361  this._hash.update(data);
38362
38363  return this;
38364};
38365
38366Verify.prototype.verify = function verifyMethod(key, sig, enc) {
38367  if (typeof sig === 'string') sig = Buffer.from(sig, enc);
38368  this.end();
38369
38370  var hash = this._hash.digest();
38371
38372  return verify(sig, hash, key, this._signType, this._tag);
38373};
38374
38375function createSign(algorithm) {
38376  return new Sign(algorithm);
38377}
38378
38379function createVerify(algorithm) {
38380  return new Verify(algorithm);
38381}
38382
38383module.exports = {
38384  Sign: createSign,
38385  Verify: createVerify,
38386  createSign: createSign,
38387  createVerify: createVerify
38388};
38389
38390},{"./algorithms.json":209,"./sign":212,"./verify":213,"create-hash":331,"inherits":387,"readable-stream":491,"safe-buffer":214}],212:[function(require,module,exports){
38391"use strict";
38392
38393// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
38394var Buffer = require('safe-buffer').Buffer;
38395
38396var createHmac = require('create-hmac');
38397
38398var crt = require('browserify-rsa');
38399
38400var EC = require('elliptic').ec;
38401
38402var BN = require('bn.js');
38403
38404var parseKeys = require('parse-asn1');
38405
38406var curves = require('./curves.json');
38407
38408function sign(hash, key, hashType, signType, tag) {
38409  var priv = parseKeys(key);
38410
38411  if (priv.curve) {
38412    // rsa keys can be interpreted as ecdsa ones in openssl
38413    if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type');
38414    return ecSign(hash, priv);
38415  } else if (priv.type === 'dsa') {
38416    if (signType !== 'dsa') throw new Error('wrong private key type');
38417    return dsaSign(hash, priv, hashType);
38418  } else {
38419    if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type');
38420  }
38421
38422  hash = Buffer.concat([tag, hash]);
38423  var len = priv.modulus.byteLength();
38424  var pad = [0, 1];
38425
38426  while (hash.length + pad.length + 1 < len) {
38427    pad.push(0xff);
38428  }
38429
38430  pad.push(0x00);
38431  var i = -1;
38432
38433  while (++i < hash.length) {
38434    pad.push(hash[i]);
38435  }
38436
38437  var out = crt(pad, priv);
38438  return out;
38439}
38440
38441function ecSign(hash, priv) {
38442  var curveId = curves[priv.curve.join('.')];
38443  if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'));
38444  var curve = new EC(curveId);
38445  var key = curve.keyFromPrivate(priv.privateKey);
38446  var out = key.sign(hash);
38447  return Buffer.from(out.toDER());
38448}
38449
38450function dsaSign(hash, priv, algo) {
38451  var x = priv.params.priv_key;
38452  var p = priv.params.p;
38453  var q = priv.params.q;
38454  var g = priv.params.g;
38455  var r = new BN(0);
38456  var k;
38457  var H = bits2int(hash, q).mod(q);
38458  var s = false;
38459  var kv = getKey(x, q, hash, algo);
38460
38461  while (s === false) {
38462    k = makeKey(q, kv, algo);
38463    r = makeR(g, k, p, q);
38464    s = k.invm(q).imul(H.add(x.mul(r))).mod(q);
38465
38466    if (s.cmpn(0) === 0) {
38467      s = false;
38468      r = new BN(0);
38469    }
38470  }
38471
38472  return toDER(r, s);
38473}
38474
38475function toDER(r, s) {
38476  r = r.toArray();
38477  s = s.toArray(); // Pad values
38478
38479  if (r[0] & 0x80) r = [0].concat(r);
38480  if (s[0] & 0x80) s = [0].concat(s);
38481  var total = r.length + s.length + 4;
38482  var res = [0x30, total, 0x02, r.length];
38483  res = res.concat(r, [0x02, s.length], s);
38484  return Buffer.from(res);
38485}
38486
38487function getKey(x, q, hash, algo) {
38488  x = Buffer.from(x.toArray());
38489
38490  if (x.length < q.byteLength()) {
38491    var zeros = Buffer.alloc(q.byteLength() - x.length);
38492    x = Buffer.concat([zeros, x]);
38493  }
38494
38495  var hlen = hash.length;
38496  var hbits = bits2octets(hash, q);
38497  var v = Buffer.alloc(hlen);
38498  v.fill(1);
38499  var k = Buffer.alloc(hlen);
38500  k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest();
38501  v = createHmac(algo, k).update(v).digest();
38502  k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest();
38503  v = createHmac(algo, k).update(v).digest();
38504  return {
38505    k: k,
38506    v: v
38507  };
38508}
38509
38510function bits2int(obits, q) {
38511  var bits = new BN(obits);
38512  var shift = (obits.length << 3) - q.bitLength();
38513  if (shift > 0) bits.ishrn(shift);
38514  return bits;
38515}
38516
38517function bits2octets(bits, q) {
38518  bits = bits2int(bits, q);
38519  bits = bits.mod(q);
38520  var out = Buffer.from(bits.toArray());
38521
38522  if (out.length < q.byteLength()) {
38523    var zeros = Buffer.alloc(q.byteLength() - out.length);
38524    out = Buffer.concat([zeros, out]);
38525  }
38526
38527  return out;
38528}
38529
38530function makeKey(q, kv, algo) {
38531  var t;
38532  var k;
38533
38534  do {
38535    t = Buffer.alloc(0);
38536
38537    while (t.length * 8 < q.bitLength()) {
38538      kv.v = createHmac(algo, kv.k).update(kv.v).digest();
38539      t = Buffer.concat([t, kv.v]);
38540    }
38541
38542    k = bits2int(t, q);
38543    kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest();
38544    kv.v = createHmac(algo, kv.k).update(kv.v).digest();
38545  } while (k.cmp(q) !== -1);
38546
38547  return k;
38548}
38549
38550function makeR(g, k, p, q) {
38551  return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q);
38552}
38553
38554module.exports = sign;
38555module.exports.getKey = getKey;
38556module.exports.makeKey = makeKey;
38557
38558},{"./curves.json":210,"bn.js":183,"browserify-rsa":206,"create-hmac":333,"elliptic":350,"parse-asn1":459,"safe-buffer":214}],213:[function(require,module,exports){
38559"use strict";
38560
38561// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
38562var Buffer = require('safe-buffer').Buffer;
38563
38564var BN = require('bn.js');
38565
38566var EC = require('elliptic').ec;
38567
38568var parseKeys = require('parse-asn1');
38569
38570var curves = require('./curves.json');
38571
38572function verify(sig, hash, key, signType, tag) {
38573  var pub = parseKeys(key);
38574
38575  if (pub.type === 'ec') {
38576    // rsa keys can be interpreted as ecdsa ones in openssl
38577    if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type');
38578    return ecVerify(sig, hash, pub);
38579  } else if (pub.type === 'dsa') {
38580    if (signType !== 'dsa') throw new Error('wrong public key type');
38581    return dsaVerify(sig, hash, pub);
38582  } else {
38583    if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type');
38584  }
38585
38586  hash = Buffer.concat([tag, hash]);
38587  var len = pub.modulus.byteLength();
38588  var pad = [1];
38589  var padNum = 0;
38590
38591  while (hash.length + pad.length + 2 < len) {
38592    pad.push(0xff);
38593    padNum++;
38594  }
38595
38596  pad.push(0x00);
38597  var i = -1;
38598
38599  while (++i < hash.length) {
38600    pad.push(hash[i]);
38601  }
38602
38603  pad = Buffer.from(pad);
38604  var red = BN.mont(pub.modulus);
38605  sig = new BN(sig).toRed(red);
38606  sig = sig.redPow(new BN(pub.publicExponent));
38607  sig = Buffer.from(sig.fromRed().toArray());
38608  var out = padNum < 8 ? 1 : 0;
38609  len = Math.min(sig.length, pad.length);
38610  if (sig.length !== pad.length) out = 1;
38611  i = -1;
38612
38613  while (++i < len) {
38614    out |= sig[i] ^ pad[i];
38615  }
38616
38617  return out === 0;
38618}
38619
38620function ecVerify(sig, hash, pub) {
38621  var curveId = curves[pub.data.algorithm.curve.join('.')];
38622  if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'));
38623  var curve = new EC(curveId);
38624  var pubkey = pub.data.subjectPrivateKey.data;
38625  return curve.verify(hash, sig, pubkey);
38626}
38627
38628function dsaVerify(sig, hash, pub) {
38629  var p = pub.data.p;
38630  var q = pub.data.q;
38631  var g = pub.data.g;
38632  var y = pub.data.pub_key;
38633  var unpacked = parseKeys.signature.decode(sig, 'der');
38634  var s = unpacked.s;
38635  var r = unpacked.r;
38636  checkValue(s, q);
38637  checkValue(r, q);
38638  var montp = BN.mont(p);
38639  var w = s.invm(q);
38640  var v = g.toRed(montp).redPow(new BN(hash).mul(w).mod(q)).fromRed().mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()).mod(p).mod(q);
38641  return v.cmp(r) === 0;
38642}
38643
38644function checkValue(b, q) {
38645  if (b.cmpn(0) <= 0) throw new Error('invalid sig');
38646  if (b.cmp(q) >= q) throw new Error('invalid sig');
38647}
38648
38649module.exports = verify;
38650
38651},{"./curves.json":210,"bn.js":183,"elliptic":350,"parse-asn1":459,"safe-buffer":214}],214:[function(require,module,exports){
38652"use strict";
38653
38654/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
38655
38656/* eslint-disable node/no-deprecated-api */
38657var buffer = require('buffer');
38658
38659var Buffer = buffer.Buffer; // alternative to using Object.keys for old browsers
38660
38661function copyProps(src, dst) {
38662  for (var key in src) {
38663    dst[key] = src[key];
38664  }
38665}
38666
38667if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
38668  module.exports = buffer;
38669} else {
38670  // Copy properties from require('buffer')
38671  copyProps(buffer, exports);
38672  exports.Buffer = SafeBuffer;
38673}
38674
38675function SafeBuffer(arg, encodingOrOffset, length) {
38676  return Buffer(arg, encodingOrOffset, length);
38677}
38678
38679SafeBuffer.prototype = Object.create(Buffer.prototype); // Copy static methods from Buffer
38680
38681copyProps(Buffer, SafeBuffer);
38682
38683SafeBuffer.from = function (arg, encodingOrOffset, length) {
38684  if (typeof arg === 'number') {
38685    throw new TypeError('Argument must not be a number');
38686  }
38687
38688  return Buffer(arg, encodingOrOffset, length);
38689};
38690
38691SafeBuffer.alloc = function (size, fill, encoding) {
38692  if (typeof size !== 'number') {
38693    throw new TypeError('Argument must be a number');
38694  }
38695
38696  var buf = Buffer(size);
38697
38698  if (fill !== undefined) {
38699    if (typeof encoding === 'string') {
38700      buf.fill(fill, encoding);
38701    } else {
38702      buf.fill(fill);
38703    }
38704  } else {
38705    buf.fill(0);
38706  }
38707
38708  return buf;
38709};
38710
38711SafeBuffer.allocUnsafe = function (size) {
38712  if (typeof size !== 'number') {
38713    throw new TypeError('Argument must be a number');
38714  }
38715
38716  return Buffer(size);
38717};
38718
38719SafeBuffer.allocUnsafeSlow = function (size) {
38720  if (typeof size !== 'number') {
38721    throw new TypeError('Argument must be a number');
38722  }
38723
38724  return buffer.SlowBuffer(size);
38725};
38726
38727},{"buffer":216}],215:[function(require,module,exports){
38728arguments[4][185][0].apply(exports,arguments)
38729},{"dup":185}],216:[function(require,module,exports){
38730(function (Buffer){
38731/*!
38732 * The buffer module from node.js, for the browser.
38733 *
38734 * @author   Feross Aboukhadijeh <https://feross.org>
38735 * @license  MIT
38736 */
38737
38738/* eslint-disable no-proto */
38739'use strict';
38740
38741function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
38742
38743var base64 = require('base64-js');
38744
38745var ieee754 = require('ieee754');
38746
38747exports.Buffer = Buffer;
38748exports.SlowBuffer = SlowBuffer;
38749exports.INSPECT_MAX_BYTES = 50;
38750var K_MAX_LENGTH = 0x7fffffff;
38751exports.kMaxLength = K_MAX_LENGTH;
38752/**
38753 * If `Buffer.TYPED_ARRAY_SUPPORT`:
38754 *   === true    Use Uint8Array implementation (fastest)
38755 *   === false   Print warning and recommend using `buffer` v4.x which has an Object
38756 *               implementation (most compatible, even IE6)
38757 *
38758 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
38759 * Opera 11.6+, iOS 4.2+.
38760 *
38761 * We report that the browser does not support typed arrays if the are not subclassable
38762 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
38763 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
38764 * for __proto__ and has a buggy typed array implementation.
38765 */
38766
38767Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
38768
38769if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && typeof console.error === 'function') {
38770  console.error('This browser lacks typed array (Uint8Array) support which is required by ' + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.');
38771}
38772
38773function typedArraySupport() {
38774  // Can typed array instances can be augmented?
38775  try {
38776    var arr = new Uint8Array(1);
38777    arr.__proto__ = {
38778      __proto__: Uint8Array.prototype,
38779      foo: function foo() {
38780        return 42;
38781      }
38782    };
38783    return arr.foo() === 42;
38784  } catch (e) {
38785    return false;
38786  }
38787}
38788
38789Object.defineProperty(Buffer.prototype, 'parent', {
38790  enumerable: true,
38791  get: function get() {
38792    if (!Buffer.isBuffer(this)) return undefined;
38793    return this.buffer;
38794  }
38795});
38796Object.defineProperty(Buffer.prototype, 'offset', {
38797  enumerable: true,
38798  get: function get() {
38799    if (!Buffer.isBuffer(this)) return undefined;
38800    return this.byteOffset;
38801  }
38802});
38803
38804function createBuffer(length) {
38805  if (length > K_MAX_LENGTH) {
38806    throw new RangeError('The value "' + length + '" is invalid for option "size"');
38807  } // Return an augmented `Uint8Array` instance
38808
38809
38810  var buf = new Uint8Array(length);
38811  buf.__proto__ = Buffer.prototype;
38812  return buf;
38813}
38814/**
38815 * The Buffer constructor returns instances of `Uint8Array` that have their
38816 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
38817 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
38818 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
38819 * returns a single octet.
38820 *
38821 * The `Uint8Array` prototype remains unmodified.
38822 */
38823
38824
38825function Buffer(arg, encodingOrOffset, length) {
38826  // Common case.
38827  if (typeof arg === 'number') {
38828    if (typeof encodingOrOffset === 'string') {
38829      throw new TypeError('The "string" argument must be of type string. Received type number');
38830    }
38831
38832    return allocUnsafe(arg);
38833  }
38834
38835  return from(arg, encodingOrOffset, length);
38836} // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
38837
38838
38839if (typeof Symbol !== 'undefined' && Symbol.species != null && Buffer[Symbol.species] === Buffer) {
38840  Object.defineProperty(Buffer, Symbol.species, {
38841    value: null,
38842    configurable: true,
38843    enumerable: false,
38844    writable: false
38845  });
38846}
38847
38848Buffer.poolSize = 8192; // not used by this implementation
38849
38850function from(value, encodingOrOffset, length) {
38851  if (typeof value === 'string') {
38852    return fromString(value, encodingOrOffset);
38853  }
38854
38855  if (ArrayBuffer.isView(value)) {
38856    return fromArrayLike(value);
38857  }
38858
38859  if (value == null) {
38860    throw TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value));
38861  }
38862
38863  if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
38864    return fromArrayBuffer(value, encodingOrOffset, length);
38865  }
38866
38867  if (typeof value === 'number') {
38868    throw new TypeError('The "value" argument must not be of type number. Received type number');
38869  }
38870
38871  var valueOf = value.valueOf && value.valueOf();
38872
38873  if (valueOf != null && valueOf !== value) {
38874    return Buffer.from(valueOf, encodingOrOffset, length);
38875  }
38876
38877  var b = fromObject(value);
38878  if (b) return b;
38879
38880  if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') {
38881    return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length);
38882  }
38883
38884  throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value));
38885}
38886/**
38887 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
38888 * if value is a number.
38889 * Buffer.from(str[, encoding])
38890 * Buffer.from(array)
38891 * Buffer.from(buffer)
38892 * Buffer.from(arrayBuffer[, byteOffset[, length]])
38893 **/
38894
38895
38896Buffer.from = function (value, encodingOrOffset, length) {
38897  return from(value, encodingOrOffset, length);
38898}; // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
38899// https://github.com/feross/buffer/pull/148
38900
38901
38902Buffer.prototype.__proto__ = Uint8Array.prototype;
38903Buffer.__proto__ = Uint8Array;
38904
38905function assertSize(size) {
38906  if (typeof size !== 'number') {
38907    throw new TypeError('"size" argument must be of type number');
38908  } else if (size < 0) {
38909    throw new RangeError('The value "' + size + '" is invalid for option "size"');
38910  }
38911}
38912
38913function alloc(size, fill, encoding) {
38914  assertSize(size);
38915
38916  if (size <= 0) {
38917    return createBuffer(size);
38918  }
38919
38920  if (fill !== undefined) {
38921    // Only pay attention to encoding if it's a string. This
38922    // prevents accidentally sending in a number that would
38923    // be interpretted as a start offset.
38924    return typeof encoding === 'string' ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
38925  }
38926
38927  return createBuffer(size);
38928}
38929/**
38930 * Creates a new filled Buffer instance.
38931 * alloc(size[, fill[, encoding]])
38932 **/
38933
38934
38935Buffer.alloc = function (size, fill, encoding) {
38936  return alloc(size, fill, encoding);
38937};
38938
38939function allocUnsafe(size) {
38940  assertSize(size);
38941  return createBuffer(size < 0 ? 0 : checked(size) | 0);
38942}
38943/**
38944 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
38945 * */
38946
38947
38948Buffer.allocUnsafe = function (size) {
38949  return allocUnsafe(size);
38950};
38951/**
38952 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
38953 */
38954
38955
38956Buffer.allocUnsafeSlow = function (size) {
38957  return allocUnsafe(size);
38958};
38959
38960function fromString(string, encoding) {
38961  if (typeof encoding !== 'string' || encoding === '') {
38962    encoding = 'utf8';
38963  }
38964
38965  if (!Buffer.isEncoding(encoding)) {
38966    throw new TypeError('Unknown encoding: ' + encoding);
38967  }
38968
38969  var length = byteLength(string, encoding) | 0;
38970  var buf = createBuffer(length);
38971  var actual = buf.write(string, encoding);
38972
38973  if (actual !== length) {
38974    // Writing a hex string, for example, that contains invalid characters will
38975    // cause everything after the first invalid character to be ignored. (e.g.
38976    // 'abxxcd' will be treated as 'ab')
38977    buf = buf.slice(0, actual);
38978  }
38979
38980  return buf;
38981}
38982
38983function fromArrayLike(array) {
38984  var length = array.length < 0 ? 0 : checked(array.length) | 0;
38985  var buf = createBuffer(length);
38986
38987  for (var i = 0; i < length; i += 1) {
38988    buf[i] = array[i] & 255;
38989  }
38990
38991  return buf;
38992}
38993
38994function fromArrayBuffer(array, byteOffset, length) {
38995  if (byteOffset < 0 || array.byteLength < byteOffset) {
38996    throw new RangeError('"offset" is outside of buffer bounds');
38997  }
38998
38999  if (array.byteLength < byteOffset + (length || 0)) {
39000    throw new RangeError('"length" is outside of buffer bounds');
39001  }
39002
39003  var buf;
39004
39005  if (byteOffset === undefined && length === undefined) {
39006    buf = new Uint8Array(array);
39007  } else if (length === undefined) {
39008    buf = new Uint8Array(array, byteOffset);
39009  } else {
39010    buf = new Uint8Array(array, byteOffset, length);
39011  } // Return an augmented `Uint8Array` instance
39012
39013
39014  buf.__proto__ = Buffer.prototype;
39015  return buf;
39016}
39017
39018function fromObject(obj) {
39019  if (Buffer.isBuffer(obj)) {
39020    var len = checked(obj.length) | 0;
39021    var buf = createBuffer(len);
39022
39023    if (buf.length === 0) {
39024      return buf;
39025    }
39026
39027    obj.copy(buf, 0, 0, len);
39028    return buf;
39029  }
39030
39031  if (obj.length !== undefined) {
39032    if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
39033      return createBuffer(0);
39034    }
39035
39036    return fromArrayLike(obj);
39037  }
39038
39039  if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
39040    return fromArrayLike(obj.data);
39041  }
39042}
39043
39044function checked(length) {
39045  // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
39046  // length is NaN (which is otherwise coerced to zero.)
39047  if (length >= K_MAX_LENGTH) {
39048    throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes');
39049  }
39050
39051  return length | 0;
39052}
39053
39054function SlowBuffer(length) {
39055  if (+length != length) {
39056    // eslint-disable-line eqeqeq
39057    length = 0;
39058  }
39059
39060  return Buffer.alloc(+length);
39061}
39062
39063Buffer.isBuffer = function isBuffer(b) {
39064  return b != null && b._isBuffer === true && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false
39065};
39066
39067Buffer.compare = function compare(a, b) {
39068  if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
39069  if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
39070
39071  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
39072    throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
39073  }
39074
39075  if (a === b) return 0;
39076  var x = a.length;
39077  var y = b.length;
39078
39079  for (var i = 0, len = Math.min(x, y); i < len; ++i) {
39080    if (a[i] !== b[i]) {
39081      x = a[i];
39082      y = b[i];
39083      break;
39084    }
39085  }
39086
39087  if (x < y) return -1;
39088  if (y < x) return 1;
39089  return 0;
39090};
39091
39092Buffer.isEncoding = function isEncoding(encoding) {
39093  switch (String(encoding).toLowerCase()) {
39094    case 'hex':
39095    case 'utf8':
39096    case 'utf-8':
39097    case 'ascii':
39098    case 'latin1':
39099    case 'binary':
39100    case 'base64':
39101    case 'ucs2':
39102    case 'ucs-2':
39103    case 'utf16le':
39104    case 'utf-16le':
39105      return true;
39106
39107    default:
39108      return false;
39109  }
39110};
39111
39112Buffer.concat = function concat(list, length) {
39113  if (!Array.isArray(list)) {
39114    throw new TypeError('"list" argument must be an Array of Buffers');
39115  }
39116
39117  if (list.length === 0) {
39118    return Buffer.alloc(0);
39119  }
39120
39121  var i;
39122
39123  if (length === undefined) {
39124    length = 0;
39125
39126    for (i = 0; i < list.length; ++i) {
39127      length += list[i].length;
39128    }
39129  }
39130
39131  var buffer = Buffer.allocUnsafe(length);
39132  var pos = 0;
39133
39134  for (i = 0; i < list.length; ++i) {
39135    var buf = list[i];
39136
39137    if (isInstance(buf, Uint8Array)) {
39138      buf = Buffer.from(buf);
39139    }
39140
39141    if (!Buffer.isBuffer(buf)) {
39142      throw new TypeError('"list" argument must be an Array of Buffers');
39143    }
39144
39145    buf.copy(buffer, pos);
39146    pos += buf.length;
39147  }
39148
39149  return buffer;
39150};
39151
39152function byteLength(string, encoding) {
39153  if (Buffer.isBuffer(string)) {
39154    return string.length;
39155  }
39156
39157  if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
39158    return string.byteLength;
39159  }
39160
39161  if (typeof string !== 'string') {
39162    throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + 'Received type ' + _typeof(string));
39163  }
39164
39165  var len = string.length;
39166  var mustMatch = arguments.length > 2 && arguments[2] === true;
39167  if (!mustMatch && len === 0) return 0; // Use a for loop to avoid recursion
39168
39169  var loweredCase = false;
39170
39171  for (;;) {
39172    switch (encoding) {
39173      case 'ascii':
39174      case 'latin1':
39175      case 'binary':
39176        return len;
39177
39178      case 'utf8':
39179      case 'utf-8':
39180        return utf8ToBytes(string).length;
39181
39182      case 'ucs2':
39183      case 'ucs-2':
39184      case 'utf16le':
39185      case 'utf-16le':
39186        return len * 2;
39187
39188      case 'hex':
39189        return len >>> 1;
39190
39191      case 'base64':
39192        return base64ToBytes(string).length;
39193
39194      default:
39195        if (loweredCase) {
39196          return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8
39197        }
39198
39199        encoding = ('' + encoding).toLowerCase();
39200        loweredCase = true;
39201    }
39202  }
39203}
39204
39205Buffer.byteLength = byteLength;
39206
39207function slowToString(encoding, start, end) {
39208  var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
39209  // property of a typed array.
39210  // This behaves neither like String nor Uint8Array in that we set start/end
39211  // to their upper/lower bounds if the value passed is out of range.
39212  // undefined is handled specially as per ECMA-262 6th Edition,
39213  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
39214
39215  if (start === undefined || start < 0) {
39216    start = 0;
39217  } // Return early if start > this.length. Done here to prevent potential uint32
39218  // coercion fail below.
39219
39220
39221  if (start > this.length) {
39222    return '';
39223  }
39224
39225  if (end === undefined || end > this.length) {
39226    end = this.length;
39227  }
39228
39229  if (end <= 0) {
39230    return '';
39231  } // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
39232
39233
39234  end >>>= 0;
39235  start >>>= 0;
39236
39237  if (end <= start) {
39238    return '';
39239  }
39240
39241  if (!encoding) encoding = 'utf8';
39242
39243  while (true) {
39244    switch (encoding) {
39245      case 'hex':
39246        return hexSlice(this, start, end);
39247
39248      case 'utf8':
39249      case 'utf-8':
39250        return utf8Slice(this, start, end);
39251
39252      case 'ascii':
39253        return asciiSlice(this, start, end);
39254
39255      case 'latin1':
39256      case 'binary':
39257        return latin1Slice(this, start, end);
39258
39259      case 'base64':
39260        return base64Slice(this, start, end);
39261
39262      case 'ucs2':
39263      case 'ucs-2':
39264      case 'utf16le':
39265      case 'utf-16le':
39266        return utf16leSlice(this, start, end);
39267
39268      default:
39269        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
39270        encoding = (encoding + '').toLowerCase();
39271        loweredCase = true;
39272    }
39273  }
39274} // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
39275// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
39276// reliably in a browserify context because there could be multiple different
39277// copies of the 'buffer' package in use. This method works even for Buffer
39278// instances that were created from another copy of the `buffer` package.
39279// See: https://github.com/feross/buffer/issues/154
39280
39281
39282Buffer.prototype._isBuffer = true;
39283
39284function swap(b, n, m) {
39285  var i = b[n];
39286  b[n] = b[m];
39287  b[m] = i;
39288}
39289
39290Buffer.prototype.swap16 = function swap16() {
39291  var len = this.length;
39292
39293  if (len % 2 !== 0) {
39294    throw new RangeError('Buffer size must be a multiple of 16-bits');
39295  }
39296
39297  for (var i = 0; i < len; i += 2) {
39298    swap(this, i, i + 1);
39299  }
39300
39301  return this;
39302};
39303
39304Buffer.prototype.swap32 = function swap32() {
39305  var len = this.length;
39306
39307  if (len % 4 !== 0) {
39308    throw new RangeError('Buffer size must be a multiple of 32-bits');
39309  }
39310
39311  for (var i = 0; i < len; i += 4) {
39312    swap(this, i, i + 3);
39313    swap(this, i + 1, i + 2);
39314  }
39315
39316  return this;
39317};
39318
39319Buffer.prototype.swap64 = function swap64() {
39320  var len = this.length;
39321
39322  if (len % 8 !== 0) {
39323    throw new RangeError('Buffer size must be a multiple of 64-bits');
39324  }
39325
39326  for (var i = 0; i < len; i += 8) {
39327    swap(this, i, i + 7);
39328    swap(this, i + 1, i + 6);
39329    swap(this, i + 2, i + 5);
39330    swap(this, i + 3, i + 4);
39331  }
39332
39333  return this;
39334};
39335
39336Buffer.prototype.toString = function toString() {
39337  var length = this.length;
39338  if (length === 0) return '';
39339  if (arguments.length === 0) return utf8Slice(this, 0, length);
39340  return slowToString.apply(this, arguments);
39341};
39342
39343Buffer.prototype.toLocaleString = Buffer.prototype.toString;
39344
39345Buffer.prototype.equals = function equals(b) {
39346  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer');
39347  if (this === b) return true;
39348  return Buffer.compare(this, b) === 0;
39349};
39350
39351Buffer.prototype.inspect = function inspect() {
39352  var str = '';
39353  var max = exports.INSPECT_MAX_BYTES;
39354  str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
39355  if (this.length > max) str += ' ... ';
39356  return '<Buffer ' + str + '>';
39357};
39358
39359Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
39360  if (isInstance(target, Uint8Array)) {
39361    target = Buffer.from(target, target.offset, target.byteLength);
39362  }
39363
39364  if (!Buffer.isBuffer(target)) {
39365    throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. ' + 'Received type ' + _typeof(target));
39366  }
39367
39368  if (start === undefined) {
39369    start = 0;
39370  }
39371
39372  if (end === undefined) {
39373    end = target ? target.length : 0;
39374  }
39375
39376  if (thisStart === undefined) {
39377    thisStart = 0;
39378  }
39379
39380  if (thisEnd === undefined) {
39381    thisEnd = this.length;
39382  }
39383
39384  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
39385    throw new RangeError('out of range index');
39386  }
39387
39388  if (thisStart >= thisEnd && start >= end) {
39389    return 0;
39390  }
39391
39392  if (thisStart >= thisEnd) {
39393    return -1;
39394  }
39395
39396  if (start >= end) {
39397    return 1;
39398  }
39399
39400  start >>>= 0;
39401  end >>>= 0;
39402  thisStart >>>= 0;
39403  thisEnd >>>= 0;
39404  if (this === target) return 0;
39405  var x = thisEnd - thisStart;
39406  var y = end - start;
39407  var len = Math.min(x, y);
39408  var thisCopy = this.slice(thisStart, thisEnd);
39409  var targetCopy = target.slice(start, end);
39410
39411  for (var i = 0; i < len; ++i) {
39412    if (thisCopy[i] !== targetCopy[i]) {
39413      x = thisCopy[i];
39414      y = targetCopy[i];
39415      break;
39416    }
39417  }
39418
39419  if (x < y) return -1;
39420  if (y < x) return 1;
39421  return 0;
39422}; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
39423// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
39424//
39425// Arguments:
39426// - buffer - a Buffer to search
39427// - val - a string, Buffer, or number
39428// - byteOffset - an index into `buffer`; will be clamped to an int32
39429// - encoding - an optional encoding, relevant is val is a string
39430// - dir - true for indexOf, false for lastIndexOf
39431
39432
39433function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
39434  // Empty buffer means no match
39435  if (buffer.length === 0) return -1; // Normalize byteOffset
39436
39437  if (typeof byteOffset === 'string') {
39438    encoding = byteOffset;
39439    byteOffset = 0;
39440  } else if (byteOffset > 0x7fffffff) {
39441    byteOffset = 0x7fffffff;
39442  } else if (byteOffset < -0x80000000) {
39443    byteOffset = -0x80000000;
39444  }
39445
39446  byteOffset = +byteOffset; // Coerce to Number.
39447
39448  if (numberIsNaN(byteOffset)) {
39449    // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
39450    byteOffset = dir ? 0 : buffer.length - 1;
39451  } // Normalize byteOffset: negative offsets start from the end of the buffer
39452
39453
39454  if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
39455
39456  if (byteOffset >= buffer.length) {
39457    if (dir) return -1;else byteOffset = buffer.length - 1;
39458  } else if (byteOffset < 0) {
39459    if (dir) byteOffset = 0;else return -1;
39460  } // Normalize val
39461
39462
39463  if (typeof val === 'string') {
39464    val = Buffer.from(val, encoding);
39465  } // Finally, search either indexOf (if dir is true) or lastIndexOf
39466
39467
39468  if (Buffer.isBuffer(val)) {
39469    // Special case: looking for empty string/buffer always fails
39470    if (val.length === 0) {
39471      return -1;
39472    }
39473
39474    return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
39475  } else if (typeof val === 'number') {
39476    val = val & 0xFF; // Search for a byte value [0-255]
39477
39478    if (typeof Uint8Array.prototype.indexOf === 'function') {
39479      if (dir) {
39480        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
39481      } else {
39482        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
39483      }
39484    }
39485
39486    return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
39487  }
39488
39489  throw new TypeError('val must be string, number or Buffer');
39490}
39491
39492function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
39493  var indexSize = 1;
39494  var arrLength = arr.length;
39495  var valLength = val.length;
39496
39497  if (encoding !== undefined) {
39498    encoding = String(encoding).toLowerCase();
39499
39500    if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') {
39501      if (arr.length < 2 || val.length < 2) {
39502        return -1;
39503      }
39504
39505      indexSize = 2;
39506      arrLength /= 2;
39507      valLength /= 2;
39508      byteOffset /= 2;
39509    }
39510  }
39511
39512  function read(buf, i) {
39513    if (indexSize === 1) {
39514      return buf[i];
39515    } else {
39516      return buf.readUInt16BE(i * indexSize);
39517    }
39518  }
39519
39520  var i;
39521
39522  if (dir) {
39523    var foundIndex = -1;
39524
39525    for (i = byteOffset; i < arrLength; i++) {
39526      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
39527        if (foundIndex === -1) foundIndex = i;
39528        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
39529      } else {
39530        if (foundIndex !== -1) i -= i - foundIndex;
39531        foundIndex = -1;
39532      }
39533    }
39534  } else {
39535    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
39536
39537    for (i = byteOffset; i >= 0; i--) {
39538      var found = true;
39539
39540      for (var j = 0; j < valLength; j++) {
39541        if (read(arr, i + j) !== read(val, j)) {
39542          found = false;
39543          break;
39544        }
39545      }
39546
39547      if (found) return i;
39548    }
39549  }
39550
39551  return -1;
39552}
39553
39554Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
39555  return this.indexOf(val, byteOffset, encoding) !== -1;
39556};
39557
39558Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
39559  return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
39560};
39561
39562Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
39563  return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
39564};
39565
39566function hexWrite(buf, string, offset, length) {
39567  offset = Number(offset) || 0;
39568  var remaining = buf.length - offset;
39569
39570  if (!length) {
39571    length = remaining;
39572  } else {
39573    length = Number(length);
39574
39575    if (length > remaining) {
39576      length = remaining;
39577    }
39578  }
39579
39580  var strLen = string.length;
39581
39582  if (length > strLen / 2) {
39583    length = strLen / 2;
39584  }
39585
39586  for (var i = 0; i < length; ++i) {
39587    var parsed = parseInt(string.substr(i * 2, 2), 16);
39588    if (numberIsNaN(parsed)) return i;
39589    buf[offset + i] = parsed;
39590  }
39591
39592  return i;
39593}
39594
39595function utf8Write(buf, string, offset, length) {
39596  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
39597}
39598
39599function asciiWrite(buf, string, offset, length) {
39600  return blitBuffer(asciiToBytes(string), buf, offset, length);
39601}
39602
39603function latin1Write(buf, string, offset, length) {
39604  return asciiWrite(buf, string, offset, length);
39605}
39606
39607function base64Write(buf, string, offset, length) {
39608  return blitBuffer(base64ToBytes(string), buf, offset, length);
39609}
39610
39611function ucs2Write(buf, string, offset, length) {
39612  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
39613}
39614
39615Buffer.prototype.write = function write(string, offset, length, encoding) {
39616  // Buffer#write(string)
39617  if (offset === undefined) {
39618    encoding = 'utf8';
39619    length = this.length;
39620    offset = 0; // Buffer#write(string, encoding)
39621  } else if (length === undefined && typeof offset === 'string') {
39622    encoding = offset;
39623    length = this.length;
39624    offset = 0; // Buffer#write(string, offset[, length][, encoding])
39625  } else if (isFinite(offset)) {
39626    offset = offset >>> 0;
39627
39628    if (isFinite(length)) {
39629      length = length >>> 0;
39630      if (encoding === undefined) encoding = 'utf8';
39631    } else {
39632      encoding = length;
39633      length = undefined;
39634    }
39635  } else {
39636    throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');
39637  }
39638
39639  var remaining = this.length - offset;
39640  if (length === undefined || length > remaining) length = remaining;
39641
39642  if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
39643    throw new RangeError('Attempt to write outside buffer bounds');
39644  }
39645
39646  if (!encoding) encoding = 'utf8';
39647  var loweredCase = false;
39648
39649  for (;;) {
39650    switch (encoding) {
39651      case 'hex':
39652        return hexWrite(this, string, offset, length);
39653
39654      case 'utf8':
39655      case 'utf-8':
39656        return utf8Write(this, string, offset, length);
39657
39658      case 'ascii':
39659        return asciiWrite(this, string, offset, length);
39660
39661      case 'latin1':
39662      case 'binary':
39663        return latin1Write(this, string, offset, length);
39664
39665      case 'base64':
39666        // Warning: maxLength not taken into account in base64Write
39667        return base64Write(this, string, offset, length);
39668
39669      case 'ucs2':
39670      case 'ucs-2':
39671      case 'utf16le':
39672      case 'utf-16le':
39673        return ucs2Write(this, string, offset, length);
39674
39675      default:
39676        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
39677        encoding = ('' + encoding).toLowerCase();
39678        loweredCase = true;
39679    }
39680  }
39681};
39682
39683Buffer.prototype.toJSON = function toJSON() {
39684  return {
39685    type: 'Buffer',
39686    data: Array.prototype.slice.call(this._arr || this, 0)
39687  };
39688};
39689
39690function base64Slice(buf, start, end) {
39691  if (start === 0 && end === buf.length) {
39692    return base64.fromByteArray(buf);
39693  } else {
39694    return base64.fromByteArray(buf.slice(start, end));
39695  }
39696}
39697
39698function utf8Slice(buf, start, end) {
39699  end = Math.min(buf.length, end);
39700  var res = [];
39701  var i = start;
39702
39703  while (i < end) {
39704    var firstByte = buf[i];
39705    var codePoint = null;
39706    var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1;
39707
39708    if (i + bytesPerSequence <= end) {
39709      var secondByte, thirdByte, fourthByte, tempCodePoint;
39710
39711      switch (bytesPerSequence) {
39712        case 1:
39713          if (firstByte < 0x80) {
39714            codePoint = firstByte;
39715          }
39716
39717          break;
39718
39719        case 2:
39720          secondByte = buf[i + 1];
39721
39722          if ((secondByte & 0xC0) === 0x80) {
39723            tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F;
39724
39725            if (tempCodePoint > 0x7F) {
39726              codePoint = tempCodePoint;
39727            }
39728          }
39729
39730          break;
39731
39732        case 3:
39733          secondByte = buf[i + 1];
39734          thirdByte = buf[i + 2];
39735
39736          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
39737            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F;
39738
39739            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
39740              codePoint = tempCodePoint;
39741            }
39742          }
39743
39744          break;
39745
39746        case 4:
39747          secondByte = buf[i + 1];
39748          thirdByte = buf[i + 2];
39749          fourthByte = buf[i + 3];
39750
39751          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
39752            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F;
39753
39754            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
39755              codePoint = tempCodePoint;
39756            }
39757          }
39758
39759      }
39760    }
39761
39762    if (codePoint === null) {
39763      // we did not generate a valid codePoint so insert a
39764      // replacement char (U+FFFD) and advance only 1 byte
39765      codePoint = 0xFFFD;
39766      bytesPerSequence = 1;
39767    } else if (codePoint > 0xFFFF) {
39768      // encode to utf16 (surrogate pair dance)
39769      codePoint -= 0x10000;
39770      res.push(codePoint >>> 10 & 0x3FF | 0xD800);
39771      codePoint = 0xDC00 | codePoint & 0x3FF;
39772    }
39773
39774    res.push(codePoint);
39775    i += bytesPerSequence;
39776  }
39777
39778  return decodeCodePointsArray(res);
39779} // Based on http://stackoverflow.com/a/22747272/680742, the browser with
39780// the lowest limit is Chrome, with 0x10000 args.
39781// We go 1 magnitude less, for safety
39782
39783
39784var MAX_ARGUMENTS_LENGTH = 0x1000;
39785
39786function decodeCodePointsArray(codePoints) {
39787  var len = codePoints.length;
39788
39789  if (len <= MAX_ARGUMENTS_LENGTH) {
39790    return String.fromCharCode.apply(String, codePoints); // avoid extra slice()
39791  } // Decode in chunks to avoid "call stack size exceeded".
39792
39793
39794  var res = '';
39795  var i = 0;
39796
39797  while (i < len) {
39798    res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
39799  }
39800
39801  return res;
39802}
39803
39804function asciiSlice(buf, start, end) {
39805  var ret = '';
39806  end = Math.min(buf.length, end);
39807
39808  for (var i = start; i < end; ++i) {
39809    ret += String.fromCharCode(buf[i] & 0x7F);
39810  }
39811
39812  return ret;
39813}
39814
39815function latin1Slice(buf, start, end) {
39816  var ret = '';
39817  end = Math.min(buf.length, end);
39818
39819  for (var i = start; i < end; ++i) {
39820    ret += String.fromCharCode(buf[i]);
39821  }
39822
39823  return ret;
39824}
39825
39826function hexSlice(buf, start, end) {
39827  var len = buf.length;
39828  if (!start || start < 0) start = 0;
39829  if (!end || end < 0 || end > len) end = len;
39830  var out = '';
39831
39832  for (var i = start; i < end; ++i) {
39833    out += toHex(buf[i]);
39834  }
39835
39836  return out;
39837}
39838
39839function utf16leSlice(buf, start, end) {
39840  var bytes = buf.slice(start, end);
39841  var res = '';
39842
39843  for (var i = 0; i < bytes.length; i += 2) {
39844    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
39845  }
39846
39847  return res;
39848}
39849
39850Buffer.prototype.slice = function slice(start, end) {
39851  var len = this.length;
39852  start = ~~start;
39853  end = end === undefined ? len : ~~end;
39854
39855  if (start < 0) {
39856    start += len;
39857    if (start < 0) start = 0;
39858  } else if (start > len) {
39859    start = len;
39860  }
39861
39862  if (end < 0) {
39863    end += len;
39864    if (end < 0) end = 0;
39865  } else if (end > len) {
39866    end = len;
39867  }
39868
39869  if (end < start) end = start;
39870  var newBuf = this.subarray(start, end); // Return an augmented `Uint8Array` instance
39871
39872  newBuf.__proto__ = Buffer.prototype;
39873  return newBuf;
39874};
39875/*
39876 * Need to make sure that buffer isn't trying to write out of bounds.
39877 */
39878
39879
39880function checkOffset(offset, ext, length) {
39881  if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint');
39882  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length');
39883}
39884
39885Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
39886  offset = offset >>> 0;
39887  byteLength = byteLength >>> 0;
39888  if (!noAssert) checkOffset(offset, byteLength, this.length);
39889  var val = this[offset];
39890  var mul = 1;
39891  var i = 0;
39892
39893  while (++i < byteLength && (mul *= 0x100)) {
39894    val += this[offset + i] * mul;
39895  }
39896
39897  return val;
39898};
39899
39900Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
39901  offset = offset >>> 0;
39902  byteLength = byteLength >>> 0;
39903
39904  if (!noAssert) {
39905    checkOffset(offset, byteLength, this.length);
39906  }
39907
39908  var val = this[offset + --byteLength];
39909  var mul = 1;
39910
39911  while (byteLength > 0 && (mul *= 0x100)) {
39912    val += this[offset + --byteLength] * mul;
39913  }
39914
39915  return val;
39916};
39917
39918Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
39919  offset = offset >>> 0;
39920  if (!noAssert) checkOffset(offset, 1, this.length);
39921  return this[offset];
39922};
39923
39924Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
39925  offset = offset >>> 0;
39926  if (!noAssert) checkOffset(offset, 2, this.length);
39927  return this[offset] | this[offset + 1] << 8;
39928};
39929
39930Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
39931  offset = offset >>> 0;
39932  if (!noAssert) checkOffset(offset, 2, this.length);
39933  return this[offset] << 8 | this[offset + 1];
39934};
39935
39936Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
39937  offset = offset >>> 0;
39938  if (!noAssert) checkOffset(offset, 4, this.length);
39939  return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000;
39940};
39941
39942Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
39943  offset = offset >>> 0;
39944  if (!noAssert) checkOffset(offset, 4, this.length);
39945  return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
39946};
39947
39948Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
39949  offset = offset >>> 0;
39950  byteLength = byteLength >>> 0;
39951  if (!noAssert) checkOffset(offset, byteLength, this.length);
39952  var val = this[offset];
39953  var mul = 1;
39954  var i = 0;
39955
39956  while (++i < byteLength && (mul *= 0x100)) {
39957    val += this[offset + i] * mul;
39958  }
39959
39960  mul *= 0x80;
39961  if (val >= mul) val -= Math.pow(2, 8 * byteLength);
39962  return val;
39963};
39964
39965Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
39966  offset = offset >>> 0;
39967  byteLength = byteLength >>> 0;
39968  if (!noAssert) checkOffset(offset, byteLength, this.length);
39969  var i = byteLength;
39970  var mul = 1;
39971  var val = this[offset + --i];
39972
39973  while (i > 0 && (mul *= 0x100)) {
39974    val += this[offset + --i] * mul;
39975  }
39976
39977  mul *= 0x80;
39978  if (val >= mul) val -= Math.pow(2, 8 * byteLength);
39979  return val;
39980};
39981
39982Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
39983  offset = offset >>> 0;
39984  if (!noAssert) checkOffset(offset, 1, this.length);
39985  if (!(this[offset] & 0x80)) return this[offset];
39986  return (0xff - this[offset] + 1) * -1;
39987};
39988
39989Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
39990  offset = offset >>> 0;
39991  if (!noAssert) checkOffset(offset, 2, this.length);
39992  var val = this[offset] | this[offset + 1] << 8;
39993  return val & 0x8000 ? val | 0xFFFF0000 : val;
39994};
39995
39996Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
39997  offset = offset >>> 0;
39998  if (!noAssert) checkOffset(offset, 2, this.length);
39999  var val = this[offset + 1] | this[offset] << 8;
40000  return val & 0x8000 ? val | 0xFFFF0000 : val;
40001};
40002
40003Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
40004  offset = offset >>> 0;
40005  if (!noAssert) checkOffset(offset, 4, this.length);
40006  return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
40007};
40008
40009Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
40010  offset = offset >>> 0;
40011  if (!noAssert) checkOffset(offset, 4, this.length);
40012  return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
40013};
40014
40015Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
40016  offset = offset >>> 0;
40017  if (!noAssert) checkOffset(offset, 4, this.length);
40018  return ieee754.read(this, offset, true, 23, 4);
40019};
40020
40021Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
40022  offset = offset >>> 0;
40023  if (!noAssert) checkOffset(offset, 4, this.length);
40024  return ieee754.read(this, offset, false, 23, 4);
40025};
40026
40027Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
40028  offset = offset >>> 0;
40029  if (!noAssert) checkOffset(offset, 8, this.length);
40030  return ieee754.read(this, offset, true, 52, 8);
40031};
40032
40033Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
40034  offset = offset >>> 0;
40035  if (!noAssert) checkOffset(offset, 8, this.length);
40036  return ieee754.read(this, offset, false, 52, 8);
40037};
40038
40039function checkInt(buf, value, offset, ext, max, min) {
40040  if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
40041  if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
40042  if (offset + ext > buf.length) throw new RangeError('Index out of range');
40043}
40044
40045Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
40046  value = +value;
40047  offset = offset >>> 0;
40048  byteLength = byteLength >>> 0;
40049
40050  if (!noAssert) {
40051    var maxBytes = Math.pow(2, 8 * byteLength) - 1;
40052    checkInt(this, value, offset, byteLength, maxBytes, 0);
40053  }
40054
40055  var mul = 1;
40056  var i = 0;
40057  this[offset] = value & 0xFF;
40058
40059  while (++i < byteLength && (mul *= 0x100)) {
40060    this[offset + i] = value / mul & 0xFF;
40061  }
40062
40063  return offset + byteLength;
40064};
40065
40066Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
40067  value = +value;
40068  offset = offset >>> 0;
40069  byteLength = byteLength >>> 0;
40070
40071  if (!noAssert) {
40072    var maxBytes = Math.pow(2, 8 * byteLength) - 1;
40073    checkInt(this, value, offset, byteLength, maxBytes, 0);
40074  }
40075
40076  var i = byteLength - 1;
40077  var mul = 1;
40078  this[offset + i] = value & 0xFF;
40079
40080  while (--i >= 0 && (mul *= 0x100)) {
40081    this[offset + i] = value / mul & 0xFF;
40082  }
40083
40084  return offset + byteLength;
40085};
40086
40087Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
40088  value = +value;
40089  offset = offset >>> 0;
40090  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
40091  this[offset] = value & 0xff;
40092  return offset + 1;
40093};
40094
40095Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
40096  value = +value;
40097  offset = offset >>> 0;
40098  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
40099  this[offset] = value & 0xff;
40100  this[offset + 1] = value >>> 8;
40101  return offset + 2;
40102};
40103
40104Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
40105  value = +value;
40106  offset = offset >>> 0;
40107  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
40108  this[offset] = value >>> 8;
40109  this[offset + 1] = value & 0xff;
40110  return offset + 2;
40111};
40112
40113Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
40114  value = +value;
40115  offset = offset >>> 0;
40116  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
40117  this[offset + 3] = value >>> 24;
40118  this[offset + 2] = value >>> 16;
40119  this[offset + 1] = value >>> 8;
40120  this[offset] = value & 0xff;
40121  return offset + 4;
40122};
40123
40124Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
40125  value = +value;
40126  offset = offset >>> 0;
40127  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
40128  this[offset] = value >>> 24;
40129  this[offset + 1] = value >>> 16;
40130  this[offset + 2] = value >>> 8;
40131  this[offset + 3] = value & 0xff;
40132  return offset + 4;
40133};
40134
40135Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
40136  value = +value;
40137  offset = offset >>> 0;
40138
40139  if (!noAssert) {
40140    var limit = Math.pow(2, 8 * byteLength - 1);
40141    checkInt(this, value, offset, byteLength, limit - 1, -limit);
40142  }
40143
40144  var i = 0;
40145  var mul = 1;
40146  var sub = 0;
40147  this[offset] = value & 0xFF;
40148
40149  while (++i < byteLength && (mul *= 0x100)) {
40150    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
40151      sub = 1;
40152    }
40153
40154    this[offset + i] = (value / mul >> 0) - sub & 0xFF;
40155  }
40156
40157  return offset + byteLength;
40158};
40159
40160Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
40161  value = +value;
40162  offset = offset >>> 0;
40163
40164  if (!noAssert) {
40165    var limit = Math.pow(2, 8 * byteLength - 1);
40166    checkInt(this, value, offset, byteLength, limit - 1, -limit);
40167  }
40168
40169  var i = byteLength - 1;
40170  var mul = 1;
40171  var sub = 0;
40172  this[offset + i] = value & 0xFF;
40173
40174  while (--i >= 0 && (mul *= 0x100)) {
40175    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
40176      sub = 1;
40177    }
40178
40179    this[offset + i] = (value / mul >> 0) - sub & 0xFF;
40180  }
40181
40182  return offset + byteLength;
40183};
40184
40185Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
40186  value = +value;
40187  offset = offset >>> 0;
40188  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
40189  if (value < 0) value = 0xff + value + 1;
40190  this[offset] = value & 0xff;
40191  return offset + 1;
40192};
40193
40194Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
40195  value = +value;
40196  offset = offset >>> 0;
40197  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
40198  this[offset] = value & 0xff;
40199  this[offset + 1] = value >>> 8;
40200  return offset + 2;
40201};
40202
40203Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
40204  value = +value;
40205  offset = offset >>> 0;
40206  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
40207  this[offset] = value >>> 8;
40208  this[offset + 1] = value & 0xff;
40209  return offset + 2;
40210};
40211
40212Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
40213  value = +value;
40214  offset = offset >>> 0;
40215  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
40216  this[offset] = value & 0xff;
40217  this[offset + 1] = value >>> 8;
40218  this[offset + 2] = value >>> 16;
40219  this[offset + 3] = value >>> 24;
40220  return offset + 4;
40221};
40222
40223Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
40224  value = +value;
40225  offset = offset >>> 0;
40226  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
40227  if (value < 0) value = 0xffffffff + value + 1;
40228  this[offset] = value >>> 24;
40229  this[offset + 1] = value >>> 16;
40230  this[offset + 2] = value >>> 8;
40231  this[offset + 3] = value & 0xff;
40232  return offset + 4;
40233};
40234
40235function checkIEEE754(buf, value, offset, ext, max, min) {
40236  if (offset + ext > buf.length) throw new RangeError('Index out of range');
40237  if (offset < 0) throw new RangeError('Index out of range');
40238}
40239
40240function writeFloat(buf, value, offset, littleEndian, noAssert) {
40241  value = +value;
40242  offset = offset >>> 0;
40243
40244  if (!noAssert) {
40245    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38);
40246  }
40247
40248  ieee754.write(buf, value, offset, littleEndian, 23, 4);
40249  return offset + 4;
40250}
40251
40252Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
40253  return writeFloat(this, value, offset, true, noAssert);
40254};
40255
40256Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
40257  return writeFloat(this, value, offset, false, noAssert);
40258};
40259
40260function writeDouble(buf, value, offset, littleEndian, noAssert) {
40261  value = +value;
40262  offset = offset >>> 0;
40263
40264  if (!noAssert) {
40265    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308);
40266  }
40267
40268  ieee754.write(buf, value, offset, littleEndian, 52, 8);
40269  return offset + 8;
40270}
40271
40272Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
40273  return writeDouble(this, value, offset, true, noAssert);
40274};
40275
40276Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
40277  return writeDouble(this, value, offset, false, noAssert);
40278}; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
40279
40280
40281Buffer.prototype.copy = function copy(target, targetStart, start, end) {
40282  if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer');
40283  if (!start) start = 0;
40284  if (!end && end !== 0) end = this.length;
40285  if (targetStart >= target.length) targetStart = target.length;
40286  if (!targetStart) targetStart = 0;
40287  if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done
40288
40289  if (end === start) return 0;
40290  if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions
40291
40292  if (targetStart < 0) {
40293    throw new RangeError('targetStart out of bounds');
40294  }
40295
40296  if (start < 0 || start >= this.length) throw new RangeError('Index out of range');
40297  if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob?
40298
40299  if (end > this.length) end = this.length;
40300
40301  if (target.length - targetStart < end - start) {
40302    end = target.length - targetStart + start;
40303  }
40304
40305  var len = end - start;
40306
40307  if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
40308    // Use built-in when available, missing from IE11
40309    this.copyWithin(targetStart, start, end);
40310  } else if (this === target && start < targetStart && targetStart < end) {
40311    // descending copy from end
40312    for (var i = len - 1; i >= 0; --i) {
40313      target[i + targetStart] = this[i + start];
40314    }
40315  } else {
40316    Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
40317  }
40318
40319  return len;
40320}; // Usage:
40321//    buffer.fill(number[, offset[, end]])
40322//    buffer.fill(buffer[, offset[, end]])
40323//    buffer.fill(string[, offset[, end]][, encoding])
40324
40325
40326Buffer.prototype.fill = function fill(val, start, end, encoding) {
40327  // Handle string cases:
40328  if (typeof val === 'string') {
40329    if (typeof start === 'string') {
40330      encoding = start;
40331      start = 0;
40332      end = this.length;
40333    } else if (typeof end === 'string') {
40334      encoding = end;
40335      end = this.length;
40336    }
40337
40338    if (encoding !== undefined && typeof encoding !== 'string') {
40339      throw new TypeError('encoding must be a string');
40340    }
40341
40342    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
40343      throw new TypeError('Unknown encoding: ' + encoding);
40344    }
40345
40346    if (val.length === 1) {
40347      var code = val.charCodeAt(0);
40348
40349      if (encoding === 'utf8' && code < 128 || encoding === 'latin1') {
40350        // Fast path: If `val` fits into a single byte, use that numeric value.
40351        val = code;
40352      }
40353    }
40354  } else if (typeof val === 'number') {
40355    val = val & 255;
40356  } // Invalid ranges are not set to a default, so can range check early.
40357
40358
40359  if (start < 0 || this.length < start || this.length < end) {
40360    throw new RangeError('Out of range index');
40361  }
40362
40363  if (end <= start) {
40364    return this;
40365  }
40366
40367  start = start >>> 0;
40368  end = end === undefined ? this.length : end >>> 0;
40369  if (!val) val = 0;
40370  var i;
40371
40372  if (typeof val === 'number') {
40373    for (i = start; i < end; ++i) {
40374      this[i] = val;
40375    }
40376  } else {
40377    var bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding);
40378    var len = bytes.length;
40379
40380    if (len === 0) {
40381      throw new TypeError('The value "' + val + '" is invalid for argument "value"');
40382    }
40383
40384    for (i = 0; i < end - start; ++i) {
40385      this[i + start] = bytes[i % len];
40386    }
40387  }
40388
40389  return this;
40390}; // HELPER FUNCTIONS
40391// ================
40392
40393
40394var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
40395
40396function base64clean(str) {
40397  // Node takes equal signs as end of the Base64 encoding
40398  str = str.split('=')[0]; // Node strips out invalid characters like \n and \t from the string, base64-js does not
40399
40400  str = str.trim().replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to ''
40401
40402  if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
40403
40404  while (str.length % 4 !== 0) {
40405    str = str + '=';
40406  }
40407
40408  return str;
40409}
40410
40411function toHex(n) {
40412  if (n < 16) return '0' + n.toString(16);
40413  return n.toString(16);
40414}
40415
40416function utf8ToBytes(string, units) {
40417  units = units || Infinity;
40418  var codePoint;
40419  var length = string.length;
40420  var leadSurrogate = null;
40421  var bytes = [];
40422
40423  for (var i = 0; i < length; ++i) {
40424    codePoint = string.charCodeAt(i); // is surrogate component
40425
40426    if (codePoint > 0xD7FF && codePoint < 0xE000) {
40427      // last char was a lead
40428      if (!leadSurrogate) {
40429        // no lead yet
40430        if (codePoint > 0xDBFF) {
40431          // unexpected trail
40432          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
40433          continue;
40434        } else if (i + 1 === length) {
40435          // unpaired lead
40436          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
40437          continue;
40438        } // valid lead
40439
40440
40441        leadSurrogate = codePoint;
40442        continue;
40443      } // 2 leads in a row
40444
40445
40446      if (codePoint < 0xDC00) {
40447        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
40448        leadSurrogate = codePoint;
40449        continue;
40450      } // valid surrogate pair
40451
40452
40453      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
40454    } else if (leadSurrogate) {
40455      // valid bmp char, but last char was a lead
40456      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
40457    }
40458
40459    leadSurrogate = null; // encode utf8
40460
40461    if (codePoint < 0x80) {
40462      if ((units -= 1) < 0) break;
40463      bytes.push(codePoint);
40464    } else if (codePoint < 0x800) {
40465      if ((units -= 2) < 0) break;
40466      bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80);
40467    } else if (codePoint < 0x10000) {
40468      if ((units -= 3) < 0) break;
40469      bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
40470    } else if (codePoint < 0x110000) {
40471      if ((units -= 4) < 0) break;
40472      bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
40473    } else {
40474      throw new Error('Invalid code point');
40475    }
40476  }
40477
40478  return bytes;
40479}
40480
40481function asciiToBytes(str) {
40482  var byteArray = [];
40483
40484  for (var i = 0; i < str.length; ++i) {
40485    // Node's code seems to be doing this and not & 0x7F..
40486    byteArray.push(str.charCodeAt(i) & 0xFF);
40487  }
40488
40489  return byteArray;
40490}
40491
40492function utf16leToBytes(str, units) {
40493  var c, hi, lo;
40494  var byteArray = [];
40495
40496  for (var i = 0; i < str.length; ++i) {
40497    if ((units -= 2) < 0) break;
40498    c = str.charCodeAt(i);
40499    hi = c >> 8;
40500    lo = c % 256;
40501    byteArray.push(lo);
40502    byteArray.push(hi);
40503  }
40504
40505  return byteArray;
40506}
40507
40508function base64ToBytes(str) {
40509  return base64.toByteArray(base64clean(str));
40510}
40511
40512function blitBuffer(src, dst, offset, length) {
40513  for (var i = 0; i < length; ++i) {
40514    if (i + offset >= dst.length || i >= src.length) break;
40515    dst[i + offset] = src[i];
40516  }
40517
40518  return i;
40519} // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
40520// the `instanceof` check but they should be treated as of that type.
40521// See: https://github.com/feross/buffer/issues/166
40522
40523
40524function isInstance(obj, type) {
40525  return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
40526}
40527
40528function numberIsNaN(obj) {
40529  // For IE11 support
40530  return obj !== obj; // eslint-disable-line no-self-compare
40531}
40532
40533}).call(this,require("buffer").Buffer)
40534
40535},{"base64-js":182,"buffer":216,"ieee754":385}],217:[function(require,module,exports){
40536(function (Buffer){
40537"use strict";
40538
40539module.exports = function xor(a, b) {
40540  var length = Math.min(a.length, b.length);
40541  var buffer = new Buffer(length);
40542
40543  for (var i = 0; i < length; ++i) {
40544    buffer[i] = a[i] ^ b[i];
40545  }
40546
40547  return buffer;
40548};
40549
40550}).call(this,require("buffer").Buffer)
40551
40552},{"buffer":216}],218:[function(require,module,exports){
40553"use strict";
40554
40555var Buffer = require('safe-buffer').Buffer;
40556
40557var Transform = require('stream').Transform;
40558
40559var StringDecoder = require('string_decoder').StringDecoder;
40560
40561var inherits = require('inherits');
40562
40563function CipherBase(hashMode) {
40564  Transform.call(this);
40565  this.hashMode = typeof hashMode === 'string';
40566
40567  if (this.hashMode) {
40568    this[hashMode] = this._finalOrDigest;
40569  } else {
40570    this.final = this._finalOrDigest;
40571  }
40572
40573  if (this._final) {
40574    this.__final = this._final;
40575    this._final = null;
40576  }
40577
40578  this._decoder = null;
40579  this._encoding = null;
40580}
40581
40582inherits(CipherBase, Transform);
40583
40584CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
40585  if (typeof data === 'string') {
40586    data = Buffer.from(data, inputEnc);
40587  }
40588
40589  var outData = this._update(data);
40590
40591  if (this.hashMode) return this;
40592
40593  if (outputEnc) {
40594    outData = this._toString(outData, outputEnc);
40595  }
40596
40597  return outData;
40598};
40599
40600CipherBase.prototype.setAutoPadding = function () {};
40601
40602CipherBase.prototype.getAuthTag = function () {
40603  throw new Error('trying to get auth tag in unsupported state');
40604};
40605
40606CipherBase.prototype.setAuthTag = function () {
40607  throw new Error('trying to set auth tag in unsupported state');
40608};
40609
40610CipherBase.prototype.setAAD = function () {
40611  throw new Error('trying to set aad in unsupported state');
40612};
40613
40614CipherBase.prototype._transform = function (data, _, next) {
40615  var err;
40616
40617  try {
40618    if (this.hashMode) {
40619      this._update(data);
40620    } else {
40621      this.push(this._update(data));
40622    }
40623  } catch (e) {
40624    err = e;
40625  } finally {
40626    next(err);
40627  }
40628};
40629
40630CipherBase.prototype._flush = function (done) {
40631  var err;
40632
40633  try {
40634    this.push(this.__final());
40635  } catch (e) {
40636    err = e;
40637  }
40638
40639  done(err);
40640};
40641
40642CipherBase.prototype._finalOrDigest = function (outputEnc) {
40643  var outData = this.__final() || Buffer.alloc(0);
40644
40645  if (outputEnc) {
40646    outData = this._toString(outData, outputEnc, true);
40647  }
40648
40649  return outData;
40650};
40651
40652CipherBase.prototype._toString = function (value, enc, fin) {
40653  if (!this._decoder) {
40654    this._decoder = new StringDecoder(enc);
40655    this._encoding = enc;
40656  }
40657
40658  if (this._encoding !== enc) throw new Error('can\'t switch encodings');
40659
40660  var out = this._decoder.write(value);
40661
40662  if (fin) {
40663    out += this._decoder.end();
40664  }
40665
40666  return out;
40667};
40668
40669module.exports = CipherBase;
40670
40671},{"inherits":387,"safe-buffer":494,"stream":506,"string_decoder":520}],219:[function(require,module,exports){
40672module.exports = function (it) {
40673  if (typeof it != 'function') {
40674    throw TypeError(String(it) + ' is not a function');
40675  } return it;
40676};
40677
40678},{}],220:[function(require,module,exports){
40679var isObject = require('../internals/is-object');
40680
40681module.exports = function (it) {
40682  if (!isObject(it) && it !== null) {
40683    throw TypeError("Can't set " + String(it) + ' as a prototype');
40684  } return it;
40685};
40686
40687},{"../internals/is-object":263}],221:[function(require,module,exports){
40688var wellKnownSymbol = require('../internals/well-known-symbol');
40689var create = require('../internals/object-create');
40690var definePropertyModule = require('../internals/object-define-property');
40691
40692var UNSCOPABLES = wellKnownSymbol('unscopables');
40693var ArrayPrototype = Array.prototype;
40694
40695// Array.prototype[@@unscopables]
40696// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
40697if (ArrayPrototype[UNSCOPABLES] == undefined) {
40698  definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
40699    configurable: true,
40700    value: create(null)
40701  });
40702}
40703
40704// add a key to Array.prototype[@@unscopables]
40705module.exports = function (key) {
40706  ArrayPrototype[UNSCOPABLES][key] = true;
40707};
40708
40709},{"../internals/object-create":276,"../internals/object-define-property":278,"../internals/well-known-symbol":314}],222:[function(require,module,exports){
40710module.exports = function (it, Constructor, name) {
40711  if (!(it instanceof Constructor)) {
40712    throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
40713  } return it;
40714};
40715
40716},{}],223:[function(require,module,exports){
40717var isObject = require('../internals/is-object');
40718
40719module.exports = function (it) {
40720  if (!isObject(it)) {
40721    throw TypeError(String(it) + ' is not an object');
40722  } return it;
40723};
40724
40725},{"../internals/is-object":263}],224:[function(require,module,exports){
40726var toIndexedObject = require('../internals/to-indexed-object');
40727var toLength = require('../internals/to-length');
40728var toAbsoluteIndex = require('../internals/to-absolute-index');
40729
40730// `Array.prototype.{ indexOf, includes }` methods implementation
40731var createMethod = function (IS_INCLUDES) {
40732  return function ($this, el, fromIndex) {
40733    var O = toIndexedObject($this);
40734    var length = toLength(O.length);
40735    var index = toAbsoluteIndex(fromIndex, length);
40736    var value;
40737    // Array#includes uses SameValueZero equality algorithm
40738    // eslint-disable-next-line no-self-compare
40739    if (IS_INCLUDES && el != el) while (length > index) {
40740      value = O[index++];
40741      // eslint-disable-next-line no-self-compare
40742      if (value != value) return true;
40743    // Array#indexOf ignores holes, Array#includes - not
40744    } else for (;length > index; index++) {
40745      if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
40746    } return !IS_INCLUDES && -1;
40747  };
40748};
40749
40750module.exports = {
40751  // `Array.prototype.includes` method
40752  // https://tc39.github.io/ecma262/#sec-array.prototype.includes
40753  includes: createMethod(true),
40754  // `Array.prototype.indexOf` method
40755  // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
40756  indexOf: createMethod(false)
40757};
40758
40759},{"../internals/to-absolute-index":304,"../internals/to-indexed-object":305,"../internals/to-length":307}],225:[function(require,module,exports){
40760var bind = require('../internals/function-bind-context');
40761var IndexedObject = require('../internals/indexed-object');
40762var toObject = require('../internals/to-object');
40763var toLength = require('../internals/to-length');
40764var arraySpeciesCreate = require('../internals/array-species-create');
40765
40766var push = [].push;
40767
40768// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
40769var createMethod = function (TYPE) {
40770  var IS_MAP = TYPE == 1;
40771  var IS_FILTER = TYPE == 2;
40772  var IS_SOME = TYPE == 3;
40773  var IS_EVERY = TYPE == 4;
40774  var IS_FIND_INDEX = TYPE == 6;
40775  var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
40776  return function ($this, callbackfn, that, specificCreate) {
40777    var O = toObject($this);
40778    var self = IndexedObject(O);
40779    var boundFunction = bind(callbackfn, that, 3);
40780    var length = toLength(self.length);
40781    var index = 0;
40782    var create = specificCreate || arraySpeciesCreate;
40783    var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
40784    var value, result;
40785    for (;length > index; index++) if (NO_HOLES || index in self) {
40786      value = self[index];
40787      result = boundFunction(value, index, O);
40788      if (TYPE) {
40789        if (IS_MAP) target[index] = result; // map
40790        else if (result) switch (TYPE) {
40791          case 3: return true;              // some
40792          case 5: return value;             // find
40793          case 6: return index;             // findIndex
40794          case 2: push.call(target, value); // filter
40795        } else if (IS_EVERY) return false;  // every
40796      }
40797    }
40798    return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
40799  };
40800};
40801
40802module.exports = {
40803  // `Array.prototype.forEach` method
40804  // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
40805  forEach: createMethod(0),
40806  // `Array.prototype.map` method
40807  // https://tc39.github.io/ecma262/#sec-array.prototype.map
40808  map: createMethod(1),
40809  // `Array.prototype.filter` method
40810  // https://tc39.github.io/ecma262/#sec-array.prototype.filter
40811  filter: createMethod(2),
40812  // `Array.prototype.some` method
40813  // https://tc39.github.io/ecma262/#sec-array.prototype.some
40814  some: createMethod(3),
40815  // `Array.prototype.every` method
40816  // https://tc39.github.io/ecma262/#sec-array.prototype.every
40817  every: createMethod(4),
40818  // `Array.prototype.find` method
40819  // https://tc39.github.io/ecma262/#sec-array.prototype.find
40820  find: createMethod(5),
40821  // `Array.prototype.findIndex` method
40822  // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
40823  findIndex: createMethod(6)
40824};
40825
40826},{"../internals/array-species-create":227,"../internals/function-bind-context":248,"../internals/indexed-object":257,"../internals/to-length":307,"../internals/to-object":308}],226:[function(require,module,exports){
40827var DESCRIPTORS = require('../internals/descriptors');
40828var fails = require('../internals/fails');
40829var has = require('../internals/has');
40830
40831var defineProperty = Object.defineProperty;
40832var cache = {};
40833
40834var thrower = function (it) { throw it; };
40835
40836module.exports = function (METHOD_NAME, options) {
40837  if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];
40838  if (!options) options = {};
40839  var method = [][METHOD_NAME];
40840  var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
40841  var argument0 = has(options, 0) ? options[0] : thrower;
40842  var argument1 = has(options, 1) ? options[1] : undefined;
40843
40844  return cache[METHOD_NAME] = !!method && !fails(function () {
40845    if (ACCESSORS && !DESCRIPTORS) return true;
40846    var O = { length: -1 };
40847
40848    if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower });
40849    else O[1] = 1;
40850
40851    method.call(O, argument0, argument1);
40852  });
40853};
40854
40855},{"../internals/descriptors":240,"../internals/fails":247,"../internals/has":252}],227:[function(require,module,exports){
40856var isObject = require('../internals/is-object');
40857var isArray = require('../internals/is-array');
40858var wellKnownSymbol = require('../internals/well-known-symbol');
40859
40860var SPECIES = wellKnownSymbol('species');
40861
40862// `ArraySpeciesCreate` abstract operation
40863// https://tc39.github.io/ecma262/#sec-arrayspeciescreate
40864module.exports = function (originalArray, length) {
40865  var C;
40866  if (isArray(originalArray)) {
40867    C = originalArray.constructor;
40868    // cross-realm fallback
40869    if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
40870    else if (isObject(C)) {
40871      C = C[SPECIES];
40872      if (C === null) C = undefined;
40873    }
40874  } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
40875};
40876
40877},{"../internals/is-array":261,"../internals/is-object":263,"../internals/well-known-symbol":314}],228:[function(require,module,exports){
40878var anObject = require('../internals/an-object');
40879
40880// call something on iterator step with safe closing on error
40881module.exports = function (iterator, fn, value, ENTRIES) {
40882  try {
40883    return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
40884  // 7.4.6 IteratorClose(iterator, completion)
40885  } catch (error) {
40886    var returnMethod = iterator['return'];
40887    if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
40888    throw error;
40889  }
40890};
40891
40892},{"../internals/an-object":223}],229:[function(require,module,exports){
40893var wellKnownSymbol = require('../internals/well-known-symbol');
40894
40895var ITERATOR = wellKnownSymbol('iterator');
40896var SAFE_CLOSING = false;
40897
40898try {
40899  var called = 0;
40900  var iteratorWithReturn = {
40901    next: function () {
40902      return { done: !!called++ };
40903    },
40904    'return': function () {
40905      SAFE_CLOSING = true;
40906    }
40907  };
40908  iteratorWithReturn[ITERATOR] = function () {
40909    return this;
40910  };
40911  // eslint-disable-next-line no-throw-literal
40912  Array.from(iteratorWithReturn, function () { throw 2; });
40913} catch (error) { /* empty */ }
40914
40915module.exports = function (exec, SKIP_CLOSING) {
40916  if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
40917  var ITERATION_SUPPORT = false;
40918  try {
40919    var object = {};
40920    object[ITERATOR] = function () {
40921      return {
40922        next: function () {
40923          return { done: ITERATION_SUPPORT = true };
40924        }
40925      };
40926    };
40927    exec(object);
40928  } catch (error) { /* empty */ }
40929  return ITERATION_SUPPORT;
40930};
40931
40932},{"../internals/well-known-symbol":314}],230:[function(require,module,exports){
40933var toString = {}.toString;
40934
40935module.exports = function (it) {
40936  return toString.call(it).slice(8, -1);
40937};
40938
40939},{}],231:[function(require,module,exports){
40940var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');
40941var classofRaw = require('../internals/classof-raw');
40942var wellKnownSymbol = require('../internals/well-known-symbol');
40943
40944var TO_STRING_TAG = wellKnownSymbol('toStringTag');
40945// ES3 wrong here
40946var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
40947
40948// fallback for IE11 Script Access Denied error
40949var tryGet = function (it, key) {
40950  try {
40951    return it[key];
40952  } catch (error) { /* empty */ }
40953};
40954
40955// getting tag from ES6+ `Object.prototype.toString`
40956module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
40957  var O, tag, result;
40958  return it === undefined ? 'Undefined' : it === null ? 'Null'
40959    // @@toStringTag case
40960    : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
40961    // builtinTag case
40962    : CORRECT_ARGUMENTS ? classofRaw(O)
40963    // ES3 arguments fallback
40964    : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
40965};
40966
40967},{"../internals/classof-raw":230,"../internals/to-string-tag-support":310,"../internals/well-known-symbol":314}],232:[function(require,module,exports){
40968var has = require('../internals/has');
40969var ownKeys = require('../internals/own-keys');
40970var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
40971var definePropertyModule = require('../internals/object-define-property');
40972
40973module.exports = function (target, source) {
40974  var keys = ownKeys(source);
40975  var defineProperty = definePropertyModule.f;
40976  var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
40977  for (var i = 0; i < keys.length; i++) {
40978    var key = keys[i];
40979    if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
40980  }
40981};
40982
40983},{"../internals/has":252,"../internals/object-define-property":278,"../internals/object-get-own-property-descriptor":279,"../internals/own-keys":289}],233:[function(require,module,exports){
40984var wellKnownSymbol = require('../internals/well-known-symbol');
40985
40986var MATCH = wellKnownSymbol('match');
40987
40988module.exports = function (METHOD_NAME) {
40989  var regexp = /./;
40990  try {
40991    '/./'[METHOD_NAME](regexp);
40992  } catch (e) {
40993    try {
40994      regexp[MATCH] = false;
40995      return '/./'[METHOD_NAME](regexp);
40996    } catch (f) { /* empty */ }
40997  } return false;
40998};
40999
41000},{"../internals/well-known-symbol":314}],234:[function(require,module,exports){
41001var fails = require('../internals/fails');
41002
41003module.exports = !fails(function () {
41004  function F() { /* empty */ }
41005  F.prototype.constructor = null;
41006  return Object.getPrototypeOf(new F()) !== F.prototype;
41007});
41008
41009},{"../internals/fails":247}],235:[function(require,module,exports){
41010'use strict';
41011var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;
41012var create = require('../internals/object-create');
41013var createPropertyDescriptor = require('../internals/create-property-descriptor');
41014var setToStringTag = require('../internals/set-to-string-tag');
41015var Iterators = require('../internals/iterators');
41016
41017var returnThis = function () { return this; };
41018
41019module.exports = function (IteratorConstructor, NAME, next) {
41020  var TO_STRING_TAG = NAME + ' Iterator';
41021  IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });
41022  setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
41023  Iterators[TO_STRING_TAG] = returnThis;
41024  return IteratorConstructor;
41025};
41026
41027},{"../internals/create-property-descriptor":237,"../internals/iterators":268,"../internals/iterators-core":267,"../internals/object-create":276,"../internals/set-to-string-tag":298}],236:[function(require,module,exports){
41028var DESCRIPTORS = require('../internals/descriptors');
41029var definePropertyModule = require('../internals/object-define-property');
41030var createPropertyDescriptor = require('../internals/create-property-descriptor');
41031
41032module.exports = DESCRIPTORS ? function (object, key, value) {
41033  return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
41034} : function (object, key, value) {
41035  object[key] = value;
41036  return object;
41037};
41038
41039},{"../internals/create-property-descriptor":237,"../internals/descriptors":240,"../internals/object-define-property":278}],237:[function(require,module,exports){
41040module.exports = function (bitmap, value) {
41041  return {
41042    enumerable: !(bitmap & 1),
41043    configurable: !(bitmap & 2),
41044    writable: !(bitmap & 4),
41045    value: value
41046  };
41047};
41048
41049},{}],238:[function(require,module,exports){
41050'use strict';
41051var $ = require('../internals/export');
41052var createIteratorConstructor = require('../internals/create-iterator-constructor');
41053var getPrototypeOf = require('../internals/object-get-prototype-of');
41054var setPrototypeOf = require('../internals/object-set-prototype-of');
41055var setToStringTag = require('../internals/set-to-string-tag');
41056var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
41057var redefine = require('../internals/redefine');
41058var wellKnownSymbol = require('../internals/well-known-symbol');
41059var IS_PURE = require('../internals/is-pure');
41060var Iterators = require('../internals/iterators');
41061var IteratorsCore = require('../internals/iterators-core');
41062
41063var IteratorPrototype = IteratorsCore.IteratorPrototype;
41064var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
41065var ITERATOR = wellKnownSymbol('iterator');
41066var KEYS = 'keys';
41067var VALUES = 'values';
41068var ENTRIES = 'entries';
41069
41070var returnThis = function () { return this; };
41071
41072module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
41073  createIteratorConstructor(IteratorConstructor, NAME, next);
41074
41075  var getIterationMethod = function (KIND) {
41076    if (KIND === DEFAULT && defaultIterator) return defaultIterator;
41077    if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
41078    switch (KIND) {
41079      case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
41080      case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
41081      case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
41082    } return function () { return new IteratorConstructor(this); };
41083  };
41084
41085  var TO_STRING_TAG = NAME + ' Iterator';
41086  var INCORRECT_VALUES_NAME = false;
41087  var IterablePrototype = Iterable.prototype;
41088  var nativeIterator = IterablePrototype[ITERATOR]
41089    || IterablePrototype['@@iterator']
41090    || DEFAULT && IterablePrototype[DEFAULT];
41091  var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
41092  var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
41093  var CurrentIteratorPrototype, methods, KEY;
41094
41095  // fix native
41096  if (anyNativeIterator) {
41097    CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
41098    if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
41099      if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
41100        if (setPrototypeOf) {
41101          setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
41102        } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {
41103          createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);
41104        }
41105      }
41106      // Set @@toStringTag to native iterators
41107      setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
41108      if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
41109    }
41110  }
41111
41112  // fix Array#{values, @@iterator}.name in V8 / FF
41113  if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
41114    INCORRECT_VALUES_NAME = true;
41115    defaultIterator = function values() { return nativeIterator.call(this); };
41116  }
41117
41118  // define iterator
41119  if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
41120    createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);
41121  }
41122  Iterators[NAME] = defaultIterator;
41123
41124  // export additional methods
41125  if (DEFAULT) {
41126    methods = {
41127      values: getIterationMethod(VALUES),
41128      keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
41129      entries: getIterationMethod(ENTRIES)
41130    };
41131    if (FORCED) for (KEY in methods) {
41132      if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
41133        redefine(IterablePrototype, KEY, methods[KEY]);
41134      }
41135    } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
41136  }
41137
41138  return methods;
41139};
41140
41141},{"../internals/create-iterator-constructor":235,"../internals/create-non-enumerable-property":236,"../internals/export":246,"../internals/is-pure":264,"../internals/iterators":268,"../internals/iterators-core":267,"../internals/object-get-prototype-of":283,"../internals/object-set-prototype-of":287,"../internals/redefine":294,"../internals/set-to-string-tag":298,"../internals/well-known-symbol":314}],239:[function(require,module,exports){
41142var path = require('../internals/path');
41143var has = require('../internals/has');
41144var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');
41145var defineProperty = require('../internals/object-define-property').f;
41146
41147module.exports = function (NAME) {
41148  var Symbol = path.Symbol || (path.Symbol = {});
41149  if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {
41150    value: wrappedWellKnownSymbolModule.f(NAME)
41151  });
41152};
41153
41154},{"../internals/has":252,"../internals/object-define-property":278,"../internals/path":290,"../internals/well-known-symbol-wrapped":313}],240:[function(require,module,exports){
41155var fails = require('../internals/fails');
41156
41157// Thank's IE8 for his funny defineProperty
41158module.exports = !fails(function () {
41159  return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
41160});
41161
41162},{"../internals/fails":247}],241:[function(require,module,exports){
41163var global = require('../internals/global');
41164var isObject = require('../internals/is-object');
41165
41166var document = global.document;
41167// typeof document.createElement is 'object' in old IE
41168var EXISTS = isObject(document) && isObject(document.createElement);
41169
41170module.exports = function (it) {
41171  return EXISTS ? document.createElement(it) : {};
41172};
41173
41174},{"../internals/global":251,"../internals/is-object":263}],242:[function(require,module,exports){
41175var userAgent = require('../internals/engine-user-agent');
41176
41177module.exports = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent);
41178
41179},{"../internals/engine-user-agent":243}],243:[function(require,module,exports){
41180var getBuiltIn = require('../internals/get-built-in');
41181
41182module.exports = getBuiltIn('navigator', 'userAgent') || '';
41183
41184},{"../internals/get-built-in":249}],244:[function(require,module,exports){
41185var global = require('../internals/global');
41186var userAgent = require('../internals/engine-user-agent');
41187
41188var process = global.process;
41189var versions = process && process.versions;
41190var v8 = versions && versions.v8;
41191var match, version;
41192
41193if (v8) {
41194  match = v8.split('.');
41195  version = match[0] + match[1];
41196} else if (userAgent) {
41197  match = userAgent.match(/Edge\/(\d+)/);
41198  if (!match || match[1] >= 74) {
41199    match = userAgent.match(/Chrome\/(\d+)/);
41200    if (match) version = match[1];
41201  }
41202}
41203
41204module.exports = version && +version;
41205
41206},{"../internals/engine-user-agent":243,"../internals/global":251}],245:[function(require,module,exports){
41207// IE8- don't enum bug keys
41208module.exports = [
41209  'constructor',
41210  'hasOwnProperty',
41211  'isPrototypeOf',
41212  'propertyIsEnumerable',
41213  'toLocaleString',
41214  'toString',
41215  'valueOf'
41216];
41217
41218},{}],246:[function(require,module,exports){
41219var global = require('../internals/global');
41220var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
41221var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
41222var redefine = require('../internals/redefine');
41223var setGlobal = require('../internals/set-global');
41224var copyConstructorProperties = require('../internals/copy-constructor-properties');
41225var isForced = require('../internals/is-forced');
41226
41227/*
41228  options.target      - name of the target object
41229  options.global      - target is the global object
41230  options.stat        - export as static methods of target
41231  options.proto       - export as prototype methods of target
41232  options.real        - real prototype method for the `pure` version
41233  options.forced      - export even if the native feature is available
41234  options.bind        - bind methods to the target, required for the `pure` version
41235  options.wrap        - wrap constructors to preventing global pollution, required for the `pure` version
41236  options.unsafe      - use the simple assignment of property instead of delete + defineProperty
41237  options.sham        - add a flag to not completely full polyfills
41238  options.enumerable  - export as enumerable property
41239  options.noTargetGet - prevent calling a getter on target
41240*/
41241module.exports = function (options, source) {
41242  var TARGET = options.target;
41243  var GLOBAL = options.global;
41244  var STATIC = options.stat;
41245  var FORCED, target, key, targetProperty, sourceProperty, descriptor;
41246  if (GLOBAL) {
41247    target = global;
41248  } else if (STATIC) {
41249    target = global[TARGET] || setGlobal(TARGET, {});
41250  } else {
41251    target = (global[TARGET] || {}).prototype;
41252  }
41253  if (target) for (key in source) {
41254    sourceProperty = source[key];
41255    if (options.noTargetGet) {
41256      descriptor = getOwnPropertyDescriptor(target, key);
41257      targetProperty = descriptor && descriptor.value;
41258    } else targetProperty = target[key];
41259    FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
41260    // contained in target
41261    if (!FORCED && targetProperty !== undefined) {
41262      if (typeof sourceProperty === typeof targetProperty) continue;
41263      copyConstructorProperties(sourceProperty, targetProperty);
41264    }
41265    // add a flag to not completely full polyfills
41266    if (options.sham || (targetProperty && targetProperty.sham)) {
41267      createNonEnumerableProperty(sourceProperty, 'sham', true);
41268    }
41269    // extend global
41270    redefine(target, key, sourceProperty, options);
41271  }
41272};
41273
41274},{"../internals/copy-constructor-properties":232,"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/is-forced":262,"../internals/object-get-own-property-descriptor":279,"../internals/redefine":294,"../internals/set-global":296}],247:[function(require,module,exports){
41275module.exports = function (exec) {
41276  try {
41277    return !!exec();
41278  } catch (error) {
41279    return true;
41280  }
41281};
41282
41283},{}],248:[function(require,module,exports){
41284var aFunction = require('../internals/a-function');
41285
41286// optional / simple context binding
41287module.exports = function (fn, that, length) {
41288  aFunction(fn);
41289  if (that === undefined) return fn;
41290  switch (length) {
41291    case 0: return function () {
41292      return fn.call(that);
41293    };
41294    case 1: return function (a) {
41295      return fn.call(that, a);
41296    };
41297    case 2: return function (a, b) {
41298      return fn.call(that, a, b);
41299    };
41300    case 3: return function (a, b, c) {
41301      return fn.call(that, a, b, c);
41302    };
41303  }
41304  return function (/* ...args */) {
41305    return fn.apply(that, arguments);
41306  };
41307};
41308
41309},{"../internals/a-function":219}],249:[function(require,module,exports){
41310var path = require('../internals/path');
41311var global = require('../internals/global');
41312
41313var aFunction = function (variable) {
41314  return typeof variable == 'function' ? variable : undefined;
41315};
41316
41317module.exports = function (namespace, method) {
41318  return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
41319    : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
41320};
41321
41322},{"../internals/global":251,"../internals/path":290}],250:[function(require,module,exports){
41323var classof = require('../internals/classof');
41324var Iterators = require('../internals/iterators');
41325var wellKnownSymbol = require('../internals/well-known-symbol');
41326
41327var ITERATOR = wellKnownSymbol('iterator');
41328
41329module.exports = function (it) {
41330  if (it != undefined) return it[ITERATOR]
41331    || it['@@iterator']
41332    || Iterators[classof(it)];
41333};
41334
41335},{"../internals/classof":231,"../internals/iterators":268,"../internals/well-known-symbol":314}],251:[function(require,module,exports){
41336(function (global){
41337var check = function (it) {
41338  return it && it.Math == Math && it;
41339};
41340
41341// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
41342module.exports =
41343  // eslint-disable-next-line no-undef
41344  check(typeof globalThis == 'object' && globalThis) ||
41345  check(typeof window == 'object' && window) ||
41346  check(typeof self == 'object' && self) ||
41347  check(typeof global == 'object' && global) ||
41348  // eslint-disable-next-line no-new-func
41349  Function('return this')();
41350
41351}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
41352
41353},{}],252:[function(require,module,exports){
41354var hasOwnProperty = {}.hasOwnProperty;
41355
41356module.exports = function (it, key) {
41357  return hasOwnProperty.call(it, key);
41358};
41359
41360},{}],253:[function(require,module,exports){
41361module.exports = {};
41362
41363},{}],254:[function(require,module,exports){
41364var global = require('../internals/global');
41365
41366module.exports = function (a, b) {
41367  var console = global.console;
41368  if (console && console.error) {
41369    arguments.length === 1 ? console.error(a) : console.error(a, b);
41370  }
41371};
41372
41373},{"../internals/global":251}],255:[function(require,module,exports){
41374var getBuiltIn = require('../internals/get-built-in');
41375
41376module.exports = getBuiltIn('document', 'documentElement');
41377
41378},{"../internals/get-built-in":249}],256:[function(require,module,exports){
41379var DESCRIPTORS = require('../internals/descriptors');
41380var fails = require('../internals/fails');
41381var createElement = require('../internals/document-create-element');
41382
41383// Thank's IE8 for his funny defineProperty
41384module.exports = !DESCRIPTORS && !fails(function () {
41385  return Object.defineProperty(createElement('div'), 'a', {
41386    get: function () { return 7; }
41387  }).a != 7;
41388});
41389
41390},{"../internals/descriptors":240,"../internals/document-create-element":241,"../internals/fails":247}],257:[function(require,module,exports){
41391var fails = require('../internals/fails');
41392var classof = require('../internals/classof-raw');
41393
41394var split = ''.split;
41395
41396// fallback for non-array-like ES3 and non-enumerable old V8 strings
41397module.exports = fails(function () {
41398  // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
41399  // eslint-disable-next-line no-prototype-builtins
41400  return !Object('z').propertyIsEnumerable(0);
41401}) ? function (it) {
41402  return classof(it) == 'String' ? split.call(it, '') : Object(it);
41403} : Object;
41404
41405},{"../internals/classof-raw":230,"../internals/fails":247}],258:[function(require,module,exports){
41406var store = require('../internals/shared-store');
41407
41408var functionToString = Function.toString;
41409
41410// this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
41411if (typeof store.inspectSource != 'function') {
41412  store.inspectSource = function (it) {
41413    return functionToString.call(it);
41414  };
41415}
41416
41417module.exports = store.inspectSource;
41418
41419},{"../internals/shared-store":300}],259:[function(require,module,exports){
41420var NATIVE_WEAK_MAP = require('../internals/native-weak-map');
41421var global = require('../internals/global');
41422var isObject = require('../internals/is-object');
41423var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
41424var objectHas = require('../internals/has');
41425var sharedKey = require('../internals/shared-key');
41426var hiddenKeys = require('../internals/hidden-keys');
41427
41428var WeakMap = global.WeakMap;
41429var set, get, has;
41430
41431var enforce = function (it) {
41432  return has(it) ? get(it) : set(it, {});
41433};
41434
41435var getterFor = function (TYPE) {
41436  return function (it) {
41437    var state;
41438    if (!isObject(it) || (state = get(it)).type !== TYPE) {
41439      throw TypeError('Incompatible receiver, ' + TYPE + ' required');
41440    } return state;
41441  };
41442};
41443
41444if (NATIVE_WEAK_MAP) {
41445  var store = new WeakMap();
41446  var wmget = store.get;
41447  var wmhas = store.has;
41448  var wmset = store.set;
41449  set = function (it, metadata) {
41450    wmset.call(store, it, metadata);
41451    return metadata;
41452  };
41453  get = function (it) {
41454    return wmget.call(store, it) || {};
41455  };
41456  has = function (it) {
41457    return wmhas.call(store, it);
41458  };
41459} else {
41460  var STATE = sharedKey('state');
41461  hiddenKeys[STATE] = true;
41462  set = function (it, metadata) {
41463    createNonEnumerableProperty(it, STATE, metadata);
41464    return metadata;
41465  };
41466  get = function (it) {
41467    return objectHas(it, STATE) ? it[STATE] : {};
41468  };
41469  has = function (it) {
41470    return objectHas(it, STATE);
41471  };
41472}
41473
41474module.exports = {
41475  set: set,
41476  get: get,
41477  has: has,
41478  enforce: enforce,
41479  getterFor: getterFor
41480};
41481
41482},{"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/has":252,"../internals/hidden-keys":253,"../internals/is-object":263,"../internals/native-weak-map":272,"../internals/shared-key":299}],260:[function(require,module,exports){
41483var wellKnownSymbol = require('../internals/well-known-symbol');
41484var Iterators = require('../internals/iterators');
41485
41486var ITERATOR = wellKnownSymbol('iterator');
41487var ArrayPrototype = Array.prototype;
41488
41489// check on default Array iterator
41490module.exports = function (it) {
41491  return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
41492};
41493
41494},{"../internals/iterators":268,"../internals/well-known-symbol":314}],261:[function(require,module,exports){
41495var classof = require('../internals/classof-raw');
41496
41497// `IsArray` abstract operation
41498// https://tc39.github.io/ecma262/#sec-isarray
41499module.exports = Array.isArray || function isArray(arg) {
41500  return classof(arg) == 'Array';
41501};
41502
41503},{"../internals/classof-raw":230}],262:[function(require,module,exports){
41504var fails = require('../internals/fails');
41505
41506var replacement = /#|\.prototype\./;
41507
41508var isForced = function (feature, detection) {
41509  var value = data[normalize(feature)];
41510  return value == POLYFILL ? true
41511    : value == NATIVE ? false
41512    : typeof detection == 'function' ? fails(detection)
41513    : !!detection;
41514};
41515
41516var normalize = isForced.normalize = function (string) {
41517  return String(string).replace(replacement, '.').toLowerCase();
41518};
41519
41520var data = isForced.data = {};
41521var NATIVE = isForced.NATIVE = 'N';
41522var POLYFILL = isForced.POLYFILL = 'P';
41523
41524module.exports = isForced;
41525
41526},{"../internals/fails":247}],263:[function(require,module,exports){
41527module.exports = function (it) {
41528  return typeof it === 'object' ? it !== null : typeof it === 'function';
41529};
41530
41531},{}],264:[function(require,module,exports){
41532module.exports = false;
41533
41534},{}],265:[function(require,module,exports){
41535var isObject = require('../internals/is-object');
41536var classof = require('../internals/classof-raw');
41537var wellKnownSymbol = require('../internals/well-known-symbol');
41538
41539var MATCH = wellKnownSymbol('match');
41540
41541// `IsRegExp` abstract operation
41542// https://tc39.github.io/ecma262/#sec-isregexp
41543module.exports = function (it) {
41544  var isRegExp;
41545  return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
41546};
41547
41548},{"../internals/classof-raw":230,"../internals/is-object":263,"../internals/well-known-symbol":314}],266:[function(require,module,exports){
41549var anObject = require('../internals/an-object');
41550var isArrayIteratorMethod = require('../internals/is-array-iterator-method');
41551var toLength = require('../internals/to-length');
41552var bind = require('../internals/function-bind-context');
41553var getIteratorMethod = require('../internals/get-iterator-method');
41554var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
41555
41556var Result = function (stopped, result) {
41557  this.stopped = stopped;
41558  this.result = result;
41559};
41560
41561var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
41562  var boundFunction = bind(fn, that, AS_ENTRIES ? 2 : 1);
41563  var iterator, iterFn, index, length, result, next, step;
41564
41565  if (IS_ITERATOR) {
41566    iterator = iterable;
41567  } else {
41568    iterFn = getIteratorMethod(iterable);
41569    if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
41570    // optimisation for array iterators
41571    if (isArrayIteratorMethod(iterFn)) {
41572      for (index = 0, length = toLength(iterable.length); length > index; index++) {
41573        result = AS_ENTRIES
41574          ? boundFunction(anObject(step = iterable[index])[0], step[1])
41575          : boundFunction(iterable[index]);
41576        if (result && result instanceof Result) return result;
41577      } return new Result(false);
41578    }
41579    iterator = iterFn.call(iterable);
41580  }
41581
41582  next = iterator.next;
41583  while (!(step = next.call(iterator)).done) {
41584    result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
41585    if (typeof result == 'object' && result && result instanceof Result) return result;
41586  } return new Result(false);
41587};
41588
41589iterate.stop = function (result) {
41590  return new Result(true, result);
41591};
41592
41593},{"../internals/an-object":223,"../internals/call-with-safe-iteration-closing":228,"../internals/function-bind-context":248,"../internals/get-iterator-method":250,"../internals/is-array-iterator-method":260,"../internals/to-length":307}],267:[function(require,module,exports){
41594'use strict';
41595var getPrototypeOf = require('../internals/object-get-prototype-of');
41596var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
41597var has = require('../internals/has');
41598var wellKnownSymbol = require('../internals/well-known-symbol');
41599var IS_PURE = require('../internals/is-pure');
41600
41601var ITERATOR = wellKnownSymbol('iterator');
41602var BUGGY_SAFARI_ITERATORS = false;
41603
41604var returnThis = function () { return this; };
41605
41606// `%IteratorPrototype%` object
41607// https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
41608var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
41609
41610if ([].keys) {
41611  arrayIterator = [].keys();
41612  // Safari 8 has buggy iterators w/o `next`
41613  if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
41614  else {
41615    PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
41616    if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
41617  }
41618}
41619
41620if (IteratorPrototype == undefined) IteratorPrototype = {};
41621
41622// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
41623if (!IS_PURE && !has(IteratorPrototype, ITERATOR)) {
41624  createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
41625}
41626
41627module.exports = {
41628  IteratorPrototype: IteratorPrototype,
41629  BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
41630};
41631
41632},{"../internals/create-non-enumerable-property":236,"../internals/has":252,"../internals/is-pure":264,"../internals/object-get-prototype-of":283,"../internals/well-known-symbol":314}],268:[function(require,module,exports){
41633arguments[4][253][0].apply(exports,arguments)
41634},{"dup":253}],269:[function(require,module,exports){
41635var global = require('../internals/global');
41636var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
41637var classof = require('../internals/classof-raw');
41638var macrotask = require('../internals/task').set;
41639var IS_IOS = require('../internals/engine-is-ios');
41640
41641var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
41642var process = global.process;
41643var Promise = global.Promise;
41644var IS_NODE = classof(process) == 'process';
41645// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
41646var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
41647var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
41648
41649var flush, head, last, notify, toggle, node, promise, then;
41650
41651// modern engines have queueMicrotask method
41652if (!queueMicrotask) {
41653  flush = function () {
41654    var parent, fn;
41655    if (IS_NODE && (parent = process.domain)) parent.exit();
41656    while (head) {
41657      fn = head.fn;
41658      head = head.next;
41659      try {
41660        fn();
41661      } catch (error) {
41662        if (head) notify();
41663        else last = undefined;
41664        throw error;
41665      }
41666    } last = undefined;
41667    if (parent) parent.enter();
41668  };
41669
41670  // Node.js
41671  if (IS_NODE) {
41672    notify = function () {
41673      process.nextTick(flush);
41674    };
41675  // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
41676  } else if (MutationObserver && !IS_IOS) {
41677    toggle = true;
41678    node = document.createTextNode('');
41679    new MutationObserver(flush).observe(node, { characterData: true });
41680    notify = function () {
41681      node.data = toggle = !toggle;
41682    };
41683  // environments with maybe non-completely correct, but existent Promise
41684  } else if (Promise && Promise.resolve) {
41685    // Promise.resolve without an argument throws an error in LG WebOS 2
41686    promise = Promise.resolve(undefined);
41687    then = promise.then;
41688    notify = function () {
41689      then.call(promise, flush);
41690    };
41691  // for other environments - macrotask based on:
41692  // - setImmediate
41693  // - MessageChannel
41694  // - window.postMessag
41695  // - onreadystatechange
41696  // - setTimeout
41697  } else {
41698    notify = function () {
41699      // strange IE + webpack dev server bug - use .call(global)
41700      macrotask.call(global, flush);
41701    };
41702  }
41703}
41704
41705module.exports = queueMicrotask || function (fn) {
41706  var task = { fn: fn, next: undefined };
41707  if (last) last.next = task;
41708  if (!head) {
41709    head = task;
41710    notify();
41711  } last = task;
41712};
41713
41714},{"../internals/classof-raw":230,"../internals/engine-is-ios":242,"../internals/global":251,"../internals/object-get-own-property-descriptor":279,"../internals/task":303}],270:[function(require,module,exports){
41715var global = require('../internals/global');
41716
41717module.exports = global.Promise;
41718
41719},{"../internals/global":251}],271:[function(require,module,exports){
41720var fails = require('../internals/fails');
41721
41722module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
41723  // Chrome 38 Symbol has incorrect toString conversion
41724  // eslint-disable-next-line no-undef
41725  return !String(Symbol());
41726});
41727
41728},{"../internals/fails":247}],272:[function(require,module,exports){
41729var global = require('../internals/global');
41730var inspectSource = require('../internals/inspect-source');
41731
41732var WeakMap = global.WeakMap;
41733
41734module.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));
41735
41736},{"../internals/global":251,"../internals/inspect-source":258}],273:[function(require,module,exports){
41737'use strict';
41738var aFunction = require('../internals/a-function');
41739
41740var PromiseCapability = function (C) {
41741  var resolve, reject;
41742  this.promise = new C(function ($$resolve, $$reject) {
41743    if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
41744    resolve = $$resolve;
41745    reject = $$reject;
41746  });
41747  this.resolve = aFunction(resolve);
41748  this.reject = aFunction(reject);
41749};
41750
41751// 25.4.1.5 NewPromiseCapability(C)
41752module.exports.f = function (C) {
41753  return new PromiseCapability(C);
41754};
41755
41756},{"../internals/a-function":219}],274:[function(require,module,exports){
41757var isRegExp = require('../internals/is-regexp');
41758
41759module.exports = function (it) {
41760  if (isRegExp(it)) {
41761    throw TypeError("The method doesn't accept regular expressions");
41762  } return it;
41763};
41764
41765},{"../internals/is-regexp":265}],275:[function(require,module,exports){
41766'use strict';
41767var DESCRIPTORS = require('../internals/descriptors');
41768var fails = require('../internals/fails');
41769var objectKeys = require('../internals/object-keys');
41770var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
41771var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
41772var toObject = require('../internals/to-object');
41773var IndexedObject = require('../internals/indexed-object');
41774
41775var nativeAssign = Object.assign;
41776var defineProperty = Object.defineProperty;
41777
41778// `Object.assign` method
41779// https://tc39.github.io/ecma262/#sec-object.assign
41780module.exports = !nativeAssign || fails(function () {
41781  // should have correct order of operations (Edge bug)
41782  if (DESCRIPTORS && nativeAssign({ b: 1 }, nativeAssign(defineProperty({}, 'a', {
41783    enumerable: true,
41784    get: function () {
41785      defineProperty(this, 'b', {
41786        value: 3,
41787        enumerable: false
41788      });
41789    }
41790  }), { b: 2 })).b !== 1) return true;
41791  // should work with symbols and should have deterministic property order (V8 bug)
41792  var A = {};
41793  var B = {};
41794  // eslint-disable-next-line no-undef
41795  var symbol = Symbol();
41796  var alphabet = 'abcdefghijklmnopqrst';
41797  A[symbol] = 7;
41798  alphabet.split('').forEach(function (chr) { B[chr] = chr; });
41799  return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
41800}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
41801  var T = toObject(target);
41802  var argumentsLength = arguments.length;
41803  var index = 1;
41804  var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
41805  var propertyIsEnumerable = propertyIsEnumerableModule.f;
41806  while (argumentsLength > index) {
41807    var S = IndexedObject(arguments[index++]);
41808    var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
41809    var length = keys.length;
41810    var j = 0;
41811    var key;
41812    while (length > j) {
41813      key = keys[j++];
41814      if (!DESCRIPTORS || propertyIsEnumerable.call(S, key)) T[key] = S[key];
41815    }
41816  } return T;
41817} : nativeAssign;
41818
41819},{"../internals/descriptors":240,"../internals/fails":247,"../internals/indexed-object":257,"../internals/object-get-own-property-symbols":282,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/to-object":308}],276:[function(require,module,exports){
41820var anObject = require('../internals/an-object');
41821var defineProperties = require('../internals/object-define-properties');
41822var enumBugKeys = require('../internals/enum-bug-keys');
41823var hiddenKeys = require('../internals/hidden-keys');
41824var html = require('../internals/html');
41825var documentCreateElement = require('../internals/document-create-element');
41826var sharedKey = require('../internals/shared-key');
41827
41828var GT = '>';
41829var LT = '<';
41830var PROTOTYPE = 'prototype';
41831var SCRIPT = 'script';
41832var IE_PROTO = sharedKey('IE_PROTO');
41833
41834var EmptyConstructor = function () { /* empty */ };
41835
41836var scriptTag = function (content) {
41837  return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
41838};
41839
41840// Create object with fake `null` prototype: use ActiveX Object with cleared prototype
41841var NullProtoObjectViaActiveX = function (activeXDocument) {
41842  activeXDocument.write(scriptTag(''));
41843  activeXDocument.close();
41844  var temp = activeXDocument.parentWindow.Object;
41845  activeXDocument = null; // avoid memory leak
41846  return temp;
41847};
41848
41849// Create object with fake `null` prototype: use iframe Object with cleared prototype
41850var NullProtoObjectViaIFrame = function () {
41851  // Thrash, waste and sodomy: IE GC bug
41852  var iframe = documentCreateElement('iframe');
41853  var JS = 'java' + SCRIPT + ':';
41854  var iframeDocument;
41855  iframe.style.display = 'none';
41856  html.appendChild(iframe);
41857  // https://github.com/zloirock/core-js/issues/475
41858  iframe.src = String(JS);
41859  iframeDocument = iframe.contentWindow.document;
41860  iframeDocument.open();
41861  iframeDocument.write(scriptTag('document.F=Object'));
41862  iframeDocument.close();
41863  return iframeDocument.F;
41864};
41865
41866// Check for document.domain and active x support
41867// No need to use active x approach when document.domain is not set
41868// see https://github.com/es-shims/es5-shim/issues/150
41869// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
41870// avoid IE GC bug
41871var activeXDocument;
41872var NullProtoObject = function () {
41873  try {
41874    /* global ActiveXObject */
41875    activeXDocument = document.domain && new ActiveXObject('htmlfile');
41876  } catch (error) { /* ignore */ }
41877  NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
41878  var length = enumBugKeys.length;
41879  while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
41880  return NullProtoObject();
41881};
41882
41883hiddenKeys[IE_PROTO] = true;
41884
41885// `Object.create` method
41886// https://tc39.github.io/ecma262/#sec-object.create
41887module.exports = Object.create || function create(O, Properties) {
41888  var result;
41889  if (O !== null) {
41890    EmptyConstructor[PROTOTYPE] = anObject(O);
41891    result = new EmptyConstructor();
41892    EmptyConstructor[PROTOTYPE] = null;
41893    // add "__proto__" for Object.getPrototypeOf polyfill
41894    result[IE_PROTO] = O;
41895  } else result = NullProtoObject();
41896  return Properties === undefined ? result : defineProperties(result, Properties);
41897};
41898
41899},{"../internals/an-object":223,"../internals/document-create-element":241,"../internals/enum-bug-keys":245,"../internals/hidden-keys":253,"../internals/html":255,"../internals/object-define-properties":277,"../internals/shared-key":299}],277:[function(require,module,exports){
41900var DESCRIPTORS = require('../internals/descriptors');
41901var definePropertyModule = require('../internals/object-define-property');
41902var anObject = require('../internals/an-object');
41903var objectKeys = require('../internals/object-keys');
41904
41905// `Object.defineProperties` method
41906// https://tc39.github.io/ecma262/#sec-object.defineproperties
41907module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
41908  anObject(O);
41909  var keys = objectKeys(Properties);
41910  var length = keys.length;
41911  var index = 0;
41912  var key;
41913  while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);
41914  return O;
41915};
41916
41917},{"../internals/an-object":223,"../internals/descriptors":240,"../internals/object-define-property":278,"../internals/object-keys":285}],278:[function(require,module,exports){
41918var DESCRIPTORS = require('../internals/descriptors');
41919var IE8_DOM_DEFINE = require('../internals/ie8-dom-define');
41920var anObject = require('../internals/an-object');
41921var toPrimitive = require('../internals/to-primitive');
41922
41923var nativeDefineProperty = Object.defineProperty;
41924
41925// `Object.defineProperty` method
41926// https://tc39.github.io/ecma262/#sec-object.defineproperty
41927exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
41928  anObject(O);
41929  P = toPrimitive(P, true);
41930  anObject(Attributes);
41931  if (IE8_DOM_DEFINE) try {
41932    return nativeDefineProperty(O, P, Attributes);
41933  } catch (error) { /* empty */ }
41934  if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
41935  if ('value' in Attributes) O[P] = Attributes.value;
41936  return O;
41937};
41938
41939},{"../internals/an-object":223,"../internals/descriptors":240,"../internals/ie8-dom-define":256,"../internals/to-primitive":309}],279:[function(require,module,exports){
41940var DESCRIPTORS = require('../internals/descriptors');
41941var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
41942var createPropertyDescriptor = require('../internals/create-property-descriptor');
41943var toIndexedObject = require('../internals/to-indexed-object');
41944var toPrimitive = require('../internals/to-primitive');
41945var has = require('../internals/has');
41946var IE8_DOM_DEFINE = require('../internals/ie8-dom-define');
41947
41948var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
41949
41950// `Object.getOwnPropertyDescriptor` method
41951// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
41952exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
41953  O = toIndexedObject(O);
41954  P = toPrimitive(P, true);
41955  if (IE8_DOM_DEFINE) try {
41956    return nativeGetOwnPropertyDescriptor(O, P);
41957  } catch (error) { /* empty */ }
41958  if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);
41959};
41960
41961},{"../internals/create-property-descriptor":237,"../internals/descriptors":240,"../internals/has":252,"../internals/ie8-dom-define":256,"../internals/object-property-is-enumerable":286,"../internals/to-indexed-object":305,"../internals/to-primitive":309}],280:[function(require,module,exports){
41962var toIndexedObject = require('../internals/to-indexed-object');
41963var nativeGetOwnPropertyNames = require('../internals/object-get-own-property-names').f;
41964
41965var toString = {}.toString;
41966
41967var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
41968  ? Object.getOwnPropertyNames(window) : [];
41969
41970var getWindowNames = function (it) {
41971  try {
41972    return nativeGetOwnPropertyNames(it);
41973  } catch (error) {
41974    return windowNames.slice();
41975  }
41976};
41977
41978// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
41979module.exports.f = function getOwnPropertyNames(it) {
41980  return windowNames && toString.call(it) == '[object Window]'
41981    ? getWindowNames(it)
41982    : nativeGetOwnPropertyNames(toIndexedObject(it));
41983};
41984
41985},{"../internals/object-get-own-property-names":281,"../internals/to-indexed-object":305}],281:[function(require,module,exports){
41986var internalObjectKeys = require('../internals/object-keys-internal');
41987var enumBugKeys = require('../internals/enum-bug-keys');
41988
41989var hiddenKeys = enumBugKeys.concat('length', 'prototype');
41990
41991// `Object.getOwnPropertyNames` method
41992// https://tc39.github.io/ecma262/#sec-object.getownpropertynames
41993exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
41994  return internalObjectKeys(O, hiddenKeys);
41995};
41996
41997},{"../internals/enum-bug-keys":245,"../internals/object-keys-internal":284}],282:[function(require,module,exports){
41998exports.f = Object.getOwnPropertySymbols;
41999
42000},{}],283:[function(require,module,exports){
42001var has = require('../internals/has');
42002var toObject = require('../internals/to-object');
42003var sharedKey = require('../internals/shared-key');
42004var CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');
42005
42006var IE_PROTO = sharedKey('IE_PROTO');
42007var ObjectPrototype = Object.prototype;
42008
42009// `Object.getPrototypeOf` method
42010// https://tc39.github.io/ecma262/#sec-object.getprototypeof
42011module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
42012  O = toObject(O);
42013  if (has(O, IE_PROTO)) return O[IE_PROTO];
42014  if (typeof O.constructor == 'function' && O instanceof O.constructor) {
42015    return O.constructor.prototype;
42016  } return O instanceof Object ? ObjectPrototype : null;
42017};
42018
42019},{"../internals/correct-prototype-getter":234,"../internals/has":252,"../internals/shared-key":299,"../internals/to-object":308}],284:[function(require,module,exports){
42020var has = require('../internals/has');
42021var toIndexedObject = require('../internals/to-indexed-object');
42022var indexOf = require('../internals/array-includes').indexOf;
42023var hiddenKeys = require('../internals/hidden-keys');
42024
42025module.exports = function (object, names) {
42026  var O = toIndexedObject(object);
42027  var i = 0;
42028  var result = [];
42029  var key;
42030  for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
42031  // Don't enum bug & hidden keys
42032  while (names.length > i) if (has(O, key = names[i++])) {
42033    ~indexOf(result, key) || result.push(key);
42034  }
42035  return result;
42036};
42037
42038},{"../internals/array-includes":224,"../internals/has":252,"../internals/hidden-keys":253,"../internals/to-indexed-object":305}],285:[function(require,module,exports){
42039var internalObjectKeys = require('../internals/object-keys-internal');
42040var enumBugKeys = require('../internals/enum-bug-keys');
42041
42042// `Object.keys` method
42043// https://tc39.github.io/ecma262/#sec-object.keys
42044module.exports = Object.keys || function keys(O) {
42045  return internalObjectKeys(O, enumBugKeys);
42046};
42047
42048},{"../internals/enum-bug-keys":245,"../internals/object-keys-internal":284}],286:[function(require,module,exports){
42049'use strict';
42050var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
42051var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
42052
42053// Nashorn ~ JDK8 bug
42054var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
42055
42056// `Object.prototype.propertyIsEnumerable` method implementation
42057// https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
42058exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
42059  var descriptor = getOwnPropertyDescriptor(this, V);
42060  return !!descriptor && descriptor.enumerable;
42061} : nativePropertyIsEnumerable;
42062
42063},{}],287:[function(require,module,exports){
42064var anObject = require('../internals/an-object');
42065var aPossiblePrototype = require('../internals/a-possible-prototype');
42066
42067// `Object.setPrototypeOf` method
42068// https://tc39.github.io/ecma262/#sec-object.setprototypeof
42069// Works with __proto__ only. Old v8 can't work with null proto objects.
42070/* eslint-disable no-proto */
42071module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
42072  var CORRECT_SETTER = false;
42073  var test = {};
42074  var setter;
42075  try {
42076    setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
42077    setter.call(test, []);
42078    CORRECT_SETTER = test instanceof Array;
42079  } catch (error) { /* empty */ }
42080  return function setPrototypeOf(O, proto) {
42081    anObject(O);
42082    aPossiblePrototype(proto);
42083    if (CORRECT_SETTER) setter.call(O, proto);
42084    else O.__proto__ = proto;
42085    return O;
42086  };
42087}() : undefined);
42088
42089},{"../internals/a-possible-prototype":220,"../internals/an-object":223}],288:[function(require,module,exports){
42090var DESCRIPTORS = require('../internals/descriptors');
42091var objectKeys = require('../internals/object-keys');
42092var toIndexedObject = require('../internals/to-indexed-object');
42093var propertyIsEnumerable = require('../internals/object-property-is-enumerable').f;
42094
42095// `Object.{ entries, values }` methods implementation
42096var createMethod = function (TO_ENTRIES) {
42097  return function (it) {
42098    var O = toIndexedObject(it);
42099    var keys = objectKeys(O);
42100    var length = keys.length;
42101    var i = 0;
42102    var result = [];
42103    var key;
42104    while (length > i) {
42105      key = keys[i++];
42106      if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {
42107        result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
42108      }
42109    }
42110    return result;
42111  };
42112};
42113
42114module.exports = {
42115  // `Object.entries` method
42116  // https://tc39.github.io/ecma262/#sec-object.entries
42117  entries: createMethod(true),
42118  // `Object.values` method
42119  // https://tc39.github.io/ecma262/#sec-object.values
42120  values: createMethod(false)
42121};
42122
42123},{"../internals/descriptors":240,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/to-indexed-object":305}],289:[function(require,module,exports){
42124var getBuiltIn = require('../internals/get-built-in');
42125var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');
42126var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
42127var anObject = require('../internals/an-object');
42128
42129// all object keys, includes non-enumerable and symbols
42130module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
42131  var keys = getOwnPropertyNamesModule.f(anObject(it));
42132  var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
42133  return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
42134};
42135
42136},{"../internals/an-object":223,"../internals/get-built-in":249,"../internals/object-get-own-property-names":281,"../internals/object-get-own-property-symbols":282}],290:[function(require,module,exports){
42137var global = require('../internals/global');
42138
42139module.exports = global;
42140
42141},{"../internals/global":251}],291:[function(require,module,exports){
42142module.exports = function (exec) {
42143  try {
42144    return { error: false, value: exec() };
42145  } catch (error) {
42146    return { error: true, value: error };
42147  }
42148};
42149
42150},{}],292:[function(require,module,exports){
42151var anObject = require('../internals/an-object');
42152var isObject = require('../internals/is-object');
42153var newPromiseCapability = require('../internals/new-promise-capability');
42154
42155module.exports = function (C, x) {
42156  anObject(C);
42157  if (isObject(x) && x.constructor === C) return x;
42158  var promiseCapability = newPromiseCapability.f(C);
42159  var resolve = promiseCapability.resolve;
42160  resolve(x);
42161  return promiseCapability.promise;
42162};
42163
42164},{"../internals/an-object":223,"../internals/is-object":263,"../internals/new-promise-capability":273}],293:[function(require,module,exports){
42165var redefine = require('../internals/redefine');
42166
42167module.exports = function (target, src, options) {
42168  for (var key in src) redefine(target, key, src[key], options);
42169  return target;
42170};
42171
42172},{"../internals/redefine":294}],294:[function(require,module,exports){
42173var global = require('../internals/global');
42174var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
42175var has = require('../internals/has');
42176var setGlobal = require('../internals/set-global');
42177var inspectSource = require('../internals/inspect-source');
42178var InternalStateModule = require('../internals/internal-state');
42179
42180var getInternalState = InternalStateModule.get;
42181var enforceInternalState = InternalStateModule.enforce;
42182var TEMPLATE = String(String).split('String');
42183
42184(module.exports = function (O, key, value, options) {
42185  var unsafe = options ? !!options.unsafe : false;
42186  var simple = options ? !!options.enumerable : false;
42187  var noTargetGet = options ? !!options.noTargetGet : false;
42188  if (typeof value == 'function') {
42189    if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);
42190    enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
42191  }
42192  if (O === global) {
42193    if (simple) O[key] = value;
42194    else setGlobal(key, value);
42195    return;
42196  } else if (!unsafe) {
42197    delete O[key];
42198  } else if (!noTargetGet && O[key]) {
42199    simple = true;
42200  }
42201  if (simple) O[key] = value;
42202  else createNonEnumerableProperty(O, key, value);
42203// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
42204})(Function.prototype, 'toString', function toString() {
42205  return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
42206});
42207
42208},{"../internals/create-non-enumerable-property":236,"../internals/global":251,"../internals/has":252,"../internals/inspect-source":258,"../internals/internal-state":259,"../internals/set-global":296}],295:[function(require,module,exports){
42209// `RequireObjectCoercible` abstract operation
42210// https://tc39.github.io/ecma262/#sec-requireobjectcoercible
42211module.exports = function (it) {
42212  if (it == undefined) throw TypeError("Can't call method on " + it);
42213  return it;
42214};
42215
42216},{}],296:[function(require,module,exports){
42217var global = require('../internals/global');
42218var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
42219
42220module.exports = function (key, value) {
42221  try {
42222    createNonEnumerableProperty(global, key, value);
42223  } catch (error) {
42224    global[key] = value;
42225  } return value;
42226};
42227
42228},{"../internals/create-non-enumerable-property":236,"../internals/global":251}],297:[function(require,module,exports){
42229'use strict';
42230var getBuiltIn = require('../internals/get-built-in');
42231var definePropertyModule = require('../internals/object-define-property');
42232var wellKnownSymbol = require('../internals/well-known-symbol');
42233var DESCRIPTORS = require('../internals/descriptors');
42234
42235var SPECIES = wellKnownSymbol('species');
42236
42237module.exports = function (CONSTRUCTOR_NAME) {
42238  var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
42239  var defineProperty = definePropertyModule.f;
42240
42241  if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
42242    defineProperty(Constructor, SPECIES, {
42243      configurable: true,
42244      get: function () { return this; }
42245    });
42246  }
42247};
42248
42249},{"../internals/descriptors":240,"../internals/get-built-in":249,"../internals/object-define-property":278,"../internals/well-known-symbol":314}],298:[function(require,module,exports){
42250var defineProperty = require('../internals/object-define-property').f;
42251var has = require('../internals/has');
42252var wellKnownSymbol = require('../internals/well-known-symbol');
42253
42254var TO_STRING_TAG = wellKnownSymbol('toStringTag');
42255
42256module.exports = function (it, TAG, STATIC) {
42257  if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
42258    defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });
42259  }
42260};
42261
42262},{"../internals/has":252,"../internals/object-define-property":278,"../internals/well-known-symbol":314}],299:[function(require,module,exports){
42263var shared = require('../internals/shared');
42264var uid = require('../internals/uid');
42265
42266var keys = shared('keys');
42267
42268module.exports = function (key) {
42269  return keys[key] || (keys[key] = uid(key));
42270};
42271
42272},{"../internals/shared":301,"../internals/uid":311}],300:[function(require,module,exports){
42273var global = require('../internals/global');
42274var setGlobal = require('../internals/set-global');
42275
42276var SHARED = '__core-js_shared__';
42277var store = global[SHARED] || setGlobal(SHARED, {});
42278
42279module.exports = store;
42280
42281},{"../internals/global":251,"../internals/set-global":296}],301:[function(require,module,exports){
42282var IS_PURE = require('../internals/is-pure');
42283var store = require('../internals/shared-store');
42284
42285(module.exports = function (key, value) {
42286  return store[key] || (store[key] = value !== undefined ? value : {});
42287})('versions', []).push({
42288  version: '3.6.5',
42289  mode: IS_PURE ? 'pure' : 'global',
42290  copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
42291});
42292
42293},{"../internals/is-pure":264,"../internals/shared-store":300}],302:[function(require,module,exports){
42294var anObject = require('../internals/an-object');
42295var aFunction = require('../internals/a-function');
42296var wellKnownSymbol = require('../internals/well-known-symbol');
42297
42298var SPECIES = wellKnownSymbol('species');
42299
42300// `SpeciesConstructor` abstract operation
42301// https://tc39.github.io/ecma262/#sec-speciesconstructor
42302module.exports = function (O, defaultConstructor) {
42303  var C = anObject(O).constructor;
42304  var S;
42305  return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);
42306};
42307
42308},{"../internals/a-function":219,"../internals/an-object":223,"../internals/well-known-symbol":314}],303:[function(require,module,exports){
42309var global = require('../internals/global');
42310var fails = require('../internals/fails');
42311var classof = require('../internals/classof-raw');
42312var bind = require('../internals/function-bind-context');
42313var html = require('../internals/html');
42314var createElement = require('../internals/document-create-element');
42315var IS_IOS = require('../internals/engine-is-ios');
42316
42317var location = global.location;
42318var set = global.setImmediate;
42319var clear = global.clearImmediate;
42320var process = global.process;
42321var MessageChannel = global.MessageChannel;
42322var Dispatch = global.Dispatch;
42323var counter = 0;
42324var queue = {};
42325var ONREADYSTATECHANGE = 'onreadystatechange';
42326var defer, channel, port;
42327
42328var run = function (id) {
42329  // eslint-disable-next-line no-prototype-builtins
42330  if (queue.hasOwnProperty(id)) {
42331    var fn = queue[id];
42332    delete queue[id];
42333    fn();
42334  }
42335};
42336
42337var runner = function (id) {
42338  return function () {
42339    run(id);
42340  };
42341};
42342
42343var listener = function (event) {
42344  run(event.data);
42345};
42346
42347var post = function (id) {
42348  // old engines have not location.origin
42349  global.postMessage(id + '', location.protocol + '//' + location.host);
42350};
42351
42352// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
42353if (!set || !clear) {
42354  set = function setImmediate(fn) {
42355    var args = [];
42356    var i = 1;
42357    while (arguments.length > i) args.push(arguments[i++]);
42358    queue[++counter] = function () {
42359      // eslint-disable-next-line no-new-func
42360      (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
42361    };
42362    defer(counter);
42363    return counter;
42364  };
42365  clear = function clearImmediate(id) {
42366    delete queue[id];
42367  };
42368  // Node.js 0.8-
42369  if (classof(process) == 'process') {
42370    defer = function (id) {
42371      process.nextTick(runner(id));
42372    };
42373  // Sphere (JS game engine) Dispatch API
42374  } else if (Dispatch && Dispatch.now) {
42375    defer = function (id) {
42376      Dispatch.now(runner(id));
42377    };
42378  // Browsers with MessageChannel, includes WebWorkers
42379  // except iOS - https://github.com/zloirock/core-js/issues/624
42380  } else if (MessageChannel && !IS_IOS) {
42381    channel = new MessageChannel();
42382    port = channel.port2;
42383    channel.port1.onmessage = listener;
42384    defer = bind(port.postMessage, port, 1);
42385  // Browsers with postMessage, skip WebWorkers
42386  // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
42387  } else if (
42388    global.addEventListener &&
42389    typeof postMessage == 'function' &&
42390    !global.importScripts &&
42391    !fails(post) &&
42392    location.protocol !== 'file:'
42393  ) {
42394    defer = post;
42395    global.addEventListener('message', listener, false);
42396  // IE8-
42397  } else if (ONREADYSTATECHANGE in createElement('script')) {
42398    defer = function (id) {
42399      html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
42400        html.removeChild(this);
42401        run(id);
42402      };
42403    };
42404  // Rest old browsers
42405  } else {
42406    defer = function (id) {
42407      setTimeout(runner(id), 0);
42408    };
42409  }
42410}
42411
42412module.exports = {
42413  set: set,
42414  clear: clear
42415};
42416
42417},{"../internals/classof-raw":230,"../internals/document-create-element":241,"../internals/engine-is-ios":242,"../internals/fails":247,"../internals/function-bind-context":248,"../internals/global":251,"../internals/html":255}],304:[function(require,module,exports){
42418var toInteger = require('../internals/to-integer');
42419
42420var max = Math.max;
42421var min = Math.min;
42422
42423// Helper for a popular repeating case of the spec:
42424// Let integer be ? ToInteger(index).
42425// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
42426module.exports = function (index, length) {
42427  var integer = toInteger(index);
42428  return integer < 0 ? max(integer + length, 0) : min(integer, length);
42429};
42430
42431},{"../internals/to-integer":306}],305:[function(require,module,exports){
42432// toObject with fallback for non-array-like ES3 strings
42433var IndexedObject = require('../internals/indexed-object');
42434var requireObjectCoercible = require('../internals/require-object-coercible');
42435
42436module.exports = function (it) {
42437  return IndexedObject(requireObjectCoercible(it));
42438};
42439
42440},{"../internals/indexed-object":257,"../internals/require-object-coercible":295}],306:[function(require,module,exports){
42441var ceil = Math.ceil;
42442var floor = Math.floor;
42443
42444// `ToInteger` abstract operation
42445// https://tc39.github.io/ecma262/#sec-tointeger
42446module.exports = function (argument) {
42447  return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
42448};
42449
42450},{}],307:[function(require,module,exports){
42451var toInteger = require('../internals/to-integer');
42452
42453var min = Math.min;
42454
42455// `ToLength` abstract operation
42456// https://tc39.github.io/ecma262/#sec-tolength
42457module.exports = function (argument) {
42458  return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
42459};
42460
42461},{"../internals/to-integer":306}],308:[function(require,module,exports){
42462var requireObjectCoercible = require('../internals/require-object-coercible');
42463
42464// `ToObject` abstract operation
42465// https://tc39.github.io/ecma262/#sec-toobject
42466module.exports = function (argument) {
42467  return Object(requireObjectCoercible(argument));
42468};
42469
42470},{"../internals/require-object-coercible":295}],309:[function(require,module,exports){
42471var isObject = require('../internals/is-object');
42472
42473// `ToPrimitive` abstract operation
42474// https://tc39.github.io/ecma262/#sec-toprimitive
42475// instead of the ES6 spec version, we didn't implement @@toPrimitive case
42476// and the second argument - flag - preferred type is a string
42477module.exports = function (input, PREFERRED_STRING) {
42478  if (!isObject(input)) return input;
42479  var fn, val;
42480  if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
42481  if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
42482  if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
42483  throw TypeError("Can't convert object to primitive value");
42484};
42485
42486},{"../internals/is-object":263}],310:[function(require,module,exports){
42487var wellKnownSymbol = require('../internals/well-known-symbol');
42488
42489var TO_STRING_TAG = wellKnownSymbol('toStringTag');
42490var test = {};
42491
42492test[TO_STRING_TAG] = 'z';
42493
42494module.exports = String(test) === '[object z]';
42495
42496},{"../internals/well-known-symbol":314}],311:[function(require,module,exports){
42497var id = 0;
42498var postfix = Math.random();
42499
42500module.exports = function (key) {
42501  return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
42502};
42503
42504},{}],312:[function(require,module,exports){
42505var NATIVE_SYMBOL = require('../internals/native-symbol');
42506
42507module.exports = NATIVE_SYMBOL
42508  // eslint-disable-next-line no-undef
42509  && !Symbol.sham
42510  // eslint-disable-next-line no-undef
42511  && typeof Symbol.iterator == 'symbol';
42512
42513},{"../internals/native-symbol":271}],313:[function(require,module,exports){
42514var wellKnownSymbol = require('../internals/well-known-symbol');
42515
42516exports.f = wellKnownSymbol;
42517
42518},{"../internals/well-known-symbol":314}],314:[function(require,module,exports){
42519var global = require('../internals/global');
42520var shared = require('../internals/shared');
42521var has = require('../internals/has');
42522var uid = require('../internals/uid');
42523var NATIVE_SYMBOL = require('../internals/native-symbol');
42524var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
42525
42526var WellKnownSymbolsStore = shared('wks');
42527var Symbol = global.Symbol;
42528var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
42529
42530module.exports = function (name) {
42531  if (!has(WellKnownSymbolsStore, name)) {
42532    if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];
42533    else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
42534  } return WellKnownSymbolsStore[name];
42535};
42536
42537},{"../internals/global":251,"../internals/has":252,"../internals/native-symbol":271,"../internals/shared":301,"../internals/uid":311,"../internals/use-symbol-as-uid":312}],315:[function(require,module,exports){
42538'use strict';
42539var $ = require('../internals/export');
42540var $findIndex = require('../internals/array-iteration').findIndex;
42541var addToUnscopables = require('../internals/add-to-unscopables');
42542var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
42543
42544var FIND_INDEX = 'findIndex';
42545var SKIPS_HOLES = true;
42546
42547var USES_TO_LENGTH = arrayMethodUsesToLength(FIND_INDEX);
42548
42549// Shouldn't skip holes
42550if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });
42551
42552// `Array.prototype.findIndex` method
42553// https://tc39.github.io/ecma262/#sec-array.prototype.findindex
42554$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {
42555  findIndex: function findIndex(callbackfn /* , that = undefined */) {
42556    return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
42557  }
42558});
42559
42560// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
42561addToUnscopables(FIND_INDEX);
42562
42563},{"../internals/add-to-unscopables":221,"../internals/array-iteration":225,"../internals/array-method-uses-to-length":226,"../internals/export":246}],316:[function(require,module,exports){
42564'use strict';
42565var $ = require('../internals/export');
42566var $find = require('../internals/array-iteration').find;
42567var addToUnscopables = require('../internals/add-to-unscopables');
42568var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
42569
42570var FIND = 'find';
42571var SKIPS_HOLES = true;
42572
42573var USES_TO_LENGTH = arrayMethodUsesToLength(FIND);
42574
42575// Shouldn't skip holes
42576if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
42577
42578// `Array.prototype.find` method
42579// https://tc39.github.io/ecma262/#sec-array.prototype.find
42580$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {
42581  find: function find(callbackfn /* , that = undefined */) {
42582    return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
42583  }
42584});
42585
42586// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
42587addToUnscopables(FIND);
42588
42589},{"../internals/add-to-unscopables":221,"../internals/array-iteration":225,"../internals/array-method-uses-to-length":226,"../internals/export":246}],317:[function(require,module,exports){
42590'use strict';
42591var $ = require('../internals/export');
42592var $includes = require('../internals/array-includes').includes;
42593var addToUnscopables = require('../internals/add-to-unscopables');
42594var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
42595
42596var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
42597
42598// `Array.prototype.includes` method
42599// https://tc39.github.io/ecma262/#sec-array.prototype.includes
42600$({ target: 'Array', proto: true, forced: !USES_TO_LENGTH }, {
42601  includes: function includes(el /* , fromIndex = 0 */) {
42602    return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
42603  }
42604});
42605
42606// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
42607addToUnscopables('includes');
42608
42609},{"../internals/add-to-unscopables":221,"../internals/array-includes":224,"../internals/array-method-uses-to-length":226,"../internals/export":246}],318:[function(require,module,exports){
42610'use strict';
42611var toIndexedObject = require('../internals/to-indexed-object');
42612var addToUnscopables = require('../internals/add-to-unscopables');
42613var Iterators = require('../internals/iterators');
42614var InternalStateModule = require('../internals/internal-state');
42615var defineIterator = require('../internals/define-iterator');
42616
42617var ARRAY_ITERATOR = 'Array Iterator';
42618var setInternalState = InternalStateModule.set;
42619var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
42620
42621// `Array.prototype.entries` method
42622// https://tc39.github.io/ecma262/#sec-array.prototype.entries
42623// `Array.prototype.keys` method
42624// https://tc39.github.io/ecma262/#sec-array.prototype.keys
42625// `Array.prototype.values` method
42626// https://tc39.github.io/ecma262/#sec-array.prototype.values
42627// `Array.prototype[@@iterator]` method
42628// https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
42629// `CreateArrayIterator` internal method
42630// https://tc39.github.io/ecma262/#sec-createarrayiterator
42631module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
42632  setInternalState(this, {
42633    type: ARRAY_ITERATOR,
42634    target: toIndexedObject(iterated), // target
42635    index: 0,                          // next index
42636    kind: kind                         // kind
42637  });
42638// `%ArrayIteratorPrototype%.next` method
42639// https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
42640}, function () {
42641  var state = getInternalState(this);
42642  var target = state.target;
42643  var kind = state.kind;
42644  var index = state.index++;
42645  if (!target || index >= target.length) {
42646    state.target = undefined;
42647    return { value: undefined, done: true };
42648  }
42649  if (kind == 'keys') return { value: index, done: false };
42650  if (kind == 'values') return { value: target[index], done: false };
42651  return { value: [index, target[index]], done: false };
42652}, 'values');
42653
42654// argumentsList[@@iterator] is %ArrayProto_values%
42655// https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
42656// https://tc39.github.io/ecma262/#sec-createmappedargumentsobject
42657Iterators.Arguments = Iterators.Array;
42658
42659// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
42660addToUnscopables('keys');
42661addToUnscopables('values');
42662addToUnscopables('entries');
42663
42664},{"../internals/add-to-unscopables":221,"../internals/define-iterator":238,"../internals/internal-state":259,"../internals/iterators":268,"../internals/to-indexed-object":305}],319:[function(require,module,exports){
42665var $ = require('../internals/export');
42666
42667// `Number.isNaN` method
42668// https://tc39.github.io/ecma262/#sec-number.isnan
42669$({ target: 'Number', stat: true }, {
42670  isNaN: function isNaN(number) {
42671    // eslint-disable-next-line no-self-compare
42672    return number != number;
42673  }
42674});
42675
42676},{"../internals/export":246}],320:[function(require,module,exports){
42677var $ = require('../internals/export');
42678var assign = require('../internals/object-assign');
42679
42680// `Object.assign` method
42681// https://tc39.github.io/ecma262/#sec-object.assign
42682$({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
42683  assign: assign
42684});
42685
42686},{"../internals/export":246,"../internals/object-assign":275}],321:[function(require,module,exports){
42687var $ = require('../internals/export');
42688var toObject = require('../internals/to-object');
42689var nativeKeys = require('../internals/object-keys');
42690var fails = require('../internals/fails');
42691
42692var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
42693
42694// `Object.keys` method
42695// https://tc39.github.io/ecma262/#sec-object.keys
42696$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
42697  keys: function keys(it) {
42698    return nativeKeys(toObject(it));
42699  }
42700});
42701
42702},{"../internals/export":246,"../internals/fails":247,"../internals/object-keys":285,"../internals/to-object":308}],322:[function(require,module,exports){
42703var $ = require('../internals/export');
42704var $values = require('../internals/object-to-array').values;
42705
42706// `Object.values` method
42707// https://tc39.github.io/ecma262/#sec-object.values
42708$({ target: 'Object', stat: true }, {
42709  values: function values(O) {
42710    return $values(O);
42711  }
42712});
42713
42714},{"../internals/export":246,"../internals/object-to-array":288}],323:[function(require,module,exports){
42715'use strict';
42716var $ = require('../internals/export');
42717var IS_PURE = require('../internals/is-pure');
42718var global = require('../internals/global');
42719var getBuiltIn = require('../internals/get-built-in');
42720var NativePromise = require('../internals/native-promise-constructor');
42721var redefine = require('../internals/redefine');
42722var redefineAll = require('../internals/redefine-all');
42723var setToStringTag = require('../internals/set-to-string-tag');
42724var setSpecies = require('../internals/set-species');
42725var isObject = require('../internals/is-object');
42726var aFunction = require('../internals/a-function');
42727var anInstance = require('../internals/an-instance');
42728var classof = require('../internals/classof-raw');
42729var inspectSource = require('../internals/inspect-source');
42730var iterate = require('../internals/iterate');
42731var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');
42732var speciesConstructor = require('../internals/species-constructor');
42733var task = require('../internals/task').set;
42734var microtask = require('../internals/microtask');
42735var promiseResolve = require('../internals/promise-resolve');
42736var hostReportErrors = require('../internals/host-report-errors');
42737var newPromiseCapabilityModule = require('../internals/new-promise-capability');
42738var perform = require('../internals/perform');
42739var InternalStateModule = require('../internals/internal-state');
42740var isForced = require('../internals/is-forced');
42741var wellKnownSymbol = require('../internals/well-known-symbol');
42742var V8_VERSION = require('../internals/engine-v8-version');
42743
42744var SPECIES = wellKnownSymbol('species');
42745var PROMISE = 'Promise';
42746var getInternalState = InternalStateModule.get;
42747var setInternalState = InternalStateModule.set;
42748var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
42749var PromiseConstructor = NativePromise;
42750var TypeError = global.TypeError;
42751var document = global.document;
42752var process = global.process;
42753var $fetch = getBuiltIn('fetch');
42754var newPromiseCapability = newPromiseCapabilityModule.f;
42755var newGenericPromiseCapability = newPromiseCapability;
42756var IS_NODE = classof(process) == 'process';
42757var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
42758var UNHANDLED_REJECTION = 'unhandledrejection';
42759var REJECTION_HANDLED = 'rejectionhandled';
42760var PENDING = 0;
42761var FULFILLED = 1;
42762var REJECTED = 2;
42763var HANDLED = 1;
42764var UNHANDLED = 2;
42765var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
42766
42767var FORCED = isForced(PROMISE, function () {
42768  var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
42769  if (!GLOBAL_CORE_JS_PROMISE) {
42770    // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
42771    // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
42772    // We can't detect it synchronously, so just check versions
42773    if (V8_VERSION === 66) return true;
42774    // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
42775    if (!IS_NODE && typeof PromiseRejectionEvent != 'function') return true;
42776  }
42777  // We need Promise#finally in the pure version for preventing prototype pollution
42778  if (IS_PURE && !PromiseConstructor.prototype['finally']) return true;
42779  // We can't use @@species feature detection in V8 since it causes
42780  // deoptimization and performance degradation
42781  // https://github.com/zloirock/core-js/issues/679
42782  if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false;
42783  // Detect correctness of subclassing with @@species support
42784  var promise = PromiseConstructor.resolve(1);
42785  var FakePromise = function (exec) {
42786    exec(function () { /* empty */ }, function () { /* empty */ });
42787  };
42788  var constructor = promise.constructor = {};
42789  constructor[SPECIES] = FakePromise;
42790  return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
42791});
42792
42793var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
42794  PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
42795});
42796
42797// helpers
42798var isThenable = function (it) {
42799  var then;
42800  return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
42801};
42802
42803var notify = function (promise, state, isReject) {
42804  if (state.notified) return;
42805  state.notified = true;
42806  var chain = state.reactions;
42807  microtask(function () {
42808    var value = state.value;
42809    var ok = state.state == FULFILLED;
42810    var index = 0;
42811    // variable length - can't use forEach
42812    while (chain.length > index) {
42813      var reaction = chain[index++];
42814      var handler = ok ? reaction.ok : reaction.fail;
42815      var resolve = reaction.resolve;
42816      var reject = reaction.reject;
42817      var domain = reaction.domain;
42818      var result, then, exited;
42819      try {
42820        if (handler) {
42821          if (!ok) {
42822            if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);
42823            state.rejection = HANDLED;
42824          }
42825          if (handler === true) result = value;
42826          else {
42827            if (domain) domain.enter();
42828            result = handler(value); // can throw
42829            if (domain) {
42830              domain.exit();
42831              exited = true;
42832            }
42833          }
42834          if (result === reaction.promise) {
42835            reject(TypeError('Promise-chain cycle'));
42836          } else if (then = isThenable(result)) {
42837            then.call(result, resolve, reject);
42838          } else resolve(result);
42839        } else reject(value);
42840      } catch (error) {
42841        if (domain && !exited) domain.exit();
42842        reject(error);
42843      }
42844    }
42845    state.reactions = [];
42846    state.notified = false;
42847    if (isReject && !state.rejection) onUnhandled(promise, state);
42848  });
42849};
42850
42851var dispatchEvent = function (name, promise, reason) {
42852  var event, handler;
42853  if (DISPATCH_EVENT) {
42854    event = document.createEvent('Event');
42855    event.promise = promise;
42856    event.reason = reason;
42857    event.initEvent(name, false, true);
42858    global.dispatchEvent(event);
42859  } else event = { promise: promise, reason: reason };
42860  if (handler = global['on' + name]) handler(event);
42861  else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
42862};
42863
42864var onUnhandled = function (promise, state) {
42865  task.call(global, function () {
42866    var value = state.value;
42867    var IS_UNHANDLED = isUnhandled(state);
42868    var result;
42869    if (IS_UNHANDLED) {
42870      result = perform(function () {
42871        if (IS_NODE) {
42872          process.emit('unhandledRejection', value, promise);
42873        } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
42874      });
42875      // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
42876      state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
42877      if (result.error) throw result.value;
42878    }
42879  });
42880};
42881
42882var isUnhandled = function (state) {
42883  return state.rejection !== HANDLED && !state.parent;
42884};
42885
42886var onHandleUnhandled = function (promise, state) {
42887  task.call(global, function () {
42888    if (IS_NODE) {
42889      process.emit('rejectionHandled', promise);
42890    } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
42891  });
42892};
42893
42894var bind = function (fn, promise, state, unwrap) {
42895  return function (value) {
42896    fn(promise, state, value, unwrap);
42897  };
42898};
42899
42900var internalReject = function (promise, state, value, unwrap) {
42901  if (state.done) return;
42902  state.done = true;
42903  if (unwrap) state = unwrap;
42904  state.value = value;
42905  state.state = REJECTED;
42906  notify(promise, state, true);
42907};
42908
42909var internalResolve = function (promise, state, value, unwrap) {
42910  if (state.done) return;
42911  state.done = true;
42912  if (unwrap) state = unwrap;
42913  try {
42914    if (promise === value) throw TypeError("Promise can't be resolved itself");
42915    var then = isThenable(value);
42916    if (then) {
42917      microtask(function () {
42918        var wrapper = { done: false };
42919        try {
42920          then.call(value,
42921            bind(internalResolve, promise, wrapper, state),
42922            bind(internalReject, promise, wrapper, state)
42923          );
42924        } catch (error) {
42925          internalReject(promise, wrapper, error, state);
42926        }
42927      });
42928    } else {
42929      state.value = value;
42930      state.state = FULFILLED;
42931      notify(promise, state, false);
42932    }
42933  } catch (error) {
42934    internalReject(promise, { done: false }, error, state);
42935  }
42936};
42937
42938// constructor polyfill
42939if (FORCED) {
42940  // 25.4.3.1 Promise(executor)
42941  PromiseConstructor = function Promise(executor) {
42942    anInstance(this, PromiseConstructor, PROMISE);
42943    aFunction(executor);
42944    Internal.call(this);
42945    var state = getInternalState(this);
42946    try {
42947      executor(bind(internalResolve, this, state), bind(internalReject, this, state));
42948    } catch (error) {
42949      internalReject(this, state, error);
42950    }
42951  };
42952  // eslint-disable-next-line no-unused-vars
42953  Internal = function Promise(executor) {
42954    setInternalState(this, {
42955      type: PROMISE,
42956      done: false,
42957      notified: false,
42958      parent: false,
42959      reactions: [],
42960      rejection: false,
42961      state: PENDING,
42962      value: undefined
42963    });
42964  };
42965  Internal.prototype = redefineAll(PromiseConstructor.prototype, {
42966    // `Promise.prototype.then` method
42967    // https://tc39.github.io/ecma262/#sec-promise.prototype.then
42968    then: function then(onFulfilled, onRejected) {
42969      var state = getInternalPromiseState(this);
42970      var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
42971      reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
42972      reaction.fail = typeof onRejected == 'function' && onRejected;
42973      reaction.domain = IS_NODE ? process.domain : undefined;
42974      state.parent = true;
42975      state.reactions.push(reaction);
42976      if (state.state != PENDING) notify(this, state, false);
42977      return reaction.promise;
42978    },
42979    // `Promise.prototype.catch` method
42980    // https://tc39.github.io/ecma262/#sec-promise.prototype.catch
42981    'catch': function (onRejected) {
42982      return this.then(undefined, onRejected);
42983    }
42984  });
42985  OwnPromiseCapability = function () {
42986    var promise = new Internal();
42987    var state = getInternalState(promise);
42988    this.promise = promise;
42989    this.resolve = bind(internalResolve, promise, state);
42990    this.reject = bind(internalReject, promise, state);
42991  };
42992  newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
42993    return C === PromiseConstructor || C === PromiseWrapper
42994      ? new OwnPromiseCapability(C)
42995      : newGenericPromiseCapability(C);
42996  };
42997
42998  if (!IS_PURE && typeof NativePromise == 'function') {
42999    nativeThen = NativePromise.prototype.then;
43000
43001    // wrap native Promise#then for native async functions
43002    redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {
43003      var that = this;
43004      return new PromiseConstructor(function (resolve, reject) {
43005        nativeThen.call(that, resolve, reject);
43006      }).then(onFulfilled, onRejected);
43007    // https://github.com/zloirock/core-js/issues/640
43008    }, { unsafe: true });
43009
43010    // wrap fetch result
43011    if (typeof $fetch == 'function') $({ global: true, enumerable: true, forced: true }, {
43012      // eslint-disable-next-line no-unused-vars
43013      fetch: function fetch(input /* , init */) {
43014        return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
43015      }
43016    });
43017  }
43018}
43019
43020$({ global: true, wrap: true, forced: FORCED }, {
43021  Promise: PromiseConstructor
43022});
43023
43024setToStringTag(PromiseConstructor, PROMISE, false, true);
43025setSpecies(PROMISE);
43026
43027PromiseWrapper = getBuiltIn(PROMISE);
43028
43029// statics
43030$({ target: PROMISE, stat: true, forced: FORCED }, {
43031  // `Promise.reject` method
43032  // https://tc39.github.io/ecma262/#sec-promise.reject
43033  reject: function reject(r) {
43034    var capability = newPromiseCapability(this);
43035    capability.reject.call(undefined, r);
43036    return capability.promise;
43037  }
43038});
43039
43040$({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, {
43041  // `Promise.resolve` method
43042  // https://tc39.github.io/ecma262/#sec-promise.resolve
43043  resolve: function resolve(x) {
43044    return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
43045  }
43046});
43047
43048$({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
43049  // `Promise.all` method
43050  // https://tc39.github.io/ecma262/#sec-promise.all
43051  all: function all(iterable) {
43052    var C = this;
43053    var capability = newPromiseCapability(C);
43054    var resolve = capability.resolve;
43055    var reject = capability.reject;
43056    var result = perform(function () {
43057      var $promiseResolve = aFunction(C.resolve);
43058      var values = [];
43059      var counter = 0;
43060      var remaining = 1;
43061      iterate(iterable, function (promise) {
43062        var index = counter++;
43063        var alreadyCalled = false;
43064        values.push(undefined);
43065        remaining++;
43066        $promiseResolve.call(C, promise).then(function (value) {
43067          if (alreadyCalled) return;
43068          alreadyCalled = true;
43069          values[index] = value;
43070          --remaining || resolve(values);
43071        }, reject);
43072      });
43073      --remaining || resolve(values);
43074    });
43075    if (result.error) reject(result.value);
43076    return capability.promise;
43077  },
43078  // `Promise.race` method
43079  // https://tc39.github.io/ecma262/#sec-promise.race
43080  race: function race(iterable) {
43081    var C = this;
43082    var capability = newPromiseCapability(C);
43083    var reject = capability.reject;
43084    var result = perform(function () {
43085      var $promiseResolve = aFunction(C.resolve);
43086      iterate(iterable, function (promise) {
43087        $promiseResolve.call(C, promise).then(capability.resolve, reject);
43088      });
43089    });
43090    if (result.error) reject(result.value);
43091    return capability.promise;
43092  }
43093});
43094
43095},{"../internals/a-function":219,"../internals/an-instance":222,"../internals/check-correctness-of-iteration":229,"../internals/classof-raw":230,"../internals/engine-v8-version":244,"../internals/export":246,"../internals/get-built-in":249,"../internals/global":251,"../internals/host-report-errors":254,"../internals/inspect-source":258,"../internals/internal-state":259,"../internals/is-forced":262,"../internals/is-object":263,"../internals/is-pure":264,"../internals/iterate":266,"../internals/microtask":269,"../internals/native-promise-constructor":270,"../internals/new-promise-capability":273,"../internals/perform":291,"../internals/promise-resolve":292,"../internals/redefine":294,"../internals/redefine-all":293,"../internals/set-species":297,"../internals/set-to-string-tag":298,"../internals/species-constructor":302,"../internals/task":303,"../internals/well-known-symbol":314}],324:[function(require,module,exports){
43096var $ = require('../internals/export');
43097var toAbsoluteIndex = require('../internals/to-absolute-index');
43098
43099var fromCharCode = String.fromCharCode;
43100var nativeFromCodePoint = String.fromCodePoint;
43101
43102// length should be 1, old FF problem
43103var INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1;
43104
43105// `String.fromCodePoint` method
43106// https://tc39.github.io/ecma262/#sec-string.fromcodepoint
43107$({ target: 'String', stat: true, forced: INCORRECT_LENGTH }, {
43108  fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
43109    var elements = [];
43110    var length = arguments.length;
43111    var i = 0;
43112    var code;
43113    while (length > i) {
43114      code = +arguments[i++];
43115      if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point');
43116      elements.push(code < 0x10000
43117        ? fromCharCode(code)
43118        : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00)
43119      );
43120    } return elements.join('');
43121  }
43122});
43123
43124},{"../internals/export":246,"../internals/to-absolute-index":304}],325:[function(require,module,exports){
43125'use strict';
43126var $ = require('../internals/export');
43127var notARegExp = require('../internals/not-a-regexp');
43128var requireObjectCoercible = require('../internals/require-object-coercible');
43129var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');
43130
43131// `String.prototype.includes` method
43132// https://tc39.github.io/ecma262/#sec-string.prototype.includes
43133$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
43134  includes: function includes(searchString /* , position = 0 */) {
43135    return !!~String(requireObjectCoercible(this))
43136      .indexOf(notARegExp(searchString), arguments.length > 1 ? arguments[1] : undefined);
43137  }
43138});
43139
43140},{"../internals/correct-is-regexp-logic":233,"../internals/export":246,"../internals/not-a-regexp":274,"../internals/require-object-coercible":295}],326:[function(require,module,exports){
43141var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
43142
43143// `Symbol.asyncIterator` well-known symbol
43144// https://tc39.github.io/ecma262/#sec-symbol.asynciterator
43145defineWellKnownSymbol('asyncIterator');
43146
43147},{"../internals/define-well-known-symbol":239}],327:[function(require,module,exports){
43148'use strict';
43149var $ = require('../internals/export');
43150var global = require('../internals/global');
43151var getBuiltIn = require('../internals/get-built-in');
43152var IS_PURE = require('../internals/is-pure');
43153var DESCRIPTORS = require('../internals/descriptors');
43154var NATIVE_SYMBOL = require('../internals/native-symbol');
43155var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
43156var fails = require('../internals/fails');
43157var has = require('../internals/has');
43158var isArray = require('../internals/is-array');
43159var isObject = require('../internals/is-object');
43160var anObject = require('../internals/an-object');
43161var toObject = require('../internals/to-object');
43162var toIndexedObject = require('../internals/to-indexed-object');
43163var toPrimitive = require('../internals/to-primitive');
43164var createPropertyDescriptor = require('../internals/create-property-descriptor');
43165var nativeObjectCreate = require('../internals/object-create');
43166var objectKeys = require('../internals/object-keys');
43167var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');
43168var getOwnPropertyNamesExternal = require('../internals/object-get-own-property-names-external');
43169var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
43170var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
43171var definePropertyModule = require('../internals/object-define-property');
43172var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
43173var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
43174var redefine = require('../internals/redefine');
43175var shared = require('../internals/shared');
43176var sharedKey = require('../internals/shared-key');
43177var hiddenKeys = require('../internals/hidden-keys');
43178var uid = require('../internals/uid');
43179var wellKnownSymbol = require('../internals/well-known-symbol');
43180var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');
43181var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
43182var setToStringTag = require('../internals/set-to-string-tag');
43183var InternalStateModule = require('../internals/internal-state');
43184var $forEach = require('../internals/array-iteration').forEach;
43185
43186var HIDDEN = sharedKey('hidden');
43187var SYMBOL = 'Symbol';
43188var PROTOTYPE = 'prototype';
43189var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
43190var setInternalState = InternalStateModule.set;
43191var getInternalState = InternalStateModule.getterFor(SYMBOL);
43192var ObjectPrototype = Object[PROTOTYPE];
43193var $Symbol = global.Symbol;
43194var $stringify = getBuiltIn('JSON', 'stringify');
43195var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
43196var nativeDefineProperty = definePropertyModule.f;
43197var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
43198var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
43199var AllSymbols = shared('symbols');
43200var ObjectPrototypeSymbols = shared('op-symbols');
43201var StringToSymbolRegistry = shared('string-to-symbol-registry');
43202var SymbolToStringRegistry = shared('symbol-to-string-registry');
43203var WellKnownSymbolsStore = shared('wks');
43204var QObject = global.QObject;
43205// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
43206var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
43207
43208// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
43209var setSymbolDescriptor = DESCRIPTORS && fails(function () {
43210  return nativeObjectCreate(nativeDefineProperty({}, 'a', {
43211    get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
43212  })).a != 7;
43213}) ? function (O, P, Attributes) {
43214  var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
43215  if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
43216  nativeDefineProperty(O, P, Attributes);
43217  if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
43218    nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
43219  }
43220} : nativeDefineProperty;
43221
43222var wrap = function (tag, description) {
43223  var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);
43224  setInternalState(symbol, {
43225    type: SYMBOL,
43226    tag: tag,
43227    description: description
43228  });
43229  if (!DESCRIPTORS) symbol.description = description;
43230  return symbol;
43231};
43232
43233var isSymbol = USE_SYMBOL_AS_UID ? function (it) {
43234  return typeof it == 'symbol';
43235} : function (it) {
43236  return Object(it) instanceof $Symbol;
43237};
43238
43239var $defineProperty = function defineProperty(O, P, Attributes) {
43240  if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
43241  anObject(O);
43242  var key = toPrimitive(P, true);
43243  anObject(Attributes);
43244  if (has(AllSymbols, key)) {
43245    if (!Attributes.enumerable) {
43246      if (!has(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
43247      O[HIDDEN][key] = true;
43248    } else {
43249      if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
43250      Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
43251    } return setSymbolDescriptor(O, key, Attributes);
43252  } return nativeDefineProperty(O, key, Attributes);
43253};
43254
43255var $defineProperties = function defineProperties(O, Properties) {
43256  anObject(O);
43257  var properties = toIndexedObject(Properties);
43258  var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
43259  $forEach(keys, function (key) {
43260    if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);
43261  });
43262  return O;
43263};
43264
43265var $create = function create(O, Properties) {
43266  return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
43267};
43268
43269var $propertyIsEnumerable = function propertyIsEnumerable(V) {
43270  var P = toPrimitive(V, true);
43271  var enumerable = nativePropertyIsEnumerable.call(this, P);
43272  if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;
43273  return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
43274};
43275
43276var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
43277  var it = toIndexedObject(O);
43278  var key = toPrimitive(P, true);
43279  if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;
43280  var descriptor = nativeGetOwnPropertyDescriptor(it, key);
43281  if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {
43282    descriptor.enumerable = true;
43283  }
43284  return descriptor;
43285};
43286
43287var $getOwnPropertyNames = function getOwnPropertyNames(O) {
43288  var names = nativeGetOwnPropertyNames(toIndexedObject(O));
43289  var result = [];
43290  $forEach(names, function (key) {
43291    if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);
43292  });
43293  return result;
43294};
43295
43296var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
43297  var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
43298  var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
43299  var result = [];
43300  $forEach(names, function (key) {
43301    if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {
43302      result.push(AllSymbols[key]);
43303    }
43304  });
43305  return result;
43306};
43307
43308// `Symbol` constructor
43309// https://tc39.github.io/ecma262/#sec-symbol-constructor
43310if (!NATIVE_SYMBOL) {
43311  $Symbol = function Symbol() {
43312    if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');
43313    var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);
43314    var tag = uid(description);
43315    var setter = function (value) {
43316      if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);
43317      if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
43318      setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
43319    };
43320    if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
43321    return wrap(tag, description);
43322  };
43323
43324  redefine($Symbol[PROTOTYPE], 'toString', function toString() {
43325    return getInternalState(this).tag;
43326  });
43327
43328  redefine($Symbol, 'withoutSetter', function (description) {
43329    return wrap(uid(description), description);
43330  });
43331
43332  propertyIsEnumerableModule.f = $propertyIsEnumerable;
43333  definePropertyModule.f = $defineProperty;
43334  getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
43335  getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
43336  getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
43337
43338  wrappedWellKnownSymbolModule.f = function (name) {
43339    return wrap(wellKnownSymbol(name), name);
43340  };
43341
43342  if (DESCRIPTORS) {
43343    // https://github.com/tc39/proposal-Symbol-description
43344    nativeDefineProperty($Symbol[PROTOTYPE], 'description', {
43345      configurable: true,
43346      get: function description() {
43347        return getInternalState(this).description;
43348      }
43349    });
43350    if (!IS_PURE) {
43351      redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
43352    }
43353  }
43354}
43355
43356$({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
43357  Symbol: $Symbol
43358});
43359
43360$forEach(objectKeys(WellKnownSymbolsStore), function (name) {
43361  defineWellKnownSymbol(name);
43362});
43363
43364$({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
43365  // `Symbol.for` method
43366  // https://tc39.github.io/ecma262/#sec-symbol.for
43367  'for': function (key) {
43368    var string = String(key);
43369    if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
43370    var symbol = $Symbol(string);
43371    StringToSymbolRegistry[string] = symbol;
43372    SymbolToStringRegistry[symbol] = string;
43373    return symbol;
43374  },
43375  // `Symbol.keyFor` method
43376  // https://tc39.github.io/ecma262/#sec-symbol.keyfor
43377  keyFor: function keyFor(sym) {
43378    if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
43379    if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
43380  },
43381  useSetter: function () { USE_SETTER = true; },
43382  useSimple: function () { USE_SETTER = false; }
43383});
43384
43385$({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
43386  // `Object.create` method
43387  // https://tc39.github.io/ecma262/#sec-object.create
43388  create: $create,
43389  // `Object.defineProperty` method
43390  // https://tc39.github.io/ecma262/#sec-object.defineproperty
43391  defineProperty: $defineProperty,
43392  // `Object.defineProperties` method
43393  // https://tc39.github.io/ecma262/#sec-object.defineproperties
43394  defineProperties: $defineProperties,
43395  // `Object.getOwnPropertyDescriptor` method
43396  // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
43397  getOwnPropertyDescriptor: $getOwnPropertyDescriptor
43398});
43399
43400$({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
43401  // `Object.getOwnPropertyNames` method
43402  // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
43403  getOwnPropertyNames: $getOwnPropertyNames,
43404  // `Object.getOwnPropertySymbols` method
43405  // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols
43406  getOwnPropertySymbols: $getOwnPropertySymbols
43407});
43408
43409// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
43410// https://bugs.chromium.org/p/v8/issues/detail?id=3443
43411$({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, {
43412  getOwnPropertySymbols: function getOwnPropertySymbols(it) {
43413    return getOwnPropertySymbolsModule.f(toObject(it));
43414  }
43415});
43416
43417// `JSON.stringify` method behavior with symbols
43418// https://tc39.github.io/ecma262/#sec-json.stringify
43419if ($stringify) {
43420  var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {
43421    var symbol = $Symbol();
43422    // MS Edge converts symbol values to JSON as {}
43423    return $stringify([symbol]) != '[null]'
43424      // WebKit converts symbol values to JSON as null
43425      || $stringify({ a: symbol }) != '{}'
43426      // V8 throws on boxed symbols
43427      || $stringify(Object(symbol)) != '{}';
43428  });
43429
43430  $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {
43431    // eslint-disable-next-line no-unused-vars
43432    stringify: function stringify(it, replacer, space) {
43433      var args = [it];
43434      var index = 1;
43435      var $replacer;
43436      while (arguments.length > index) args.push(arguments[index++]);
43437      $replacer = replacer;
43438      if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
43439      if (!isArray(replacer)) replacer = function (key, value) {
43440        if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
43441        if (!isSymbol(value)) return value;
43442      };
43443      args[1] = replacer;
43444      return $stringify.apply(null, args);
43445    }
43446  });
43447}
43448
43449// `Symbol.prototype[@@toPrimitive]` method
43450// https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive
43451if (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {
43452  createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
43453}
43454// `Symbol.prototype[@@toStringTag]` property
43455// https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag
43456setToStringTag($Symbol, SYMBOL);
43457
43458hiddenKeys[HIDDEN] = true;
43459
43460},{"../internals/an-object":223,"../internals/array-iteration":225,"../internals/create-non-enumerable-property":236,"../internals/create-property-descriptor":237,"../internals/define-well-known-symbol":239,"../internals/descriptors":240,"../internals/export":246,"../internals/fails":247,"../internals/get-built-in":249,"../internals/global":251,"../internals/has":252,"../internals/hidden-keys":253,"../internals/internal-state":259,"../internals/is-array":261,"../internals/is-object":263,"../internals/is-pure":264,"../internals/native-symbol":271,"../internals/object-create":276,"../internals/object-define-property":278,"../internals/object-get-own-property-descriptor":279,"../internals/object-get-own-property-names":281,"../internals/object-get-own-property-names-external":280,"../internals/object-get-own-property-symbols":282,"../internals/object-keys":285,"../internals/object-property-is-enumerable":286,"../internals/redefine":294,"../internals/set-to-string-tag":298,"../internals/shared":301,"../internals/shared-key":299,"../internals/to-indexed-object":305,"../internals/to-object":308,"../internals/to-primitive":309,"../internals/uid":311,"../internals/use-symbol-as-uid":312,"../internals/well-known-symbol":314,"../internals/well-known-symbol-wrapped":313}],328:[function(require,module,exports){
43461(function (Buffer){
43462"use strict";
43463
43464function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
43465
43466// Copyright Joyent, Inc. and other Node contributors.
43467//
43468// Permission is hereby granted, free of charge, to any person obtaining a
43469// copy of this software and associated documentation files (the
43470// "Software"), to deal in the Software without restriction, including
43471// without limitation the rights to use, copy, modify, merge, publish,
43472// distribute, sublicense, and/or sell copies of the Software, and to permit
43473// persons to whom the Software is furnished to do so, subject to the
43474// following conditions:
43475//
43476// The above copyright notice and this permission notice shall be included
43477// in all copies or substantial portions of the Software.
43478//
43479// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
43480// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
43481// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
43482// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
43483// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
43484// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
43485// USE OR OTHER DEALINGS IN THE SOFTWARE.
43486// NOTE: These type checking functions intentionally don't use `instanceof`
43487// because it is fragile and can be easily faked with `Object.create()`.
43488function isArray(arg) {
43489  if (Array.isArray) {
43490    return Array.isArray(arg);
43491  }
43492
43493  return objectToString(arg) === '[object Array]';
43494}
43495
43496exports.isArray = isArray;
43497
43498function isBoolean(arg) {
43499  return typeof arg === 'boolean';
43500}
43501
43502exports.isBoolean = isBoolean;
43503
43504function isNull(arg) {
43505  return arg === null;
43506}
43507
43508exports.isNull = isNull;
43509
43510function isNullOrUndefined(arg) {
43511  return arg == null;
43512}
43513
43514exports.isNullOrUndefined = isNullOrUndefined;
43515
43516function isNumber(arg) {
43517  return typeof arg === 'number';
43518}
43519
43520exports.isNumber = isNumber;
43521
43522function isString(arg) {
43523  return typeof arg === 'string';
43524}
43525
43526exports.isString = isString;
43527
43528function isSymbol(arg) {
43529  return _typeof(arg) === 'symbol';
43530}
43531
43532exports.isSymbol = isSymbol;
43533
43534function isUndefined(arg) {
43535  return arg === void 0;
43536}
43537
43538exports.isUndefined = isUndefined;
43539
43540function isRegExp(re) {
43541  return objectToString(re) === '[object RegExp]';
43542}
43543
43544exports.isRegExp = isRegExp;
43545
43546function isObject(arg) {
43547  return _typeof(arg) === 'object' && arg !== null;
43548}
43549
43550exports.isObject = isObject;
43551
43552function isDate(d) {
43553  return objectToString(d) === '[object Date]';
43554}
43555
43556exports.isDate = isDate;
43557
43558function isError(e) {
43559  return objectToString(e) === '[object Error]' || e instanceof Error;
43560}
43561
43562exports.isError = isError;
43563
43564function isFunction(arg) {
43565  return typeof arg === 'function';
43566}
43567
43568exports.isFunction = isFunction;
43569
43570function isPrimitive(arg) {
43571  return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || _typeof(arg) === 'symbol' || // ES6 symbol
43572  typeof arg === 'undefined';
43573}
43574
43575exports.isPrimitive = isPrimitive;
43576exports.isBuffer = Buffer.isBuffer;
43577
43578function objectToString(o) {
43579  return Object.prototype.toString.call(o);
43580}
43581
43582}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
43583
43584},{"../../is-buffer/index.js":388}],329:[function(require,module,exports){
43585(function (Buffer){
43586"use strict";
43587
43588var elliptic = require('elliptic');
43589
43590var BN = require('bn.js');
43591
43592module.exports = function createECDH(curve) {
43593  return new ECDH(curve);
43594};
43595
43596var aliases = {
43597  secp256k1: {
43598    name: 'secp256k1',
43599    byteLength: 32
43600  },
43601  secp224r1: {
43602    name: 'p224',
43603    byteLength: 28
43604  },
43605  prime256v1: {
43606    name: 'p256',
43607    byteLength: 32
43608  },
43609  prime192v1: {
43610    name: 'p192',
43611    byteLength: 24
43612  },
43613  ed25519: {
43614    name: 'ed25519',
43615    byteLength: 32
43616  },
43617  secp384r1: {
43618    name: 'p384',
43619    byteLength: 48
43620  },
43621  secp521r1: {
43622    name: 'p521',
43623    byteLength: 66
43624  }
43625};
43626aliases.p224 = aliases.secp224r1;
43627aliases.p256 = aliases.secp256r1 = aliases.prime256v1;
43628aliases.p192 = aliases.secp192r1 = aliases.prime192v1;
43629aliases.p384 = aliases.secp384r1;
43630aliases.p521 = aliases.secp521r1;
43631
43632function ECDH(curve) {
43633  this.curveType = aliases[curve];
43634
43635  if (!this.curveType) {
43636    this.curveType = {
43637      name: curve
43638    };
43639  }
43640
43641  this.curve = new elliptic.ec(this.curveType.name); // eslint-disable-line new-cap
43642
43643  this.keys = void 0;
43644}
43645
43646ECDH.prototype.generateKeys = function (enc, format) {
43647  this.keys = this.curve.genKeyPair();
43648  return this.getPublicKey(enc, format);
43649};
43650
43651ECDH.prototype.computeSecret = function (other, inenc, enc) {
43652  inenc = inenc || 'utf8';
43653
43654  if (!Buffer.isBuffer(other)) {
43655    other = new Buffer(other, inenc);
43656  }
43657
43658  var otherPub = this.curve.keyFromPublic(other).getPublic();
43659  var out = otherPub.mul(this.keys.getPrivate()).getX();
43660  return formatReturnValue(out, enc, this.curveType.byteLength);
43661};
43662
43663ECDH.prototype.getPublicKey = function (enc, format) {
43664  var key = this.keys.getPublic(format === 'compressed', true);
43665
43666  if (format === 'hybrid') {
43667    if (key[key.length - 1] % 2) {
43668      key[0] = 7;
43669    } else {
43670      key[0] = 6;
43671    }
43672  }
43673
43674  return formatReturnValue(key, enc);
43675};
43676
43677ECDH.prototype.getPrivateKey = function (enc) {
43678  return formatReturnValue(this.keys.getPrivate(), enc);
43679};
43680
43681ECDH.prototype.setPublicKey = function (pub, enc) {
43682  enc = enc || 'utf8';
43683
43684  if (!Buffer.isBuffer(pub)) {
43685    pub = new Buffer(pub, enc);
43686  }
43687
43688  this.keys._importPublic(pub);
43689
43690  return this;
43691};
43692
43693ECDH.prototype.setPrivateKey = function (priv, enc) {
43694  enc = enc || 'utf8';
43695
43696  if (!Buffer.isBuffer(priv)) {
43697    priv = new Buffer(priv, enc);
43698  }
43699
43700  var _priv = new BN(priv);
43701
43702  _priv = _priv.toString(16);
43703  this.keys = this.curve.genKeyPair();
43704
43705  this.keys._importPrivate(_priv);
43706
43707  return this;
43708};
43709
43710function formatReturnValue(bn, enc, len) {
43711  if (!Array.isArray(bn)) {
43712    bn = bn.toArray();
43713  }
43714
43715  var buf = new Buffer(bn);
43716
43717  if (len && buf.length < len) {
43718    var zeros = new Buffer(len - buf.length);
43719    zeros.fill(0);
43720    buf = Buffer.concat([zeros, buf]);
43721  }
43722
43723  if (!enc) {
43724    return buf;
43725  } else {
43726    return buf.toString(enc);
43727  }
43728}
43729
43730}).call(this,require("buffer").Buffer)
43731
43732},{"bn.js":330,"buffer":216,"elliptic":350}],330:[function(require,module,exports){
43733arguments[4][181][0].apply(exports,arguments)
43734},{"buffer":185,"dup":181}],331:[function(require,module,exports){
43735'use strict';
43736
43737var inherits = require('inherits');
43738
43739var MD5 = require('md5.js');
43740
43741var RIPEMD160 = require('ripemd160');
43742
43743var sha = require('sha.js');
43744
43745var Base = require('cipher-base');
43746
43747function Hash(hash) {
43748  Base.call(this, 'digest');
43749  this._hash = hash;
43750}
43751
43752inherits(Hash, Base);
43753
43754Hash.prototype._update = function (data) {
43755  this._hash.update(data);
43756};
43757
43758Hash.prototype._final = function () {
43759  return this._hash.digest();
43760};
43761
43762module.exports = function createHash(alg) {
43763  alg = alg.toLowerCase();
43764  if (alg === 'md5') return new MD5();
43765  if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160();
43766  return new Hash(sha(alg));
43767};
43768
43769},{"cipher-base":218,"inherits":387,"md5.js":434,"ripemd160":493,"sha.js":499}],332:[function(require,module,exports){
43770"use strict";
43771
43772var MD5 = require('md5.js');
43773
43774module.exports = function (buffer) {
43775  return new MD5().update(buffer).digest();
43776};
43777
43778},{"md5.js":434}],333:[function(require,module,exports){
43779'use strict';
43780
43781var inherits = require('inherits');
43782
43783var Legacy = require('./legacy');
43784
43785var Base = require('cipher-base');
43786
43787var Buffer = require('safe-buffer').Buffer;
43788
43789var md5 = require('create-hash/md5');
43790
43791var RIPEMD160 = require('ripemd160');
43792
43793var sha = require('sha.js');
43794
43795var ZEROS = Buffer.alloc(128);
43796
43797function Hmac(alg, key) {
43798  Base.call(this, 'digest');
43799
43800  if (typeof key === 'string') {
43801    key = Buffer.from(key);
43802  }
43803
43804  var blocksize = alg === 'sha512' || alg === 'sha384' ? 128 : 64;
43805  this._alg = alg;
43806  this._key = key;
43807
43808  if (key.length > blocksize) {
43809    var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg);
43810    key = hash.update(key).digest();
43811  } else if (key.length < blocksize) {
43812    key = Buffer.concat([key, ZEROS], blocksize);
43813  }
43814
43815  var ipad = this._ipad = Buffer.allocUnsafe(blocksize);
43816  var opad = this._opad = Buffer.allocUnsafe(blocksize);
43817
43818  for (var i = 0; i < blocksize; i++) {
43819    ipad[i] = key[i] ^ 0x36;
43820    opad[i] = key[i] ^ 0x5C;
43821  }
43822
43823  this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg);
43824
43825  this._hash.update(ipad);
43826}
43827
43828inherits(Hmac, Base);
43829
43830Hmac.prototype._update = function (data) {
43831  this._hash.update(data);
43832};
43833
43834Hmac.prototype._final = function () {
43835  var h = this._hash.digest();
43836
43837  var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg);
43838  return hash.update(this._opad).update(h).digest();
43839};
43840
43841module.exports = function createHmac(alg, key) {
43842  alg = alg.toLowerCase();
43843
43844  if (alg === 'rmd160' || alg === 'ripemd160') {
43845    return new Hmac('rmd160', key);
43846  }
43847
43848  if (alg === 'md5') {
43849    return new Legacy(md5, key);
43850  }
43851
43852  return new Hmac(alg, key);
43853};
43854
43855},{"./legacy":334,"cipher-base":218,"create-hash/md5":332,"inherits":387,"ripemd160":493,"safe-buffer":494,"sha.js":499}],334:[function(require,module,exports){
43856'use strict';
43857
43858var inherits = require('inherits');
43859
43860var Buffer = require('safe-buffer').Buffer;
43861
43862var Base = require('cipher-base');
43863
43864var ZEROS = Buffer.alloc(128);
43865var blocksize = 64;
43866
43867function Hmac(alg, key) {
43868  Base.call(this, 'digest');
43869
43870  if (typeof key === 'string') {
43871    key = Buffer.from(key);
43872  }
43873
43874  this._alg = alg;
43875  this._key = key;
43876
43877  if (key.length > blocksize) {
43878    key = alg(key);
43879  } else if (key.length < blocksize) {
43880    key = Buffer.concat([key, ZEROS], blocksize);
43881  }
43882
43883  var ipad = this._ipad = Buffer.allocUnsafe(blocksize);
43884  var opad = this._opad = Buffer.allocUnsafe(blocksize);
43885
43886  for (var i = 0; i < blocksize; i++) {
43887    ipad[i] = key[i] ^ 0x36;
43888    opad[i] = key[i] ^ 0x5C;
43889  }
43890
43891  this._hash = [ipad];
43892}
43893
43894inherits(Hmac, Base);
43895
43896Hmac.prototype._update = function (data) {
43897  this._hash.push(data);
43898};
43899
43900Hmac.prototype._final = function () {
43901  var h = this._alg(Buffer.concat(this._hash));
43902
43903  return this._alg(Buffer.concat([this._opad, h]));
43904};
43905
43906module.exports = Hmac;
43907
43908},{"cipher-base":218,"inherits":387,"safe-buffer":494}],335:[function(require,module,exports){
43909'use strict';
43910
43911exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes');
43912exports.createHash = exports.Hash = require('create-hash');
43913exports.createHmac = exports.Hmac = require('create-hmac');
43914
43915var algos = require('browserify-sign/algos');
43916
43917var algoKeys = Object.keys(algos);
43918var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys);
43919
43920exports.getHashes = function () {
43921  return hashes;
43922};
43923
43924var p = require('pbkdf2');
43925
43926exports.pbkdf2 = p.pbkdf2;
43927exports.pbkdf2Sync = p.pbkdf2Sync;
43928
43929var aes = require('browserify-cipher');
43930
43931exports.Cipher = aes.Cipher;
43932exports.createCipher = aes.createCipher;
43933exports.Cipheriv = aes.Cipheriv;
43934exports.createCipheriv = aes.createCipheriv;
43935exports.Decipher = aes.Decipher;
43936exports.createDecipher = aes.createDecipher;
43937exports.Decipheriv = aes.Decipheriv;
43938exports.createDecipheriv = aes.createDecipheriv;
43939exports.getCiphers = aes.getCiphers;
43940exports.listCiphers = aes.listCiphers;
43941
43942var dh = require('diffie-hellman');
43943
43944exports.DiffieHellmanGroup = dh.DiffieHellmanGroup;
43945exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup;
43946exports.getDiffieHellman = dh.getDiffieHellman;
43947exports.createDiffieHellman = dh.createDiffieHellman;
43948exports.DiffieHellman = dh.DiffieHellman;
43949
43950var sign = require('browserify-sign');
43951
43952exports.createSign = sign.createSign;
43953exports.Sign = sign.Sign;
43954exports.createVerify = sign.createVerify;
43955exports.Verify = sign.Verify;
43956exports.createECDH = require('create-ecdh');
43957
43958var publicEncrypt = require('public-encrypt');
43959
43960exports.publicEncrypt = publicEncrypt.publicEncrypt;
43961exports.privateEncrypt = publicEncrypt.privateEncrypt;
43962exports.publicDecrypt = publicEncrypt.publicDecrypt;
43963exports.privateDecrypt = publicEncrypt.privateDecrypt; // the least I can do is make error messages for the rest of the node.js/crypto api.
43964// ;[
43965//   'createCredentials'
43966// ].forEach(function (name) {
43967//   exports[name] = function () {
43968//     throw new Error([
43969//       'sorry, ' + name + ' is not implemented yet',
43970//       'we accept pull requests',
43971//       'https://github.com/crypto-browserify/crypto-browserify'
43972//     ].join('\n'))
43973//   }
43974// })
43975
43976var rf = require('randomfill');
43977
43978exports.randomFill = rf.randomFill;
43979exports.randomFillSync = rf.randomFillSync;
43980
43981exports.createCredentials = function () {
43982  throw new Error(['sorry, createCredentials is not implemented yet', 'we accept pull requests', 'https://github.com/crypto-browserify/crypto-browserify'].join('\n'));
43983};
43984
43985exports.constants = {
43986  'DH_CHECK_P_NOT_SAFE_PRIME': 2,
43987  'DH_CHECK_P_NOT_PRIME': 1,
43988  'DH_UNABLE_TO_CHECK_GENERATOR': 4,
43989  'DH_NOT_SUITABLE_GENERATOR': 8,
43990  'NPN_ENABLED': 1,
43991  'ALPN_ENABLED': 1,
43992  'RSA_PKCS1_PADDING': 1,
43993  'RSA_SSLV23_PADDING': 2,
43994  'RSA_NO_PADDING': 3,
43995  'RSA_PKCS1_OAEP_PADDING': 4,
43996  'RSA_X931_PADDING': 5,
43997  'RSA_PKCS1_PSS_PADDING': 6,
43998  'POINT_CONVERSION_COMPRESSED': 2,
43999  'POINT_CONVERSION_UNCOMPRESSED': 4,
44000  'POINT_CONVERSION_HYBRID': 6
44001};
44002
44003},{"browserify-cipher":203,"browserify-sign":211,"browserify-sign/algos":208,"create-ecdh":329,"create-hash":331,"create-hmac":333,"diffie-hellman":345,"pbkdf2":460,"public-encrypt":468,"randombytes":475,"randomfill":476}],336:[function(require,module,exports){
44004"use strict";
44005
44006function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
44007
44008!function (t, e) {
44009  "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : t.dayjs = e();
44010}(void 0, function () {
44011  "use strict";
44012
44013  var t = "millisecond",
44014      e = "second",
44015      n = "minute",
44016      r = "hour",
44017      i = "day",
44018      s = "week",
44019      u = "month",
44020      a = "quarter",
44021      o = "year",
44022      f = "date",
44023      h = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d+)?$/,
44024      c = /\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,
44025      d = function d(t, e, n) {
44026    var r = String(t);
44027    return !r || r.length >= e ? t : "" + Array(e + 1 - r.length).join(n) + t;
44028  },
44029      $ = {
44030    s: d,
44031    z: function z(t) {
44032      var e = -t.utcOffset(),
44033          n = Math.abs(e),
44034          r = Math.floor(n / 60),
44035          i = n % 60;
44036      return (e <= 0 ? "+" : "-") + d(r, 2, "0") + ":" + d(i, 2, "0");
44037    },
44038    m: function t(e, n) {
44039      if (e.date() < n.date()) return -t(n, e);
44040      var r = 12 * (n.year() - e.year()) + (n.month() - e.month()),
44041          i = e.add(r, u),
44042          s = n - i < 0,
44043          a = e.add(r + (s ? -1 : 1), u);
44044      return +(-(r + (n - i) / (s ? i - a : a - i)) || 0);
44045    },
44046    a: function a(t) {
44047      return t < 0 ? Math.ceil(t) || 0 : Math.floor(t);
44048    },
44049    p: function p(h) {
44050      return {
44051        M: u,
44052        y: o,
44053        w: s,
44054        d: i,
44055        D: f,
44056        h: r,
44057        m: n,
44058        s: e,
44059        ms: t,
44060        Q: a
44061      }[h] || String(h || "").toLowerCase().replace(/s$/, "");
44062    },
44063    u: function u(t) {
44064      return void 0 === t;
44065    }
44066  },
44067      l = {
44068    name: "en",
44069    weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
44070    months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_")
44071  },
44072      y = "en",
44073      M = {};
44074
44075  M[y] = l;
44076
44077  var m = function m(t) {
44078    return t instanceof S;
44079  },
44080      D = function D(t, e, n) {
44081    var r;
44082    if (!t) return y;
44083    if ("string" == typeof t) M[t] && (r = t), e && (M[t] = e, r = t);else {
44084      var i = t.name;
44085      M[i] = t, r = i;
44086    }
44087    return !n && r && (y = r), r || !n && y;
44088  },
44089      v = function v(t, e) {
44090    if (m(t)) return t.clone();
44091    var n = "object" == _typeof(e) ? e : {};
44092    return n.date = t, n.args = arguments, new S(n);
44093  },
44094      g = $;
44095
44096  g.l = D, g.i = m, g.w = function (t, e) {
44097    return v(t, {
44098      locale: e.$L,
44099      utc: e.$u,
44100      $offset: e.$offset
44101    });
44102  };
44103
44104  var S = function () {
44105    function d(t) {
44106      this.$L = this.$L || D(t.locale, null, !0), this.parse(t);
44107    }
44108
44109    var $ = d.prototype;
44110    return $.parse = function (t) {
44111      this.$d = function (t) {
44112        var e = t.date,
44113            n = t.utc;
44114        if (null === e) return new Date(NaN);
44115        if (g.u(e)) return new Date();
44116        if (e instanceof Date) return new Date(e);
44117
44118        if ("string" == typeof e && !/Z$/i.test(e)) {
44119          var r = e.match(h);
44120
44121          if (r) {
44122            var i = r[2] - 1 || 0,
44123                s = (r[7] || "0").substring(0, 3);
44124            return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s)) : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s);
44125          }
44126        }
44127
44128        return new Date(e);
44129      }(t), this.init();
44130    }, $.init = function () {
44131      var t = this.$d;
44132      this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds();
44133    }, $.$utils = function () {
44134      return g;
44135    }, $.isValid = function () {
44136      return !("Invalid Date" === this.$d.toString());
44137    }, $.isSame = function (t, e) {
44138      var n = v(t);
44139      return this.startOf(e) <= n && n <= this.endOf(e);
44140    }, $.isAfter = function (t, e) {
44141      return v(t) < this.startOf(e);
44142    }, $.isBefore = function (t, e) {
44143      return this.endOf(e) < v(t);
44144    }, $.$g = function (t, e, n) {
44145      return g.u(t) ? this[e] : this.set(n, t);
44146    }, $.unix = function () {
44147      return Math.floor(this.valueOf() / 1e3);
44148    }, $.valueOf = function () {
44149      return this.$d.getTime();
44150    }, $.startOf = function (t, a) {
44151      var h = this,
44152          c = !!g.u(a) || a,
44153          d = g.p(t),
44154          $ = function $(t, e) {
44155        var n = g.w(h.$u ? Date.UTC(h.$y, e, t) : new Date(h.$y, e, t), h);
44156        return c ? n : n.endOf(i);
44157      },
44158          l = function l(t, e) {
44159        return g.w(h.toDate()[t].apply(h.toDate("s"), (c ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e)), h);
44160      },
44161          y = this.$W,
44162          M = this.$M,
44163          m = this.$D,
44164          D = "set" + (this.$u ? "UTC" : "");
44165
44166      switch (d) {
44167        case o:
44168          return c ? $(1, 0) : $(31, 11);
44169
44170        case u:
44171          return c ? $(1, M) : $(0, M + 1);
44172
44173        case s:
44174          var v = this.$locale().weekStart || 0,
44175              S = (y < v ? y + 7 : y) - v;
44176          return $(c ? m - S : m + (6 - S), M);
44177
44178        case i:
44179        case f:
44180          return l(D + "Hours", 0);
44181
44182        case r:
44183          return l(D + "Minutes", 1);
44184
44185        case n:
44186          return l(D + "Seconds", 2);
44187
44188        case e:
44189          return l(D + "Milliseconds", 3);
44190
44191        default:
44192          return this.clone();
44193      }
44194    }, $.endOf = function (t) {
44195      return this.startOf(t, !1);
44196    }, $.$set = function (s, a) {
44197      var h,
44198          c = g.p(s),
44199          d = "set" + (this.$u ? "UTC" : ""),
44200          $ = (h = {}, h[i] = d + "Date", h[f] = d + "Date", h[u] = d + "Month", h[o] = d + "FullYear", h[r] = d + "Hours", h[n] = d + "Minutes", h[e] = d + "Seconds", h[t] = d + "Milliseconds", h)[c],
44201          l = c === i ? this.$D + (a - this.$W) : a;
44202
44203      if (c === u || c === o) {
44204        var y = this.clone().set(f, 1);
44205        y.$d[$](l), y.init(), this.$d = y.set(f, Math.min(this.$D, y.daysInMonth())).$d;
44206      } else $ && this.$d[$](l);
44207
44208      return this.init(), this;
44209    }, $.set = function (t, e) {
44210      return this.clone().$set(t, e);
44211    }, $.get = function (t) {
44212      return this[g.p(t)]();
44213    }, $.add = function (t, a) {
44214      var f,
44215          h = this;
44216      t = Number(t);
44217
44218      var c = g.p(a),
44219          d = function d(e) {
44220        var n = v(h);
44221        return g.w(n.date(n.date() + Math.round(e * t)), h);
44222      };
44223
44224      if (c === u) return this.set(u, this.$M + t);
44225      if (c === o) return this.set(o, this.$y + t);
44226      if (c === i) return d(1);
44227      if (c === s) return d(7);
44228      var $ = (f = {}, f[n] = 6e4, f[r] = 36e5, f[e] = 1e3, f)[c] || 1,
44229          l = this.$d.getTime() + t * $;
44230      return g.w(l, this);
44231    }, $.subtract = function (t, e) {
44232      return this.add(-1 * t, e);
44233    }, $.format = function (t) {
44234      var e = this;
44235      if (!this.isValid()) return "Invalid Date";
44236
44237      var n = t || "YYYY-MM-DDTHH:mm:ssZ",
44238          r = g.z(this),
44239          i = this.$locale(),
44240          s = this.$H,
44241          u = this.$m,
44242          a = this.$M,
44243          o = i.weekdays,
44244          f = i.months,
44245          h = function h(t, r, i, s) {
44246        return t && (t[r] || t(e, n)) || i[r].substr(0, s);
44247      },
44248          d = function d(t) {
44249        return g.s(s % 12 || 12, t, "0");
44250      },
44251          $ = i.meridiem || function (t, e, n) {
44252        var r = t < 12 ? "AM" : "PM";
44253        return n ? r.toLowerCase() : r;
44254      },
44255          l = {
44256        YY: String(this.$y).slice(-2),
44257        YYYY: this.$y,
44258        M: a + 1,
44259        MM: g.s(a + 1, 2, "0"),
44260        MMM: h(i.monthsShort, a, f, 3),
44261        MMMM: h(f, a),
44262        D: this.$D,
44263        DD: g.s(this.$D, 2, "0"),
44264        d: String(this.$W),
44265        dd: h(i.weekdaysMin, this.$W, o, 2),
44266        ddd: h(i.weekdaysShort, this.$W, o, 3),
44267        dddd: o[this.$W],
44268        H: String(s),
44269        HH: g.s(s, 2, "0"),
44270        h: d(1),
44271        hh: d(2),
44272        a: $(s, u, !0),
44273        A: $(s, u, !1),
44274        m: String(u),
44275        mm: g.s(u, 2, "0"),
44276        s: String(this.$s),
44277        ss: g.s(this.$s, 2, "0"),
44278        SSS: g.s(this.$ms, 3, "0"),
44279        Z: r
44280      };
44281
44282      return n.replace(c, function (t, e) {
44283        return e || l[t] || r.replace(":", "");
44284      });
44285    }, $.utcOffset = function () {
44286      return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
44287    }, $.diff = function (t, f, h) {
44288      var c,
44289          d = g.p(f),
44290          $ = v(t),
44291          l = 6e4 * ($.utcOffset() - this.utcOffset()),
44292          y = this - $,
44293          M = g.m(this, $);
44294      return M = (c = {}, c[o] = M / 12, c[u] = M, c[a] = M / 3, c[s] = (y - l) / 6048e5, c[i] = (y - l) / 864e5, c[r] = y / 36e5, c[n] = y / 6e4, c[e] = y / 1e3, c)[d] || y, h ? M : g.a(M);
44295    }, $.daysInMonth = function () {
44296      return this.endOf(u).$D;
44297    }, $.$locale = function () {
44298      return M[this.$L];
44299    }, $.locale = function (t, e) {
44300      if (!t) return this.$L;
44301      var n = this.clone(),
44302          r = D(t, e, !0);
44303      return r && (n.$L = r), n;
44304    }, $.clone = function () {
44305      return g.w(this.$d, this);
44306    }, $.toDate = function () {
44307      return new Date(this.valueOf());
44308    }, $.toJSON = function () {
44309      return this.isValid() ? this.toISOString() : null;
44310    }, $.toISOString = function () {
44311      return this.$d.toISOString();
44312    }, $.toString = function () {
44313      return this.$d.toUTCString();
44314    }, d;
44315  }(),
44316      p = S.prototype;
44317
44318  return v.prototype = p, [["$ms", t], ["$s", e], ["$m", n], ["$H", r], ["$W", i], ["$M", u], ["$y", o], ["$D", f]].forEach(function (t) {
44319    p[t[1]] = function (e) {
44320      return this.$g(e, t[0], t[1]);
44321    };
44322  }), v.extend = function (t, e) {
44323    return t(e, S, v), v;
44324  }, v.locale = D, v.isDayjs = m, v.unix = function (t) {
44325    return v(1e3 * t);
44326  }, v.en = M[y], v.Ls = M, v;
44327});
44328
44329},{}],337:[function(require,module,exports){
44330"use strict";
44331
44332function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
44333
44334!function (t, e) {
44335  "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : t.dayjs_plugin_customParseFormat = e();
44336}(void 0, function () {
44337  "use strict";
44338
44339  var t,
44340      e = /(\[[^[]*\])|([-:/.()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,
44341      n = /\d\d/,
44342      r = /\d\d?/,
44343      o = /\d*[^\s\d-:/()]+/;
44344
44345  var i = function i(t) {
44346    return function (e) {
44347      this[t] = +e;
44348    };
44349  },
44350      s = [/[+-]\d\d:?\d\d/, function (t) {
44351    var e, n;
44352    (this.zone || (this.zone = {})).offset = (e = t.match(/([+-]|\d\d)/g), 0 === (n = 60 * e[1] + +e[2]) ? 0 : "+" === e[0] ? -n : n);
44353  }],
44354      a = function a(e) {
44355    var n = t[e];
44356    return n && (n.indexOf ? n : n.s.concat(n.f));
44357  },
44358      h = {
44359    A: [/[AP]M/, function (t) {
44360      this.afternoon = "PM" === t;
44361    }],
44362    a: [/[ap]m/, function (t) {
44363      this.afternoon = "pm" === t;
44364    }],
44365    S: [/\d/, function (t) {
44366      this.milliseconds = 100 * +t;
44367    }],
44368    SS: [n, function (t) {
44369      this.milliseconds = 10 * +t;
44370    }],
44371    SSS: [/\d{3}/, function (t) {
44372      this.milliseconds = +t;
44373    }],
44374    s: [r, i("seconds")],
44375    ss: [r, i("seconds")],
44376    m: [r, i("minutes")],
44377    mm: [r, i("minutes")],
44378    H: [r, i("hours")],
44379    h: [r, i("hours")],
44380    HH: [r, i("hours")],
44381    hh: [r, i("hours")],
44382    D: [r, i("day")],
44383    DD: [n, i("day")],
44384    Do: [o, function (e) {
44385      var n = t.ordinal,
44386          r = e.match(/\d+/);
44387      if (this.day = r[0], n) for (var o = 1; o <= 31; o += 1) {
44388        n(o).replace(/\[|\]/g, "") === e && (this.day = o);
44389      }
44390    }],
44391    M: [r, i("month")],
44392    MM: [n, i("month")],
44393    MMM: [o, function (t) {
44394      var e = a("months"),
44395          n = (a("monthsShort") || e.map(function (t) {
44396        return t.substr(0, 3);
44397      })).indexOf(t) + 1;
44398      if (n < 1) throw new Error();
44399      this.month = n % 12 || n;
44400    }],
44401    MMMM: [o, function (t) {
44402      var e = a("months").indexOf(t) + 1;
44403      if (e < 1) throw new Error();
44404      this.month = e % 12 || e;
44405    }],
44406    Y: [/[+-]?\d+/, i("year")],
44407    YY: [n, function (t) {
44408      t = +t, this.year = t + (t > 68 ? 1900 : 2e3);
44409    }],
44410    YYYY: [/\d{4}/, i("year")],
44411    Z: s,
44412    ZZ: s
44413  };
44414
44415  var f = function f(t, n, r) {
44416    try {
44417      var o = function (t) {
44418        for (var n = t.match(e), r = n.length, o = 0; o < r; o += 1) {
44419          var i = n[o],
44420              s = h[i],
44421              a = s && s[0],
44422              f = s && s[1];
44423          n[o] = f ? {
44424            regex: a,
44425            parser: f
44426          } : i.replace(/^\[|\]$/g, "");
44427        }
44428
44429        return function (t) {
44430          for (var e = {}, o = 0, i = 0; o < r; o += 1) {
44431            var s = n[o];
44432            if ("string" == typeof s) i += s.length;else {
44433              var a = s.regex,
44434                  h = s.parser,
44435                  f = t.substr(i),
44436                  u = a.exec(f)[0];
44437              h.call(e, u), t = t.replace(u, "");
44438            }
44439          }
44440
44441          return function (t) {
44442            var e = t.afternoon;
44443
44444            if (void 0 !== e) {
44445              var n = t.hours;
44446              e ? n < 12 && (t.hours += 12) : 12 === n && (t.hours = 0), delete t.afternoon;
44447            }
44448          }(e), e;
44449        };
44450      }(n)(t),
44451          i = o.year,
44452          s = o.month,
44453          a = o.day,
44454          f = o.hours,
44455          u = o.minutes,
44456          d = o.seconds,
44457          c = o.milliseconds,
44458          l = o.zone,
44459          m = new Date(),
44460          v = a || (i || s ? 1 : m.getDate()),
44461          p = i || m.getFullYear(),
44462          y = 0;
44463
44464      i && !s || (y = s > 0 ? s - 1 : m.getMonth());
44465      var D = f || 0,
44466          M = u || 0,
44467          g = d || 0,
44468          Y = c || 0;
44469      return l ? new Date(Date.UTC(p, y, v, D, M, g, Y + 60 * l.offset * 1e3)) : r ? new Date(Date.UTC(p, y, v, D, M, g, Y)) : new Date(p, y, v, D, M, g, Y);
44470    } catch (t) {
44471      return new Date("");
44472    }
44473  };
44474
44475  return function (e, n, r) {
44476    var o = n.prototype,
44477        i = o.parse;
44478
44479    o.parse = function (e) {
44480      var n = e.date,
44481          o = e.utc,
44482          s = e.args;
44483      this.$u = o;
44484      var a = s[1];
44485
44486      if ("string" == typeof a) {
44487        var h = !0 === s[2],
44488            u = !0 === s[3],
44489            d = h || u,
44490            c = s[2];
44491        u && (c = s[2]), h || (t = c ? r.Ls[c] : this.$locale()), this.$d = f(n, a, o), this.init(), c && !0 !== c && (this.$L = this.locale(c).$L), d && n !== this.format(a) && (this.$d = new Date(""));
44492      } else if (a instanceof Array) for (var l = a.length, m = 1; m <= l; m += 1) {
44493        s[1] = a[m - 1];
44494        var v = r.apply(this, s);
44495
44496        if (v.isValid()) {
44497          this.$d = v.$d, this.$L = v.$L, this.init();
44498          break;
44499        }
44500
44501        m === l && (this.$d = new Date(""));
44502      } else i.call(this, e);
44503    };
44504  };
44505});
44506
44507},{}],338:[function(require,module,exports){
44508"use strict";
44509
44510function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
44511
44512!function (t, i) {
44513  "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = i() : "function" == typeof define && define.amd ? define(i) : t.dayjs_plugin_utc = i();
44514}(void 0, function () {
44515  "use strict";
44516
44517  return function (t, i, e) {
44518    var s = new Date().getTimezoneOffset(),
44519        n = i.prototype;
44520    e.utc = function (t) {
44521      return new i({
44522        date: t,
44523        utc: !0,
44524        args: arguments
44525      });
44526    }, n.utc = function () {
44527      return e(this.toDate(), {
44528        locale: this.$L,
44529        utc: !0
44530      });
44531    }, n.local = function () {
44532      return e(this.toDate(), {
44533        locale: this.$L,
44534        utc: !1
44535      });
44536    };
44537    var u = n.parse;
44538
44539    n.parse = function (t) {
44540      t.utc && (this.$u = !0), this.$utils().u(t.$offset) || (this.$offset = t.$offset), u.call(this, t);
44541    };
44542
44543    var o = n.init;
44544
44545    n.init = function () {
44546      if (this.$u) {
44547        var t = this.$d;
44548        this.$y = t.getUTCFullYear(), this.$M = t.getUTCMonth(), this.$D = t.getUTCDate(), this.$W = t.getUTCDay(), this.$H = t.getUTCHours(), this.$m = t.getUTCMinutes(), this.$s = t.getUTCSeconds(), this.$ms = t.getUTCMilliseconds();
44549      } else o.call(this);
44550    };
44551
44552    var f = n.utcOffset;
44553
44554    n.utcOffset = function (t, i) {
44555      var e = this.$utils().u;
44556      if (e(t)) return this.$u ? 0 : e(this.$offset) ? f.call(this) : this.$offset;
44557      var n = Math.abs(t) <= 16 ? 60 * t : t,
44558          u = this;
44559      return i ? (u.$offset = n, u.$u = 0 === t, u) : (0 !== t ? (u = this.local().add(n + s, "minute")).$offset = n : u = this.utc(), u);
44560    };
44561
44562    var r = n.format;
44563    n.format = function (t) {
44564      var i = t || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
44565      return r.call(this, i);
44566    }, n.valueOf = function () {
44567      var t = this.$utils().u(this.$offset) ? 0 : this.$offset + s;
44568      return this.$d.valueOf() - 6e4 * t;
44569    }, n.isUTC = function () {
44570      return !!this.$u;
44571    }, n.toISOString = function () {
44572      return this.toDate().toISOString();
44573    }, n.toString = function () {
44574      return this.toDate().toUTCString();
44575    };
44576    var a = n.toDate;
44577
44578    n.toDate = function (t) {
44579      return "s" === t && this.$offset ? e(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : a.call(this);
44580    };
44581
44582    var c = n.diff;
44583
44584    n.diff = function (t, i, s) {
44585      var n = this.local(),
44586          u = e(t).local();
44587      return c.call(n, u, i, s);
44588    };
44589  };
44590});
44591
44592},{}],339:[function(require,module,exports){
44593'use strict';
44594
44595exports.utils = require('./des/utils');
44596exports.Cipher = require('./des/cipher');
44597exports.DES = require('./des/des');
44598exports.CBC = require('./des/cbc');
44599exports.EDE = require('./des/ede');
44600
44601},{"./des/cbc":340,"./des/cipher":341,"./des/des":342,"./des/ede":343,"./des/utils":344}],340:[function(require,module,exports){
44602'use strict';
44603
44604var assert = require('minimalistic-assert');
44605
44606var inherits = require('inherits');
44607
44608var proto = {};
44609
44610function CBCState(iv) {
44611  assert.equal(iv.length, 8, 'Invalid IV length');
44612  this.iv = new Array(8);
44613
44614  for (var i = 0; i < this.iv.length; i++) {
44615    this.iv[i] = iv[i];
44616  }
44617}
44618
44619function instantiate(Base) {
44620  function CBC(options) {
44621    Base.call(this, options);
44622
44623    this._cbcInit();
44624  }
44625
44626  inherits(CBC, Base);
44627  var keys = Object.keys(proto);
44628
44629  for (var i = 0; i < keys.length; i++) {
44630    var key = keys[i];
44631    CBC.prototype[key] = proto[key];
44632  }
44633
44634  CBC.create = function create(options) {
44635    return new CBC(options);
44636  };
44637
44638  return CBC;
44639}
44640
44641exports.instantiate = instantiate;
44642
44643proto._cbcInit = function _cbcInit() {
44644  var state = new CBCState(this.options.iv);
44645  this._cbcState = state;
44646};
44647
44648proto._update = function _update(inp, inOff, out, outOff) {
44649  var state = this._cbcState;
44650  var superProto = this.constructor.super_.prototype;
44651  var iv = state.iv;
44652
44653  if (this.type === 'encrypt') {
44654    for (var i = 0; i < this.blockSize; i++) {
44655      iv[i] ^= inp[inOff + i];
44656    }
44657
44658    superProto._update.call(this, iv, 0, out, outOff);
44659
44660    for (var i = 0; i < this.blockSize; i++) {
44661      iv[i] = out[outOff + i];
44662    }
44663  } else {
44664    superProto._update.call(this, inp, inOff, out, outOff);
44665
44666    for (var i = 0; i < this.blockSize; i++) {
44667      out[outOff + i] ^= iv[i];
44668    }
44669
44670    for (var i = 0; i < this.blockSize; i++) {
44671      iv[i] = inp[inOff + i];
44672    }
44673  }
44674};
44675
44676},{"inherits":387,"minimalistic-assert":437}],341:[function(require,module,exports){
44677'use strict';
44678
44679var assert = require('minimalistic-assert');
44680
44681function Cipher(options) {
44682  this.options = options;
44683  this.type = this.options.type;
44684  this.blockSize = 8;
44685
44686  this._init();
44687
44688  this.buffer = new Array(this.blockSize);
44689  this.bufferOff = 0;
44690}
44691
44692module.exports = Cipher;
44693
44694Cipher.prototype._init = function _init() {// Might be overrided
44695};
44696
44697Cipher.prototype.update = function update(data) {
44698  if (data.length === 0) return [];
44699  if (this.type === 'decrypt') return this._updateDecrypt(data);else return this._updateEncrypt(data);
44700};
44701
44702Cipher.prototype._buffer = function _buffer(data, off) {
44703  // Append data to buffer
44704  var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
44705
44706  for (var i = 0; i < min; i++) {
44707    this.buffer[this.bufferOff + i] = data[off + i];
44708  }
44709
44710  this.bufferOff += min; // Shift next
44711
44712  return min;
44713};
44714
44715Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
44716  this._update(this.buffer, 0, out, off);
44717
44718  this.bufferOff = 0;
44719  return this.blockSize;
44720};
44721
44722Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
44723  var inputOff = 0;
44724  var outputOff = 0;
44725  var count = (this.bufferOff + data.length) / this.blockSize | 0;
44726  var out = new Array(count * this.blockSize);
44727
44728  if (this.bufferOff !== 0) {
44729    inputOff += this._buffer(data, inputOff);
44730    if (this.bufferOff === this.buffer.length) outputOff += this._flushBuffer(out, outputOff);
44731  } // Write blocks
44732
44733
44734  var max = data.length - (data.length - inputOff) % this.blockSize;
44735
44736  for (; inputOff < max; inputOff += this.blockSize) {
44737    this._update(data, inputOff, out, outputOff);
44738
44739    outputOff += this.blockSize;
44740  } // Queue rest
44741
44742
44743  for (; inputOff < data.length; inputOff++, this.bufferOff++) {
44744    this.buffer[this.bufferOff] = data[inputOff];
44745  }
44746
44747  return out;
44748};
44749
44750Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
44751  var inputOff = 0;
44752  var outputOff = 0;
44753  var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
44754  var out = new Array(count * this.blockSize); // TODO(indutny): optimize it, this is far from optimal
44755
44756  for (; count > 0; count--) {
44757    inputOff += this._buffer(data, inputOff);
44758    outputOff += this._flushBuffer(out, outputOff);
44759  } // Buffer rest of the input
44760
44761
44762  inputOff += this._buffer(data, inputOff);
44763  return out;
44764};
44765
44766Cipher.prototype.final = function final(buffer) {
44767  var first;
44768  if (buffer) first = this.update(buffer);
44769  var last;
44770  if (this.type === 'encrypt') last = this._finalEncrypt();else last = this._finalDecrypt();
44771  if (first) return first.concat(last);else return last;
44772};
44773
44774Cipher.prototype._pad = function _pad(buffer, off) {
44775  if (off === 0) return false;
44776
44777  while (off < buffer.length) {
44778    buffer[off++] = 0;
44779  }
44780
44781  return true;
44782};
44783
44784Cipher.prototype._finalEncrypt = function _finalEncrypt() {
44785  if (!this._pad(this.buffer, this.bufferOff)) return [];
44786  var out = new Array(this.blockSize);
44787
44788  this._update(this.buffer, 0, out, 0);
44789
44790  return out;
44791};
44792
44793Cipher.prototype._unpad = function _unpad(buffer) {
44794  return buffer;
44795};
44796
44797Cipher.prototype._finalDecrypt = function _finalDecrypt() {
44798  assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
44799  var out = new Array(this.blockSize);
44800
44801  this._flushBuffer(out, 0);
44802
44803  return this._unpad(out);
44804};
44805
44806},{"minimalistic-assert":437}],342:[function(require,module,exports){
44807'use strict';
44808
44809var assert = require('minimalistic-assert');
44810
44811var inherits = require('inherits');
44812
44813var utils = require('./utils');
44814
44815var Cipher = require('./cipher');
44816
44817function DESState() {
44818  this.tmp = new Array(2);
44819  this.keys = null;
44820}
44821
44822function DES(options) {
44823  Cipher.call(this, options);
44824  var state = new DESState();
44825  this._desState = state;
44826  this.deriveKeys(state, options.key);
44827}
44828
44829inherits(DES, Cipher);
44830module.exports = DES;
44831
44832DES.create = function create(options) {
44833  return new DES(options);
44834};
44835
44836var shiftTable = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1];
44837
44838DES.prototype.deriveKeys = function deriveKeys(state, key) {
44839  state.keys = new Array(16 * 2);
44840  assert.equal(key.length, this.blockSize, 'Invalid key length');
44841  var kL = utils.readUInt32BE(key, 0);
44842  var kR = utils.readUInt32BE(key, 4);
44843  utils.pc1(kL, kR, state.tmp, 0);
44844  kL = state.tmp[0];
44845  kR = state.tmp[1];
44846
44847  for (var i = 0; i < state.keys.length; i += 2) {
44848    var shift = shiftTable[i >>> 1];
44849    kL = utils.r28shl(kL, shift);
44850    kR = utils.r28shl(kR, shift);
44851    utils.pc2(kL, kR, state.keys, i);
44852  }
44853};
44854
44855DES.prototype._update = function _update(inp, inOff, out, outOff) {
44856  var state = this._desState;
44857  var l = utils.readUInt32BE(inp, inOff);
44858  var r = utils.readUInt32BE(inp, inOff + 4); // Initial Permutation
44859
44860  utils.ip(l, r, state.tmp, 0);
44861  l = state.tmp[0];
44862  r = state.tmp[1];
44863  if (this.type === 'encrypt') this._encrypt(state, l, r, state.tmp, 0);else this._decrypt(state, l, r, state.tmp, 0);
44864  l = state.tmp[0];
44865  r = state.tmp[1];
44866  utils.writeUInt32BE(out, l, outOff);
44867  utils.writeUInt32BE(out, r, outOff + 4);
44868};
44869
44870DES.prototype._pad = function _pad(buffer, off) {
44871  var value = buffer.length - off;
44872
44873  for (var i = off; i < buffer.length; i++) {
44874    buffer[i] = value;
44875  }
44876
44877  return true;
44878};
44879
44880DES.prototype._unpad = function _unpad(buffer) {
44881  var pad = buffer[buffer.length - 1];
44882
44883  for (var i = buffer.length - pad; i < buffer.length; i++) {
44884    assert.equal(buffer[i], pad);
44885  }
44886
44887  return buffer.slice(0, buffer.length - pad);
44888};
44889
44890DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
44891  var l = lStart;
44892  var r = rStart; // Apply f() x16 times
44893
44894  for (var i = 0; i < state.keys.length; i += 2) {
44895    var keyL = state.keys[i];
44896    var keyR = state.keys[i + 1]; // f(r, k)
44897
44898    utils.expand(r, state.tmp, 0);
44899    keyL ^= state.tmp[0];
44900    keyR ^= state.tmp[1];
44901    var s = utils.substitute(keyL, keyR);
44902    var f = utils.permute(s);
44903    var t = r;
44904    r = (l ^ f) >>> 0;
44905    l = t;
44906  } // Reverse Initial Permutation
44907
44908
44909  utils.rip(r, l, out, off);
44910};
44911
44912DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
44913  var l = rStart;
44914  var r = lStart; // Apply f() x16 times
44915
44916  for (var i = state.keys.length - 2; i >= 0; i -= 2) {
44917    var keyL = state.keys[i];
44918    var keyR = state.keys[i + 1]; // f(r, k)
44919
44920    utils.expand(l, state.tmp, 0);
44921    keyL ^= state.tmp[0];
44922    keyR ^= state.tmp[1];
44923    var s = utils.substitute(keyL, keyR);
44924    var f = utils.permute(s);
44925    var t = l;
44926    l = (r ^ f) >>> 0;
44927    r = t;
44928  } // Reverse Initial Permutation
44929
44930
44931  utils.rip(l, r, out, off);
44932};
44933
44934},{"./cipher":341,"./utils":344,"inherits":387,"minimalistic-assert":437}],343:[function(require,module,exports){
44935'use strict';
44936
44937var assert = require('minimalistic-assert');
44938
44939var inherits = require('inherits');
44940
44941var Cipher = require('./cipher');
44942
44943var DES = require('./des');
44944
44945function EDEState(type, key) {
44946  assert.equal(key.length, 24, 'Invalid key length');
44947  var k1 = key.slice(0, 8);
44948  var k2 = key.slice(8, 16);
44949  var k3 = key.slice(16, 24);
44950
44951  if (type === 'encrypt') {
44952    this.ciphers = [DES.create({
44953      type: 'encrypt',
44954      key: k1
44955    }), DES.create({
44956      type: 'decrypt',
44957      key: k2
44958    }), DES.create({
44959      type: 'encrypt',
44960      key: k3
44961    })];
44962  } else {
44963    this.ciphers = [DES.create({
44964      type: 'decrypt',
44965      key: k3
44966    }), DES.create({
44967      type: 'encrypt',
44968      key: k2
44969    }), DES.create({
44970      type: 'decrypt',
44971      key: k1
44972    })];
44973  }
44974}
44975
44976function EDE(options) {
44977  Cipher.call(this, options);
44978  var state = new EDEState(this.type, this.options.key);
44979  this._edeState = state;
44980}
44981
44982inherits(EDE, Cipher);
44983module.exports = EDE;
44984
44985EDE.create = function create(options) {
44986  return new EDE(options);
44987};
44988
44989EDE.prototype._update = function _update(inp, inOff, out, outOff) {
44990  var state = this._edeState;
44991
44992  state.ciphers[0]._update(inp, inOff, out, outOff);
44993
44994  state.ciphers[1]._update(out, outOff, out, outOff);
44995
44996  state.ciphers[2]._update(out, outOff, out, outOff);
44997};
44998
44999EDE.prototype._pad = DES.prototype._pad;
45000EDE.prototype._unpad = DES.prototype._unpad;
45001
45002},{"./cipher":341,"./des":342,"inherits":387,"minimalistic-assert":437}],344:[function(require,module,exports){
45003'use strict';
45004
45005exports.readUInt32BE = function readUInt32BE(bytes, off) {
45006  var res = bytes[0 + off] << 24 | bytes[1 + off] << 16 | bytes[2 + off] << 8 | bytes[3 + off];
45007  return res >>> 0;
45008};
45009
45010exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
45011  bytes[0 + off] = value >>> 24;
45012  bytes[1 + off] = value >>> 16 & 0xff;
45013  bytes[2 + off] = value >>> 8 & 0xff;
45014  bytes[3 + off] = value & 0xff;
45015};
45016
45017exports.ip = function ip(inL, inR, out, off) {
45018  var outL = 0;
45019  var outR = 0;
45020
45021  for (var i = 6; i >= 0; i -= 2) {
45022    for (var j = 0; j <= 24; j += 8) {
45023      outL <<= 1;
45024      outL |= inR >>> j + i & 1;
45025    }
45026
45027    for (var j = 0; j <= 24; j += 8) {
45028      outL <<= 1;
45029      outL |= inL >>> j + i & 1;
45030    }
45031  }
45032
45033  for (var i = 6; i >= 0; i -= 2) {
45034    for (var j = 1; j <= 25; j += 8) {
45035      outR <<= 1;
45036      outR |= inR >>> j + i & 1;
45037    }
45038
45039    for (var j = 1; j <= 25; j += 8) {
45040      outR <<= 1;
45041      outR |= inL >>> j + i & 1;
45042    }
45043  }
45044
45045  out[off + 0] = outL >>> 0;
45046  out[off + 1] = outR >>> 0;
45047};
45048
45049exports.rip = function rip(inL, inR, out, off) {
45050  var outL = 0;
45051  var outR = 0;
45052
45053  for (var i = 0; i < 4; i++) {
45054    for (var j = 24; j >= 0; j -= 8) {
45055      outL <<= 1;
45056      outL |= inR >>> j + i & 1;
45057      outL <<= 1;
45058      outL |= inL >>> j + i & 1;
45059    }
45060  }
45061
45062  for (var i = 4; i < 8; i++) {
45063    for (var j = 24; j >= 0; j -= 8) {
45064      outR <<= 1;
45065      outR |= inR >>> j + i & 1;
45066      outR <<= 1;
45067      outR |= inL >>> j + i & 1;
45068    }
45069  }
45070
45071  out[off + 0] = outL >>> 0;
45072  out[off + 1] = outR >>> 0;
45073};
45074
45075exports.pc1 = function pc1(inL, inR, out, off) {
45076  var outL = 0;
45077  var outR = 0; // 7, 15, 23, 31, 39, 47, 55, 63
45078  // 6, 14, 22, 30, 39, 47, 55, 63
45079  // 5, 13, 21, 29, 39, 47, 55, 63
45080  // 4, 12, 20, 28
45081
45082  for (var i = 7; i >= 5; i--) {
45083    for (var j = 0; j <= 24; j += 8) {
45084      outL <<= 1;
45085      outL |= inR >> j + i & 1;
45086    }
45087
45088    for (var j = 0; j <= 24; j += 8) {
45089      outL <<= 1;
45090      outL |= inL >> j + i & 1;
45091    }
45092  }
45093
45094  for (var j = 0; j <= 24; j += 8) {
45095    outL <<= 1;
45096    outL |= inR >> j + i & 1;
45097  } // 1, 9, 17, 25, 33, 41, 49, 57
45098  // 2, 10, 18, 26, 34, 42, 50, 58
45099  // 3, 11, 19, 27, 35, 43, 51, 59
45100  // 36, 44, 52, 60
45101
45102
45103  for (var i = 1; i <= 3; i++) {
45104    for (var j = 0; j <= 24; j += 8) {
45105      outR <<= 1;
45106      outR |= inR >> j + i & 1;
45107    }
45108
45109    for (var j = 0; j <= 24; j += 8) {
45110      outR <<= 1;
45111      outR |= inL >> j + i & 1;
45112    }
45113  }
45114
45115  for (var j = 0; j <= 24; j += 8) {
45116    outR <<= 1;
45117    outR |= inL >> j + i & 1;
45118  }
45119
45120  out[off + 0] = outL >>> 0;
45121  out[off + 1] = outR >>> 0;
45122};
45123
45124exports.r28shl = function r28shl(num, shift) {
45125  return num << shift & 0xfffffff | num >>> 28 - shift;
45126};
45127
45128var pc2table = [// inL => outL
4512914, 11, 17, 4, 27, 23, 25, 0, 13, 22, 7, 18, 5, 9, 16, 24, 2, 20, 12, 21, 1, 8, 15, 26, // inR => outR
4513015, 4, 25, 19, 9, 1, 26, 16, 5, 11, 23, 8, 12, 7, 17, 0, 22, 3, 10, 14, 6, 20, 27, 24];
45131
45132exports.pc2 = function pc2(inL, inR, out, off) {
45133  var outL = 0;
45134  var outR = 0;
45135  var len = pc2table.length >>> 1;
45136
45137  for (var i = 0; i < len; i++) {
45138    outL <<= 1;
45139    outL |= inL >>> pc2table[i] & 0x1;
45140  }
45141
45142  for (var i = len; i < pc2table.length; i++) {
45143    outR <<= 1;
45144    outR |= inR >>> pc2table[i] & 0x1;
45145  }
45146
45147  out[off + 0] = outL >>> 0;
45148  out[off + 1] = outR >>> 0;
45149};
45150
45151exports.expand = function expand(r, out, off) {
45152  var outL = 0;
45153  var outR = 0;
45154  outL = (r & 1) << 5 | r >>> 27;
45155
45156  for (var i = 23; i >= 15; i -= 4) {
45157    outL <<= 6;
45158    outL |= r >>> i & 0x3f;
45159  }
45160
45161  for (var i = 11; i >= 3; i -= 4) {
45162    outR |= r >>> i & 0x3f;
45163    outR <<= 6;
45164  }
45165
45166  outR |= (r & 0x1f) << 1 | r >>> 31;
45167  out[off + 0] = outL >>> 0;
45168  out[off + 1] = outR >>> 0;
45169};
45170
45171var sTable = [14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11];
45172
45173exports.substitute = function substitute(inL, inR) {
45174  var out = 0;
45175
45176  for (var i = 0; i < 4; i++) {
45177    var b = inL >>> 18 - i * 6 & 0x3f;
45178    var sb = sTable[i * 0x40 + b];
45179    out <<= 4;
45180    out |= sb;
45181  }
45182
45183  for (var i = 0; i < 4; i++) {
45184    var b = inR >>> 18 - i * 6 & 0x3f;
45185    var sb = sTable[4 * 0x40 + i * 0x40 + b];
45186    out <<= 4;
45187    out |= sb;
45188  }
45189
45190  return out >>> 0;
45191};
45192
45193var permuteTable = [16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7];
45194
45195exports.permute = function permute(num) {
45196  var out = 0;
45197
45198  for (var i = 0; i < permuteTable.length; i++) {
45199    out <<= 1;
45200    out |= num >>> permuteTable[i] & 0x1;
45201  }
45202
45203  return out >>> 0;
45204};
45205
45206exports.padSplit = function padSplit(num, size, group) {
45207  var str = num.toString(2);
45208
45209  while (str.length < size) {
45210    str = '0' + str;
45211  }
45212
45213  var out = [];
45214
45215  for (var i = 0; i < size; i += group) {
45216    out.push(str.slice(i, i + group));
45217  }
45218
45219  return out.join(' ');
45220};
45221
45222},{}],345:[function(require,module,exports){
45223(function (Buffer){
45224"use strict";
45225
45226var generatePrime = require('./lib/generatePrime');
45227
45228var primes = require('./lib/primes.json');
45229
45230var DH = require('./lib/dh');
45231
45232function getDiffieHellman(mod) {
45233  var prime = new Buffer(primes[mod].prime, 'hex');
45234  var gen = new Buffer(primes[mod].gen, 'hex');
45235  return new DH(prime, gen);
45236}
45237
45238var ENCODINGS = {
45239  'binary': true,
45240  'hex': true,
45241  'base64': true
45242};
45243
45244function createDiffieHellman(prime, enc, generator, genc) {
45245  if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
45246    return createDiffieHellman(prime, 'binary', enc, generator);
45247  }
45248
45249  enc = enc || 'binary';
45250  genc = genc || 'binary';
45251  generator = generator || new Buffer([2]);
45252
45253  if (!Buffer.isBuffer(generator)) {
45254    generator = new Buffer(generator, genc);
45255  }
45256
45257  if (typeof prime === 'number') {
45258    return new DH(generatePrime(prime, generator), generator, true);
45259  }
45260
45261  if (!Buffer.isBuffer(prime)) {
45262    prime = new Buffer(prime, enc);
45263  }
45264
45265  return new DH(prime, generator, true);
45266}
45267
45268exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman;
45269exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman;
45270
45271}).call(this,require("buffer").Buffer)
45272
45273},{"./lib/dh":346,"./lib/generatePrime":347,"./lib/primes.json":348,"buffer":216}],346:[function(require,module,exports){
45274(function (Buffer){
45275"use strict";
45276
45277var BN = require('bn.js');
45278
45279var MillerRabin = require('miller-rabin');
45280
45281var millerRabin = new MillerRabin();
45282var TWENTYFOUR = new BN(24);
45283var ELEVEN = new BN(11);
45284var TEN = new BN(10);
45285var THREE = new BN(3);
45286var SEVEN = new BN(7);
45287
45288var primes = require('./generatePrime');
45289
45290var randomBytes = require('randombytes');
45291
45292module.exports = DH;
45293
45294function setPublicKey(pub, enc) {
45295  enc = enc || 'utf8';
45296
45297  if (!Buffer.isBuffer(pub)) {
45298    pub = new Buffer(pub, enc);
45299  }
45300
45301  this._pub = new BN(pub);
45302  return this;
45303}
45304
45305function setPrivateKey(priv, enc) {
45306  enc = enc || 'utf8';
45307
45308  if (!Buffer.isBuffer(priv)) {
45309    priv = new Buffer(priv, enc);
45310  }
45311
45312  this._priv = new BN(priv);
45313  return this;
45314}
45315
45316var primeCache = {};
45317
45318function checkPrime(prime, generator) {
45319  var gen = generator.toString('hex');
45320  var hex = [gen, prime.toString(16)].join('_');
45321
45322  if (hex in primeCache) {
45323    return primeCache[hex];
45324  }
45325
45326  var error = 0;
45327
45328  if (prime.isEven() || !primes.simpleSieve || !primes.fermatTest(prime) || !millerRabin.test(prime)) {
45329    //not a prime so +1
45330    error += 1;
45331
45332    if (gen === '02' || gen === '05') {
45333      // we'd be able to check the generator
45334      // it would fail so +8
45335      error += 8;
45336    } else {
45337      //we wouldn't be able to test the generator
45338      // so +4
45339      error += 4;
45340    }
45341
45342    primeCache[hex] = error;
45343    return error;
45344  }
45345
45346  if (!millerRabin.test(prime.shrn(1))) {
45347    //not a safe prime
45348    error += 2;
45349  }
45350
45351  var rem;
45352
45353  switch (gen) {
45354    case '02':
45355      if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
45356        // unsuidable generator
45357        error += 8;
45358      }
45359
45360      break;
45361
45362    case '05':
45363      rem = prime.mod(TEN);
45364
45365      if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
45366        // prime mod 10 needs to equal 3 or 7
45367        error += 8;
45368      }
45369
45370      break;
45371
45372    default:
45373      error += 4;
45374  }
45375
45376  primeCache[hex] = error;
45377  return error;
45378}
45379
45380function DH(prime, generator, malleable) {
45381  this.setGenerator(generator);
45382  this.__prime = new BN(prime);
45383  this._prime = BN.mont(this.__prime);
45384  this._primeLen = prime.length;
45385  this._pub = undefined;
45386  this._priv = undefined;
45387  this._primeCode = undefined;
45388
45389  if (malleable) {
45390    this.setPublicKey = setPublicKey;
45391    this.setPrivateKey = setPrivateKey;
45392  } else {
45393    this._primeCode = 8;
45394  }
45395}
45396
45397Object.defineProperty(DH.prototype, 'verifyError', {
45398  enumerable: true,
45399  get: function get() {
45400    if (typeof this._primeCode !== 'number') {
45401      this._primeCode = checkPrime(this.__prime, this.__gen);
45402    }
45403
45404    return this._primeCode;
45405  }
45406});
45407
45408DH.prototype.generateKeys = function () {
45409  if (!this._priv) {
45410    this._priv = new BN(randomBytes(this._primeLen));
45411  }
45412
45413  this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
45414  return this.getPublicKey();
45415};
45416
45417DH.prototype.computeSecret = function (other) {
45418  other = new BN(other);
45419  other = other.toRed(this._prime);
45420  var secret = other.redPow(this._priv).fromRed();
45421  var out = new Buffer(secret.toArray());
45422  var prime = this.getPrime();
45423
45424  if (out.length < prime.length) {
45425    var front = new Buffer(prime.length - out.length);
45426    front.fill(0);
45427    out = Buffer.concat([front, out]);
45428  }
45429
45430  return out;
45431};
45432
45433DH.prototype.getPublicKey = function getPublicKey(enc) {
45434  return formatReturnValue(this._pub, enc);
45435};
45436
45437DH.prototype.getPrivateKey = function getPrivateKey(enc) {
45438  return formatReturnValue(this._priv, enc);
45439};
45440
45441DH.prototype.getPrime = function (enc) {
45442  return formatReturnValue(this.__prime, enc);
45443};
45444
45445DH.prototype.getGenerator = function (enc) {
45446  return formatReturnValue(this._gen, enc);
45447};
45448
45449DH.prototype.setGenerator = function (gen, enc) {
45450  enc = enc || 'utf8';
45451
45452  if (!Buffer.isBuffer(gen)) {
45453    gen = new Buffer(gen, enc);
45454  }
45455
45456  this.__gen = gen;
45457  this._gen = new BN(gen);
45458  return this;
45459};
45460
45461function formatReturnValue(bn, enc) {
45462  var buf = new Buffer(bn.toArray());
45463
45464  if (!enc) {
45465    return buf;
45466  } else {
45467    return buf.toString(enc);
45468  }
45469}
45470
45471}).call(this,require("buffer").Buffer)
45472
45473},{"./generatePrime":347,"bn.js":349,"buffer":216,"miller-rabin":435,"randombytes":475}],347:[function(require,module,exports){
45474"use strict";
45475
45476var randomBytes = require('randombytes');
45477
45478module.exports = findPrime;
45479findPrime.simpleSieve = simpleSieve;
45480findPrime.fermatTest = fermatTest;
45481
45482var BN = require('bn.js');
45483
45484var TWENTYFOUR = new BN(24);
45485
45486var MillerRabin = require('miller-rabin');
45487
45488var millerRabin = new MillerRabin();
45489var ONE = new BN(1);
45490var TWO = new BN(2);
45491var FIVE = new BN(5);
45492var SIXTEEN = new BN(16);
45493var EIGHT = new BN(8);
45494var TEN = new BN(10);
45495var THREE = new BN(3);
45496var SEVEN = new BN(7);
45497var ELEVEN = new BN(11);
45498var FOUR = new BN(4);
45499var TWELVE = new BN(12);
45500var primes = null;
45501
45502function _getPrimes() {
45503  if (primes !== null) return primes;
45504  var limit = 0x100000;
45505  var res = [];
45506  res[0] = 2;
45507
45508  for (var i = 1, k = 3; k < limit; k += 2) {
45509    var sqrt = Math.ceil(Math.sqrt(k));
45510
45511    for (var j = 0; j < i && res[j] <= sqrt; j++) {
45512      if (k % res[j] === 0) break;
45513    }
45514
45515    if (i !== j && res[j] <= sqrt) continue;
45516    res[i++] = k;
45517  }
45518
45519  primes = res;
45520  return res;
45521}
45522
45523function simpleSieve(p) {
45524  var primes = _getPrimes();
45525
45526  for (var i = 0; i < primes.length; i++) {
45527    if (p.modn(primes[i]) === 0) {
45528      if (p.cmpn(primes[i]) === 0) {
45529        return true;
45530      } else {
45531        return false;
45532      }
45533    }
45534  }
45535
45536  return true;
45537}
45538
45539function fermatTest(p) {
45540  var red = BN.mont(p);
45541  return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
45542}
45543
45544function findPrime(bits, gen) {
45545  if (bits < 16) {
45546    // this is what openssl does
45547    if (gen === 2 || gen === 5) {
45548      return new BN([0x8c, 0x7b]);
45549    } else {
45550      return new BN([0x8c, 0x27]);
45551    }
45552  }
45553
45554  gen = new BN(gen);
45555  var num, n2;
45556
45557  while (true) {
45558    num = new BN(randomBytes(Math.ceil(bits / 8)));
45559
45560    while (num.bitLength() > bits) {
45561      num.ishrn(1);
45562    }
45563
45564    if (num.isEven()) {
45565      num.iadd(ONE);
45566    }
45567
45568    if (!num.testn(1)) {
45569      num.iadd(TWO);
45570    }
45571
45572    if (!gen.cmp(TWO)) {
45573      while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
45574        num.iadd(FOUR);
45575      }
45576    } else if (!gen.cmp(FIVE)) {
45577      while (num.mod(TEN).cmp(THREE)) {
45578        num.iadd(FOUR);
45579      }
45580    }
45581
45582    n2 = num.shrn(1);
45583
45584    if (simpleSieve(n2) && simpleSieve(num) && fermatTest(n2) && fermatTest(num) && millerRabin.test(n2) && millerRabin.test(num)) {
45585      return num;
45586    }
45587  }
45588}
45589
45590},{"bn.js":349,"miller-rabin":435,"randombytes":475}],348:[function(require,module,exports){
45591module.exports={
45592    "modp1": {
45593        "gen": "02",
45594        "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
45595    },
45596    "modp2": {
45597        "gen": "02",
45598        "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
45599    },
45600    "modp5": {
45601        "gen": "02",
45602        "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
45603    },
45604    "modp14": {
45605        "gen": "02",
45606        "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
45607    },
45608    "modp15": {
45609        "gen": "02",
45610        "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
45611    },
45612    "modp16": {
45613        "gen": "02",
45614        "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
45615    },
45616    "modp17": {
45617        "gen": "02",
45618        "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
45619    },
45620    "modp18": {
45621        "gen": "02",
45622        "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
45623    }
45624}
45625},{}],349:[function(require,module,exports){
45626arguments[4][181][0].apply(exports,arguments)
45627},{"buffer":185,"dup":181}],350:[function(require,module,exports){
45628'use strict';
45629
45630var elliptic = exports;
45631elliptic.version = require('../package.json').version;
45632elliptic.utils = require('./elliptic/utils');
45633elliptic.rand = require('brorand');
45634elliptic.curve = require('./elliptic/curve');
45635elliptic.curves = require('./elliptic/curves'); // Protocols
45636
45637elliptic.ec = require('./elliptic/ec');
45638elliptic.eddsa = require('./elliptic/eddsa');
45639
45640},{"../package.json":366,"./elliptic/curve":353,"./elliptic/curves":356,"./elliptic/ec":357,"./elliptic/eddsa":360,"./elliptic/utils":364,"brorand":184}],351:[function(require,module,exports){
45641'use strict';
45642
45643var BN = require('bn.js');
45644
45645var utils = require('../utils');
45646
45647var getNAF = utils.getNAF;
45648var getJSF = utils.getJSF;
45649var assert = utils.assert;
45650
45651function BaseCurve(type, conf) {
45652  this.type = type;
45653  this.p = new BN(conf.p, 16); // Use Montgomery, when there is no fast reduction for the prime
45654
45655  this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); // Useful for many curves
45656
45657  this.zero = new BN(0).toRed(this.red);
45658  this.one = new BN(1).toRed(this.red);
45659  this.two = new BN(2).toRed(this.red); // Curve configuration, optional
45660
45661  this.n = conf.n && new BN(conf.n, 16);
45662  this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); // Temporary arrays
45663
45664  this._wnafT1 = new Array(4);
45665  this._wnafT2 = new Array(4);
45666  this._wnafT3 = new Array(4);
45667  this._wnafT4 = new Array(4);
45668  this._bitLength = this.n ? this.n.bitLength() : 0; // Generalized Greg Maxwell's trick
45669
45670  var adjustCount = this.n && this.p.div(this.n);
45671
45672  if (!adjustCount || adjustCount.cmpn(100) > 0) {
45673    this.redN = null;
45674  } else {
45675    this._maxwellTrick = true;
45676    this.redN = this.n.toRed(this.red);
45677  }
45678}
45679
45680module.exports = BaseCurve;
45681
45682BaseCurve.prototype.point = function point() {
45683  throw new Error('Not implemented');
45684};
45685
45686BaseCurve.prototype.validate = function validate() {
45687  throw new Error('Not implemented');
45688};
45689
45690BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
45691  assert(p.precomputed);
45692
45693  var doubles = p._getDoubles();
45694
45695  var naf = getNAF(k, 1, this._bitLength);
45696  var I = (1 << doubles.step + 1) - (doubles.step % 2 === 0 ? 2 : 1);
45697  I /= 3; // Translate into more windowed form
45698
45699  var repr = [];
45700
45701  for (var j = 0; j < naf.length; j += doubles.step) {
45702    var nafW = 0;
45703
45704    for (var k = j + doubles.step - 1; k >= j; k--) {
45705      nafW = (nafW << 1) + naf[k];
45706    }
45707
45708    repr.push(nafW);
45709  }
45710
45711  var a = this.jpoint(null, null, null);
45712  var b = this.jpoint(null, null, null);
45713
45714  for (var i = I; i > 0; i--) {
45715    for (var j = 0; j < repr.length; j++) {
45716      var nafW = repr[j];
45717      if (nafW === i) b = b.mixedAdd(doubles.points[j]);else if (nafW === -i) b = b.mixedAdd(doubles.points[j].neg());
45718    }
45719
45720    a = a.add(b);
45721  }
45722
45723  return a.toP();
45724};
45725
45726BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
45727  var w = 4; // Precompute window
45728
45729  var nafPoints = p._getNAFPoints(w);
45730
45731  w = nafPoints.wnd;
45732  var wnd = nafPoints.points; // Get NAF form
45733
45734  var naf = getNAF(k, w, this._bitLength); // Add `this`*(N+1) for every w-NAF index
45735
45736  var acc = this.jpoint(null, null, null);
45737
45738  for (var i = naf.length - 1; i >= 0; i--) {
45739    // Count zeroes
45740    for (var k = 0; i >= 0 && naf[i] === 0; i--) {
45741      k++;
45742    }
45743
45744    if (i >= 0) k++;
45745    acc = acc.dblp(k);
45746    if (i < 0) break;
45747    var z = naf[i];
45748    assert(z !== 0);
45749
45750    if (p.type === 'affine') {
45751      // J +- P
45752      if (z > 0) acc = acc.mixedAdd(wnd[z - 1 >> 1]);else acc = acc.mixedAdd(wnd[-z - 1 >> 1].neg());
45753    } else {
45754      // J +- J
45755      if (z > 0) acc = acc.add(wnd[z - 1 >> 1]);else acc = acc.add(wnd[-z - 1 >> 1].neg());
45756    }
45757  }
45758
45759  return p.type === 'affine' ? acc.toP() : acc;
45760};
45761
45762BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, points, coeffs, len, jacobianResult) {
45763  var wndWidth = this._wnafT1;
45764  var wnd = this._wnafT2;
45765  var naf = this._wnafT3; // Fill all arrays
45766
45767  var max = 0;
45768
45769  for (var i = 0; i < len; i++) {
45770    var p = points[i];
45771
45772    var nafPoints = p._getNAFPoints(defW);
45773
45774    wndWidth[i] = nafPoints.wnd;
45775    wnd[i] = nafPoints.points;
45776  } // Comb small window NAFs
45777
45778
45779  for (var i = len - 1; i >= 1; i -= 2) {
45780    var a = i - 1;
45781    var b = i;
45782
45783    if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
45784      naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength);
45785      naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength);
45786      max = Math.max(naf[a].length, max);
45787      max = Math.max(naf[b].length, max);
45788      continue;
45789    }
45790
45791    var comb = [points[a],
45792    /* 1 */
45793    null,
45794    /* 3 */
45795    null,
45796    /* 5 */
45797    points[b]
45798    /* 7 */
45799    ]; // Try to avoid Projective points, if possible
45800
45801    if (points[a].y.cmp(points[b].y) === 0) {
45802      comb[1] = points[a].add(points[b]);
45803      comb[2] = points[a].toJ().mixedAdd(points[b].neg());
45804    } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
45805      comb[1] = points[a].toJ().mixedAdd(points[b]);
45806      comb[2] = points[a].add(points[b].neg());
45807    } else {
45808      comb[1] = points[a].toJ().mixedAdd(points[b]);
45809      comb[2] = points[a].toJ().mixedAdd(points[b].neg());
45810    }
45811
45812    var index = [-3,
45813    /* -1 -1 */
45814    -1,
45815    /* -1 0 */
45816    -5,
45817    /* -1 1 */
45818    -7,
45819    /* 0 -1 */
45820    0,
45821    /* 0 0 */
45822    7,
45823    /* 0 1 */
45824    5,
45825    /* 1 -1 */
45826    1,
45827    /* 1 0 */
45828    3
45829    /* 1 1 */
45830    ];
45831    var jsf = getJSF(coeffs[a], coeffs[b]);
45832    max = Math.max(jsf[0].length, max);
45833    naf[a] = new Array(max);
45834    naf[b] = new Array(max);
45835
45836    for (var j = 0; j < max; j++) {
45837      var ja = jsf[0][j] | 0;
45838      var jb = jsf[1][j] | 0;
45839      naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
45840      naf[b][j] = 0;
45841      wnd[a] = comb;
45842    }
45843  }
45844
45845  var acc = this.jpoint(null, null, null);
45846  var tmp = this._wnafT4;
45847
45848  for (var i = max; i >= 0; i--) {
45849    var k = 0;
45850
45851    while (i >= 0) {
45852      var zero = true;
45853
45854      for (var j = 0; j < len; j++) {
45855        tmp[j] = naf[j][i] | 0;
45856        if (tmp[j] !== 0) zero = false;
45857      }
45858
45859      if (!zero) break;
45860      k++;
45861      i--;
45862    }
45863
45864    if (i >= 0) k++;
45865    acc = acc.dblp(k);
45866    if (i < 0) break;
45867
45868    for (var j = 0; j < len; j++) {
45869      var z = tmp[j];
45870      var p;
45871      if (z === 0) continue;else if (z > 0) p = wnd[j][z - 1 >> 1];else if (z < 0) p = wnd[j][-z - 1 >> 1].neg();
45872      if (p.type === 'affine') acc = acc.mixedAdd(p);else acc = acc.add(p);
45873    }
45874  } // Zeroify references
45875
45876
45877  for (var i = 0; i < len; i++) {
45878    wnd[i] = null;
45879  }
45880
45881  if (jacobianResult) return acc;else return acc.toP();
45882};
45883
45884function BasePoint(curve, type) {
45885  this.curve = curve;
45886  this.type = type;
45887  this.precomputed = null;
45888}
45889
45890BaseCurve.BasePoint = BasePoint;
45891
45892BasePoint.prototype.eq = function eq()
45893/*other*/
45894{
45895  throw new Error('Not implemented');
45896};
45897
45898BasePoint.prototype.validate = function validate() {
45899  return this.curve.validate(this);
45900};
45901
45902BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
45903  bytes = utils.toArray(bytes, enc);
45904  var len = this.p.byteLength(); // uncompressed, hybrid-odd, hybrid-even
45905
45906  if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && bytes.length - 1 === 2 * len) {
45907    if (bytes[0] === 0x06) assert(bytes[bytes.length - 1] % 2 === 0);else if (bytes[0] === 0x07) assert(bytes[bytes.length - 1] % 2 === 1);
45908    var res = this.point(bytes.slice(1, 1 + len), bytes.slice(1 + len, 1 + 2 * len));
45909    return res;
45910  } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && bytes.length - 1 === len) {
45911    return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
45912  }
45913
45914  throw new Error('Unknown point format');
45915};
45916
45917BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
45918  return this.encode(enc, true);
45919};
45920
45921BasePoint.prototype._encode = function _encode(compact) {
45922  var len = this.curve.p.byteLength();
45923  var x = this.getX().toArray('be', len);
45924  if (compact) return [this.getY().isEven() ? 0x02 : 0x03].concat(x);
45925  return [0x04].concat(x, this.getY().toArray('be', len));
45926};
45927
45928BasePoint.prototype.encode = function encode(enc, compact) {
45929  return utils.encode(this._encode(compact), enc);
45930};
45931
45932BasePoint.prototype.precompute = function precompute(power) {
45933  if (this.precomputed) return this;
45934  var precomputed = {
45935    doubles: null,
45936    naf: null,
45937    beta: null
45938  };
45939  precomputed.naf = this._getNAFPoints(8);
45940  precomputed.doubles = this._getDoubles(4, power);
45941  precomputed.beta = this._getBeta();
45942  this.precomputed = precomputed;
45943  return this;
45944};
45945
45946BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
45947  if (!this.precomputed) return false;
45948  var doubles = this.precomputed.doubles;
45949  if (!doubles) return false;
45950  return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
45951};
45952
45953BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
45954  if (this.precomputed && this.precomputed.doubles) return this.precomputed.doubles;
45955  var doubles = [this];
45956  var acc = this;
45957
45958  for (var i = 0; i < power; i += step) {
45959    for (var j = 0; j < step; j++) {
45960      acc = acc.dbl();
45961    }
45962
45963    doubles.push(acc);
45964  }
45965
45966  return {
45967    step: step,
45968    points: doubles
45969  };
45970};
45971
45972BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
45973  if (this.precomputed && this.precomputed.naf) return this.precomputed.naf;
45974  var res = [this];
45975  var max = (1 << wnd) - 1;
45976  var dbl = max === 1 ? null : this.dbl();
45977
45978  for (var i = 1; i < max; i++) {
45979    res[i] = res[i - 1].add(dbl);
45980  }
45981
45982  return {
45983    wnd: wnd,
45984    points: res
45985  };
45986};
45987
45988BasePoint.prototype._getBeta = function _getBeta() {
45989  return null;
45990};
45991
45992BasePoint.prototype.dblp = function dblp(k) {
45993  var r = this;
45994
45995  for (var i = 0; i < k; i++) {
45996    r = r.dbl();
45997  }
45998
45999  return r;
46000};
46001
46002},{"../utils":364,"bn.js":365}],352:[function(require,module,exports){
46003'use strict';
46004
46005var utils = require('../utils');
46006
46007var BN = require('bn.js');
46008
46009var inherits = require('inherits');
46010
46011var Base = require('./base');
46012
46013var assert = utils.assert;
46014
46015function EdwardsCurve(conf) {
46016  // NOTE: Important as we are creating point in Base.call()
46017  this.twisted = (conf.a | 0) !== 1;
46018  this.mOneA = this.twisted && (conf.a | 0) === -1;
46019  this.extended = this.mOneA;
46020  Base.call(this, 'edwards', conf);
46021  this.a = new BN(conf.a, 16).umod(this.red.m);
46022  this.a = this.a.toRed(this.red);
46023  this.c = new BN(conf.c, 16).toRed(this.red);
46024  this.c2 = this.c.redSqr();
46025  this.d = new BN(conf.d, 16).toRed(this.red);
46026  this.dd = this.d.redAdd(this.d);
46027  assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
46028  this.oneC = (conf.c | 0) === 1;
46029}
46030
46031inherits(EdwardsCurve, Base);
46032module.exports = EdwardsCurve;
46033
46034EdwardsCurve.prototype._mulA = function _mulA(num) {
46035  if (this.mOneA) return num.redNeg();else return this.a.redMul(num);
46036};
46037
46038EdwardsCurve.prototype._mulC = function _mulC(num) {
46039  if (this.oneC) return num;else return this.c.redMul(num);
46040}; // Just for compatibility with Short curve
46041
46042
46043EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
46044  return this.point(x, y, z, t);
46045};
46046
46047EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
46048  x = new BN(x, 16);
46049  if (!x.red) x = x.toRed(this.red);
46050  var x2 = x.redSqr();
46051  var rhs = this.c2.redSub(this.a.redMul(x2));
46052  var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
46053  var y2 = rhs.redMul(lhs.redInvm());
46054  var y = y2.redSqrt();
46055  if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) throw new Error('invalid point');
46056  var isOdd = y.fromRed().isOdd();
46057  if (odd && !isOdd || !odd && isOdd) y = y.redNeg();
46058  return this.point(x, y);
46059};
46060
46061EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
46062  y = new BN(y, 16);
46063  if (!y.red) y = y.toRed(this.red); // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
46064
46065  var y2 = y.redSqr();
46066  var lhs = y2.redSub(this.c2);
46067  var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
46068  var x2 = lhs.redMul(rhs.redInvm());
46069
46070  if (x2.cmp(this.zero) === 0) {
46071    if (odd) throw new Error('invalid point');else return this.point(this.zero, y);
46072  }
46073
46074  var x = x2.redSqrt();
46075  if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) throw new Error('invalid point');
46076  if (x.fromRed().isOdd() !== odd) x = x.redNeg();
46077  return this.point(x, y);
46078};
46079
46080EdwardsCurve.prototype.validate = function validate(point) {
46081  if (point.isInfinity()) return true; // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
46082
46083  point.normalize();
46084  var x2 = point.x.redSqr();
46085  var y2 = point.y.redSqr();
46086  var lhs = x2.redMul(this.a).redAdd(y2);
46087  var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
46088  return lhs.cmp(rhs) === 0;
46089};
46090
46091function Point(curve, x, y, z, t) {
46092  Base.BasePoint.call(this, curve, 'projective');
46093
46094  if (x === null && y === null && z === null) {
46095    this.x = this.curve.zero;
46096    this.y = this.curve.one;
46097    this.z = this.curve.one;
46098    this.t = this.curve.zero;
46099    this.zOne = true;
46100  } else {
46101    this.x = new BN(x, 16);
46102    this.y = new BN(y, 16);
46103    this.z = z ? new BN(z, 16) : this.curve.one;
46104    this.t = t && new BN(t, 16);
46105    if (!this.x.red) this.x = this.x.toRed(this.curve.red);
46106    if (!this.y.red) this.y = this.y.toRed(this.curve.red);
46107    if (!this.z.red) this.z = this.z.toRed(this.curve.red);
46108    if (this.t && !this.t.red) this.t = this.t.toRed(this.curve.red);
46109    this.zOne = this.z === this.curve.one; // Use extended coordinates
46110
46111    if (this.curve.extended && !this.t) {
46112      this.t = this.x.redMul(this.y);
46113      if (!this.zOne) this.t = this.t.redMul(this.z.redInvm());
46114    }
46115  }
46116}
46117
46118inherits(Point, Base.BasePoint);
46119
46120EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
46121  return Point.fromJSON(this, obj);
46122};
46123
46124EdwardsCurve.prototype.point = function point(x, y, z, t) {
46125  return new Point(this, x, y, z, t);
46126};
46127
46128Point.fromJSON = function fromJSON(curve, obj) {
46129  return new Point(curve, obj[0], obj[1], obj[2]);
46130};
46131
46132Point.prototype.inspect = function inspect() {
46133  if (this.isInfinity()) return '<EC Point Infinity>';
46134  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + ' y: ' + this.y.fromRed().toString(16, 2) + ' z: ' + this.z.fromRed().toString(16, 2) + '>';
46135};
46136
46137Point.prototype.isInfinity = function isInfinity() {
46138  // XXX This code assumes that zero is always zero in red
46139  return this.x.cmpn(0) === 0 && (this.y.cmp(this.z) === 0 || this.zOne && this.y.cmp(this.curve.c) === 0);
46140};
46141
46142Point.prototype._extDbl = function _extDbl() {
46143  // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
46144  //     #doubling-dbl-2008-hwcd
46145  // 4M + 4S
46146  // A = X1^2
46147  var a = this.x.redSqr(); // B = Y1^2
46148
46149  var b = this.y.redSqr(); // C = 2 * Z1^2
46150
46151  var c = this.z.redSqr();
46152  c = c.redIAdd(c); // D = a * A
46153
46154  var d = this.curve._mulA(a); // E = (X1 + Y1)^2 - A - B
46155
46156
46157  var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); // G = D + B
46158
46159  var g = d.redAdd(b); // F = G - C
46160
46161  var f = g.redSub(c); // H = D - B
46162
46163  var h = d.redSub(b); // X3 = E * F
46164
46165  var nx = e.redMul(f); // Y3 = G * H
46166
46167  var ny = g.redMul(h); // T3 = E * H
46168
46169  var nt = e.redMul(h); // Z3 = F * G
46170
46171  var nz = f.redMul(g);
46172  return this.curve.point(nx, ny, nz, nt);
46173};
46174
46175Point.prototype._projDbl = function _projDbl() {
46176  // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
46177  //     #doubling-dbl-2008-bbjlp
46178  //     #doubling-dbl-2007-bl
46179  // and others
46180  // Generally 3M + 4S or 2M + 4S
46181  // B = (X1 + Y1)^2
46182  var b = this.x.redAdd(this.y).redSqr(); // C = X1^2
46183
46184  var c = this.x.redSqr(); // D = Y1^2
46185
46186  var d = this.y.redSqr();
46187  var nx;
46188  var ny;
46189  var nz;
46190
46191  if (this.curve.twisted) {
46192    // E = a * C
46193    var e = this.curve._mulA(c); // F = E + D
46194
46195
46196    var f = e.redAdd(d);
46197
46198    if (this.zOne) {
46199      // X3 = (B - C - D) * (F - 2)
46200      nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); // Y3 = F * (E - D)
46201
46202      ny = f.redMul(e.redSub(d)); // Z3 = F^2 - 2 * F
46203
46204      nz = f.redSqr().redSub(f).redSub(f);
46205    } else {
46206      // H = Z1^2
46207      var h = this.z.redSqr(); // J = F - 2 * H
46208
46209      var j = f.redSub(h).redISub(h); // X3 = (B-C-D)*J
46210
46211      nx = b.redSub(c).redISub(d).redMul(j); // Y3 = F * (E - D)
46212
46213      ny = f.redMul(e.redSub(d)); // Z3 = F * J
46214
46215      nz = f.redMul(j);
46216    }
46217  } else {
46218    // E = C + D
46219    var e = c.redAdd(d); // H = (c * Z1)^2
46220
46221    var h = this.curve._mulC(this.z).redSqr(); // J = E - 2 * H
46222
46223
46224    var j = e.redSub(h).redSub(h); // X3 = c * (B - E) * J
46225
46226    nx = this.curve._mulC(b.redISub(e)).redMul(j); // Y3 = c * E * (C - D)
46227
46228    ny = this.curve._mulC(e).redMul(c.redISub(d)); // Z3 = E * J
46229
46230    nz = e.redMul(j);
46231  }
46232
46233  return this.curve.point(nx, ny, nz);
46234};
46235
46236Point.prototype.dbl = function dbl() {
46237  if (this.isInfinity()) return this; // Double in extended coordinates
46238
46239  if (this.curve.extended) return this._extDbl();else return this._projDbl();
46240};
46241
46242Point.prototype._extAdd = function _extAdd(p) {
46243  // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
46244  //     #addition-add-2008-hwcd-3
46245  // 8M
46246  // A = (Y1 - X1) * (Y2 - X2)
46247  var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); // B = (Y1 + X1) * (Y2 + X2)
46248
46249  var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); // C = T1 * k * T2
46250
46251  var c = this.t.redMul(this.curve.dd).redMul(p.t); // D = Z1 * 2 * Z2
46252
46253  var d = this.z.redMul(p.z.redAdd(p.z)); // E = B - A
46254
46255  var e = b.redSub(a); // F = D - C
46256
46257  var f = d.redSub(c); // G = D + C
46258
46259  var g = d.redAdd(c); // H = B + A
46260
46261  var h = b.redAdd(a); // X3 = E * F
46262
46263  var nx = e.redMul(f); // Y3 = G * H
46264
46265  var ny = g.redMul(h); // T3 = E * H
46266
46267  var nt = e.redMul(h); // Z3 = F * G
46268
46269  var nz = f.redMul(g);
46270  return this.curve.point(nx, ny, nz, nt);
46271};
46272
46273Point.prototype._projAdd = function _projAdd(p) {
46274  // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
46275  //     #addition-add-2008-bbjlp
46276  //     #addition-add-2007-bl
46277  // 10M + 1S
46278  // A = Z1 * Z2
46279  var a = this.z.redMul(p.z); // B = A^2
46280
46281  var b = a.redSqr(); // C = X1 * X2
46282
46283  var c = this.x.redMul(p.x); // D = Y1 * Y2
46284
46285  var d = this.y.redMul(p.y); // E = d * C * D
46286
46287  var e = this.curve.d.redMul(c).redMul(d); // F = B - E
46288
46289  var f = b.redSub(e); // G = B + E
46290
46291  var g = b.redAdd(e); // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
46292
46293  var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
46294  var nx = a.redMul(f).redMul(tmp);
46295  var ny;
46296  var nz;
46297
46298  if (this.curve.twisted) {
46299    // Y3 = A * G * (D - a * C)
46300    ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); // Z3 = F * G
46301
46302    nz = f.redMul(g);
46303  } else {
46304    // Y3 = A * G * (D - C)
46305    ny = a.redMul(g).redMul(d.redSub(c)); // Z3 = c * F * G
46306
46307    nz = this.curve._mulC(f).redMul(g);
46308  }
46309
46310  return this.curve.point(nx, ny, nz);
46311};
46312
46313Point.prototype.add = function add(p) {
46314  if (this.isInfinity()) return p;
46315  if (p.isInfinity()) return this;
46316  if (this.curve.extended) return this._extAdd(p);else return this._projAdd(p);
46317};
46318
46319Point.prototype.mul = function mul(k) {
46320  if (this._hasDoubles(k)) return this.curve._fixedNafMul(this, k);else return this.curve._wnafMul(this, k);
46321};
46322
46323Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
46324  return this.curve._wnafMulAdd(1, [this, p], [k1, k2], 2, false);
46325};
46326
46327Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
46328  return this.curve._wnafMulAdd(1, [this, p], [k1, k2], 2, true);
46329};
46330
46331Point.prototype.normalize = function normalize() {
46332  if (this.zOne) return this; // Normalize coordinates
46333
46334  var zi = this.z.redInvm();
46335  this.x = this.x.redMul(zi);
46336  this.y = this.y.redMul(zi);
46337  if (this.t) this.t = this.t.redMul(zi);
46338  this.z = this.curve.one;
46339  this.zOne = true;
46340  return this;
46341};
46342
46343Point.prototype.neg = function neg() {
46344  return this.curve.point(this.x.redNeg(), this.y, this.z, this.t && this.t.redNeg());
46345};
46346
46347Point.prototype.getX = function getX() {
46348  this.normalize();
46349  return this.x.fromRed();
46350};
46351
46352Point.prototype.getY = function getY() {
46353  this.normalize();
46354  return this.y.fromRed();
46355};
46356
46357Point.prototype.eq = function eq(other) {
46358  return this === other || this.getX().cmp(other.getX()) === 0 && this.getY().cmp(other.getY()) === 0;
46359};
46360
46361Point.prototype.eqXToP = function eqXToP(x) {
46362  var rx = x.toRed(this.curve.red).redMul(this.z);
46363  if (this.x.cmp(rx) === 0) return true;
46364  var xc = x.clone();
46365  var t = this.curve.redN.redMul(this.z);
46366
46367  for (;;) {
46368    xc.iadd(this.curve.n);
46369    if (xc.cmp(this.curve.p) >= 0) return false;
46370    rx.redIAdd(t);
46371    if (this.x.cmp(rx) === 0) return true;
46372  }
46373}; // Compatibility with BaseCurve
46374
46375
46376Point.prototype.toP = Point.prototype.normalize;
46377Point.prototype.mixedAdd = Point.prototype.add;
46378
46379},{"../utils":364,"./base":351,"bn.js":365,"inherits":387}],353:[function(require,module,exports){
46380'use strict';
46381
46382var curve = exports;
46383curve.base = require('./base');
46384curve.short = require('./short');
46385curve.mont = require('./mont');
46386curve.edwards = require('./edwards');
46387
46388},{"./base":351,"./edwards":352,"./mont":354,"./short":355}],354:[function(require,module,exports){
46389'use strict';
46390
46391var BN = require('bn.js');
46392
46393var inherits = require('inherits');
46394
46395var Base = require('./base');
46396
46397var utils = require('../utils');
46398
46399function MontCurve(conf) {
46400  Base.call(this, 'mont', conf);
46401  this.a = new BN(conf.a, 16).toRed(this.red);
46402  this.b = new BN(conf.b, 16).toRed(this.red);
46403  this.i4 = new BN(4).toRed(this.red).redInvm();
46404  this.two = new BN(2).toRed(this.red);
46405  this.a24 = this.i4.redMul(this.a.redAdd(this.two));
46406}
46407
46408inherits(MontCurve, Base);
46409module.exports = MontCurve;
46410
46411MontCurve.prototype.validate = function validate(point) {
46412  var x = point.normalize().x;
46413  var x2 = x.redSqr();
46414  var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
46415  var y = rhs.redSqrt();
46416  return y.redSqr().cmp(rhs) === 0;
46417};
46418
46419function Point(curve, x, z) {
46420  Base.BasePoint.call(this, curve, 'projective');
46421
46422  if (x === null && z === null) {
46423    this.x = this.curve.one;
46424    this.z = this.curve.zero;
46425  } else {
46426    this.x = new BN(x, 16);
46427    this.z = new BN(z, 16);
46428    if (!this.x.red) this.x = this.x.toRed(this.curve.red);
46429    if (!this.z.red) this.z = this.z.toRed(this.curve.red);
46430  }
46431}
46432
46433inherits(Point, Base.BasePoint);
46434
46435MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
46436  return this.point(utils.toArray(bytes, enc), 1);
46437};
46438
46439MontCurve.prototype.point = function point(x, z) {
46440  return new Point(this, x, z);
46441};
46442
46443MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
46444  return Point.fromJSON(this, obj);
46445};
46446
46447Point.prototype.precompute = function precompute() {// No-op
46448};
46449
46450Point.prototype._encode = function _encode() {
46451  return this.getX().toArray('be', this.curve.p.byteLength());
46452};
46453
46454Point.fromJSON = function fromJSON(curve, obj) {
46455  return new Point(curve, obj[0], obj[1] || curve.one);
46456};
46457
46458Point.prototype.inspect = function inspect() {
46459  if (this.isInfinity()) return '<EC Point Infinity>';
46460  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + ' z: ' + this.z.fromRed().toString(16, 2) + '>';
46461};
46462
46463Point.prototype.isInfinity = function isInfinity() {
46464  // XXX This code assumes that zero is always zero in red
46465  return this.z.cmpn(0) === 0;
46466};
46467
46468Point.prototype.dbl = function dbl() {
46469  // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
46470  // 2M + 2S + 4A
46471  // A = X1 + Z1
46472  var a = this.x.redAdd(this.z); // AA = A^2
46473
46474  var aa = a.redSqr(); // B = X1 - Z1
46475
46476  var b = this.x.redSub(this.z); // BB = B^2
46477
46478  var bb = b.redSqr(); // C = AA - BB
46479
46480  var c = aa.redSub(bb); // X3 = AA * BB
46481
46482  var nx = aa.redMul(bb); // Z3 = C * (BB + A24 * C)
46483
46484  var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
46485  return this.curve.point(nx, nz);
46486};
46487
46488Point.prototype.add = function add() {
46489  throw new Error('Not supported on Montgomery curve');
46490};
46491
46492Point.prototype.diffAdd = function diffAdd(p, diff) {
46493  // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
46494  // 4M + 2S + 6A
46495  // A = X2 + Z2
46496  var a = this.x.redAdd(this.z); // B = X2 - Z2
46497
46498  var b = this.x.redSub(this.z); // C = X3 + Z3
46499
46500  var c = p.x.redAdd(p.z); // D = X3 - Z3
46501
46502  var d = p.x.redSub(p.z); // DA = D * A
46503
46504  var da = d.redMul(a); // CB = C * B
46505
46506  var cb = c.redMul(b); // X5 = Z1 * (DA + CB)^2
46507
46508  var nx = diff.z.redMul(da.redAdd(cb).redSqr()); // Z5 = X1 * (DA - CB)^2
46509
46510  var nz = diff.x.redMul(da.redISub(cb).redSqr());
46511  return this.curve.point(nx, nz);
46512};
46513
46514Point.prototype.mul = function mul(k) {
46515  var t = k.clone();
46516  var a = this; // (N / 2) * Q + Q
46517
46518  var b = this.curve.point(null, null); // (N / 2) * Q
46519
46520  var c = this; // Q
46521
46522  for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) {
46523    bits.push(t.andln(1));
46524  }
46525
46526  for (var i = bits.length - 1; i >= 0; i--) {
46527    if (bits[i] === 0) {
46528      // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
46529      a = a.diffAdd(b, c); // N * Q = 2 * ((N / 2) * Q + Q))
46530
46531      b = b.dbl();
46532    } else {
46533      // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
46534      b = a.diffAdd(b, c); // N * Q + Q = 2 * ((N / 2) * Q + Q)
46535
46536      a = a.dbl();
46537    }
46538  }
46539
46540  return b;
46541};
46542
46543Point.prototype.mulAdd = function mulAdd() {
46544  throw new Error('Not supported on Montgomery curve');
46545};
46546
46547Point.prototype.jumlAdd = function jumlAdd() {
46548  throw new Error('Not supported on Montgomery curve');
46549};
46550
46551Point.prototype.eq = function eq(other) {
46552  return this.getX().cmp(other.getX()) === 0;
46553};
46554
46555Point.prototype.normalize = function normalize() {
46556  this.x = this.x.redMul(this.z.redInvm());
46557  this.z = this.curve.one;
46558  return this;
46559};
46560
46561Point.prototype.getX = function getX() {
46562  // Normalize coordinates
46563  this.normalize();
46564  return this.x.fromRed();
46565};
46566
46567},{"../utils":364,"./base":351,"bn.js":365,"inherits":387}],355:[function(require,module,exports){
46568'use strict';
46569
46570var utils = require('../utils');
46571
46572var BN = require('bn.js');
46573
46574var inherits = require('inherits');
46575
46576var Base = require('./base');
46577
46578var assert = utils.assert;
46579
46580function ShortCurve(conf) {
46581  Base.call(this, 'short', conf);
46582  this.a = new BN(conf.a, 16).toRed(this.red);
46583  this.b = new BN(conf.b, 16).toRed(this.red);
46584  this.tinv = this.two.redInvm();
46585  this.zeroA = this.a.fromRed().cmpn(0) === 0;
46586  this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; // If the curve is endomorphic, precalculate beta and lambda
46587
46588  this.endo = this._getEndomorphism(conf);
46589  this._endoWnafT1 = new Array(4);
46590  this._endoWnafT2 = new Array(4);
46591}
46592
46593inherits(ShortCurve, Base);
46594module.exports = ShortCurve;
46595
46596ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
46597  // No efficient endomorphism
46598  if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) return; // Compute beta and lambda, that lambda * P = (beta * Px; Py)
46599
46600  var beta;
46601  var lambda;
46602
46603  if (conf.beta) {
46604    beta = new BN(conf.beta, 16).toRed(this.red);
46605  } else {
46606    var betas = this._getEndoRoots(this.p); // Choose the smallest beta
46607
46608
46609    beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
46610    beta = beta.toRed(this.red);
46611  }
46612
46613  if (conf.lambda) {
46614    lambda = new BN(conf.lambda, 16);
46615  } else {
46616    // Choose the lambda that is matching selected beta
46617    var lambdas = this._getEndoRoots(this.n);
46618
46619    if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
46620      lambda = lambdas[0];
46621    } else {
46622      lambda = lambdas[1];
46623      assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
46624    }
46625  } // Get basis vectors, used for balanced length-two representation
46626
46627
46628  var basis;
46629
46630  if (conf.basis) {
46631    basis = conf.basis.map(function (vec) {
46632      return {
46633        a: new BN(vec.a, 16),
46634        b: new BN(vec.b, 16)
46635      };
46636    });
46637  } else {
46638    basis = this._getEndoBasis(lambda);
46639  }
46640
46641  return {
46642    beta: beta,
46643    lambda: lambda,
46644    basis: basis
46645  };
46646};
46647
46648ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
46649  // Find roots of for x^2 + x + 1 in F
46650  // Root = (-1 +- Sqrt(-3)) / 2
46651  //
46652  var red = num === this.p ? this.red : BN.mont(num);
46653  var tinv = new BN(2).toRed(red).redInvm();
46654  var ntinv = tinv.redNeg();
46655  var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
46656  var l1 = ntinv.redAdd(s).fromRed();
46657  var l2 = ntinv.redSub(s).fromRed();
46658  return [l1, l2];
46659};
46660
46661ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
46662  // aprxSqrt >= sqrt(this.n)
46663  var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); // 3.74
46664  // Run EGCD, until r(L + 1) < aprxSqrt
46665
46666  var u = lambda;
46667  var v = this.n.clone();
46668  var x1 = new BN(1);
46669  var y1 = new BN(0);
46670  var x2 = new BN(0);
46671  var y2 = new BN(1); // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
46672
46673  var a0;
46674  var b0; // First vector
46675
46676  var a1;
46677  var b1; // Second vector
46678
46679  var a2;
46680  var b2;
46681  var prevR;
46682  var i = 0;
46683  var r;
46684  var x;
46685
46686  while (u.cmpn(0) !== 0) {
46687    var q = v.div(u);
46688    r = v.sub(q.mul(u));
46689    x = x2.sub(q.mul(x1));
46690    var y = y2.sub(q.mul(y1));
46691
46692    if (!a1 && r.cmp(aprxSqrt) < 0) {
46693      a0 = prevR.neg();
46694      b0 = x1;
46695      a1 = r.neg();
46696      b1 = x;
46697    } else if (a1 && ++i === 2) {
46698      break;
46699    }
46700
46701    prevR = r;
46702    v = u;
46703    u = r;
46704    x2 = x1;
46705    x1 = x;
46706    y2 = y1;
46707    y1 = y;
46708  }
46709
46710  a2 = r.neg();
46711  b2 = x;
46712  var len1 = a1.sqr().add(b1.sqr());
46713  var len2 = a2.sqr().add(b2.sqr());
46714
46715  if (len2.cmp(len1) >= 0) {
46716    a2 = a0;
46717    b2 = b0;
46718  } // Normalize signs
46719
46720
46721  if (a1.negative) {
46722    a1 = a1.neg();
46723    b1 = b1.neg();
46724  }
46725
46726  if (a2.negative) {
46727    a2 = a2.neg();
46728    b2 = b2.neg();
46729  }
46730
46731  return [{
46732    a: a1,
46733    b: b1
46734  }, {
46735    a: a2,
46736    b: b2
46737  }];
46738};
46739
46740ShortCurve.prototype._endoSplit = function _endoSplit(k) {
46741  var basis = this.endo.basis;
46742  var v1 = basis[0];
46743  var v2 = basis[1];
46744  var c1 = v2.b.mul(k).divRound(this.n);
46745  var c2 = v1.b.neg().mul(k).divRound(this.n);
46746  var p1 = c1.mul(v1.a);
46747  var p2 = c2.mul(v2.a);
46748  var q1 = c1.mul(v1.b);
46749  var q2 = c2.mul(v2.b); // Calculate answer
46750
46751  var k1 = k.sub(p1).sub(p2);
46752  var k2 = q1.add(q2).neg();
46753  return {
46754    k1: k1,
46755    k2: k2
46756  };
46757};
46758
46759ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
46760  x = new BN(x, 16);
46761  if (!x.red) x = x.toRed(this.red);
46762  var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
46763  var y = y2.redSqrt();
46764  if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) throw new Error('invalid point'); // XXX Is there any way to tell if the number is odd without converting it
46765  // to non-red form?
46766
46767  var isOdd = y.fromRed().isOdd();
46768  if (odd && !isOdd || !odd && isOdd) y = y.redNeg();
46769  return this.point(x, y);
46770};
46771
46772ShortCurve.prototype.validate = function validate(point) {
46773  if (point.inf) return true;
46774  var x = point.x;
46775  var y = point.y;
46776  var ax = this.a.redMul(x);
46777  var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
46778  return y.redSqr().redISub(rhs).cmpn(0) === 0;
46779};
46780
46781ShortCurve.prototype._endoWnafMulAdd = function _endoWnafMulAdd(points, coeffs, jacobianResult) {
46782  var npoints = this._endoWnafT1;
46783  var ncoeffs = this._endoWnafT2;
46784
46785  for (var i = 0; i < points.length; i++) {
46786    var split = this._endoSplit(coeffs[i]);
46787
46788    var p = points[i];
46789
46790    var beta = p._getBeta();
46791
46792    if (split.k1.negative) {
46793      split.k1.ineg();
46794      p = p.neg(true);
46795    }
46796
46797    if (split.k2.negative) {
46798      split.k2.ineg();
46799      beta = beta.neg(true);
46800    }
46801
46802    npoints[i * 2] = p;
46803    npoints[i * 2 + 1] = beta;
46804    ncoeffs[i * 2] = split.k1;
46805    ncoeffs[i * 2 + 1] = split.k2;
46806  }
46807
46808  var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); // Clean-up references to points and coefficients
46809
46810
46811  for (var j = 0; j < i * 2; j++) {
46812    npoints[j] = null;
46813    ncoeffs[j] = null;
46814  }
46815
46816  return res;
46817};
46818
46819function Point(curve, x, y, isRed) {
46820  Base.BasePoint.call(this, curve, 'affine');
46821
46822  if (x === null && y === null) {
46823    this.x = null;
46824    this.y = null;
46825    this.inf = true;
46826  } else {
46827    this.x = new BN(x, 16);
46828    this.y = new BN(y, 16); // Force redgomery representation when loading from JSON
46829
46830    if (isRed) {
46831      this.x.forceRed(this.curve.red);
46832      this.y.forceRed(this.curve.red);
46833    }
46834
46835    if (!this.x.red) this.x = this.x.toRed(this.curve.red);
46836    if (!this.y.red) this.y = this.y.toRed(this.curve.red);
46837    this.inf = false;
46838  }
46839}
46840
46841inherits(Point, Base.BasePoint);
46842
46843ShortCurve.prototype.point = function point(x, y, isRed) {
46844  return new Point(this, x, y, isRed);
46845};
46846
46847ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
46848  return Point.fromJSON(this, obj, red);
46849};
46850
46851Point.prototype._getBeta = function _getBeta() {
46852  if (!this.curve.endo) return;
46853  var pre = this.precomputed;
46854  if (pre && pre.beta) return pre.beta;
46855  var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
46856
46857  if (pre) {
46858    var curve = this.curve;
46859
46860    var endoMul = function endoMul(p) {
46861      return curve.point(p.x.redMul(curve.endo.beta), p.y);
46862    };
46863
46864    pre.beta = beta;
46865    beta.precomputed = {
46866      beta: null,
46867      naf: pre.naf && {
46868        wnd: pre.naf.wnd,
46869        points: pre.naf.points.map(endoMul)
46870      },
46871      doubles: pre.doubles && {
46872        step: pre.doubles.step,
46873        points: pre.doubles.points.map(endoMul)
46874      }
46875    };
46876  }
46877
46878  return beta;
46879};
46880
46881Point.prototype.toJSON = function toJSON() {
46882  if (!this.precomputed) return [this.x, this.y];
46883  return [this.x, this.y, this.precomputed && {
46884    doubles: this.precomputed.doubles && {
46885      step: this.precomputed.doubles.step,
46886      points: this.precomputed.doubles.points.slice(1)
46887    },
46888    naf: this.precomputed.naf && {
46889      wnd: this.precomputed.naf.wnd,
46890      points: this.precomputed.naf.points.slice(1)
46891    }
46892  }];
46893};
46894
46895Point.fromJSON = function fromJSON(curve, obj, red) {
46896  if (typeof obj === 'string') obj = JSON.parse(obj);
46897  var res = curve.point(obj[0], obj[1], red);
46898  if (!obj[2]) return res;
46899
46900  function obj2point(obj) {
46901    return curve.point(obj[0], obj[1], red);
46902  }
46903
46904  var pre = obj[2];
46905  res.precomputed = {
46906    beta: null,
46907    doubles: pre.doubles && {
46908      step: pre.doubles.step,
46909      points: [res].concat(pre.doubles.points.map(obj2point))
46910    },
46911    naf: pre.naf && {
46912      wnd: pre.naf.wnd,
46913      points: [res].concat(pre.naf.points.map(obj2point))
46914    }
46915  };
46916  return res;
46917};
46918
46919Point.prototype.inspect = function inspect() {
46920  if (this.isInfinity()) return '<EC Point Infinity>';
46921  return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + ' y: ' + this.y.fromRed().toString(16, 2) + '>';
46922};
46923
46924Point.prototype.isInfinity = function isInfinity() {
46925  return this.inf;
46926};
46927
46928Point.prototype.add = function add(p) {
46929  // O + P = P
46930  if (this.inf) return p; // P + O = P
46931
46932  if (p.inf) return this; // P + P = 2P
46933
46934  if (this.eq(p)) return this.dbl(); // P + (-P) = O
46935
46936  if (this.neg().eq(p)) return this.curve.point(null, null); // P + Q = O
46937
46938  if (this.x.cmp(p.x) === 0) return this.curve.point(null, null);
46939  var c = this.y.redSub(p.y);
46940  if (c.cmpn(0) !== 0) c = c.redMul(this.x.redSub(p.x).redInvm());
46941  var nx = c.redSqr().redISub(this.x).redISub(p.x);
46942  var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
46943  return this.curve.point(nx, ny);
46944};
46945
46946Point.prototype.dbl = function dbl() {
46947  if (this.inf) return this; // 2P = O
46948
46949  var ys1 = this.y.redAdd(this.y);
46950  if (ys1.cmpn(0) === 0) return this.curve.point(null, null);
46951  var a = this.curve.a;
46952  var x2 = this.x.redSqr();
46953  var dyinv = ys1.redInvm();
46954  var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
46955  var nx = c.redSqr().redISub(this.x.redAdd(this.x));
46956  var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
46957  return this.curve.point(nx, ny);
46958};
46959
46960Point.prototype.getX = function getX() {
46961  return this.x.fromRed();
46962};
46963
46964Point.prototype.getY = function getY() {
46965  return this.y.fromRed();
46966};
46967
46968Point.prototype.mul = function mul(k) {
46969  k = new BN(k, 16);
46970  if (this.isInfinity()) return this;else if (this._hasDoubles(k)) return this.curve._fixedNafMul(this, k);else if (this.curve.endo) return this.curve._endoWnafMulAdd([this], [k]);else return this.curve._wnafMul(this, k);
46971};
46972
46973Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
46974  var points = [this, p2];
46975  var coeffs = [k1, k2];
46976  if (this.curve.endo) return this.curve._endoWnafMulAdd(points, coeffs);else return this.curve._wnafMulAdd(1, points, coeffs, 2);
46977};
46978
46979Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
46980  var points = [this, p2];
46981  var coeffs = [k1, k2];
46982  if (this.curve.endo) return this.curve._endoWnafMulAdd(points, coeffs, true);else return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
46983};
46984
46985Point.prototype.eq = function eq(p) {
46986  return this === p || this.inf === p.inf && (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
46987};
46988
46989Point.prototype.neg = function neg(_precompute) {
46990  if (this.inf) return this;
46991  var res = this.curve.point(this.x, this.y.redNeg());
46992
46993  if (_precompute && this.precomputed) {
46994    var pre = this.precomputed;
46995
46996    var negate = function negate(p) {
46997      return p.neg();
46998    };
46999
47000    res.precomputed = {
47001      naf: pre.naf && {
47002        wnd: pre.naf.wnd,
47003        points: pre.naf.points.map(negate)
47004      },
47005      doubles: pre.doubles && {
47006        step: pre.doubles.step,
47007        points: pre.doubles.points.map(negate)
47008      }
47009    };
47010  }
47011
47012  return res;
47013};
47014
47015Point.prototype.toJ = function toJ() {
47016  if (this.inf) return this.curve.jpoint(null, null, null);
47017  var res = this.curve.jpoint(this.x, this.y, this.curve.one);
47018  return res;
47019};
47020
47021function JPoint(curve, x, y, z) {
47022  Base.BasePoint.call(this, curve, 'jacobian');
47023
47024  if (x === null && y === null && z === null) {
47025    this.x = this.curve.one;
47026    this.y = this.curve.one;
47027    this.z = new BN(0);
47028  } else {
47029    this.x = new BN(x, 16);
47030    this.y = new BN(y, 16);
47031    this.z = new BN(z, 16);
47032  }
47033
47034  if (!this.x.red) this.x = this.x.toRed(this.curve.red);
47035  if (!this.y.red) this.y = this.y.toRed(this.curve.red);
47036  if (!this.z.red) this.z = this.z.toRed(this.curve.red);
47037  this.zOne = this.z === this.curve.one;
47038}
47039
47040inherits(JPoint, Base.BasePoint);
47041
47042ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
47043  return new JPoint(this, x, y, z);
47044};
47045
47046JPoint.prototype.toP = function toP() {
47047  if (this.isInfinity()) return this.curve.point(null, null);
47048  var zinv = this.z.redInvm();
47049  var zinv2 = zinv.redSqr();
47050  var ax = this.x.redMul(zinv2);
47051  var ay = this.y.redMul(zinv2).redMul(zinv);
47052  return this.curve.point(ax, ay);
47053};
47054
47055JPoint.prototype.neg = function neg() {
47056  return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
47057};
47058
47059JPoint.prototype.add = function add(p) {
47060  // O + P = P
47061  if (this.isInfinity()) return p; // P + O = P
47062
47063  if (p.isInfinity()) return this; // 12M + 4S + 7A
47064
47065  var pz2 = p.z.redSqr();
47066  var z2 = this.z.redSqr();
47067  var u1 = this.x.redMul(pz2);
47068  var u2 = p.x.redMul(z2);
47069  var s1 = this.y.redMul(pz2.redMul(p.z));
47070  var s2 = p.y.redMul(z2.redMul(this.z));
47071  var h = u1.redSub(u2);
47072  var r = s1.redSub(s2);
47073
47074  if (h.cmpn(0) === 0) {
47075    if (r.cmpn(0) !== 0) return this.curve.jpoint(null, null, null);else return this.dbl();
47076  }
47077
47078  var h2 = h.redSqr();
47079  var h3 = h2.redMul(h);
47080  var v = u1.redMul(h2);
47081  var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
47082  var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
47083  var nz = this.z.redMul(p.z).redMul(h);
47084  return this.curve.jpoint(nx, ny, nz);
47085};
47086
47087JPoint.prototype.mixedAdd = function mixedAdd(p) {
47088  // O + P = P
47089  if (this.isInfinity()) return p.toJ(); // P + O = P
47090
47091  if (p.isInfinity()) return this; // 8M + 3S + 7A
47092
47093  var z2 = this.z.redSqr();
47094  var u1 = this.x;
47095  var u2 = p.x.redMul(z2);
47096  var s1 = this.y;
47097  var s2 = p.y.redMul(z2).redMul(this.z);
47098  var h = u1.redSub(u2);
47099  var r = s1.redSub(s2);
47100
47101  if (h.cmpn(0) === 0) {
47102    if (r.cmpn(0) !== 0) return this.curve.jpoint(null, null, null);else return this.dbl();
47103  }
47104
47105  var h2 = h.redSqr();
47106  var h3 = h2.redMul(h);
47107  var v = u1.redMul(h2);
47108  var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
47109  var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
47110  var nz = this.z.redMul(h);
47111  return this.curve.jpoint(nx, ny, nz);
47112};
47113
47114JPoint.prototype.dblp = function dblp(pow) {
47115  if (pow === 0) return this;
47116  if (this.isInfinity()) return this;
47117  if (!pow) return this.dbl();
47118
47119  if (this.curve.zeroA || this.curve.threeA) {
47120    var r = this;
47121
47122    for (var i = 0; i < pow; i++) {
47123      r = r.dbl();
47124    }
47125
47126    return r;
47127  } // 1M + 2S + 1A + N * (4S + 5M + 8A)
47128  // N = 1 => 6M + 6S + 9A
47129
47130
47131  var a = this.curve.a;
47132  var tinv = this.curve.tinv;
47133  var jx = this.x;
47134  var jy = this.y;
47135  var jz = this.z;
47136  var jz4 = jz.redSqr().redSqr(); // Reuse results
47137
47138  var jyd = jy.redAdd(jy);
47139
47140  for (var i = 0; i < pow; i++) {
47141    var jx2 = jx.redSqr();
47142    var jyd2 = jyd.redSqr();
47143    var jyd4 = jyd2.redSqr();
47144    var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
47145    var t1 = jx.redMul(jyd2);
47146    var nx = c.redSqr().redISub(t1.redAdd(t1));
47147    var t2 = t1.redISub(nx);
47148    var dny = c.redMul(t2);
47149    dny = dny.redIAdd(dny).redISub(jyd4);
47150    var nz = jyd.redMul(jz);
47151    if (i + 1 < pow) jz4 = jz4.redMul(jyd4);
47152    jx = nx;
47153    jz = nz;
47154    jyd = dny;
47155  }
47156
47157  return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
47158};
47159
47160JPoint.prototype.dbl = function dbl() {
47161  if (this.isInfinity()) return this;
47162  if (this.curve.zeroA) return this._zeroDbl();else if (this.curve.threeA) return this._threeDbl();else return this._dbl();
47163};
47164
47165JPoint.prototype._zeroDbl = function _zeroDbl() {
47166  var nx;
47167  var ny;
47168  var nz; // Z = 1
47169
47170  if (this.zOne) {
47171    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
47172    //     #doubling-mdbl-2007-bl
47173    // 1M + 5S + 14A
47174    // XX = X1^2
47175    var xx = this.x.redSqr(); // YY = Y1^2
47176
47177    var yy = this.y.redSqr(); // YYYY = YY^2
47178
47179    var yyyy = yy.redSqr(); // S = 2 * ((X1 + YY)^2 - XX - YYYY)
47180
47181    var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
47182    s = s.redIAdd(s); // M = 3 * XX + a; a = 0
47183
47184    var m = xx.redAdd(xx).redIAdd(xx); // T = M ^ 2 - 2*S
47185
47186    var t = m.redSqr().redISub(s).redISub(s); // 8 * YYYY
47187
47188    var yyyy8 = yyyy.redIAdd(yyyy);
47189    yyyy8 = yyyy8.redIAdd(yyyy8);
47190    yyyy8 = yyyy8.redIAdd(yyyy8); // X3 = T
47191
47192    nx = t; // Y3 = M * (S - T) - 8 * YYYY
47193
47194    ny = m.redMul(s.redISub(t)).redISub(yyyy8); // Z3 = 2*Y1
47195
47196    nz = this.y.redAdd(this.y);
47197  } else {
47198    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
47199    //     #doubling-dbl-2009-l
47200    // 2M + 5S + 13A
47201    // A = X1^2
47202    var a = this.x.redSqr(); // B = Y1^2
47203
47204    var b = this.y.redSqr(); // C = B^2
47205
47206    var c = b.redSqr(); // D = 2 * ((X1 + B)^2 - A - C)
47207
47208    var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
47209    d = d.redIAdd(d); // E = 3 * A
47210
47211    var e = a.redAdd(a).redIAdd(a); // F = E^2
47212
47213    var f = e.redSqr(); // 8 * C
47214
47215    var c8 = c.redIAdd(c);
47216    c8 = c8.redIAdd(c8);
47217    c8 = c8.redIAdd(c8); // X3 = F - 2 * D
47218
47219    nx = f.redISub(d).redISub(d); // Y3 = E * (D - X3) - 8 * C
47220
47221    ny = e.redMul(d.redISub(nx)).redISub(c8); // Z3 = 2 * Y1 * Z1
47222
47223    nz = this.y.redMul(this.z);
47224    nz = nz.redIAdd(nz);
47225  }
47226
47227  return this.curve.jpoint(nx, ny, nz);
47228};
47229
47230JPoint.prototype._threeDbl = function _threeDbl() {
47231  var nx;
47232  var ny;
47233  var nz; // Z = 1
47234
47235  if (this.zOne) {
47236    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
47237    //     #doubling-mdbl-2007-bl
47238    // 1M + 5S + 15A
47239    // XX = X1^2
47240    var xx = this.x.redSqr(); // YY = Y1^2
47241
47242    var yy = this.y.redSqr(); // YYYY = YY^2
47243
47244    var yyyy = yy.redSqr(); // S = 2 * ((X1 + YY)^2 - XX - YYYY)
47245
47246    var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
47247    s = s.redIAdd(s); // M = 3 * XX + a
47248
47249    var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); // T = M^2 - 2 * S
47250
47251    var t = m.redSqr().redISub(s).redISub(s); // X3 = T
47252
47253    nx = t; // Y3 = M * (S - T) - 8 * YYYY
47254
47255    var yyyy8 = yyyy.redIAdd(yyyy);
47256    yyyy8 = yyyy8.redIAdd(yyyy8);
47257    yyyy8 = yyyy8.redIAdd(yyyy8);
47258    ny = m.redMul(s.redISub(t)).redISub(yyyy8); // Z3 = 2 * Y1
47259
47260    nz = this.y.redAdd(this.y);
47261  } else {
47262    // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
47263    // 3M + 5S
47264    // delta = Z1^2
47265    var delta = this.z.redSqr(); // gamma = Y1^2
47266
47267    var gamma = this.y.redSqr(); // beta = X1 * gamma
47268
47269    var beta = this.x.redMul(gamma); // alpha = 3 * (X1 - delta) * (X1 + delta)
47270
47271    var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
47272    alpha = alpha.redAdd(alpha).redIAdd(alpha); // X3 = alpha^2 - 8 * beta
47273
47274    var beta4 = beta.redIAdd(beta);
47275    beta4 = beta4.redIAdd(beta4);
47276    var beta8 = beta4.redAdd(beta4);
47277    nx = alpha.redSqr().redISub(beta8); // Z3 = (Y1 + Z1)^2 - gamma - delta
47278
47279    nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
47280
47281    var ggamma8 = gamma.redSqr();
47282    ggamma8 = ggamma8.redIAdd(ggamma8);
47283    ggamma8 = ggamma8.redIAdd(ggamma8);
47284    ggamma8 = ggamma8.redIAdd(ggamma8);
47285    ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
47286  }
47287
47288  return this.curve.jpoint(nx, ny, nz);
47289};
47290
47291JPoint.prototype._dbl = function _dbl() {
47292  var a = this.curve.a; // 4M + 6S + 10A
47293
47294  var jx = this.x;
47295  var jy = this.y;
47296  var jz = this.z;
47297  var jz4 = jz.redSqr().redSqr();
47298  var jx2 = jx.redSqr();
47299  var jy2 = jy.redSqr();
47300  var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
47301  var jxd4 = jx.redAdd(jx);
47302  jxd4 = jxd4.redIAdd(jxd4);
47303  var t1 = jxd4.redMul(jy2);
47304  var nx = c.redSqr().redISub(t1.redAdd(t1));
47305  var t2 = t1.redISub(nx);
47306  var jyd8 = jy2.redSqr();
47307  jyd8 = jyd8.redIAdd(jyd8);
47308  jyd8 = jyd8.redIAdd(jyd8);
47309  jyd8 = jyd8.redIAdd(jyd8);
47310  var ny = c.redMul(t2).redISub(jyd8);
47311  var nz = jy.redAdd(jy).redMul(jz);
47312  return this.curve.jpoint(nx, ny, nz);
47313};
47314
47315JPoint.prototype.trpl = function trpl() {
47316  if (!this.curve.zeroA) return this.dbl().add(this); // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
47317  // 5M + 10S + ...
47318  // XX = X1^2
47319
47320  var xx = this.x.redSqr(); // YY = Y1^2
47321
47322  var yy = this.y.redSqr(); // ZZ = Z1^2
47323
47324  var zz = this.z.redSqr(); // YYYY = YY^2
47325
47326  var yyyy = yy.redSqr(); // M = 3 * XX + a * ZZ2; a = 0
47327
47328  var m = xx.redAdd(xx).redIAdd(xx); // MM = M^2
47329
47330  var mm = m.redSqr(); // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
47331
47332  var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
47333  e = e.redIAdd(e);
47334  e = e.redAdd(e).redIAdd(e);
47335  e = e.redISub(mm); // EE = E^2
47336
47337  var ee = e.redSqr(); // T = 16*YYYY
47338
47339  var t = yyyy.redIAdd(yyyy);
47340  t = t.redIAdd(t);
47341  t = t.redIAdd(t);
47342  t = t.redIAdd(t); // U = (M + E)^2 - MM - EE - T
47343
47344  var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); // X3 = 4 * (X1 * EE - 4 * YY * U)
47345
47346  var yyu4 = yy.redMul(u);
47347  yyu4 = yyu4.redIAdd(yyu4);
47348  yyu4 = yyu4.redIAdd(yyu4);
47349  var nx = this.x.redMul(ee).redISub(yyu4);
47350  nx = nx.redIAdd(nx);
47351  nx = nx.redIAdd(nx); // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
47352
47353  var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
47354  ny = ny.redIAdd(ny);
47355  ny = ny.redIAdd(ny);
47356  ny = ny.redIAdd(ny); // Z3 = (Z1 + E)^2 - ZZ - EE
47357
47358  var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
47359  return this.curve.jpoint(nx, ny, nz);
47360};
47361
47362JPoint.prototype.mul = function mul(k, kbase) {
47363  k = new BN(k, kbase);
47364  return this.curve._wnafMul(this, k);
47365};
47366
47367JPoint.prototype.eq = function eq(p) {
47368  if (p.type === 'affine') return this.eq(p.toJ());
47369  if (this === p) return true; // x1 * z2^2 == x2 * z1^2
47370
47371  var z2 = this.z.redSqr();
47372  var pz2 = p.z.redSqr();
47373  if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) return false; // y1 * z2^3 == y2 * z1^3
47374
47375  var z3 = z2.redMul(this.z);
47376  var pz3 = pz2.redMul(p.z);
47377  return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
47378};
47379
47380JPoint.prototype.eqXToP = function eqXToP(x) {
47381  var zs = this.z.redSqr();
47382  var rx = x.toRed(this.curve.red).redMul(zs);
47383  if (this.x.cmp(rx) === 0) return true;
47384  var xc = x.clone();
47385  var t = this.curve.redN.redMul(zs);
47386
47387  for (;;) {
47388    xc.iadd(this.curve.n);
47389    if (xc.cmp(this.curve.p) >= 0) return false;
47390    rx.redIAdd(t);
47391    if (this.x.cmp(rx) === 0) return true;
47392  }
47393};
47394
47395JPoint.prototype.inspect = function inspect() {
47396  if (this.isInfinity()) return '<EC JPoint Infinity>';
47397  return '<EC JPoint x: ' + this.x.toString(16, 2) + ' y: ' + this.y.toString(16, 2) + ' z: ' + this.z.toString(16, 2) + '>';
47398};
47399
47400JPoint.prototype.isInfinity = function isInfinity() {
47401  // XXX This code assumes that zero is always zero in red
47402  return this.z.cmpn(0) === 0;
47403};
47404
47405},{"../utils":364,"./base":351,"bn.js":365,"inherits":387}],356:[function(require,module,exports){
47406'use strict';
47407
47408var curves = exports;
47409
47410var hash = require('hash.js');
47411
47412var curve = require('./curve');
47413
47414var utils = require('./utils');
47415
47416var assert = utils.assert;
47417
47418function PresetCurve(options) {
47419  if (options.type === 'short') this.curve = new curve.short(options);else if (options.type === 'edwards') this.curve = new curve.edwards(options);else this.curve = new curve.mont(options);
47420  this.g = this.curve.g;
47421  this.n = this.curve.n;
47422  this.hash = options.hash;
47423  assert(this.g.validate(), 'Invalid curve');
47424  assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
47425}
47426
47427curves.PresetCurve = PresetCurve;
47428
47429function defineCurve(name, options) {
47430  Object.defineProperty(curves, name, {
47431    configurable: true,
47432    enumerable: true,
47433    get: function get() {
47434      var curve = new PresetCurve(options);
47435      Object.defineProperty(curves, name, {
47436        configurable: true,
47437        enumerable: true,
47438        value: curve
47439      });
47440      return curve;
47441    }
47442  });
47443}
47444
47445defineCurve('p192', {
47446  type: 'short',
47447  prime: 'p192',
47448  p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
47449  a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
47450  b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
47451  n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
47452  hash: hash.sha256,
47453  gRed: false,
47454  g: ['188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811']
47455});
47456defineCurve('p224', {
47457  type: 'short',
47458  prime: 'p224',
47459  p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
47460  a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
47461  b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
47462  n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
47463  hash: hash.sha256,
47464  gRed: false,
47465  g: ['b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34']
47466});
47467defineCurve('p256', {
47468  type: 'short',
47469  prime: null,
47470  p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
47471  a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
47472  b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
47473  n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
47474  hash: hash.sha256,
47475  gRed: false,
47476  g: ['6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5']
47477});
47478defineCurve('p384', {
47479  type: 'short',
47480  prime: null,
47481  p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'fffffffe ffffffff 00000000 00000000 ffffffff',
47482  a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'fffffffe ffffffff 00000000 00000000 fffffffc',
47483  b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
47484  n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
47485  hash: hash.sha384,
47486  gRed: false,
47487  g: ['aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + '5502f25d bf55296c 3a545e38 72760ab7', '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f']
47488});
47489defineCurve('p521', {
47490  type: 'short',
47491  prime: null,
47492  p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff ffffffff ffffffff ffffffff',
47493  a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff ffffffff ffffffff fffffffc',
47494  b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
47495  n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
47496  hash: hash.sha512,
47497  gRed: false,
47498  g: ['000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + '3fad0761 353c7086 a272c240 88be9476 9fd16650']
47499});
47500defineCurve('curve25519', {
47501  type: 'mont',
47502  prime: 'p25519',
47503  p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
47504  a: '76d06',
47505  b: '1',
47506  n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
47507  hash: hash.sha256,
47508  gRed: false,
47509  g: ['9']
47510});
47511defineCurve('ed25519', {
47512  type: 'edwards',
47513  prime: 'p25519',
47514  p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
47515  a: '-1',
47516  c: '1',
47517  // -121665 * (121666^(-1)) (mod P)
47518  d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
47519  n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
47520  hash: hash.sha256,
47521  gRed: false,
47522  g: ['216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', // 4/5
47523  '6666666666666666666666666666666666666666666666666666666666666658']
47524});
47525var pre;
47526
47527try {
47528  pre = require('./precomputed/secp256k1');
47529} catch (e) {
47530  pre = undefined;
47531}
47532
47533defineCurve('secp256k1', {
47534  type: 'short',
47535  prime: 'k256',
47536  p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
47537  a: '0',
47538  b: '7',
47539  n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
47540  h: '1',
47541  hash: hash.sha256,
47542  // Precomputed endomorphism
47543  beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
47544  lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
47545  basis: [{
47546    a: '3086d221a7d46bcde86c90e49284eb15',
47547    b: '-e4437ed6010e88286f547fa90abfe4c3'
47548  }, {
47549    a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
47550    b: '3086d221a7d46bcde86c90e49284eb15'
47551  }],
47552  gRed: false,
47553  g: ['79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', pre]
47554});
47555
47556},{"./curve":353,"./precomputed/secp256k1":363,"./utils":364,"hash.js":372}],357:[function(require,module,exports){
47557'use strict';
47558
47559function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
47560
47561var BN = require('bn.js');
47562
47563var HmacDRBG = require('hmac-drbg');
47564
47565var utils = require('../utils');
47566
47567var curves = require('../curves');
47568
47569var rand = require('brorand');
47570
47571var assert = utils.assert;
47572
47573var KeyPair = require('./key');
47574
47575var Signature = require('./signature');
47576
47577function EC(options) {
47578  if (!(this instanceof EC)) return new EC(options); // Shortcut `elliptic.ec(curve-name)`
47579
47580  if (typeof options === 'string') {
47581    assert(curves.hasOwnProperty(options), 'Unknown curve ' + options);
47582    options = curves[options];
47583  } // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
47584
47585
47586  if (options instanceof curves.PresetCurve) options = {
47587    curve: options
47588  };
47589  this.curve = options.curve.curve;
47590  this.n = this.curve.n;
47591  this.nh = this.n.ushrn(1);
47592  this.g = this.curve.g; // Point on curve
47593
47594  this.g = options.curve.g;
47595  this.g.precompute(options.curve.n.bitLength() + 1); // Hash for function for DRBG
47596
47597  this.hash = options.hash || options.curve.hash;
47598}
47599
47600module.exports = EC;
47601
47602EC.prototype.keyPair = function keyPair(options) {
47603  return new KeyPair(this, options);
47604};
47605
47606EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
47607  return KeyPair.fromPrivate(this, priv, enc);
47608};
47609
47610EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
47611  return KeyPair.fromPublic(this, pub, enc);
47612};
47613
47614EC.prototype.genKeyPair = function genKeyPair(options) {
47615  if (!options) options = {}; // Instantiate Hmac_DRBG
47616
47617  var drbg = new HmacDRBG({
47618    hash: this.hash,
47619    pers: options.pers,
47620    persEnc: options.persEnc || 'utf8',
47621    entropy: options.entropy || rand(this.hash.hmacStrength),
47622    entropyEnc: options.entropy && options.entropyEnc || 'utf8',
47623    nonce: this.n.toArray()
47624  });
47625  var bytes = this.n.byteLength();
47626  var ns2 = this.n.sub(new BN(2));
47627
47628  do {
47629    var priv = new BN(drbg.generate(bytes));
47630    if (priv.cmp(ns2) > 0) continue;
47631    priv.iaddn(1);
47632    return this.keyFromPrivate(priv);
47633  } while (true);
47634};
47635
47636EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
47637  var delta = msg.byteLength() * 8 - this.n.bitLength();
47638  if (delta > 0) msg = msg.ushrn(delta);
47639  if (!truncOnly && msg.cmp(this.n) >= 0) return msg.sub(this.n);else return msg;
47640};
47641
47642EC.prototype.sign = function sign(msg, key, enc, options) {
47643  if (_typeof(enc) === 'object') {
47644    options = enc;
47645    enc = null;
47646  }
47647
47648  if (!options) options = {};
47649  key = this.keyFromPrivate(key, enc);
47650  msg = this._truncateToN(new BN(msg, 16)); // Zero-extend key to provide enough entropy
47651
47652  var bytes = this.n.byteLength();
47653  var bkey = key.getPrivate().toArray('be', bytes); // Zero-extend nonce to have the same byte size as N
47654
47655  var nonce = msg.toArray('be', bytes); // Instantiate Hmac_DRBG
47656
47657  var drbg = new HmacDRBG({
47658    hash: this.hash,
47659    entropy: bkey,
47660    nonce: nonce,
47661    pers: options.pers,
47662    persEnc: options.persEnc || 'utf8'
47663  }); // Number of bytes to generate
47664
47665  var ns1 = this.n.sub(new BN(1));
47666
47667  for (var iter = 0; true; iter++) {
47668    var k = options.k ? options.k(iter) : new BN(drbg.generate(this.n.byteLength()));
47669    k = this._truncateToN(k, true);
47670    if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) continue;
47671    var kp = this.g.mul(k);
47672    if (kp.isInfinity()) continue;
47673    var kpX = kp.getX();
47674    var r = kpX.umod(this.n);
47675    if (r.cmpn(0) === 0) continue;
47676    var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
47677    s = s.umod(this.n);
47678    if (s.cmpn(0) === 0) continue;
47679    var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | (kpX.cmp(r) !== 0 ? 2 : 0); // Use complement of `s`, if it is > `n / 2`
47680
47681    if (options.canonical && s.cmp(this.nh) > 0) {
47682      s = this.n.sub(s);
47683      recoveryParam ^= 1;
47684    }
47685
47686    return new Signature({
47687      r: r,
47688      s: s,
47689      recoveryParam: recoveryParam
47690    });
47691  }
47692};
47693
47694EC.prototype.verify = function verify(msg, signature, key, enc) {
47695  msg = this._truncateToN(new BN(msg, 16));
47696  key = this.keyFromPublic(key, enc);
47697  signature = new Signature(signature, 'hex'); // Perform primitive values validation
47698
47699  var r = signature.r;
47700  var s = signature.s;
47701  if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) return false;
47702  if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) return false; // Validate signature
47703
47704  var sinv = s.invm(this.n);
47705  var u1 = sinv.mul(msg).umod(this.n);
47706  var u2 = sinv.mul(r).umod(this.n);
47707
47708  if (!this.curve._maxwellTrick) {
47709    var p = this.g.mulAdd(u1, key.getPublic(), u2);
47710    if (p.isInfinity()) return false;
47711    return p.getX().umod(this.n).cmp(r) === 0;
47712  } // NOTE: Greg Maxwell's trick, inspired by:
47713  // https://git.io/vad3K
47714
47715
47716  var p = this.g.jmulAdd(u1, key.getPublic(), u2);
47717  if (p.isInfinity()) return false; // Compare `p.x` of Jacobian point with `r`,
47718  // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
47719  // inverse of `p.z^2`
47720
47721  return p.eqXToP(r);
47722};
47723
47724EC.prototype.recoverPubKey = function (msg, signature, j, enc) {
47725  assert((3 & j) === j, 'The recovery param is more than two bits');
47726  signature = new Signature(signature, enc);
47727  var n = this.n;
47728  var e = new BN(msg);
47729  var r = signature.r;
47730  var s = signature.s; // A set LSB signifies that the y-coordinate is odd
47731
47732  var isYOdd = j & 1;
47733  var isSecondKey = j >> 1;
47734  if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) throw new Error('Unable to find sencond key candinate'); // 1.1. Let x = r + jn.
47735
47736  if (isSecondKey) r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);else r = this.curve.pointFromX(r, isYOdd);
47737  var rInv = signature.r.invm(n);
47738  var s1 = n.sub(e).mul(rInv).umod(n);
47739  var s2 = s.mul(rInv).umod(n); // 1.6.1 Compute Q = r^-1 (sR -  eG)
47740  //               Q = r^-1 (sR + -eG)
47741
47742  return this.g.mulAdd(s1, r, s2);
47743};
47744
47745EC.prototype.getKeyRecoveryParam = function (e, signature, Q, enc) {
47746  signature = new Signature(signature, enc);
47747  if (signature.recoveryParam !== null) return signature.recoveryParam;
47748
47749  for (var i = 0; i < 4; i++) {
47750    var Qprime;
47751
47752    try {
47753      Qprime = this.recoverPubKey(e, signature, i);
47754    } catch (e) {
47755      continue;
47756    }
47757
47758    if (Qprime.eq(Q)) return i;
47759  }
47760
47761  throw new Error('Unable to find valid recovery factor');
47762};
47763
47764},{"../curves":356,"../utils":364,"./key":358,"./signature":359,"bn.js":365,"brorand":184,"hmac-drbg":384}],358:[function(require,module,exports){
47765'use strict';
47766
47767var BN = require('bn.js');
47768
47769var utils = require('../utils');
47770
47771var assert = utils.assert;
47772
47773function KeyPair(ec, options) {
47774  this.ec = ec;
47775  this.priv = null;
47776  this.pub = null; // KeyPair(ec, { priv: ..., pub: ... })
47777
47778  if (options.priv) this._importPrivate(options.priv, options.privEnc);
47779  if (options.pub) this._importPublic(options.pub, options.pubEnc);
47780}
47781
47782module.exports = KeyPair;
47783
47784KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
47785  if (pub instanceof KeyPair) return pub;
47786  return new KeyPair(ec, {
47787    pub: pub,
47788    pubEnc: enc
47789  });
47790};
47791
47792KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
47793  if (priv instanceof KeyPair) return priv;
47794  return new KeyPair(ec, {
47795    priv: priv,
47796    privEnc: enc
47797  });
47798};
47799
47800KeyPair.prototype.validate = function validate() {
47801  var pub = this.getPublic();
47802  if (pub.isInfinity()) return {
47803    result: false,
47804    reason: 'Invalid public key'
47805  };
47806  if (!pub.validate()) return {
47807    result: false,
47808    reason: 'Public key is not a point'
47809  };
47810  if (!pub.mul(this.ec.curve.n).isInfinity()) return {
47811    result: false,
47812    reason: 'Public key * N != O'
47813  };
47814  return {
47815    result: true,
47816    reason: null
47817  };
47818};
47819
47820KeyPair.prototype.getPublic = function getPublic(compact, enc) {
47821  // compact is optional argument
47822  if (typeof compact === 'string') {
47823    enc = compact;
47824    compact = null;
47825  }
47826
47827  if (!this.pub) this.pub = this.ec.g.mul(this.priv);
47828  if (!enc) return this.pub;
47829  return this.pub.encode(enc, compact);
47830};
47831
47832KeyPair.prototype.getPrivate = function getPrivate(enc) {
47833  if (enc === 'hex') return this.priv.toString(16, 2);else return this.priv;
47834};
47835
47836KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
47837  this.priv = new BN(key, enc || 16); // Ensure that the priv won't be bigger than n, otherwise we may fail
47838  // in fixed multiplication method
47839
47840  this.priv = this.priv.umod(this.ec.curve.n);
47841};
47842
47843KeyPair.prototype._importPublic = function _importPublic(key, enc) {
47844  if (key.x || key.y) {
47845    // Montgomery points only have an `x` coordinate.
47846    // Weierstrass/Edwards points on the other hand have both `x` and
47847    // `y` coordinates.
47848    if (this.ec.curve.type === 'mont') {
47849      assert(key.x, 'Need x coordinate');
47850    } else if (this.ec.curve.type === 'short' || this.ec.curve.type === 'edwards') {
47851      assert(key.x && key.y, 'Need both x and y coordinate');
47852    }
47853
47854    this.pub = this.ec.curve.point(key.x, key.y);
47855    return;
47856  }
47857
47858  this.pub = this.ec.curve.decodePoint(key, enc);
47859}; // ECDH
47860
47861
47862KeyPair.prototype.derive = function derive(pub) {
47863  return pub.mul(this.priv).getX();
47864}; // ECDSA
47865
47866
47867KeyPair.prototype.sign = function sign(msg, enc, options) {
47868  return this.ec.sign(msg, this, enc, options);
47869};
47870
47871KeyPair.prototype.verify = function verify(msg, signature) {
47872  return this.ec.verify(msg, signature, this);
47873};
47874
47875KeyPair.prototype.inspect = function inspect() {
47876  return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) + ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
47877};
47878
47879},{"../utils":364,"bn.js":365}],359:[function(require,module,exports){
47880'use strict';
47881
47882var BN = require('bn.js');
47883
47884var utils = require('../utils');
47885
47886var assert = utils.assert;
47887
47888function Signature(options, enc) {
47889  if (options instanceof Signature) return options;
47890  if (this._importDER(options, enc)) return;
47891  assert(options.r && options.s, 'Signature without r or s');
47892  this.r = new BN(options.r, 16);
47893  this.s = new BN(options.s, 16);
47894  if (options.recoveryParam === undefined) this.recoveryParam = null;else this.recoveryParam = options.recoveryParam;
47895}
47896
47897module.exports = Signature;
47898
47899function Position() {
47900  this.place = 0;
47901}
47902
47903function getLength(buf, p) {
47904  var initial = buf[p.place++];
47905
47906  if (!(initial & 0x80)) {
47907    return initial;
47908  }
47909
47910  var octetLen = initial & 0xf; // Indefinite length or overflow
47911
47912  if (octetLen === 0 || octetLen > 4) {
47913    return false;
47914  }
47915
47916  var val = 0;
47917
47918  for (var i = 0, off = p.place; i < octetLen; i++, off++) {
47919    val <<= 8;
47920    val |= buf[off];
47921    val >>>= 0;
47922  } // Leading zeroes
47923
47924
47925  if (val <= 0x7f) {
47926    return false;
47927  }
47928
47929  p.place = off;
47930  return val;
47931}
47932
47933function rmPadding(buf) {
47934  var i = 0;
47935  var len = buf.length - 1;
47936
47937  while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
47938    i++;
47939  }
47940
47941  if (i === 0) {
47942    return buf;
47943  }
47944
47945  return buf.slice(i);
47946}
47947
47948Signature.prototype._importDER = function _importDER(data, enc) {
47949  data = utils.toArray(data, enc);
47950  var p = new Position();
47951
47952  if (data[p.place++] !== 0x30) {
47953    return false;
47954  }
47955
47956  var len = getLength(data, p);
47957
47958  if (len === false) {
47959    return false;
47960  }
47961
47962  if (len + p.place !== data.length) {
47963    return false;
47964  }
47965
47966  if (data[p.place++] !== 0x02) {
47967    return false;
47968  }
47969
47970  var rlen = getLength(data, p);
47971
47972  if (rlen === false) {
47973    return false;
47974  }
47975
47976  var r = data.slice(p.place, rlen + p.place);
47977  p.place += rlen;
47978
47979  if (data[p.place++] !== 0x02) {
47980    return false;
47981  }
47982
47983  var slen = getLength(data, p);
47984
47985  if (slen === false) {
47986    return false;
47987  }
47988
47989  if (data.length !== slen + p.place) {
47990    return false;
47991  }
47992
47993  var s = data.slice(p.place, slen + p.place);
47994
47995  if (r[0] === 0) {
47996    if (r[1] & 0x80) {
47997      r = r.slice(1);
47998    } else {
47999      // Leading zeroes
48000      return false;
48001    }
48002  }
48003
48004  if (s[0] === 0) {
48005    if (s[1] & 0x80) {
48006      s = s.slice(1);
48007    } else {
48008      // Leading zeroes
48009      return false;
48010    }
48011  }
48012
48013  this.r = new BN(r);
48014  this.s = new BN(s);
48015  this.recoveryParam = null;
48016  return true;
48017};
48018
48019function constructLength(arr, len) {
48020  if (len < 0x80) {
48021    arr.push(len);
48022    return;
48023  }
48024
48025  var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
48026  arr.push(octets | 0x80);
48027
48028  while (--octets) {
48029    arr.push(len >>> (octets << 3) & 0xff);
48030  }
48031
48032  arr.push(len);
48033}
48034
48035Signature.prototype.toDER = function toDER(enc) {
48036  var r = this.r.toArray();
48037  var s = this.s.toArray(); // Pad values
48038
48039  if (r[0] & 0x80) r = [0].concat(r); // Pad values
48040
48041  if (s[0] & 0x80) s = [0].concat(s);
48042  r = rmPadding(r);
48043  s = rmPadding(s);
48044
48045  while (!s[0] && !(s[1] & 0x80)) {
48046    s = s.slice(1);
48047  }
48048
48049  var arr = [0x02];
48050  constructLength(arr, r.length);
48051  arr = arr.concat(r);
48052  arr.push(0x02);
48053  constructLength(arr, s.length);
48054  var backHalf = arr.concat(s);
48055  var res = [0x30];
48056  constructLength(res, backHalf.length);
48057  res = res.concat(backHalf);
48058  return utils.encode(res, enc);
48059};
48060
48061},{"../utils":364,"bn.js":365}],360:[function(require,module,exports){
48062'use strict';
48063
48064var hash = require('hash.js');
48065
48066var curves = require('../curves');
48067
48068var utils = require('../utils');
48069
48070var assert = utils.assert;
48071var parseBytes = utils.parseBytes;
48072
48073var KeyPair = require('./key');
48074
48075var Signature = require('./signature');
48076
48077function EDDSA(curve) {
48078  assert(curve === 'ed25519', 'only tested with ed25519 so far');
48079  if (!(this instanceof EDDSA)) return new EDDSA(curve);
48080  var curve = curves[curve].curve;
48081  this.curve = curve;
48082  this.g = curve.g;
48083  this.g.precompute(curve.n.bitLength() + 1);
48084  this.pointClass = curve.point().constructor;
48085  this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
48086  this.hash = hash.sha512;
48087}
48088
48089module.exports = EDDSA;
48090/**
48091* @param {Array|String} message - message bytes
48092* @param {Array|String|KeyPair} secret - secret bytes or a keypair
48093* @returns {Signature} - signature
48094*/
48095
48096EDDSA.prototype.sign = function sign(message, secret) {
48097  message = parseBytes(message);
48098  var key = this.keyFromSecret(secret);
48099  var r = this.hashInt(key.messagePrefix(), message);
48100  var R = this.g.mul(r);
48101  var Rencoded = this.encodePoint(R);
48102  var s_ = this.hashInt(Rencoded, key.pubBytes(), message).mul(key.priv());
48103  var S = r.add(s_).umod(this.curve.n);
48104  return this.makeSignature({
48105    R: R,
48106    S: S,
48107    Rencoded: Rencoded
48108  });
48109};
48110/**
48111* @param {Array} message - message bytes
48112* @param {Array|String|Signature} sig - sig bytes
48113* @param {Array|String|Point|KeyPair} pub - public key
48114* @returns {Boolean} - true if public key matches sig of message
48115*/
48116
48117
48118EDDSA.prototype.verify = function verify(message, sig, pub) {
48119  message = parseBytes(message);
48120  sig = this.makeSignature(sig);
48121  var key = this.keyFromPublic(pub);
48122  var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
48123  var SG = this.g.mul(sig.S());
48124  var RplusAh = sig.R().add(key.pub().mul(h));
48125  return RplusAh.eq(SG);
48126};
48127
48128EDDSA.prototype.hashInt = function hashInt() {
48129  var hash = this.hash();
48130
48131  for (var i = 0; i < arguments.length; i++) {
48132    hash.update(arguments[i]);
48133  }
48134
48135  return utils.intFromLE(hash.digest()).umod(this.curve.n);
48136};
48137
48138EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
48139  return KeyPair.fromPublic(this, pub);
48140};
48141
48142EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
48143  return KeyPair.fromSecret(this, secret);
48144};
48145
48146EDDSA.prototype.makeSignature = function makeSignature(sig) {
48147  if (sig instanceof Signature) return sig;
48148  return new Signature(this, sig);
48149};
48150/**
48151* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
48152*
48153* EDDSA defines methods for encoding and decoding points and integers. These are
48154* helper convenience methods, that pass along to utility functions implied
48155* parameters.
48156*
48157*/
48158
48159
48160EDDSA.prototype.encodePoint = function encodePoint(point) {
48161  var enc = point.getY().toArray('le', this.encodingLength);
48162  enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
48163  return enc;
48164};
48165
48166EDDSA.prototype.decodePoint = function decodePoint(bytes) {
48167  bytes = utils.parseBytes(bytes);
48168  var lastIx = bytes.length - 1;
48169  var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
48170  var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
48171  var y = utils.intFromLE(normed);
48172  return this.curve.pointFromY(y, xIsOdd);
48173};
48174
48175EDDSA.prototype.encodeInt = function encodeInt(num) {
48176  return num.toArray('le', this.encodingLength);
48177};
48178
48179EDDSA.prototype.decodeInt = function decodeInt(bytes) {
48180  return utils.intFromLE(bytes);
48181};
48182
48183EDDSA.prototype.isPoint = function isPoint(val) {
48184  return val instanceof this.pointClass;
48185};
48186
48187},{"../curves":356,"../utils":364,"./key":361,"./signature":362,"hash.js":372}],361:[function(require,module,exports){
48188'use strict';
48189
48190var utils = require('../utils');
48191
48192var assert = utils.assert;
48193var parseBytes = utils.parseBytes;
48194var cachedProperty = utils.cachedProperty;
48195/**
48196* @param {EDDSA} eddsa - instance
48197* @param {Object} params - public/private key parameters
48198*
48199* @param {Array<Byte>} [params.secret] - secret seed bytes
48200* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
48201* @param {Array<Byte>} [params.pub] - public key point encoded as bytes
48202*
48203*/
48204
48205function KeyPair(eddsa, params) {
48206  this.eddsa = eddsa;
48207  this._secret = parseBytes(params.secret);
48208  if (eddsa.isPoint(params.pub)) this._pub = params.pub;else this._pubBytes = parseBytes(params.pub);
48209}
48210
48211KeyPair.fromPublic = function fromPublic(eddsa, pub) {
48212  if (pub instanceof KeyPair) return pub;
48213  return new KeyPair(eddsa, {
48214    pub: pub
48215  });
48216};
48217
48218KeyPair.fromSecret = function fromSecret(eddsa, secret) {
48219  if (secret instanceof KeyPair) return secret;
48220  return new KeyPair(eddsa, {
48221    secret: secret
48222  });
48223};
48224
48225KeyPair.prototype.secret = function secret() {
48226  return this._secret;
48227};
48228
48229cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
48230  return this.eddsa.encodePoint(this.pub());
48231});
48232cachedProperty(KeyPair, 'pub', function pub() {
48233  if (this._pubBytes) return this.eddsa.decodePoint(this._pubBytes);
48234  return this.eddsa.g.mul(this.priv());
48235});
48236cachedProperty(KeyPair, 'privBytes', function privBytes() {
48237  var eddsa = this.eddsa;
48238  var hash = this.hash();
48239  var lastIx = eddsa.encodingLength - 1;
48240  var a = hash.slice(0, eddsa.encodingLength);
48241  a[0] &= 248;
48242  a[lastIx] &= 127;
48243  a[lastIx] |= 64;
48244  return a;
48245});
48246cachedProperty(KeyPair, 'priv', function priv() {
48247  return this.eddsa.decodeInt(this.privBytes());
48248});
48249cachedProperty(KeyPair, 'hash', function hash() {
48250  return this.eddsa.hash().update(this.secret()).digest();
48251});
48252cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
48253  return this.hash().slice(this.eddsa.encodingLength);
48254});
48255
48256KeyPair.prototype.sign = function sign(message) {
48257  assert(this._secret, 'KeyPair can only verify');
48258  return this.eddsa.sign(message, this);
48259};
48260
48261KeyPair.prototype.verify = function verify(message, sig) {
48262  return this.eddsa.verify(message, sig, this);
48263};
48264
48265KeyPair.prototype.getSecret = function getSecret(enc) {
48266  assert(this._secret, 'KeyPair is public only');
48267  return utils.encode(this.secret(), enc);
48268};
48269
48270KeyPair.prototype.getPublic = function getPublic(enc) {
48271  return utils.encode(this.pubBytes(), enc);
48272};
48273
48274module.exports = KeyPair;
48275
48276},{"../utils":364}],362:[function(require,module,exports){
48277'use strict';
48278
48279function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
48280
48281var BN = require('bn.js');
48282
48283var utils = require('../utils');
48284
48285var assert = utils.assert;
48286var cachedProperty = utils.cachedProperty;
48287var parseBytes = utils.parseBytes;
48288/**
48289* @param {EDDSA} eddsa - eddsa instance
48290* @param {Array<Bytes>|Object} sig -
48291* @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
48292* @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
48293* @param {Array<Bytes>} [sig.Rencoded] - R point encoded
48294* @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
48295*/
48296
48297function Signature(eddsa, sig) {
48298  this.eddsa = eddsa;
48299  if (_typeof(sig) !== 'object') sig = parseBytes(sig);
48300
48301  if (Array.isArray(sig)) {
48302    sig = {
48303      R: sig.slice(0, eddsa.encodingLength),
48304      S: sig.slice(eddsa.encodingLength)
48305    };
48306  }
48307
48308  assert(sig.R && sig.S, 'Signature without R or S');
48309  if (eddsa.isPoint(sig.R)) this._R = sig.R;
48310  if (sig.S instanceof BN) this._S = sig.S;
48311  this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
48312  this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
48313}
48314
48315cachedProperty(Signature, 'S', function S() {
48316  return this.eddsa.decodeInt(this.Sencoded());
48317});
48318cachedProperty(Signature, 'R', function R() {
48319  return this.eddsa.decodePoint(this.Rencoded());
48320});
48321cachedProperty(Signature, 'Rencoded', function Rencoded() {
48322  return this.eddsa.encodePoint(this.R());
48323});
48324cachedProperty(Signature, 'Sencoded', function Sencoded() {
48325  return this.eddsa.encodeInt(this.S());
48326});
48327
48328Signature.prototype.toBytes = function toBytes() {
48329  return this.Rencoded().concat(this.Sencoded());
48330};
48331
48332Signature.prototype.toHex = function toHex() {
48333  return utils.encode(this.toBytes(), 'hex').toUpperCase();
48334};
48335
48336module.exports = Signature;
48337
48338},{"../utils":364,"bn.js":365}],363:[function(require,module,exports){
48339"use strict";
48340
48341module.exports = {
48342  doubles: {
48343    step: 4,
48344    points: [['e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'], ['8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'], ['175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'], ['363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'], ['8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'], ['723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'], ['eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'], ['100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'], ['e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'], ['feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'], ['da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'], ['53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'], ['8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'], ['385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'], ['6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'], ['3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'], ['85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'], ['948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'], ['6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'], ['e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'], ['e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'], ['213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'], ['4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'], ['fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'], ['76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'], ['c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'], ['d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'], ['b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'], ['e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'], ['a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'], ['90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'], ['8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'], ['e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'], ['8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'], ['e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'], ['b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'], ['d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'], ['324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'], ['4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'], ['9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'], ['6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'], ['a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'], ['7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'], ['928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'], ['85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'], ['ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'], ['827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'], ['eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'], ['e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'], ['1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'], ['146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'], ['fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'], ['da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'], ['a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'], ['174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'], ['959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'], ['d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'], ['64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'], ['8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'], ['13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'], ['bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'], ['8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'], ['8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'], ['dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'], ['f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82']]
48345  },
48346  naf: {
48347    wnd: 7,
48348    points: [['f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'], ['2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'], ['5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'], ['acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'], ['774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'], ['f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'], ['d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'], ['defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'], ['2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'], ['352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'], ['2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'], ['9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'], ['daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'], ['c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'], ['6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'], ['1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'], ['605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'], ['62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'], ['80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'], ['7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'], ['d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'], ['49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'], ['77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'], ['f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'], ['463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'], ['f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'], ['caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'], ['2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'], ['7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'], ['754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'], ['e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'], ['186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'], ['df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'], ['5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'], ['290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'], ['af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'], ['766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'], ['59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'], ['f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'], ['7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'], ['948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'], ['7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'], ['3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'], ['d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'], ['1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'], ['733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'], ['15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'], ['a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'], ['e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'], ['311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'], ['34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'], ['f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'], ['d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'], ['32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'], ['7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'], ['ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'], ['16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'], ['eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'], ['78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'], ['494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'], ['a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'], ['c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'], ['841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'], ['5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'], ['36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'], ['336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'], ['8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'], ['1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'], ['85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'], ['29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'], ['a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'], ['4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'], ['d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'], ['ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'], ['af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'], ['e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'], ['591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'], ['11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'], ['3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'], ['cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'], ['c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'], ['c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'], ['a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'], ['347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'], ['da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'], ['c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'], ['4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'], ['3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'], ['cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'], ['b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'], ['d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'], ['48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'], ['dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'], ['6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'], ['e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'], ['eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'], ['13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'], ['ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'], ['b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'], ['ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'], ['8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'], ['52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'], ['e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'], ['7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'], ['5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'], ['32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'], ['e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'], ['8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'], ['4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'], ['3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'], ['674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'], ['d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'], ['30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'], ['be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'], ['93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'], ['b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'], ['d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'], ['d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'], ['463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'], ['7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'], ['74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'], ['30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'], ['9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'], ['176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'], ['75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'], ['809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'], ['1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9']]
48349  }
48350};
48351
48352},{}],364:[function(require,module,exports){
48353'use strict';
48354
48355var utils = exports;
48356
48357var BN = require('bn.js');
48358
48359var minAssert = require('minimalistic-assert');
48360
48361var minUtils = require('minimalistic-crypto-utils');
48362
48363utils.assert = minAssert;
48364utils.toArray = minUtils.toArray;
48365utils.zero2 = minUtils.zero2;
48366utils.toHex = minUtils.toHex;
48367utils.encode = minUtils.encode; // Represent num in a w-NAF form
48368
48369function getNAF(num, w, bits) {
48370  var naf = new Array(Math.max(num.bitLength(), bits) + 1);
48371  naf.fill(0);
48372  var ws = 1 << w + 1;
48373  var k = num.clone();
48374
48375  for (var i = 0; i < naf.length; i++) {
48376    var z;
48377    var mod = k.andln(ws - 1);
48378
48379    if (k.isOdd()) {
48380      if (mod > (ws >> 1) - 1) z = (ws >> 1) - mod;else z = mod;
48381      k.isubn(z);
48382    } else {
48383      z = 0;
48384    }
48385
48386    naf[i] = z;
48387    k.iushrn(1);
48388  }
48389
48390  return naf;
48391}
48392
48393utils.getNAF = getNAF; // Represent k1, k2 in a Joint Sparse Form
48394
48395function getJSF(k1, k2) {
48396  var jsf = [[], []];
48397  k1 = k1.clone();
48398  k2 = k2.clone();
48399  var d1 = 0;
48400  var d2 = 0;
48401
48402  while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
48403    // First phase
48404    var m14 = k1.andln(3) + d1 & 3;
48405    var m24 = k2.andln(3) + d2 & 3;
48406    if (m14 === 3) m14 = -1;
48407    if (m24 === 3) m24 = -1;
48408    var u1;
48409
48410    if ((m14 & 1) === 0) {
48411      u1 = 0;
48412    } else {
48413      var m8 = k1.andln(7) + d1 & 7;
48414      if ((m8 === 3 || m8 === 5) && m24 === 2) u1 = -m14;else u1 = m14;
48415    }
48416
48417    jsf[0].push(u1);
48418    var u2;
48419
48420    if ((m24 & 1) === 0) {
48421      u2 = 0;
48422    } else {
48423      var m8 = k2.andln(7) + d2 & 7;
48424      if ((m8 === 3 || m8 === 5) && m14 === 2) u2 = -m24;else u2 = m24;
48425    }
48426
48427    jsf[1].push(u2); // Second phase
48428
48429    if (2 * d1 === u1 + 1) d1 = 1 - d1;
48430    if (2 * d2 === u2 + 1) d2 = 1 - d2;
48431    k1.iushrn(1);
48432    k2.iushrn(1);
48433  }
48434
48435  return jsf;
48436}
48437
48438utils.getJSF = getJSF;
48439
48440function cachedProperty(obj, name, computer) {
48441  var key = '_' + name;
48442
48443  obj.prototype[name] = function cachedProperty() {
48444    return this[key] !== undefined ? this[key] : this[key] = computer.call(this);
48445  };
48446}
48447
48448utils.cachedProperty = cachedProperty;
48449
48450function parseBytes(bytes) {
48451  return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : bytes;
48452}
48453
48454utils.parseBytes = parseBytes;
48455
48456function intFromLE(bytes) {
48457  return new BN(bytes, 'hex', 'le');
48458}
48459
48460utils.intFromLE = intFromLE;
48461
48462},{"bn.js":365,"minimalistic-assert":437,"minimalistic-crypto-utils":438}],365:[function(require,module,exports){
48463arguments[4][181][0].apply(exports,arguments)
48464},{"buffer":185,"dup":181}],366:[function(require,module,exports){
48465module.exports={
48466  "_from": "elliptic@^6.5.3",
48467  "_id": "elliptic@6.5.3",
48468  "_inBundle": false,
48469  "_integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
48470  "_location": "/elliptic",
48471  "_phantomChildren": {},
48472  "_requested": {
48473    "type": "range",
48474    "registry": true,
48475    "raw": "elliptic@^6.5.3",
48476    "name": "elliptic",
48477    "escapedName": "elliptic",
48478    "rawSpec": "^6.5.3",
48479    "saveSpec": null,
48480    "fetchSpec": "^6.5.3"
48481  },
48482  "_requiredBy": [
48483    "/browserify-sign",
48484    "/create-ecdh"
48485  ],
48486  "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
48487  "_shasum": "cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6",
48488  "_spec": "elliptic@^6.5.3",
48489  "_where": "/mnt/d/dev/git/exceljs/node_modules/browserify-sign",
48490  "author": {
48491    "name": "Fedor Indutny",
48492    "email": "fedor@indutny.com"
48493  },
48494  "bugs": {
48495    "url": "https://github.com/indutny/elliptic/issues"
48496  },
48497  "bundleDependencies": false,
48498  "dependencies": {
48499    "bn.js": "^4.4.0",
48500    "brorand": "^1.0.1",
48501    "hash.js": "^1.0.0",
48502    "hmac-drbg": "^1.0.0",
48503    "inherits": "^2.0.1",
48504    "minimalistic-assert": "^1.0.0",
48505    "minimalistic-crypto-utils": "^1.0.0"
48506  },
48507  "deprecated": false,
48508  "description": "EC cryptography",
48509  "devDependencies": {
48510    "brfs": "^1.4.3",
48511    "coveralls": "^3.0.8",
48512    "grunt": "^1.0.4",
48513    "grunt-browserify": "^5.0.0",
48514    "grunt-cli": "^1.2.0",
48515    "grunt-contrib-connect": "^1.0.0",
48516    "grunt-contrib-copy": "^1.0.0",
48517    "grunt-contrib-uglify": "^1.0.1",
48518    "grunt-mocha-istanbul": "^3.0.1",
48519    "grunt-saucelabs": "^9.0.1",
48520    "istanbul": "^0.4.2",
48521    "jscs": "^3.0.7",
48522    "jshint": "^2.10.3",
48523    "mocha": "^6.2.2"
48524  },
48525  "files": [
48526    "lib"
48527  ],
48528  "homepage": "https://github.com/indutny/elliptic",
48529  "keywords": [
48530    "EC",
48531    "Elliptic",
48532    "curve",
48533    "Cryptography"
48534  ],
48535  "license": "MIT",
48536  "main": "lib/elliptic.js",
48537  "name": "elliptic",
48538  "repository": {
48539    "type": "git",
48540    "url": "git+ssh://git@github.com/indutny/elliptic.git"
48541  },
48542  "scripts": {
48543    "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
48544    "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
48545    "lint": "npm run jscs && npm run jshint",
48546    "test": "npm run lint && npm run unit",
48547    "unit": "istanbul test _mocha --reporter=spec test/index.js",
48548    "version": "grunt dist && git add dist/"
48549  },
48550  "version": "6.5.3"
48551}
48552
48553},{}],367:[function(require,module,exports){
48554"use strict";
48555
48556function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
48557
48558// Copyright Joyent, Inc. and other Node contributors.
48559//
48560// Permission is hereby granted, free of charge, to any person obtaining a
48561// copy of this software and associated documentation files (the
48562// "Software"), to deal in the Software without restriction, including
48563// without limitation the rights to use, copy, modify, merge, publish,
48564// distribute, sublicense, and/or sell copies of the Software, and to permit
48565// persons to whom the Software is furnished to do so, subject to the
48566// following conditions:
48567//
48568// The above copyright notice and this permission notice shall be included
48569// in all copies or substantial portions of the Software.
48570//
48571// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
48572// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48573// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
48574// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
48575// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
48576// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
48577// USE OR OTHER DEALINGS IN THE SOFTWARE.
48578var objectCreate = Object.create || objectCreatePolyfill;
48579var objectKeys = Object.keys || objectKeysPolyfill;
48580var bind = Function.prototype.bind || functionBindPolyfill;
48581
48582function EventEmitter() {
48583  if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
48584    this._events = objectCreate(null);
48585    this._eventsCount = 0;
48586  }
48587
48588  this._maxListeners = this._maxListeners || undefined;
48589}
48590
48591module.exports = EventEmitter; // Backwards-compat with node 0.10.x
48592
48593EventEmitter.EventEmitter = EventEmitter;
48594EventEmitter.prototype._events = undefined;
48595EventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are
48596// added to it. This is a useful default which helps finding memory leaks.
48597
48598var defaultMaxListeners = 10;
48599var hasDefineProperty;
48600
48601try {
48602  var o = {};
48603  if (Object.defineProperty) Object.defineProperty(o, 'x', {
48604    value: 0
48605  });
48606  hasDefineProperty = o.x === 0;
48607} catch (err) {
48608  hasDefineProperty = false;
48609}
48610
48611if (hasDefineProperty) {
48612  Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
48613    enumerable: true,
48614    get: function get() {
48615      return defaultMaxListeners;
48616    },
48617    set: function set(arg) {
48618      // check whether the input is a positive number (whose value is zero or
48619      // greater and not a NaN).
48620      if (typeof arg !== 'number' || arg < 0 || arg !== arg) throw new TypeError('"defaultMaxListeners" must be a positive number');
48621      defaultMaxListeners = arg;
48622    }
48623  });
48624} else {
48625  EventEmitter.defaultMaxListeners = defaultMaxListeners;
48626} // Obviously not all Emitters should be limited to 10. This function allows
48627// that to be increased. Set to zero for unlimited.
48628
48629
48630EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
48631  if (typeof n !== 'number' || n < 0 || isNaN(n)) throw new TypeError('"n" argument must be a positive number');
48632  this._maxListeners = n;
48633  return this;
48634};
48635
48636function $getMaxListeners(that) {
48637  if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners;
48638  return that._maxListeners;
48639}
48640
48641EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
48642  return $getMaxListeners(this);
48643}; // These standalone emit* functions are used to optimize calling of event
48644// handlers for fast cases because emit() itself often has a variable number of
48645// arguments and can be deoptimized because of that. These functions always have
48646// the same number of arguments and thus do not get deoptimized, so the code
48647// inside them can execute faster.
48648
48649
48650function emitNone(handler, isFn, self) {
48651  if (isFn) handler.call(self);else {
48652    var len = handler.length;
48653    var listeners = arrayClone(handler, len);
48654
48655    for (var i = 0; i < len; ++i) {
48656      listeners[i].call(self);
48657    }
48658  }
48659}
48660
48661function emitOne(handler, isFn, self, arg1) {
48662  if (isFn) handler.call(self, arg1);else {
48663    var len = handler.length;
48664    var listeners = arrayClone(handler, len);
48665
48666    for (var i = 0; i < len; ++i) {
48667      listeners[i].call(self, arg1);
48668    }
48669  }
48670}
48671
48672function emitTwo(handler, isFn, self, arg1, arg2) {
48673  if (isFn) handler.call(self, arg1, arg2);else {
48674    var len = handler.length;
48675    var listeners = arrayClone(handler, len);
48676
48677    for (var i = 0; i < len; ++i) {
48678      listeners[i].call(self, arg1, arg2);
48679    }
48680  }
48681}
48682
48683function emitThree(handler, isFn, self, arg1, arg2, arg3) {
48684  if (isFn) handler.call(self, arg1, arg2, arg3);else {
48685    var len = handler.length;
48686    var listeners = arrayClone(handler, len);
48687
48688    for (var i = 0; i < len; ++i) {
48689      listeners[i].call(self, arg1, arg2, arg3);
48690    }
48691  }
48692}
48693
48694function emitMany(handler, isFn, self, args) {
48695  if (isFn) handler.apply(self, args);else {
48696    var len = handler.length;
48697    var listeners = arrayClone(handler, len);
48698
48699    for (var i = 0; i < len; ++i) {
48700      listeners[i].apply(self, args);
48701    }
48702  }
48703}
48704
48705EventEmitter.prototype.emit = function emit(type) {
48706  var er, handler, len, args, i, events;
48707  var doError = type === 'error';
48708  events = this._events;
48709  if (events) doError = doError && events.error == null;else if (!doError) return false; // If there is no 'error' event listener then throw.
48710
48711  if (doError) {
48712    if (arguments.length > 1) er = arguments[1];
48713
48714    if (er instanceof Error) {
48715      throw er; // Unhandled 'error' event
48716    } else {
48717      // At least give some kind of context to the user
48718      var err = new Error('Unhandled "error" event. (' + er + ')');
48719      err.context = er;
48720      throw err;
48721    }
48722
48723    return false;
48724  }
48725
48726  handler = events[type];
48727  if (!handler) return false;
48728  var isFn = typeof handler === 'function';
48729  len = arguments.length;
48730
48731  switch (len) {
48732    // fast cases
48733    case 1:
48734      emitNone(handler, isFn, this);
48735      break;
48736
48737    case 2:
48738      emitOne(handler, isFn, this, arguments[1]);
48739      break;
48740
48741    case 3:
48742      emitTwo(handler, isFn, this, arguments[1], arguments[2]);
48743      break;
48744
48745    case 4:
48746      emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
48747      break;
48748    // slower
48749
48750    default:
48751      args = new Array(len - 1);
48752
48753      for (i = 1; i < len; i++) {
48754        args[i - 1] = arguments[i];
48755      }
48756
48757      emitMany(handler, isFn, this, args);
48758  }
48759
48760  return true;
48761};
48762
48763function _addListener(target, type, listener, prepend) {
48764  var m;
48765  var events;
48766  var existing;
48767  if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
48768  events = target._events;
48769
48770  if (!events) {
48771    events = target._events = objectCreate(null);
48772    target._eventsCount = 0;
48773  } else {
48774    // To avoid recursion in the case that type === "newListener"! Before
48775    // adding it to the listeners, first emit "newListener".
48776    if (events.newListener) {
48777      target.emit('newListener', type, listener.listener ? listener.listener : listener); // Re-assign `events` because a newListener handler could have caused the
48778      // this._events to be assigned to a new object
48779
48780      events = target._events;
48781    }
48782
48783    existing = events[type];
48784  }
48785
48786  if (!existing) {
48787    // Optimize the case of one listener. Don't need the extra array object.
48788    existing = events[type] = listener;
48789    ++target._eventsCount;
48790  } else {
48791    if (typeof existing === 'function') {
48792      // Adding the second element, need to change to array.
48793      existing = events[type] = prepend ? [listener, existing] : [existing, listener];
48794    } else {
48795      // If we've already got an array, just append.
48796      if (prepend) {
48797        existing.unshift(listener);
48798      } else {
48799        existing.push(listener);
48800      }
48801    } // Check for listener leak
48802
48803
48804    if (!existing.warned) {
48805      m = $getMaxListeners(target);
48806
48807      if (m && m > 0 && existing.length > m) {
48808        existing.warned = true;
48809        var w = new Error('Possible EventEmitter memory leak detected. ' + existing.length + ' "' + String(type) + '" listeners ' + 'added. Use emitter.setMaxListeners() to ' + 'increase limit.');
48810        w.name = 'MaxListenersExceededWarning';
48811        w.emitter = target;
48812        w.type = type;
48813        w.count = existing.length;
48814
48815        if ((typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.warn) {
48816          console.warn('%s: %s', w.name, w.message);
48817        }
48818      }
48819    }
48820  }
48821
48822  return target;
48823}
48824
48825EventEmitter.prototype.addListener = function addListener(type, listener) {
48826  return _addListener(this, type, listener, false);
48827};
48828
48829EventEmitter.prototype.on = EventEmitter.prototype.addListener;
48830
48831EventEmitter.prototype.prependListener = function prependListener(type, listener) {
48832  return _addListener(this, type, listener, true);
48833};
48834
48835function onceWrapper() {
48836  if (!this.fired) {
48837    this.target.removeListener(this.type, this.wrapFn);
48838    this.fired = true;
48839
48840    switch (arguments.length) {
48841      case 0:
48842        return this.listener.call(this.target);
48843
48844      case 1:
48845        return this.listener.call(this.target, arguments[0]);
48846
48847      case 2:
48848        return this.listener.call(this.target, arguments[0], arguments[1]);
48849
48850      case 3:
48851        return this.listener.call(this.target, arguments[0], arguments[1], arguments[2]);
48852
48853      default:
48854        var args = new Array(arguments.length);
48855
48856        for (var i = 0; i < args.length; ++i) {
48857          args[i] = arguments[i];
48858        }
48859
48860        this.listener.apply(this.target, args);
48861    }
48862  }
48863}
48864
48865function _onceWrap(target, type, listener) {
48866  var state = {
48867    fired: false,
48868    wrapFn: undefined,
48869    target: target,
48870    type: type,
48871    listener: listener
48872  };
48873  var wrapped = bind.call(onceWrapper, state);
48874  wrapped.listener = listener;
48875  state.wrapFn = wrapped;
48876  return wrapped;
48877}
48878
48879EventEmitter.prototype.once = function once(type, listener) {
48880  if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
48881  this.on(type, _onceWrap(this, type, listener));
48882  return this;
48883};
48884
48885EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
48886  if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
48887  this.prependListener(type, _onceWrap(this, type, listener));
48888  return this;
48889}; // Emits a 'removeListener' event if and only if the listener was removed.
48890
48891
48892EventEmitter.prototype.removeListener = function removeListener(type, listener) {
48893  var list, events, position, i, originalListener;
48894  if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
48895  events = this._events;
48896  if (!events) return this;
48897  list = events[type];
48898  if (!list) return this;
48899
48900  if (list === listener || list.listener === listener) {
48901    if (--this._eventsCount === 0) this._events = objectCreate(null);else {
48902      delete events[type];
48903      if (events.removeListener) this.emit('removeListener', type, list.listener || listener);
48904    }
48905  } else if (typeof list !== 'function') {
48906    position = -1;
48907
48908    for (i = list.length - 1; i >= 0; i--) {
48909      if (list[i] === listener || list[i].listener === listener) {
48910        originalListener = list[i].listener;
48911        position = i;
48912        break;
48913      }
48914    }
48915
48916    if (position < 0) return this;
48917    if (position === 0) list.shift();else spliceOne(list, position);
48918    if (list.length === 1) events[type] = list[0];
48919    if (events.removeListener) this.emit('removeListener', type, originalListener || listener);
48920  }
48921
48922  return this;
48923};
48924
48925EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
48926  var listeners, events, i;
48927  events = this._events;
48928  if (!events) return this; // not listening for removeListener, no need to emit
48929
48930  if (!events.removeListener) {
48931    if (arguments.length === 0) {
48932      this._events = objectCreate(null);
48933      this._eventsCount = 0;
48934    } else if (events[type]) {
48935      if (--this._eventsCount === 0) this._events = objectCreate(null);else delete events[type];
48936    }
48937
48938    return this;
48939  } // emit removeListener for all listeners on all events
48940
48941
48942  if (arguments.length === 0) {
48943    var keys = objectKeys(events);
48944    var key;
48945
48946    for (i = 0; i < keys.length; ++i) {
48947      key = keys[i];
48948      if (key === 'removeListener') continue;
48949      this.removeAllListeners(key);
48950    }
48951
48952    this.removeAllListeners('removeListener');
48953    this._events = objectCreate(null);
48954    this._eventsCount = 0;
48955    return this;
48956  }
48957
48958  listeners = events[type];
48959
48960  if (typeof listeners === 'function') {
48961    this.removeListener(type, listeners);
48962  } else if (listeners) {
48963    // LIFO order
48964    for (i = listeners.length - 1; i >= 0; i--) {
48965      this.removeListener(type, listeners[i]);
48966    }
48967  }
48968
48969  return this;
48970};
48971
48972function _listeners(target, type, unwrap) {
48973  var events = target._events;
48974  if (!events) return [];
48975  var evlistener = events[type];
48976  if (!evlistener) return [];
48977  if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener];
48978  return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
48979}
48980
48981EventEmitter.prototype.listeners = function listeners(type) {
48982  return _listeners(this, type, true);
48983};
48984
48985EventEmitter.prototype.rawListeners = function rawListeners(type) {
48986  return _listeners(this, type, false);
48987};
48988
48989EventEmitter.listenerCount = function (emitter, type) {
48990  if (typeof emitter.listenerCount === 'function') {
48991    return emitter.listenerCount(type);
48992  } else {
48993    return listenerCount.call(emitter, type);
48994  }
48995};
48996
48997EventEmitter.prototype.listenerCount = listenerCount;
48998
48999function listenerCount(type) {
49000  var events = this._events;
49001
49002  if (events) {
49003    var evlistener = events[type];
49004
49005    if (typeof evlistener === 'function') {
49006      return 1;
49007    } else if (evlistener) {
49008      return evlistener.length;
49009    }
49010  }
49011
49012  return 0;
49013}
49014
49015EventEmitter.prototype.eventNames = function eventNames() {
49016  return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
49017}; // About 1.5x faster than the two-arg version of Array#splice().
49018
49019
49020function spliceOne(list, index) {
49021  for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
49022    list[i] = list[k];
49023  }
49024
49025  list.pop();
49026}
49027
49028function arrayClone(arr, n) {
49029  var copy = new Array(n);
49030
49031  for (var i = 0; i < n; ++i) {
49032    copy[i] = arr[i];
49033  }
49034
49035  return copy;
49036}
49037
49038function unwrapListeners(arr) {
49039  var ret = new Array(arr.length);
49040
49041  for (var i = 0; i < ret.length; ++i) {
49042    ret[i] = arr[i].listener || arr[i];
49043  }
49044
49045  return ret;
49046}
49047
49048function objectCreatePolyfill(proto) {
49049  var F = function F() {};
49050
49051  F.prototype = proto;
49052  return new F();
49053}
49054
49055function objectKeysPolyfill(obj) {
49056  var keys = [];
49057
49058  for (var k in obj) {
49059    if (Object.prototype.hasOwnProperty.call(obj, k)) {
49060      keys.push(k);
49061    }
49062  }
49063
49064  return k;
49065}
49066
49067function functionBindPolyfill(context) {
49068  var fn = this;
49069  return function () {
49070    return fn.apply(context, arguments);
49071  };
49072}
49073
49074},{}],368:[function(require,module,exports){
49075"use strict";
49076
49077var Buffer = require('safe-buffer').Buffer;
49078
49079var MD5 = require('md5.js');
49080/* eslint-disable camelcase */
49081
49082
49083function EVP_BytesToKey(password, salt, keyBits, ivLen) {
49084  if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary');
49085
49086  if (salt) {
49087    if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary');
49088    if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length');
49089  }
49090
49091  var keyLen = keyBits / 8;
49092  var key = Buffer.alloc(keyLen);
49093  var iv = Buffer.alloc(ivLen || 0);
49094  var tmp = Buffer.alloc(0);
49095
49096  while (keyLen > 0 || ivLen > 0) {
49097    var hash = new MD5();
49098    hash.update(tmp);
49099    hash.update(password);
49100    if (salt) hash.update(salt);
49101    tmp = hash.digest();
49102    var used = 0;
49103
49104    if (keyLen > 0) {
49105      var keyStart = key.length - keyLen;
49106      used = Math.min(keyLen, tmp.length);
49107      tmp.copy(key, keyStart, 0, used);
49108      keyLen -= used;
49109    }
49110
49111    if (used < tmp.length && ivLen > 0) {
49112      var ivStart = iv.length - ivLen;
49113      var length = Math.min(ivLen, tmp.length - used);
49114      tmp.copy(iv, ivStart, used, used + length);
49115      ivLen -= length;
49116    }
49117  }
49118
49119  tmp.fill(0);
49120  return {
49121    key: key,
49122    iv: iv
49123  };
49124}
49125
49126module.exports = EVP_BytesToKey;
49127
49128},{"md5.js":434,"safe-buffer":494}],369:[function(require,module,exports){
49129"use strict";
49130
49131Object.defineProperty(exports, "__esModule", {
49132  value: true
49133});
49134
49135var format_1 = require("@fast-csv/format");
49136
49137Object.defineProperty(exports, "format", {
49138  enumerable: true,
49139  get: function get() {
49140    return format_1.format;
49141  }
49142});
49143Object.defineProperty(exports, "write", {
49144  enumerable: true,
49145  get: function get() {
49146    return format_1.write;
49147  }
49148});
49149Object.defineProperty(exports, "writeToStream", {
49150  enumerable: true,
49151  get: function get() {
49152    return format_1.writeToStream;
49153  }
49154});
49155Object.defineProperty(exports, "writeToBuffer", {
49156  enumerable: true,
49157  get: function get() {
49158    return format_1.writeToBuffer;
49159  }
49160});
49161Object.defineProperty(exports, "writeToString", {
49162  enumerable: true,
49163  get: function get() {
49164    return format_1.writeToString;
49165  }
49166});
49167Object.defineProperty(exports, "writeToPath", {
49168  enumerable: true,
49169  get: function get() {
49170    return format_1.writeToPath;
49171  }
49172});
49173Object.defineProperty(exports, "CsvFormatterStream", {
49174  enumerable: true,
49175  get: function get() {
49176    return format_1.CsvFormatterStream;
49177  }
49178});
49179Object.defineProperty(exports, "FormatterOptions", {
49180  enumerable: true,
49181  get: function get() {
49182    return format_1.FormatterOptions;
49183  }
49184});
49185
49186var parse_1 = require("@fast-csv/parse");
49187
49188Object.defineProperty(exports, "parse", {
49189  enumerable: true,
49190  get: function get() {
49191    return parse_1.parse;
49192  }
49193});
49194Object.defineProperty(exports, "parseString", {
49195  enumerable: true,
49196  get: function get() {
49197    return parse_1.parseString;
49198  }
49199});
49200Object.defineProperty(exports, "parseStream", {
49201  enumerable: true,
49202  get: function get() {
49203    return parse_1.parseStream;
49204  }
49205});
49206Object.defineProperty(exports, "parseFile", {
49207  enumerable: true,
49208  get: function get() {
49209    return parse_1.parseFile;
49210  }
49211});
49212Object.defineProperty(exports, "ParserOptions", {
49213  enumerable: true,
49214  get: function get() {
49215    return parse_1.ParserOptions;
49216  }
49217});
49218Object.defineProperty(exports, "CsvParserStream", {
49219  enumerable: true,
49220  get: function get() {
49221    return parse_1.CsvParserStream;
49222  }
49223});
49224
49225},{"@fast-csv/format":148,"@fast-csv/parse":152}],370:[function(require,module,exports){
49226'use strict';
49227
49228var Buffer = require('safe-buffer').Buffer;
49229
49230var Transform = require('readable-stream').Transform;
49231
49232var inherits = require('inherits');
49233
49234function throwIfNotStringOrBuffer(val, prefix) {
49235  if (!Buffer.isBuffer(val) && typeof val !== 'string') {
49236    throw new TypeError(prefix + ' must be a string or a buffer');
49237  }
49238}
49239
49240function HashBase(blockSize) {
49241  Transform.call(this);
49242  this._block = Buffer.allocUnsafe(blockSize);
49243  this._blockSize = blockSize;
49244  this._blockOffset = 0;
49245  this._length = [0, 0, 0, 0];
49246  this._finalized = false;
49247}
49248
49249inherits(HashBase, Transform);
49250
49251HashBase.prototype._transform = function (chunk, encoding, callback) {
49252  var error = null;
49253
49254  try {
49255    this.update(chunk, encoding);
49256  } catch (err) {
49257    error = err;
49258  }
49259
49260  callback(error);
49261};
49262
49263HashBase.prototype._flush = function (callback) {
49264  var error = null;
49265
49266  try {
49267    this.push(this.digest());
49268  } catch (err) {
49269    error = err;
49270  }
49271
49272  callback(error);
49273};
49274
49275HashBase.prototype.update = function (data, encoding) {
49276  throwIfNotStringOrBuffer(data, 'Data');
49277  if (this._finalized) throw new Error('Digest already called');
49278  if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding); // consume data
49279
49280  var block = this._block;
49281  var offset = 0;
49282
49283  while (this._blockOffset + data.length - offset >= this._blockSize) {
49284    for (var i = this._blockOffset; i < this._blockSize;) {
49285      block[i++] = data[offset++];
49286    }
49287
49288    this._update();
49289
49290    this._blockOffset = 0;
49291  }
49292
49293  while (offset < data.length) {
49294    block[this._blockOffset++] = data[offset++];
49295  } // update length
49296
49297
49298  for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
49299    this._length[j] += carry;
49300    carry = this._length[j] / 0x0100000000 | 0;
49301    if (carry > 0) this._length[j] -= 0x0100000000 * carry;
49302  }
49303
49304  return this;
49305};
49306
49307HashBase.prototype._update = function () {
49308  throw new Error('_update is not implemented');
49309};
49310
49311HashBase.prototype.digest = function (encoding) {
49312  if (this._finalized) throw new Error('Digest already called');
49313  this._finalized = true;
49314
49315  var digest = this._digest();
49316
49317  if (encoding !== undefined) digest = digest.toString(encoding); // reset state
49318
49319  this._block.fill(0);
49320
49321  this._blockOffset = 0;
49322
49323  for (var i = 0; i < 4; ++i) {
49324    this._length[i] = 0;
49325  }
49326
49327  return digest;
49328};
49329
49330HashBase.prototype._digest = function () {
49331  throw new Error('_digest is not implemented');
49332};
49333
49334module.exports = HashBase;
49335
49336},{"inherits":387,"readable-stream":491,"safe-buffer":371}],371:[function(require,module,exports){
49337arguments[4][214][0].apply(exports,arguments)
49338},{"buffer":216,"dup":214}],372:[function(require,module,exports){
49339"use strict";
49340
49341var hash = exports;
49342hash.utils = require('./hash/utils');
49343hash.common = require('./hash/common');
49344hash.sha = require('./hash/sha');
49345hash.ripemd = require('./hash/ripemd');
49346hash.hmac = require('./hash/hmac'); // Proxy hash functions to the main object
49347
49348hash.sha1 = hash.sha.sha1;
49349hash.sha256 = hash.sha.sha256;
49350hash.sha224 = hash.sha.sha224;
49351hash.sha384 = hash.sha.sha384;
49352hash.sha512 = hash.sha.sha512;
49353hash.ripemd160 = hash.ripemd.ripemd160;
49354
49355},{"./hash/common":373,"./hash/hmac":374,"./hash/ripemd":375,"./hash/sha":376,"./hash/utils":383}],373:[function(require,module,exports){
49356'use strict';
49357
49358var utils = require('./utils');
49359
49360var assert = require('minimalistic-assert');
49361
49362function BlockHash() {
49363  this.pending = null;
49364  this.pendingTotal = 0;
49365  this.blockSize = this.constructor.blockSize;
49366  this.outSize = this.constructor.outSize;
49367  this.hmacStrength = this.constructor.hmacStrength;
49368  this.padLength = this.constructor.padLength / 8;
49369  this.endian = 'big';
49370  this._delta8 = this.blockSize / 8;
49371  this._delta32 = this.blockSize / 32;
49372}
49373
49374exports.BlockHash = BlockHash;
49375
49376BlockHash.prototype.update = function update(msg, enc) {
49377  // Convert message to array, pad it, and join into 32bit blocks
49378  msg = utils.toArray(msg, enc);
49379  if (!this.pending) this.pending = msg;else this.pending = this.pending.concat(msg);
49380  this.pendingTotal += msg.length; // Enough data, try updating
49381
49382  if (this.pending.length >= this._delta8) {
49383    msg = this.pending; // Process pending data in blocks
49384
49385    var r = msg.length % this._delta8;
49386    this.pending = msg.slice(msg.length - r, msg.length);
49387    if (this.pending.length === 0) this.pending = null;
49388    msg = utils.join32(msg, 0, msg.length - r, this.endian);
49389
49390    for (var i = 0; i < msg.length; i += this._delta32) {
49391      this._update(msg, i, i + this._delta32);
49392    }
49393  }
49394
49395  return this;
49396};
49397
49398BlockHash.prototype.digest = function digest(enc) {
49399  this.update(this._pad());
49400  assert(this.pending === null);
49401  return this._digest(enc);
49402};
49403
49404BlockHash.prototype._pad = function pad() {
49405  var len = this.pendingTotal;
49406  var bytes = this._delta8;
49407  var k = bytes - (len + this.padLength) % bytes;
49408  var res = new Array(k + this.padLength);
49409  res[0] = 0x80;
49410
49411  for (var i = 1; i < k; i++) {
49412    res[i] = 0;
49413  } // Append length
49414
49415
49416  len <<= 3;
49417
49418  if (this.endian === 'big') {
49419    for (var t = 8; t < this.padLength; t++) {
49420      res[i++] = 0;
49421    }
49422
49423    res[i++] = 0;
49424    res[i++] = 0;
49425    res[i++] = 0;
49426    res[i++] = 0;
49427    res[i++] = len >>> 24 & 0xff;
49428    res[i++] = len >>> 16 & 0xff;
49429    res[i++] = len >>> 8 & 0xff;
49430    res[i++] = len & 0xff;
49431  } else {
49432    res[i++] = len & 0xff;
49433    res[i++] = len >>> 8 & 0xff;
49434    res[i++] = len >>> 16 & 0xff;
49435    res[i++] = len >>> 24 & 0xff;
49436    res[i++] = 0;
49437    res[i++] = 0;
49438    res[i++] = 0;
49439    res[i++] = 0;
49440
49441    for (t = 8; t < this.padLength; t++) {
49442      res[i++] = 0;
49443    }
49444  }
49445
49446  return res;
49447};
49448
49449},{"./utils":383,"minimalistic-assert":437}],374:[function(require,module,exports){
49450'use strict';
49451
49452var utils = require('./utils');
49453
49454var assert = require('minimalistic-assert');
49455
49456function Hmac(hash, key, enc) {
49457  if (!(this instanceof Hmac)) return new Hmac(hash, key, enc);
49458  this.Hash = hash;
49459  this.blockSize = hash.blockSize / 8;
49460  this.outSize = hash.outSize / 8;
49461  this.inner = null;
49462  this.outer = null;
49463
49464  this._init(utils.toArray(key, enc));
49465}
49466
49467module.exports = Hmac;
49468
49469Hmac.prototype._init = function init(key) {
49470  // Shorten key, if needed
49471  if (key.length > this.blockSize) key = new this.Hash().update(key).digest();
49472  assert(key.length <= this.blockSize); // Add padding to key
49473
49474  for (var i = key.length; i < this.blockSize; i++) {
49475    key.push(0);
49476  }
49477
49478  for (i = 0; i < key.length; i++) {
49479    key[i] ^= 0x36;
49480  }
49481
49482  this.inner = new this.Hash().update(key); // 0x36 ^ 0x5c = 0x6a
49483
49484  for (i = 0; i < key.length; i++) {
49485    key[i] ^= 0x6a;
49486  }
49487
49488  this.outer = new this.Hash().update(key);
49489};
49490
49491Hmac.prototype.update = function update(msg, enc) {
49492  this.inner.update(msg, enc);
49493  return this;
49494};
49495
49496Hmac.prototype.digest = function digest(enc) {
49497  this.outer.update(this.inner.digest());
49498  return this.outer.digest(enc);
49499};
49500
49501},{"./utils":383,"minimalistic-assert":437}],375:[function(require,module,exports){
49502'use strict';
49503
49504var utils = require('./utils');
49505
49506var common = require('./common');
49507
49508var rotl32 = utils.rotl32;
49509var sum32 = utils.sum32;
49510var sum32_3 = utils.sum32_3;
49511var sum32_4 = utils.sum32_4;
49512var BlockHash = common.BlockHash;
49513
49514function RIPEMD160() {
49515  if (!(this instanceof RIPEMD160)) return new RIPEMD160();
49516  BlockHash.call(this);
49517  this.h = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
49518  this.endian = 'little';
49519}
49520
49521utils.inherits(RIPEMD160, BlockHash);
49522exports.ripemd160 = RIPEMD160;
49523RIPEMD160.blockSize = 512;
49524RIPEMD160.outSize = 160;
49525RIPEMD160.hmacStrength = 192;
49526RIPEMD160.padLength = 64;
49527
49528RIPEMD160.prototype._update = function update(msg, start) {
49529  var A = this.h[0];
49530  var B = this.h[1];
49531  var C = this.h[2];
49532  var D = this.h[3];
49533  var E = this.h[4];
49534  var Ah = A;
49535  var Bh = B;
49536  var Ch = C;
49537  var Dh = D;
49538  var Eh = E;
49539
49540  for (var j = 0; j < 80; j++) {
49541    var T = sum32(rotl32(sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), s[j]), E);
49542    A = E;
49543    E = D;
49544    D = rotl32(C, 10);
49545    C = B;
49546    B = T;
49547    T = sum32(rotl32(sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), sh[j]), Eh);
49548    Ah = Eh;
49549    Eh = Dh;
49550    Dh = rotl32(Ch, 10);
49551    Ch = Bh;
49552    Bh = T;
49553  }
49554
49555  T = sum32_3(this.h[1], C, Dh);
49556  this.h[1] = sum32_3(this.h[2], D, Eh);
49557  this.h[2] = sum32_3(this.h[3], E, Ah);
49558  this.h[3] = sum32_3(this.h[4], A, Bh);
49559  this.h[4] = sum32_3(this.h[0], B, Ch);
49560  this.h[0] = T;
49561};
49562
49563RIPEMD160.prototype._digest = function digest(enc) {
49564  if (enc === 'hex') return utils.toHex32(this.h, 'little');else return utils.split32(this.h, 'little');
49565};
49566
49567function f(j, x, y, z) {
49568  if (j <= 15) return x ^ y ^ z;else if (j <= 31) return x & y | ~x & z;else if (j <= 47) return (x | ~y) ^ z;else if (j <= 63) return x & z | y & ~z;else return x ^ (y | ~z);
49569}
49570
49571function K(j) {
49572  if (j <= 15) return 0x00000000;else if (j <= 31) return 0x5a827999;else if (j <= 47) return 0x6ed9eba1;else if (j <= 63) return 0x8f1bbcdc;else return 0xa953fd4e;
49573}
49574
49575function Kh(j) {
49576  if (j <= 15) return 0x50a28be6;else if (j <= 31) return 0x5c4dd124;else if (j <= 47) return 0x6d703ef3;else if (j <= 63) return 0x7a6d76e9;else return 0x00000000;
49577}
49578
49579var r = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
49580var rh = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
49581var s = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6];
49582var sh = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11];
49583
49584},{"./common":373,"./utils":383}],376:[function(require,module,exports){
49585'use strict';
49586
49587exports.sha1 = require('./sha/1');
49588exports.sha224 = require('./sha/224');
49589exports.sha256 = require('./sha/256');
49590exports.sha384 = require('./sha/384');
49591exports.sha512 = require('./sha/512');
49592
49593},{"./sha/1":377,"./sha/224":378,"./sha/256":379,"./sha/384":380,"./sha/512":381}],377:[function(require,module,exports){
49594'use strict';
49595
49596var utils = require('../utils');
49597
49598var common = require('../common');
49599
49600var shaCommon = require('./common');
49601
49602var rotl32 = utils.rotl32;
49603var sum32 = utils.sum32;
49604var sum32_5 = utils.sum32_5;
49605var ft_1 = shaCommon.ft_1;
49606var BlockHash = common.BlockHash;
49607var sha1_K = [0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6];
49608
49609function SHA1() {
49610  if (!(this instanceof SHA1)) return new SHA1();
49611  BlockHash.call(this);
49612  this.h = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
49613  this.W = new Array(80);
49614}
49615
49616utils.inherits(SHA1, BlockHash);
49617module.exports = SHA1;
49618SHA1.blockSize = 512;
49619SHA1.outSize = 160;
49620SHA1.hmacStrength = 80;
49621SHA1.padLength = 64;
49622
49623SHA1.prototype._update = function _update(msg, start) {
49624  var W = this.W;
49625
49626  for (var i = 0; i < 16; i++) {
49627    W[i] = msg[start + i];
49628  }
49629
49630  for (; i < W.length; i++) {
49631    W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
49632  }
49633
49634  var a = this.h[0];
49635  var b = this.h[1];
49636  var c = this.h[2];
49637  var d = this.h[3];
49638  var e = this.h[4];
49639
49640  for (i = 0; i < W.length; i++) {
49641    var s = ~~(i / 20);
49642    var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
49643    e = d;
49644    d = c;
49645    c = rotl32(b, 30);
49646    b = a;
49647    a = t;
49648  }
49649
49650  this.h[0] = sum32(this.h[0], a);
49651  this.h[1] = sum32(this.h[1], b);
49652  this.h[2] = sum32(this.h[2], c);
49653  this.h[3] = sum32(this.h[3], d);
49654  this.h[4] = sum32(this.h[4], e);
49655};
49656
49657SHA1.prototype._digest = function digest(enc) {
49658  if (enc === 'hex') return utils.toHex32(this.h, 'big');else return utils.split32(this.h, 'big');
49659};
49660
49661},{"../common":373,"../utils":383,"./common":382}],378:[function(require,module,exports){
49662'use strict';
49663
49664var utils = require('../utils');
49665
49666var SHA256 = require('./256');
49667
49668function SHA224() {
49669  if (!(this instanceof SHA224)) return new SHA224();
49670  SHA256.call(this);
49671  this.h = [0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4];
49672}
49673
49674utils.inherits(SHA224, SHA256);
49675module.exports = SHA224;
49676SHA224.blockSize = 512;
49677SHA224.outSize = 224;
49678SHA224.hmacStrength = 192;
49679SHA224.padLength = 64;
49680
49681SHA224.prototype._digest = function digest(enc) {
49682  // Just truncate output
49683  if (enc === 'hex') return utils.toHex32(this.h.slice(0, 7), 'big');else return utils.split32(this.h.slice(0, 7), 'big');
49684};
49685
49686},{"../utils":383,"./256":379}],379:[function(require,module,exports){
49687'use strict';
49688
49689var utils = require('../utils');
49690
49691var common = require('../common');
49692
49693var shaCommon = require('./common');
49694
49695var assert = require('minimalistic-assert');
49696
49697var sum32 = utils.sum32;
49698var sum32_4 = utils.sum32_4;
49699var sum32_5 = utils.sum32_5;
49700var ch32 = shaCommon.ch32;
49701var maj32 = shaCommon.maj32;
49702var s0_256 = shaCommon.s0_256;
49703var s1_256 = shaCommon.s1_256;
49704var g0_256 = shaCommon.g0_256;
49705var g1_256 = shaCommon.g1_256;
49706var BlockHash = common.BlockHash;
49707var sha256_K = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
49708
49709function SHA256() {
49710  if (!(this instanceof SHA256)) return new SHA256();
49711  BlockHash.call(this);
49712  this.h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
49713  this.k = sha256_K;
49714  this.W = new Array(64);
49715}
49716
49717utils.inherits(SHA256, BlockHash);
49718module.exports = SHA256;
49719SHA256.blockSize = 512;
49720SHA256.outSize = 256;
49721SHA256.hmacStrength = 192;
49722SHA256.padLength = 64;
49723
49724SHA256.prototype._update = function _update(msg, start) {
49725  var W = this.W;
49726
49727  for (var i = 0; i < 16; i++) {
49728    W[i] = msg[start + i];
49729  }
49730
49731  for (; i < W.length; i++) {
49732    W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
49733  }
49734
49735  var a = this.h[0];
49736  var b = this.h[1];
49737  var c = this.h[2];
49738  var d = this.h[3];
49739  var e = this.h[4];
49740  var f = this.h[5];
49741  var g = this.h[6];
49742  var h = this.h[7];
49743  assert(this.k.length === W.length);
49744
49745  for (i = 0; i < W.length; i++) {
49746    var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
49747    var T2 = sum32(s0_256(a), maj32(a, b, c));
49748    h = g;
49749    g = f;
49750    f = e;
49751    e = sum32(d, T1);
49752    d = c;
49753    c = b;
49754    b = a;
49755    a = sum32(T1, T2);
49756  }
49757
49758  this.h[0] = sum32(this.h[0], a);
49759  this.h[1] = sum32(this.h[1], b);
49760  this.h[2] = sum32(this.h[2], c);
49761  this.h[3] = sum32(this.h[3], d);
49762  this.h[4] = sum32(this.h[4], e);
49763  this.h[5] = sum32(this.h[5], f);
49764  this.h[6] = sum32(this.h[6], g);
49765  this.h[7] = sum32(this.h[7], h);
49766};
49767
49768SHA256.prototype._digest = function digest(enc) {
49769  if (enc === 'hex') return utils.toHex32(this.h, 'big');else return utils.split32(this.h, 'big');
49770};
49771
49772},{"../common":373,"../utils":383,"./common":382,"minimalistic-assert":437}],380:[function(require,module,exports){
49773'use strict';
49774
49775var utils = require('../utils');
49776
49777var SHA512 = require('./512');
49778
49779function SHA384() {
49780  if (!(this instanceof SHA384)) return new SHA384();
49781  SHA512.call(this);
49782  this.h = [0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939, 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4];
49783}
49784
49785utils.inherits(SHA384, SHA512);
49786module.exports = SHA384;
49787SHA384.blockSize = 1024;
49788SHA384.outSize = 384;
49789SHA384.hmacStrength = 192;
49790SHA384.padLength = 128;
49791
49792SHA384.prototype._digest = function digest(enc) {
49793  if (enc === 'hex') return utils.toHex32(this.h.slice(0, 12), 'big');else return utils.split32(this.h.slice(0, 12), 'big');
49794};
49795
49796},{"../utils":383,"./512":381}],381:[function(require,module,exports){
49797'use strict';
49798
49799var utils = require('../utils');
49800
49801var common = require('../common');
49802
49803var assert = require('minimalistic-assert');
49804
49805var rotr64_hi = utils.rotr64_hi;
49806var rotr64_lo = utils.rotr64_lo;
49807var shr64_hi = utils.shr64_hi;
49808var shr64_lo = utils.shr64_lo;
49809var sum64 = utils.sum64;
49810var sum64_hi = utils.sum64_hi;
49811var sum64_lo = utils.sum64_lo;
49812var sum64_4_hi = utils.sum64_4_hi;
49813var sum64_4_lo = utils.sum64_4_lo;
49814var sum64_5_hi = utils.sum64_5_hi;
49815var sum64_5_lo = utils.sum64_5_lo;
49816var BlockHash = common.BlockHash;
49817var sha512_K = [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817];
49818
49819function SHA512() {
49820  if (!(this instanceof SHA512)) return new SHA512();
49821  BlockHash.call(this);
49822  this.h = [0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179];
49823  this.k = sha512_K;
49824  this.W = new Array(160);
49825}
49826
49827utils.inherits(SHA512, BlockHash);
49828module.exports = SHA512;
49829SHA512.blockSize = 1024;
49830SHA512.outSize = 512;
49831SHA512.hmacStrength = 192;
49832SHA512.padLength = 128;
49833
49834SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
49835  var W = this.W; // 32 x 32bit words
49836
49837  for (var i = 0; i < 32; i++) {
49838    W[i] = msg[start + i];
49839  }
49840
49841  for (; i < W.length; i += 2) {
49842    var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
49843
49844    var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
49845    var c1_hi = W[i - 14]; // i - 7
49846
49847    var c1_lo = W[i - 13];
49848    var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
49849
49850    var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
49851    var c3_hi = W[i - 32]; // i - 16
49852
49853    var c3_lo = W[i - 31];
49854    W[i] = sum64_4_hi(c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo);
49855    W[i + 1] = sum64_4_lo(c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo);
49856  }
49857};
49858
49859SHA512.prototype._update = function _update(msg, start) {
49860  this._prepareBlock(msg, start);
49861
49862  var W = this.W;
49863  var ah = this.h[0];
49864  var al = this.h[1];
49865  var bh = this.h[2];
49866  var bl = this.h[3];
49867  var ch = this.h[4];
49868  var cl = this.h[5];
49869  var dh = this.h[6];
49870  var dl = this.h[7];
49871  var eh = this.h[8];
49872  var el = this.h[9];
49873  var fh = this.h[10];
49874  var fl = this.h[11];
49875  var gh = this.h[12];
49876  var gl = this.h[13];
49877  var hh = this.h[14];
49878  var hl = this.h[15];
49879  assert(this.k.length === W.length);
49880
49881  for (var i = 0; i < W.length; i += 2) {
49882    var c0_hi = hh;
49883    var c0_lo = hl;
49884    var c1_hi = s1_512_hi(eh, el);
49885    var c1_lo = s1_512_lo(eh, el);
49886    var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
49887    var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
49888    var c3_hi = this.k[i];
49889    var c3_lo = this.k[i + 1];
49890    var c4_hi = W[i];
49891    var c4_lo = W[i + 1];
49892    var T1_hi = sum64_5_hi(c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo);
49893    var T1_lo = sum64_5_lo(c0_hi, c0_lo, c1_hi, c1_lo, c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo);
49894    c0_hi = s0_512_hi(ah, al);
49895    c0_lo = s0_512_lo(ah, al);
49896    c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
49897    c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
49898    var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
49899    var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
49900    hh = gh;
49901    hl = gl;
49902    gh = fh;
49903    gl = fl;
49904    fh = eh;
49905    fl = el;
49906    eh = sum64_hi(dh, dl, T1_hi, T1_lo);
49907    el = sum64_lo(dl, dl, T1_hi, T1_lo);
49908    dh = ch;
49909    dl = cl;
49910    ch = bh;
49911    cl = bl;
49912    bh = ah;
49913    bl = al;
49914    ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
49915    al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
49916  }
49917
49918  sum64(this.h, 0, ah, al);
49919  sum64(this.h, 2, bh, bl);
49920  sum64(this.h, 4, ch, cl);
49921  sum64(this.h, 6, dh, dl);
49922  sum64(this.h, 8, eh, el);
49923  sum64(this.h, 10, fh, fl);
49924  sum64(this.h, 12, gh, gl);
49925  sum64(this.h, 14, hh, hl);
49926};
49927
49928SHA512.prototype._digest = function digest(enc) {
49929  if (enc === 'hex') return utils.toHex32(this.h, 'big');else return utils.split32(this.h, 'big');
49930};
49931
49932function ch64_hi(xh, xl, yh, yl, zh) {
49933  var r = xh & yh ^ ~xh & zh;
49934  if (r < 0) r += 0x100000000;
49935  return r;
49936}
49937
49938function ch64_lo(xh, xl, yh, yl, zh, zl) {
49939  var r = xl & yl ^ ~xl & zl;
49940  if (r < 0) r += 0x100000000;
49941  return r;
49942}
49943
49944function maj64_hi(xh, xl, yh, yl, zh) {
49945  var r = xh & yh ^ xh & zh ^ yh & zh;
49946  if (r < 0) r += 0x100000000;
49947  return r;
49948}
49949
49950function maj64_lo(xh, xl, yh, yl, zh, zl) {
49951  var r = xl & yl ^ xl & zl ^ yl & zl;
49952  if (r < 0) r += 0x100000000;
49953  return r;
49954}
49955
49956function s0_512_hi(xh, xl) {
49957  var c0_hi = rotr64_hi(xh, xl, 28);
49958  var c1_hi = rotr64_hi(xl, xh, 2); // 34
49959
49960  var c2_hi = rotr64_hi(xl, xh, 7); // 39
49961
49962  var r = c0_hi ^ c1_hi ^ c2_hi;
49963  if (r < 0) r += 0x100000000;
49964  return r;
49965}
49966
49967function s0_512_lo(xh, xl) {
49968  var c0_lo = rotr64_lo(xh, xl, 28);
49969  var c1_lo = rotr64_lo(xl, xh, 2); // 34
49970
49971  var c2_lo = rotr64_lo(xl, xh, 7); // 39
49972
49973  var r = c0_lo ^ c1_lo ^ c2_lo;
49974  if (r < 0) r += 0x100000000;
49975  return r;
49976}
49977
49978function s1_512_hi(xh, xl) {
49979  var c0_hi = rotr64_hi(xh, xl, 14);
49980  var c1_hi = rotr64_hi(xh, xl, 18);
49981  var c2_hi = rotr64_hi(xl, xh, 9); // 41
49982
49983  var r = c0_hi ^ c1_hi ^ c2_hi;
49984  if (r < 0) r += 0x100000000;
49985  return r;
49986}
49987
49988function s1_512_lo(xh, xl) {
49989  var c0_lo = rotr64_lo(xh, xl, 14);
49990  var c1_lo = rotr64_lo(xh, xl, 18);
49991  var c2_lo = rotr64_lo(xl, xh, 9); // 41
49992
49993  var r = c0_lo ^ c1_lo ^ c2_lo;
49994  if (r < 0) r += 0x100000000;
49995  return r;
49996}
49997
49998function g0_512_hi(xh, xl) {
49999  var c0_hi = rotr64_hi(xh, xl, 1);
50000  var c1_hi = rotr64_hi(xh, xl, 8);
50001  var c2_hi = shr64_hi(xh, xl, 7);
50002  var r = c0_hi ^ c1_hi ^ c2_hi;
50003  if (r < 0) r += 0x100000000;
50004  return r;
50005}
50006
50007function g0_512_lo(xh, xl) {
50008  var c0_lo = rotr64_lo(xh, xl, 1);
50009  var c1_lo = rotr64_lo(xh, xl, 8);
50010  var c2_lo = shr64_lo(xh, xl, 7);
50011  var r = c0_lo ^ c1_lo ^ c2_lo;
50012  if (r < 0) r += 0x100000000;
50013  return r;
50014}
50015
50016function g1_512_hi(xh, xl) {
50017  var c0_hi = rotr64_hi(xh, xl, 19);
50018  var c1_hi = rotr64_hi(xl, xh, 29); // 61
50019
50020  var c2_hi = shr64_hi(xh, xl, 6);
50021  var r = c0_hi ^ c1_hi ^ c2_hi;
50022  if (r < 0) r += 0x100000000;
50023  return r;
50024}
50025
50026function g1_512_lo(xh, xl) {
50027  var c0_lo = rotr64_lo(xh, xl, 19);
50028  var c1_lo = rotr64_lo(xl, xh, 29); // 61
50029
50030  var c2_lo = shr64_lo(xh, xl, 6);
50031  var r = c0_lo ^ c1_lo ^ c2_lo;
50032  if (r < 0) r += 0x100000000;
50033  return r;
50034}
50035
50036},{"../common":373,"../utils":383,"minimalistic-assert":437}],382:[function(require,module,exports){
50037'use strict';
50038
50039var utils = require('../utils');
50040
50041var rotr32 = utils.rotr32;
50042
50043function ft_1(s, x, y, z) {
50044  if (s === 0) return ch32(x, y, z);
50045  if (s === 1 || s === 3) return p32(x, y, z);
50046  if (s === 2) return maj32(x, y, z);
50047}
50048
50049exports.ft_1 = ft_1;
50050
50051function ch32(x, y, z) {
50052  return x & y ^ ~x & z;
50053}
50054
50055exports.ch32 = ch32;
50056
50057function maj32(x, y, z) {
50058  return x & y ^ x & z ^ y & z;
50059}
50060
50061exports.maj32 = maj32;
50062
50063function p32(x, y, z) {
50064  return x ^ y ^ z;
50065}
50066
50067exports.p32 = p32;
50068
50069function s0_256(x) {
50070  return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
50071}
50072
50073exports.s0_256 = s0_256;
50074
50075function s1_256(x) {
50076  return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
50077}
50078
50079exports.s1_256 = s1_256;
50080
50081function g0_256(x) {
50082  return rotr32(x, 7) ^ rotr32(x, 18) ^ x >>> 3;
50083}
50084
50085exports.g0_256 = g0_256;
50086
50087function g1_256(x) {
50088  return rotr32(x, 17) ^ rotr32(x, 19) ^ x >>> 10;
50089}
50090
50091exports.g1_256 = g1_256;
50092
50093},{"../utils":383}],383:[function(require,module,exports){
50094'use strict';
50095
50096var assert = require('minimalistic-assert');
50097
50098var inherits = require('inherits');
50099
50100exports.inherits = inherits;
50101
50102function isSurrogatePair(msg, i) {
50103  if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
50104    return false;
50105  }
50106
50107  if (i < 0 || i + 1 >= msg.length) {
50108    return false;
50109  }
50110
50111  return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
50112}
50113
50114function toArray(msg, enc) {
50115  if (Array.isArray(msg)) return msg.slice();
50116  if (!msg) return [];
50117  var res = [];
50118
50119  if (typeof msg === 'string') {
50120    if (!enc) {
50121      // Inspired by stringToUtf8ByteArray() in closure-library by Google
50122      // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
50123      // Apache License 2.0
50124      // https://github.com/google/closure-library/blob/master/LICENSE
50125      var p = 0;
50126
50127      for (var i = 0; i < msg.length; i++) {
50128        var c = msg.charCodeAt(i);
50129
50130        if (c < 128) {
50131          res[p++] = c;
50132        } else if (c < 2048) {
50133          res[p++] = c >> 6 | 192;
50134          res[p++] = c & 63 | 128;
50135        } else if (isSurrogatePair(msg, i)) {
50136          c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
50137          res[p++] = c >> 18 | 240;
50138          res[p++] = c >> 12 & 63 | 128;
50139          res[p++] = c >> 6 & 63 | 128;
50140          res[p++] = c & 63 | 128;
50141        } else {
50142          res[p++] = c >> 12 | 224;
50143          res[p++] = c >> 6 & 63 | 128;
50144          res[p++] = c & 63 | 128;
50145        }
50146      }
50147    } else if (enc === 'hex') {
50148      msg = msg.replace(/[^a-z0-9]+/ig, '');
50149      if (msg.length % 2 !== 0) msg = '0' + msg;
50150
50151      for (i = 0; i < msg.length; i += 2) {
50152        res.push(parseInt(msg[i] + msg[i + 1], 16));
50153      }
50154    }
50155  } else {
50156    for (i = 0; i < msg.length; i++) {
50157      res[i] = msg[i] | 0;
50158    }
50159  }
50160
50161  return res;
50162}
50163
50164exports.toArray = toArray;
50165
50166function toHex(msg) {
50167  var res = '';
50168
50169  for (var i = 0; i < msg.length; i++) {
50170    res += zero2(msg[i].toString(16));
50171  }
50172
50173  return res;
50174}
50175
50176exports.toHex = toHex;
50177
50178function htonl(w) {
50179  var res = w >>> 24 | w >>> 8 & 0xff00 | w << 8 & 0xff0000 | (w & 0xff) << 24;
50180  return res >>> 0;
50181}
50182
50183exports.htonl = htonl;
50184
50185function toHex32(msg, endian) {
50186  var res = '';
50187
50188  for (var i = 0; i < msg.length; i++) {
50189    var w = msg[i];
50190    if (endian === 'little') w = htonl(w);
50191    res += zero8(w.toString(16));
50192  }
50193
50194  return res;
50195}
50196
50197exports.toHex32 = toHex32;
50198
50199function zero2(word) {
50200  if (word.length === 1) return '0' + word;else return word;
50201}
50202
50203exports.zero2 = zero2;
50204
50205function zero8(word) {
50206  if (word.length === 7) return '0' + word;else if (word.length === 6) return '00' + word;else if (word.length === 5) return '000' + word;else if (word.length === 4) return '0000' + word;else if (word.length === 3) return '00000' + word;else if (word.length === 2) return '000000' + word;else if (word.length === 1) return '0000000' + word;else return word;
50207}
50208
50209exports.zero8 = zero8;
50210
50211function join32(msg, start, end, endian) {
50212  var len = end - start;
50213  assert(len % 4 === 0);
50214  var res = new Array(len / 4);
50215
50216  for (var i = 0, k = start; i < res.length; i++, k += 4) {
50217    var w;
50218    if (endian === 'big') w = msg[k] << 24 | msg[k + 1] << 16 | msg[k + 2] << 8 | msg[k + 3];else w = msg[k + 3] << 24 | msg[k + 2] << 16 | msg[k + 1] << 8 | msg[k];
50219    res[i] = w >>> 0;
50220  }
50221
50222  return res;
50223}
50224
50225exports.join32 = join32;
50226
50227function split32(msg, endian) {
50228  var res = new Array(msg.length * 4);
50229
50230  for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
50231    var m = msg[i];
50232
50233    if (endian === 'big') {
50234      res[k] = m >>> 24;
50235      res[k + 1] = m >>> 16 & 0xff;
50236      res[k + 2] = m >>> 8 & 0xff;
50237      res[k + 3] = m & 0xff;
50238    } else {
50239      res[k + 3] = m >>> 24;
50240      res[k + 2] = m >>> 16 & 0xff;
50241      res[k + 1] = m >>> 8 & 0xff;
50242      res[k] = m & 0xff;
50243    }
50244  }
50245
50246  return res;
50247}
50248
50249exports.split32 = split32;
50250
50251function rotr32(w, b) {
50252  return w >>> b | w << 32 - b;
50253}
50254
50255exports.rotr32 = rotr32;
50256
50257function rotl32(w, b) {
50258  return w << b | w >>> 32 - b;
50259}
50260
50261exports.rotl32 = rotl32;
50262
50263function sum32(a, b) {
50264  return a + b >>> 0;
50265}
50266
50267exports.sum32 = sum32;
50268
50269function sum32_3(a, b, c) {
50270  return a + b + c >>> 0;
50271}
50272
50273exports.sum32_3 = sum32_3;
50274
50275function sum32_4(a, b, c, d) {
50276  return a + b + c + d >>> 0;
50277}
50278
50279exports.sum32_4 = sum32_4;
50280
50281function sum32_5(a, b, c, d, e) {
50282  return a + b + c + d + e >>> 0;
50283}
50284
50285exports.sum32_5 = sum32_5;
50286
50287function sum64(buf, pos, ah, al) {
50288  var bh = buf[pos];
50289  var bl = buf[pos + 1];
50290  var lo = al + bl >>> 0;
50291  var hi = (lo < al ? 1 : 0) + ah + bh;
50292  buf[pos] = hi >>> 0;
50293  buf[pos + 1] = lo;
50294}
50295
50296exports.sum64 = sum64;
50297
50298function sum64_hi(ah, al, bh, bl) {
50299  var lo = al + bl >>> 0;
50300  var hi = (lo < al ? 1 : 0) + ah + bh;
50301  return hi >>> 0;
50302}
50303
50304exports.sum64_hi = sum64_hi;
50305
50306function sum64_lo(ah, al, bh, bl) {
50307  var lo = al + bl;
50308  return lo >>> 0;
50309}
50310
50311exports.sum64_lo = sum64_lo;
50312
50313function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
50314  var carry = 0;
50315  var lo = al;
50316  lo = lo + bl >>> 0;
50317  carry += lo < al ? 1 : 0;
50318  lo = lo + cl >>> 0;
50319  carry += lo < cl ? 1 : 0;
50320  lo = lo + dl >>> 0;
50321  carry += lo < dl ? 1 : 0;
50322  var hi = ah + bh + ch + dh + carry;
50323  return hi >>> 0;
50324}
50325
50326exports.sum64_4_hi = sum64_4_hi;
50327
50328function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
50329  var lo = al + bl + cl + dl;
50330  return lo >>> 0;
50331}
50332
50333exports.sum64_4_lo = sum64_4_lo;
50334
50335function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
50336  var carry = 0;
50337  var lo = al;
50338  lo = lo + bl >>> 0;
50339  carry += lo < al ? 1 : 0;
50340  lo = lo + cl >>> 0;
50341  carry += lo < cl ? 1 : 0;
50342  lo = lo + dl >>> 0;
50343  carry += lo < dl ? 1 : 0;
50344  lo = lo + el >>> 0;
50345  carry += lo < el ? 1 : 0;
50346  var hi = ah + bh + ch + dh + eh + carry;
50347  return hi >>> 0;
50348}
50349
50350exports.sum64_5_hi = sum64_5_hi;
50351
50352function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
50353  var lo = al + bl + cl + dl + el;
50354  return lo >>> 0;
50355}
50356
50357exports.sum64_5_lo = sum64_5_lo;
50358
50359function rotr64_hi(ah, al, num) {
50360  var r = al << 32 - num | ah >>> num;
50361  return r >>> 0;
50362}
50363
50364exports.rotr64_hi = rotr64_hi;
50365
50366function rotr64_lo(ah, al, num) {
50367  var r = ah << 32 - num | al >>> num;
50368  return r >>> 0;
50369}
50370
50371exports.rotr64_lo = rotr64_lo;
50372
50373function shr64_hi(ah, al, num) {
50374  return ah >>> num;
50375}
50376
50377exports.shr64_hi = shr64_hi;
50378
50379function shr64_lo(ah, al, num) {
50380  var r = ah << 32 - num | al >>> num;
50381  return r >>> 0;
50382}
50383
50384exports.shr64_lo = shr64_lo;
50385
50386},{"inherits":387,"minimalistic-assert":437}],384:[function(require,module,exports){
50387'use strict';
50388
50389var hash = require('hash.js');
50390
50391var utils = require('minimalistic-crypto-utils');
50392
50393var assert = require('minimalistic-assert');
50394
50395function HmacDRBG(options) {
50396  if (!(this instanceof HmacDRBG)) return new HmacDRBG(options);
50397  this.hash = options.hash;
50398  this.predResist = !!options.predResist;
50399  this.outLen = this.hash.outSize;
50400  this.minEntropy = options.minEntropy || this.hash.hmacStrength;
50401  this._reseed = null;
50402  this.reseedInterval = null;
50403  this.K = null;
50404  this.V = null;
50405  var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
50406  var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
50407  var pers = utils.toArray(options.pers, options.persEnc || 'hex');
50408  assert(entropy.length >= this.minEntropy / 8, 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
50409
50410  this._init(entropy, nonce, pers);
50411}
50412
50413module.exports = HmacDRBG;
50414
50415HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
50416  var seed = entropy.concat(nonce).concat(pers);
50417  this.K = new Array(this.outLen / 8);
50418  this.V = new Array(this.outLen / 8);
50419
50420  for (var i = 0; i < this.V.length; i++) {
50421    this.K[i] = 0x00;
50422    this.V[i] = 0x01;
50423  }
50424
50425  this._update(seed);
50426
50427  this._reseed = 1;
50428  this.reseedInterval = 0x1000000000000; // 2^48
50429};
50430
50431HmacDRBG.prototype._hmac = function hmac() {
50432  return new hash.hmac(this.hash, this.K);
50433};
50434
50435HmacDRBG.prototype._update = function update(seed) {
50436  var kmac = this._hmac().update(this.V).update([0x00]);
50437
50438  if (seed) kmac = kmac.update(seed);
50439  this.K = kmac.digest();
50440  this.V = this._hmac().update(this.V).digest();
50441  if (!seed) return;
50442  this.K = this._hmac().update(this.V).update([0x01]).update(seed).digest();
50443  this.V = this._hmac().update(this.V).digest();
50444};
50445
50446HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
50447  // Optional entropy enc
50448  if (typeof entropyEnc !== 'string') {
50449    addEnc = add;
50450    add = entropyEnc;
50451    entropyEnc = null;
50452  }
50453
50454  entropy = utils.toArray(entropy, entropyEnc);
50455  add = utils.toArray(add, addEnc);
50456  assert(entropy.length >= this.minEntropy / 8, 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
50457
50458  this._update(entropy.concat(add || []));
50459
50460  this._reseed = 1;
50461};
50462
50463HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
50464  if (this._reseed > this.reseedInterval) throw new Error('Reseed is required'); // Optional encoding
50465
50466  if (typeof enc !== 'string') {
50467    addEnc = add;
50468    add = enc;
50469    enc = null;
50470  } // Optional additional data
50471
50472
50473  if (add) {
50474    add = utils.toArray(add, addEnc || 'hex');
50475
50476    this._update(add);
50477  }
50478
50479  var temp = [];
50480
50481  while (temp.length < len) {
50482    this.V = this._hmac().update(this.V).digest();
50483    temp = temp.concat(this.V);
50484  }
50485
50486  var res = temp.slice(0, len);
50487
50488  this._update(add);
50489
50490  this._reseed++;
50491  return utils.encode(res, enc);
50492};
50493
50494},{"hash.js":372,"minimalistic-assert":437,"minimalistic-crypto-utils":438}],385:[function(require,module,exports){
50495"use strict";
50496
50497exports.read = function (buffer, offset, isLE, mLen, nBytes) {
50498  var e, m;
50499  var eLen = nBytes * 8 - mLen - 1;
50500  var eMax = (1 << eLen) - 1;
50501  var eBias = eMax >> 1;
50502  var nBits = -7;
50503  var i = isLE ? nBytes - 1 : 0;
50504  var d = isLE ? -1 : 1;
50505  var s = buffer[offset + i];
50506  i += d;
50507  e = s & (1 << -nBits) - 1;
50508  s >>= -nBits;
50509  nBits += eLen;
50510
50511  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
50512
50513  m = e & (1 << -nBits) - 1;
50514  e >>= -nBits;
50515  nBits += mLen;
50516
50517  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
50518
50519  if (e === 0) {
50520    e = 1 - eBias;
50521  } else if (e === eMax) {
50522    return m ? NaN : (s ? -1 : 1) * Infinity;
50523  } else {
50524    m = m + Math.pow(2, mLen);
50525    e = e - eBias;
50526  }
50527
50528  return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
50529};
50530
50531exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
50532  var e, m, c;
50533  var eLen = nBytes * 8 - mLen - 1;
50534  var eMax = (1 << eLen) - 1;
50535  var eBias = eMax >> 1;
50536  var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
50537  var i = isLE ? 0 : nBytes - 1;
50538  var d = isLE ? 1 : -1;
50539  var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
50540  value = Math.abs(value);
50541
50542  if (isNaN(value) || value === Infinity) {
50543    m = isNaN(value) ? 1 : 0;
50544    e = eMax;
50545  } else {
50546    e = Math.floor(Math.log(value) / Math.LN2);
50547
50548    if (value * (c = Math.pow(2, -e)) < 1) {
50549      e--;
50550      c *= 2;
50551    }
50552
50553    if (e + eBias >= 1) {
50554      value += rt / c;
50555    } else {
50556      value += rt * Math.pow(2, 1 - eBias);
50557    }
50558
50559    if (value * c >= 2) {
50560      e++;
50561      c /= 2;
50562    }
50563
50564    if (e + eBias >= eMax) {
50565      m = 0;
50566      e = eMax;
50567    } else if (e + eBias >= 1) {
50568      m = (value * c - 1) * Math.pow(2, mLen);
50569      e = e + eBias;
50570    } else {
50571      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
50572      e = 0;
50573    }
50574  }
50575
50576  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
50577
50578  e = e << mLen | m;
50579  eLen += mLen;
50580
50581  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
50582
50583  buffer[offset + i - d] |= s * 128;
50584};
50585
50586},{}],386:[function(require,module,exports){
50587(function (global){
50588'use strict';
50589
50590var Mutation = global.MutationObserver || global.WebKitMutationObserver;
50591var scheduleDrain;
50592{
50593  if (Mutation) {
50594    var called = 0;
50595    var observer = new Mutation(nextTick);
50596    var element = global.document.createTextNode('');
50597    observer.observe(element, {
50598      characterData: true
50599    });
50600
50601    scheduleDrain = function scheduleDrain() {
50602      element.data = called = ++called % 2;
50603    };
50604  } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
50605    var channel = new global.MessageChannel();
50606    channel.port1.onmessage = nextTick;
50607
50608    scheduleDrain = function scheduleDrain() {
50609      channel.port2.postMessage(0);
50610    };
50611  } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
50612    scheduleDrain = function scheduleDrain() {
50613      // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
50614      // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
50615      var scriptEl = global.document.createElement('script');
50616
50617      scriptEl.onreadystatechange = function () {
50618        nextTick();
50619        scriptEl.onreadystatechange = null;
50620        scriptEl.parentNode.removeChild(scriptEl);
50621        scriptEl = null;
50622      };
50623
50624      global.document.documentElement.appendChild(scriptEl);
50625    };
50626  } else {
50627    scheduleDrain = function scheduleDrain() {
50628      setTimeout(nextTick, 0);
50629    };
50630  }
50631}
50632var draining;
50633var queue = []; //named nextTick for less confusing stack traces
50634
50635function nextTick() {
50636  draining = true;
50637  var i, oldQueue;
50638  var len = queue.length;
50639
50640  while (len) {
50641    oldQueue = queue;
50642    queue = [];
50643    i = -1;
50644
50645    while (++i < len) {
50646      oldQueue[i]();
50647    }
50648
50649    len = queue.length;
50650  }
50651
50652  draining = false;
50653}
50654
50655module.exports = immediate;
50656
50657function immediate(task) {
50658  if (queue.push(task) === 1 && !draining) {
50659    scheduleDrain();
50660  }
50661}
50662
50663}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
50664
50665},{}],387:[function(require,module,exports){
50666"use strict";
50667
50668if (typeof Object.create === 'function') {
50669  // implementation from standard node.js 'util' module
50670  module.exports = function inherits(ctor, superCtor) {
50671    if (superCtor) {
50672      ctor.super_ = superCtor;
50673      ctor.prototype = Object.create(superCtor.prototype, {
50674        constructor: {
50675          value: ctor,
50676          enumerable: false,
50677          writable: true,
50678          configurable: true
50679        }
50680      });
50681    }
50682  };
50683} else {
50684  // old school shim for old browsers
50685  module.exports = function inherits(ctor, superCtor) {
50686    if (superCtor) {
50687      ctor.super_ = superCtor;
50688
50689      var TempCtor = function TempCtor() {};
50690
50691      TempCtor.prototype = superCtor.prototype;
50692      ctor.prototype = new TempCtor();
50693      ctor.prototype.constructor = ctor;
50694    }
50695  };
50696}
50697
50698},{}],388:[function(require,module,exports){
50699"use strict";
50700
50701/*!
50702 * Determine if an object is a Buffer
50703 *
50704 * @author   Feross Aboukhadijeh <https://feross.org>
50705 * @license  MIT
50706 */
50707// The _isBuffer check is for Safari 5-7 support, because it's missing
50708// Object.prototype.constructor. Remove this eventually
50709module.exports = function (obj) {
50710  return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer);
50711};
50712
50713function isBuffer(obj) {
50714  return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj);
50715} // For Node v0.10 support. Remove this eventually.
50716
50717
50718function isSlowBuffer(obj) {
50719  return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0));
50720}
50721
50722},{}],389:[function(require,module,exports){
50723"use strict";
50724
50725var toString = {}.toString;
50726
50727module.exports = Array.isArray || function (arr) {
50728  return toString.call(arr) == '[object Array]';
50729};
50730
50731},{}],390:[function(require,module,exports){
50732'use strict';
50733
50734var utils = require('./utils');
50735
50736var support = require('./support'); // private property
50737
50738
50739var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; // public method for encoding
50740
50741exports.encode = function (input) {
50742  var output = [];
50743  var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
50744  var i = 0,
50745      len = input.length,
50746      remainingBytes = len;
50747  var isArray = utils.getTypeOf(input) !== "string";
50748
50749  while (i < input.length) {
50750    remainingBytes = len - i;
50751
50752    if (!isArray) {
50753      chr1 = input.charCodeAt(i++);
50754      chr2 = i < len ? input.charCodeAt(i++) : 0;
50755      chr3 = i < len ? input.charCodeAt(i++) : 0;
50756    } else {
50757      chr1 = input[i++];
50758      chr2 = i < len ? input[i++] : 0;
50759      chr3 = i < len ? input[i++] : 0;
50760    }
50761
50762    enc1 = chr1 >> 2;
50763    enc2 = (chr1 & 3) << 4 | chr2 >> 4;
50764    enc3 = remainingBytes > 1 ? (chr2 & 15) << 2 | chr3 >> 6 : 64;
50765    enc4 = remainingBytes > 2 ? chr3 & 63 : 64;
50766    output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4));
50767  }
50768
50769  return output.join("");
50770}; // public method for decoding
50771
50772
50773exports.decode = function (input) {
50774  var chr1, chr2, chr3;
50775  var enc1, enc2, enc3, enc4;
50776  var i = 0,
50777      resultIndex = 0;
50778  var dataUrlPrefix = "data:";
50779
50780  if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) {
50781    // This is a common error: people give a data url
50782    // (data:image/png;base64,iVBOR...) with a {base64: true} and
50783    // wonders why things don't work.
50784    // We can detect that the string input looks like a data url but we
50785    // *can't* be sure it is one: removing everything up to the comma would
50786    // be too dangerous.
50787    throw new Error("Invalid base64 input, it looks like a data url.");
50788  }
50789
50790  input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
50791  var totalLength = input.length * 3 / 4;
50792
50793  if (input.charAt(input.length - 1) === _keyStr.charAt(64)) {
50794    totalLength--;
50795  }
50796
50797  if (input.charAt(input.length - 2) === _keyStr.charAt(64)) {
50798    totalLength--;
50799  }
50800
50801  if (totalLength % 1 !== 0) {
50802    // totalLength is not an integer, the length does not match a valid
50803    // base64 content. That can happen if:
50804    // - the input is not a base64 content
50805    // - the input is *almost* a base64 content, with a extra chars at the
50806    //   beginning or at the end
50807    // - the input uses a base64 variant (base64url for example)
50808    throw new Error("Invalid base64 input, bad content length.");
50809  }
50810
50811  var output;
50812
50813  if (support.uint8array) {
50814    output = new Uint8Array(totalLength | 0);
50815  } else {
50816    output = new Array(totalLength | 0);
50817  }
50818
50819  while (i < input.length) {
50820    enc1 = _keyStr.indexOf(input.charAt(i++));
50821    enc2 = _keyStr.indexOf(input.charAt(i++));
50822    enc3 = _keyStr.indexOf(input.charAt(i++));
50823    enc4 = _keyStr.indexOf(input.charAt(i++));
50824    chr1 = enc1 << 2 | enc2 >> 4;
50825    chr2 = (enc2 & 15) << 4 | enc3 >> 2;
50826    chr3 = (enc3 & 3) << 6 | enc4;
50827    output[resultIndex++] = chr1;
50828
50829    if (enc3 !== 64) {
50830      output[resultIndex++] = chr2;
50831    }
50832
50833    if (enc4 !== 64) {
50834      output[resultIndex++] = chr3;
50835    }
50836  }
50837
50838  return output;
50839};
50840
50841},{"./support":419,"./utils":421}],391:[function(require,module,exports){
50842'use strict';
50843
50844var external = require("./external");
50845
50846var DataWorker = require('./stream/DataWorker');
50847
50848var DataLengthProbe = require('./stream/DataLengthProbe');
50849
50850var Crc32Probe = require('./stream/Crc32Probe');
50851
50852var DataLengthProbe = require('./stream/DataLengthProbe');
50853/**
50854 * Represent a compressed object, with everything needed to decompress it.
50855 * @constructor
50856 * @param {number} compressedSize the size of the data compressed.
50857 * @param {number} uncompressedSize the size of the data after decompression.
50858 * @param {number} crc32 the crc32 of the decompressed file.
50859 * @param {object} compression the type of compression, see lib/compressions.js.
50860 * @param {String|ArrayBuffer|Uint8Array|Buffer} data the compressed data.
50861 */
50862
50863
50864function CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) {
50865  this.compressedSize = compressedSize;
50866  this.uncompressedSize = uncompressedSize;
50867  this.crc32 = crc32;
50868  this.compression = compression;
50869  this.compressedContent = data;
50870}
50871
50872CompressedObject.prototype = {
50873  /**
50874   * Create a worker to get the uncompressed content.
50875   * @return {GenericWorker} the worker.
50876   */
50877  getContentWorker: function getContentWorker() {
50878    var worker = new DataWorker(external.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new DataLengthProbe("data_length"));
50879    var that = this;
50880    worker.on("end", function () {
50881      if (this.streamInfo['data_length'] !== that.uncompressedSize) {
50882        throw new Error("Bug : uncompressed data size mismatch");
50883      }
50884    });
50885    return worker;
50886  },
50887
50888  /**
50889   * Create a worker to get the compressed content.
50890   * @return {GenericWorker} the worker.
50891   */
50892  getCompressedWorker: function getCompressedWorker() {
50893    return new DataWorker(external.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression);
50894  }
50895};
50896/**
50897 * Chain the given worker with other workers to compress the content with the
50898 * given compression.
50899 * @param {GenericWorker} uncompressedWorker the worker to pipe.
50900 * @param {Object} compression the compression object.
50901 * @param {Object} compressionOptions the options to use when compressing.
50902 * @return {GenericWorker} the new worker compressing the content.
50903 */
50904
50905CompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions) {
50906  return uncompressedWorker.pipe(new Crc32Probe()).pipe(new DataLengthProbe("uncompressedSize")).pipe(compression.compressWorker(compressionOptions)).pipe(new DataLengthProbe("compressedSize")).withStreamInfo("compression", compression);
50907};
50908
50909module.exports = CompressedObject;
50910
50911},{"./external":395,"./stream/Crc32Probe":414,"./stream/DataLengthProbe":415,"./stream/DataWorker":416}],392:[function(require,module,exports){
50912'use strict';
50913
50914var GenericWorker = require("./stream/GenericWorker");
50915
50916exports.STORE = {
50917  magic: "\x00\x00",
50918  compressWorker: function compressWorker(compressionOptions) {
50919    return new GenericWorker("STORE compression");
50920  },
50921  uncompressWorker: function uncompressWorker() {
50922    return new GenericWorker("STORE decompression");
50923  }
50924};
50925exports.DEFLATE = require('./flate');
50926
50927},{"./flate":396,"./stream/GenericWorker":417}],393:[function(require,module,exports){
50928'use strict';
50929
50930var utils = require('./utils');
50931/**
50932 * The following functions come from pako, from pako/lib/zlib/crc32.js
50933 * released under the MIT license, see pako https://github.com/nodeca/pako/
50934 */
50935// Use ordinary array, since untyped makes no boost here
50936
50937
50938function makeTable() {
50939  var c,
50940      table = [];
50941
50942  for (var n = 0; n < 256; n++) {
50943    c = n;
50944
50945    for (var k = 0; k < 8; k++) {
50946      c = c & 1 ? 0xEDB88320 ^ c >>> 1 : c >>> 1;
50947    }
50948
50949    table[n] = c;
50950  }
50951
50952  return table;
50953} // Create table on load. Just 255 signed longs. Not a problem.
50954
50955
50956var crcTable = makeTable();
50957
50958function crc32(crc, buf, len, pos) {
50959  var t = crcTable,
50960      end = pos + len;
50961  crc = crc ^ -1;
50962
50963  for (var i = pos; i < end; i++) {
50964    crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 0xFF];
50965  }
50966
50967  return crc ^ -1; // >>> 0;
50968} // That's all for the pako functions.
50969
50970/**
50971 * Compute the crc32 of a string.
50972 * This is almost the same as the function crc32, but for strings. Using the
50973 * same function for the two use cases leads to horrible performances.
50974 * @param {Number} crc the starting value of the crc.
50975 * @param {String} str the string to use.
50976 * @param {Number} len the length of the string.
50977 * @param {Number} pos the starting position for the crc32 computation.
50978 * @return {Number} the computed crc32.
50979 */
50980
50981
50982function crc32str(crc, str, len, pos) {
50983  var t = crcTable,
50984      end = pos + len;
50985  crc = crc ^ -1;
50986
50987  for (var i = pos; i < end; i++) {
50988    crc = crc >>> 8 ^ t[(crc ^ str.charCodeAt(i)) & 0xFF];
50989  }
50990
50991  return crc ^ -1; // >>> 0;
50992}
50993
50994module.exports = function crc32wrapper(input, crc) {
50995  if (typeof input === "undefined" || !input.length) {
50996    return 0;
50997  }
50998
50999  var isArray = utils.getTypeOf(input) !== "string";
51000
51001  if (isArray) {
51002    return crc32(crc | 0, input, input.length, 0);
51003  } else {
51004    return crc32str(crc | 0, input, input.length, 0);
51005  }
51006};
51007
51008},{"./utils":421}],394:[function(require,module,exports){
51009'use strict';
51010
51011exports.base64 = false;
51012exports.binary = false;
51013exports.dir = false;
51014exports.createFolders = true;
51015exports.date = null;
51016exports.compression = null;
51017exports.compressionOptions = null;
51018exports.comment = null;
51019exports.unixPermissions = null;
51020exports.dosPermissions = null;
51021
51022},{}],395:[function(require,module,exports){
51023/* global Promise */
51024'use strict'; // load the global object first:
51025// - it should be better integrated in the system (unhandledRejection in node)
51026// - the environment may have a custom Promise implementation (see zone.js)
51027
51028var ES6Promise = null;
51029
51030if (typeof Promise !== "undefined") {
51031  ES6Promise = Promise;
51032} else {
51033  ES6Promise = require("lie");
51034}
51035/**
51036 * Let the user use/change some implementations.
51037 */
51038
51039
51040module.exports = {
51041  Promise: ES6Promise
51042};
51043
51044},{"lie":425}],396:[function(require,module,exports){
51045'use strict';
51046
51047var USE_TYPEDARRAY = typeof Uint8Array !== 'undefined' && typeof Uint16Array !== 'undefined' && typeof Uint32Array !== 'undefined';
51048
51049var pako = require("pako");
51050
51051var utils = require("./utils");
51052
51053var GenericWorker = require("./stream/GenericWorker");
51054
51055var ARRAY_TYPE = USE_TYPEDARRAY ? "uint8array" : "array";
51056exports.magic = "\x08\x00";
51057/**
51058 * Create a worker that uses pako to inflate/deflate.
51059 * @constructor
51060 * @param {String} action the name of the pako function to call : either "Deflate" or "Inflate".
51061 * @param {Object} options the options to use when (de)compressing.
51062 */
51063
51064function FlateWorker(action, options) {
51065  GenericWorker.call(this, "FlateWorker/" + action);
51066  this._pako = null;
51067  this._pakoAction = action;
51068  this._pakoOptions = options; // the `meta` object from the last chunk received
51069  // this allow this worker to pass around metadata
51070
51071  this.meta = {};
51072}
51073
51074utils.inherits(FlateWorker, GenericWorker);
51075/**
51076 * @see GenericWorker.processChunk
51077 */
51078
51079FlateWorker.prototype.processChunk = function (chunk) {
51080  this.meta = chunk.meta;
51081
51082  if (this._pako === null) {
51083    this._createPako();
51084  }
51085
51086  this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false);
51087};
51088/**
51089 * @see GenericWorker.flush
51090 */
51091
51092
51093FlateWorker.prototype.flush = function () {
51094  GenericWorker.prototype.flush.call(this);
51095
51096  if (this._pako === null) {
51097    this._createPako();
51098  }
51099
51100  this._pako.push([], true);
51101};
51102/**
51103 * @see GenericWorker.cleanUp
51104 */
51105
51106
51107FlateWorker.prototype.cleanUp = function () {
51108  GenericWorker.prototype.cleanUp.call(this);
51109  this._pako = null;
51110};
51111/**
51112 * Create the _pako object.
51113 * TODO: lazy-loading this object isn't the best solution but it's the
51114 * quickest. The best solution is to lazy-load the worker list. See also the
51115 * issue #446.
51116 */
51117
51118
51119FlateWorker.prototype._createPako = function () {
51120  this._pako = new pako[this._pakoAction]({
51121    raw: true,
51122    level: this._pakoOptions.level || -1 // default compression
51123
51124  });
51125  var self = this;
51126
51127  this._pako.onData = function (data) {
51128    self.push({
51129      data: data,
51130      meta: self.meta
51131    });
51132  };
51133};
51134
51135exports.compressWorker = function (compressionOptions) {
51136  return new FlateWorker("Deflate", compressionOptions);
51137};
51138
51139exports.uncompressWorker = function () {
51140  return new FlateWorker("Inflate", {});
51141};
51142
51143},{"./stream/GenericWorker":417,"./utils":421,"pako":439}],397:[function(require,module,exports){
51144'use strict';
51145
51146var utils = require('../utils');
51147
51148var GenericWorker = require('../stream/GenericWorker');
51149
51150var utf8 = require('../utf8');
51151
51152var crc32 = require('../crc32');
51153
51154var signature = require('../signature');
51155/**
51156 * Transform an integer into a string in hexadecimal.
51157 * @private
51158 * @param {number} dec the number to convert.
51159 * @param {number} bytes the number of bytes to generate.
51160 * @returns {string} the result.
51161 */
51162
51163
51164var decToHex = function decToHex(dec, bytes) {
51165  var hex = "",
51166      i;
51167
51168  for (i = 0; i < bytes; i++) {
51169    hex += String.fromCharCode(dec & 0xff);
51170    dec = dec >>> 8;
51171  }
51172
51173  return hex;
51174};
51175/**
51176 * Generate the UNIX part of the external file attributes.
51177 * @param {Object} unixPermissions the unix permissions or null.
51178 * @param {Boolean} isDir true if the entry is a directory, false otherwise.
51179 * @return {Number} a 32 bit integer.
51180 *
51181 * adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :
51182 *
51183 * TTTTsstrwxrwxrwx0000000000ADVSHR
51184 * ^^^^____________________________ file type, see zipinfo.c (UNX_*)
51185 *     ^^^_________________________ setuid, setgid, sticky
51186 *        ^^^^^^^^^________________ permissions
51187 *                 ^^^^^^^^^^______ not used ?
51188 *                           ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only
51189 */
51190
51191
51192var generateUnixExternalFileAttr = function generateUnixExternalFileAttr(unixPermissions, isDir) {
51193  var result = unixPermissions;
51194
51195  if (!unixPermissions) {
51196    // I can't use octal values in strict mode, hence the hexa.
51197    //  040775 => 0x41fd
51198    // 0100664 => 0x81b4
51199    result = isDir ? 0x41fd : 0x81b4;
51200  }
51201
51202  return (result & 0xFFFF) << 16;
51203};
51204/**
51205 * Generate the DOS part of the external file attributes.
51206 * @param {Object} dosPermissions the dos permissions or null.
51207 * @param {Boolean} isDir true if the entry is a directory, false otherwise.
51208 * @return {Number} a 32 bit integer.
51209 *
51210 * Bit 0     Read-Only
51211 * Bit 1     Hidden
51212 * Bit 2     System
51213 * Bit 3     Volume Label
51214 * Bit 4     Directory
51215 * Bit 5     Archive
51216 */
51217
51218
51219var generateDosExternalFileAttr = function generateDosExternalFileAttr(dosPermissions, isDir) {
51220  // the dir flag is already set for compatibility
51221  return (dosPermissions || 0) & 0x3F;
51222};
51223/**
51224 * Generate the various parts used in the construction of the final zip file.
51225 * @param {Object} streamInfo the hash with information about the compressed file.
51226 * @param {Boolean} streamedContent is the content streamed ?
51227 * @param {Boolean} streamingEnded is the stream finished ?
51228 * @param {number} offset the current offset from the start of the zip file.
51229 * @param {String} platform let's pretend we are this platform (change platform dependents fields)
51230 * @param {Function} encodeFileName the function to encode the file name / comment.
51231 * @return {Object} the zip parts.
51232 */
51233
51234
51235var generateZipParts = function generateZipParts(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) {
51236  var file = streamInfo['file'],
51237      compression = streamInfo['compression'],
51238      useCustomEncoding = encodeFileName !== utf8.utf8encode,
51239      encodedFileName = utils.transformTo("string", encodeFileName(file.name)),
51240      utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)),
51241      comment = file.comment,
51242      encodedComment = utils.transformTo("string", encodeFileName(comment)),
51243      utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)),
51244      useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,
51245      useUTF8ForComment = utfEncodedComment.length !== comment.length,
51246      dosTime,
51247      dosDate,
51248      extraFields = "",
51249      unicodePathExtraField = "",
51250      unicodeCommentExtraField = "",
51251      dir = file.dir,
51252      date = file.date;
51253  var dataInfo = {
51254    crc32: 0,
51255    compressedSize: 0,
51256    uncompressedSize: 0
51257  }; // if the content is streamed, the sizes/crc32 are only available AFTER
51258  // the end of the stream.
51259
51260  if (!streamedContent || streamingEnded) {
51261    dataInfo.crc32 = streamInfo['crc32'];
51262    dataInfo.compressedSize = streamInfo['compressedSize'];
51263    dataInfo.uncompressedSize = streamInfo['uncompressedSize'];
51264  }
51265
51266  var bitflag = 0;
51267
51268  if (streamedContent) {
51269    // Bit 3: the sizes/crc32 are set to zero in the local header.
51270    // The correct values are put in the data descriptor immediately
51271    // following the compressed data.
51272    bitflag |= 0x0008;
51273  }
51274
51275  if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) {
51276    // Bit 11: Language encoding flag (EFS).
51277    bitflag |= 0x0800;
51278  }
51279
51280  var extFileAttr = 0;
51281  var versionMadeBy = 0;
51282
51283  if (dir) {
51284    // dos or unix, we set the dos dir flag
51285    extFileAttr |= 0x00010;
51286  }
51287
51288  if (platform === "UNIX") {
51289    versionMadeBy = 0x031E; // UNIX, version 3.0
51290
51291    extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);
51292  } else {
51293    // DOS or other, fallback to DOS
51294    versionMadeBy = 0x0014; // DOS, version 2.0
51295
51296    extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);
51297  } // date
51298  // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
51299  // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
51300  // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
51301
51302
51303  dosTime = date.getUTCHours();
51304  dosTime = dosTime << 6;
51305  dosTime = dosTime | date.getUTCMinutes();
51306  dosTime = dosTime << 5;
51307  dosTime = dosTime | date.getUTCSeconds() / 2;
51308  dosDate = date.getUTCFullYear() - 1980;
51309  dosDate = dosDate << 4;
51310  dosDate = dosDate | date.getUTCMonth() + 1;
51311  dosDate = dosDate << 5;
51312  dosDate = dosDate | date.getUTCDate();
51313
51314  if (useUTF8ForFileName) {
51315    // set the unicode path extra field. unzip needs at least one extra
51316    // field to correctly handle unicode path, so using the path is as good
51317    // as any other information. This could improve the situation with
51318    // other archive managers too.
51319    // This field is usually used without the utf8 flag, with a non
51320    // unicode path in the header (winrar, winzip). This helps (a bit)
51321    // with the messy Windows' default compressed folders feature but
51322    // breaks on p7zip which doesn't seek the unicode path extra field.
51323    // So for now, UTF-8 everywhere !
51324    unicodePathExtraField = // Version
51325    decToHex(1, 1) + // NameCRC32
51326    decToHex(crc32(encodedFileName), 4) + // UnicodeName
51327    utfEncodedFileName;
51328    extraFields += // Info-ZIP Unicode Path Extra Field
51329    "\x75\x70" + // size
51330    decToHex(unicodePathExtraField.length, 2) + // content
51331    unicodePathExtraField;
51332  }
51333
51334  if (useUTF8ForComment) {
51335    unicodeCommentExtraField = // Version
51336    decToHex(1, 1) + // CommentCRC32
51337    decToHex(crc32(encodedComment), 4) + // UnicodeName
51338    utfEncodedComment;
51339    extraFields += // Info-ZIP Unicode Path Extra Field
51340    "\x75\x63" + // size
51341    decToHex(unicodeCommentExtraField.length, 2) + // content
51342    unicodeCommentExtraField;
51343  }
51344
51345  var header = ""; // version needed to extract
51346
51347  header += "\x0A\x00"; // general purpose bit flag
51348
51349  header += decToHex(bitflag, 2); // compression method
51350
51351  header += compression.magic; // last mod file time
51352
51353  header += decToHex(dosTime, 2); // last mod file date
51354
51355  header += decToHex(dosDate, 2); // crc-32
51356
51357  header += decToHex(dataInfo.crc32, 4); // compressed size
51358
51359  header += decToHex(dataInfo.compressedSize, 4); // uncompressed size
51360
51361  header += decToHex(dataInfo.uncompressedSize, 4); // file name length
51362
51363  header += decToHex(encodedFileName.length, 2); // extra field length
51364
51365  header += decToHex(extraFields.length, 2);
51366  var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;
51367  var dirRecord = signature.CENTRAL_FILE_HEADER + // version made by (00: DOS)
51368  decToHex(versionMadeBy, 2) + // file header (common to file and central directory)
51369  header + // file comment length
51370  decToHex(encodedComment.length, 2) + // disk number start
51371  "\x00\x00" + // internal file attributes TODO
51372  "\x00\x00" + // external file attributes
51373  decToHex(extFileAttr, 4) + // relative offset of local header
51374  decToHex(offset, 4) + // file name
51375  encodedFileName + // extra field
51376  extraFields + // file comment
51377  encodedComment;
51378  return {
51379    fileRecord: fileRecord,
51380    dirRecord: dirRecord
51381  };
51382};
51383/**
51384 * Generate the EOCD record.
51385 * @param {Number} entriesCount the number of entries in the zip file.
51386 * @param {Number} centralDirLength the length (in bytes) of the central dir.
51387 * @param {Number} localDirLength the length (in bytes) of the local dir.
51388 * @param {String} comment the zip file comment as a binary string.
51389 * @param {Function} encodeFileName the function to encode the comment.
51390 * @return {String} the EOCD record.
51391 */
51392
51393
51394var generateCentralDirectoryEnd = function generateCentralDirectoryEnd(entriesCount, centralDirLength, localDirLength, comment, encodeFileName) {
51395  var dirEnd = "";
51396  var encodedComment = utils.transformTo("string", encodeFileName(comment)); // end of central dir signature
51397
51398  dirEnd = signature.CENTRAL_DIRECTORY_END + // number of this disk
51399  "\x00\x00" + // number of the disk with the start of the central directory
51400  "\x00\x00" + // total number of entries in the central directory on this disk
51401  decToHex(entriesCount, 2) + // total number of entries in the central directory
51402  decToHex(entriesCount, 2) + // size of the central directory   4 bytes
51403  decToHex(centralDirLength, 4) + // offset of start of central directory with respect to the starting disk number
51404  decToHex(localDirLength, 4) + // .ZIP file comment length
51405  decToHex(encodedComment.length, 2) + // .ZIP file comment
51406  encodedComment;
51407  return dirEnd;
51408};
51409/**
51410 * Generate data descriptors for a file entry.
51411 * @param {Object} streamInfo the hash generated by a worker, containing information
51412 * on the file entry.
51413 * @return {String} the data descriptors.
51414 */
51415
51416
51417var generateDataDescriptors = function generateDataDescriptors(streamInfo) {
51418  var descriptor = "";
51419  descriptor = signature.DATA_DESCRIPTOR + // crc-32                          4 bytes
51420  decToHex(streamInfo['crc32'], 4) + // compressed size                 4 bytes
51421  decToHex(streamInfo['compressedSize'], 4) + // uncompressed size               4 bytes
51422  decToHex(streamInfo['uncompressedSize'], 4);
51423  return descriptor;
51424};
51425/**
51426 * A worker to concatenate other workers to create a zip file.
51427 * @param {Boolean} streamFiles `true` to stream the content of the files,
51428 * `false` to accumulate it.
51429 * @param {String} comment the comment to use.
51430 * @param {String} platform the platform to use, "UNIX" or "DOS".
51431 * @param {Function} encodeFileName the function to encode file names and comments.
51432 */
51433
51434
51435function ZipFileWorker(streamFiles, comment, platform, encodeFileName) {
51436  GenericWorker.call(this, "ZipFileWorker"); // The number of bytes written so far. This doesn't count accumulated chunks.
51437
51438  this.bytesWritten = 0; // The comment of the zip file
51439
51440  this.zipComment = comment; // The platform "generating" the zip file.
51441
51442  this.zipPlatform = platform; // the function to encode file names and comments.
51443
51444  this.encodeFileName = encodeFileName; // Should we stream the content of the files ?
51445
51446  this.streamFiles = streamFiles; // If `streamFiles` is false, we will need to accumulate the content of the
51447  // files to calculate sizes / crc32 (and write them *before* the content).
51448  // This boolean indicates if we are accumulating chunks (it will change a lot
51449  // during the lifetime of this worker).
51450
51451  this.accumulate = false; // The buffer receiving chunks when accumulating content.
51452
51453  this.contentBuffer = []; // The list of generated directory records.
51454
51455  this.dirRecords = []; // The offset (in bytes) from the beginning of the zip file for the current source.
51456
51457  this.currentSourceOffset = 0; // The total number of entries in this zip file.
51458
51459  this.entriesCount = 0; // the name of the file currently being added, null when handling the end of the zip file.
51460  // Used for the emitted metadata.
51461
51462  this.currentFile = null;
51463  this._sources = [];
51464}
51465
51466utils.inherits(ZipFileWorker, GenericWorker);
51467/**
51468 * @see GenericWorker.push
51469 */
51470
51471ZipFileWorker.prototype.push = function (chunk) {
51472  var currentFilePercent = chunk.meta.percent || 0;
51473  var entriesCount = this.entriesCount;
51474  var remainingFiles = this._sources.length;
51475
51476  if (this.accumulate) {
51477    this.contentBuffer.push(chunk);
51478  } else {
51479    this.bytesWritten += chunk.data.length;
51480    GenericWorker.prototype.push.call(this, {
51481      data: chunk.data,
51482      meta: {
51483        currentFile: this.currentFile,
51484        percent: entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100
51485      }
51486    });
51487  }
51488};
51489/**
51490 * The worker started a new source (an other worker).
51491 * @param {Object} streamInfo the streamInfo object from the new source.
51492 */
51493
51494
51495ZipFileWorker.prototype.openedSource = function (streamInfo) {
51496  this.currentSourceOffset = this.bytesWritten;
51497  this.currentFile = streamInfo['file'].name;
51498  var streamedContent = this.streamFiles && !streamInfo['file'].dir; // don't stream folders (because they don't have any content)
51499
51500  if (streamedContent) {
51501    var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
51502    this.push({
51503      data: record.fileRecord,
51504      meta: {
51505        percent: 0
51506      }
51507    });
51508  } else {
51509    // we need to wait for the whole file before pushing anything
51510    this.accumulate = true;
51511  }
51512};
51513/**
51514 * The worker finished a source (an other worker).
51515 * @param {Object} streamInfo the streamInfo object from the finished source.
51516 */
51517
51518
51519ZipFileWorker.prototype.closedSource = function (streamInfo) {
51520  this.accumulate = false;
51521  var streamedContent = this.streamFiles && !streamInfo['file'].dir;
51522  var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
51523  this.dirRecords.push(record.dirRecord);
51524
51525  if (streamedContent) {
51526    // after the streamed file, we put data descriptors
51527    this.push({
51528      data: generateDataDescriptors(streamInfo),
51529      meta: {
51530        percent: 100
51531      }
51532    });
51533  } else {
51534    // the content wasn't streamed, we need to push everything now
51535    // first the file record, then the content
51536    this.push({
51537      data: record.fileRecord,
51538      meta: {
51539        percent: 0
51540      }
51541    });
51542
51543    while (this.contentBuffer.length) {
51544      this.push(this.contentBuffer.shift());
51545    }
51546  }
51547
51548  this.currentFile = null;
51549};
51550/**
51551 * @see GenericWorker.flush
51552 */
51553
51554
51555ZipFileWorker.prototype.flush = function () {
51556  var localDirLength = this.bytesWritten;
51557
51558  for (var i = 0; i < this.dirRecords.length; i++) {
51559    this.push({
51560      data: this.dirRecords[i],
51561      meta: {
51562        percent: 100
51563      }
51564    });
51565  }
51566
51567  var centralDirLength = this.bytesWritten - localDirLength;
51568  var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName);
51569  this.push({
51570    data: dirEnd,
51571    meta: {
51572      percent: 100
51573    }
51574  });
51575};
51576/**
51577 * Prepare the next source to be read.
51578 */
51579
51580
51581ZipFileWorker.prototype.prepareNextSource = function () {
51582  this.previous = this._sources.shift();
51583  this.openedSource(this.previous.streamInfo);
51584
51585  if (this.isPaused) {
51586    this.previous.pause();
51587  } else {
51588    this.previous.resume();
51589  }
51590};
51591/**
51592 * @see GenericWorker.registerPrevious
51593 */
51594
51595
51596ZipFileWorker.prototype.registerPrevious = function (previous) {
51597  this._sources.push(previous);
51598
51599  var self = this;
51600  previous.on('data', function (chunk) {
51601    self.processChunk(chunk);
51602  });
51603  previous.on('end', function () {
51604    self.closedSource(self.previous.streamInfo);
51605
51606    if (self._sources.length) {
51607      self.prepareNextSource();
51608    } else {
51609      self.end();
51610    }
51611  });
51612  previous.on('error', function (e) {
51613    self.error(e);
51614  });
51615  return this;
51616};
51617/**
51618 * @see GenericWorker.resume
51619 */
51620
51621
51622ZipFileWorker.prototype.resume = function () {
51623  if (!GenericWorker.prototype.resume.call(this)) {
51624    return false;
51625  }
51626
51627  if (!this.previous && this._sources.length) {
51628    this.prepareNextSource();
51629    return true;
51630  }
51631
51632  if (!this.previous && !this._sources.length && !this.generatedError) {
51633    this.end();
51634    return true;
51635  }
51636};
51637/**
51638 * @see GenericWorker.error
51639 */
51640
51641
51642ZipFileWorker.prototype.error = function (e) {
51643  var sources = this._sources;
51644
51645  if (!GenericWorker.prototype.error.call(this, e)) {
51646    return false;
51647  }
51648
51649  for (var i = 0; i < sources.length; i++) {
51650    try {
51651      sources[i].error(e);
51652    } catch (e) {// the `error` exploded, nothing to do
51653    }
51654  }
51655
51656  return true;
51657};
51658/**
51659 * @see GenericWorker.lock
51660 */
51661
51662
51663ZipFileWorker.prototype.lock = function () {
51664  GenericWorker.prototype.lock.call(this);
51665  var sources = this._sources;
51666
51667  for (var i = 0; i < sources.length; i++) {
51668    sources[i].lock();
51669  }
51670};
51671
51672module.exports = ZipFileWorker;
51673
51674},{"../crc32":393,"../signature":412,"../stream/GenericWorker":417,"../utf8":420,"../utils":421}],398:[function(require,module,exports){
51675'use strict';
51676
51677var compressions = require('../compressions');
51678
51679var ZipFileWorker = require('./ZipFileWorker');
51680/**
51681 * Find the compression to use.
51682 * @param {String} fileCompression the compression defined at the file level, if any.
51683 * @param {String} zipCompression the compression defined at the load() level.
51684 * @return {Object} the compression object to use.
51685 */
51686
51687
51688var getCompression = function getCompression(fileCompression, zipCompression) {
51689  var compressionName = fileCompression || zipCompression;
51690  var compression = compressions[compressionName];
51691
51692  if (!compression) {
51693    throw new Error(compressionName + " is not a valid compression method !");
51694  }
51695
51696  return compression;
51697};
51698/**
51699 * Create a worker to generate a zip file.
51700 * @param {JSZip} zip the JSZip instance at the right root level.
51701 * @param {Object} options to generate the zip file.
51702 * @param {String} comment the comment to use.
51703 */
51704
51705
51706exports.generateWorker = function (zip, options, comment) {
51707  var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName);
51708  var entriesCount = 0;
51709
51710  try {
51711    zip.forEach(function (relativePath, file) {
51712      entriesCount++;
51713      var compression = getCompression(file.options.compression, options.compression);
51714      var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};
51715      var dir = file.dir,
51716          date = file.date;
51717
51718      file._compressWorker(compression, compressionOptions).withStreamInfo("file", {
51719        name: relativePath,
51720        dir: dir,
51721        date: date,
51722        comment: file.comment || "",
51723        unixPermissions: file.unixPermissions,
51724        dosPermissions: file.dosPermissions
51725      }).pipe(zipFileWorker);
51726    });
51727    zipFileWorker.entriesCount = entriesCount;
51728  } catch (e) {
51729    zipFileWorker.error(e);
51730  }
51731
51732  return zipFileWorker;
51733};
51734
51735},{"../compressions":392,"./ZipFileWorker":397}],399:[function(require,module,exports){
51736'use strict';
51737/**
51738 * Representation a of zip file in js
51739 * @constructor
51740 */
51741
51742function JSZip() {
51743  // if this constructor is used without `new`, it adds `new` before itself:
51744  if (!(this instanceof JSZip)) {
51745    return new JSZip();
51746  }
51747
51748  if (arguments.length) {
51749    throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
51750  } // object containing the files :
51751  // {
51752  //   "folder/" : {...},
51753  //   "folder/data.txt" : {...}
51754  // }
51755
51756
51757  this.files = {};
51758  this.comment = null; // Where we are in the hierarchy
51759
51760  this.root = "";
51761
51762  this.clone = function () {
51763    var newObj = new JSZip();
51764
51765    for (var i in this) {
51766      if (typeof this[i] !== "function") {
51767        newObj[i] = this[i];
51768      }
51769    }
51770
51771    return newObj;
51772  };
51773}
51774
51775JSZip.prototype = require('./object');
51776JSZip.prototype.loadAsync = require('./load');
51777JSZip.support = require('./support');
51778JSZip.defaults = require('./defaults'); // TODO find a better way to handle this version,
51779// a require('package.json').version doesn't work with webpack, see #327
51780
51781JSZip.version = "3.5.0";
51782
51783JSZip.loadAsync = function (content, options) {
51784  return new JSZip().loadAsync(content, options);
51785};
51786
51787JSZip.external = require("./external");
51788module.exports = JSZip;
51789
51790},{"./defaults":394,"./external":395,"./load":400,"./object":404,"./support":419}],400:[function(require,module,exports){
51791'use strict';
51792
51793var utils = require('./utils');
51794
51795var external = require("./external");
51796
51797var utf8 = require('./utf8');
51798
51799var utils = require('./utils');
51800
51801var ZipEntries = require('./zipEntries');
51802
51803var Crc32Probe = require('./stream/Crc32Probe');
51804
51805var nodejsUtils = require("./nodejsUtils");
51806/**
51807 * Check the CRC32 of an entry.
51808 * @param {ZipEntry} zipEntry the zip entry to check.
51809 * @return {Promise} the result.
51810 */
51811
51812
51813function checkEntryCRC32(zipEntry) {
51814  return new external.Promise(function (resolve, reject) {
51815    var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
51816    worker.on("error", function (e) {
51817      reject(e);
51818    }).on("end", function () {
51819      if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
51820        reject(new Error("Corrupted zip : CRC32 mismatch"));
51821      } else {
51822        resolve();
51823      }
51824    }).resume();
51825  });
51826}
51827
51828module.exports = function (data, options) {
51829  var zip = this;
51830  options = utils.extend(options || {}, {
51831    base64: false,
51832    checkCRC32: false,
51833    optimizedBinaryString: false,
51834    createFolders: false,
51835    decodeFileName: utf8.utf8decode
51836  });
51837
51838  if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
51839    return external.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file."));
51840  }
51841
51842  return utils.prepareContent("the loaded zip file", data, true, options.optimizedBinaryString, options.base64).then(function (data) {
51843    var zipEntries = new ZipEntries(options);
51844    zipEntries.load(data);
51845    return zipEntries;
51846  }).then(function checkCRC32(zipEntries) {
51847    var promises = [external.Promise.resolve(zipEntries)];
51848    var files = zipEntries.files;
51849
51850    if (options.checkCRC32) {
51851      for (var i = 0; i < files.length; i++) {
51852        promises.push(checkEntryCRC32(files[i]));
51853      }
51854    }
51855
51856    return external.Promise.all(promises);
51857  }).then(function addFiles(results) {
51858    var zipEntries = results.shift();
51859    var files = zipEntries.files;
51860
51861    for (var i = 0; i < files.length; i++) {
51862      var input = files[i];
51863      zip.file(input.fileNameStr, input.decompressed, {
51864        binary: true,
51865        optimizedBinaryString: true,
51866        date: input.date,
51867        dir: input.dir,
51868        comment: input.fileCommentStr.length ? input.fileCommentStr : null,
51869        unixPermissions: input.unixPermissions,
51870        dosPermissions: input.dosPermissions,
51871        createFolders: options.createFolders
51872      });
51873    }
51874
51875    if (zipEntries.zipComment.length) {
51876      zip.comment = zipEntries.zipComment;
51877    }
51878
51879    return zip;
51880  });
51881};
51882
51883},{"./external":395,"./nodejsUtils":403,"./stream/Crc32Probe":414,"./utf8":420,"./utils":421,"./zipEntries":422}],401:[function(require,module,exports){
51884"use strict";
51885
51886var utils = require('../utils');
51887
51888var GenericWorker = require('../stream/GenericWorker');
51889/**
51890 * A worker that use a nodejs stream as source.
51891 * @constructor
51892 * @param {String} filename the name of the file entry for this stream.
51893 * @param {Readable} stream the nodejs stream.
51894 */
51895
51896
51897function NodejsStreamInputAdapter(filename, stream) {
51898  GenericWorker.call(this, "Nodejs stream input adapter for " + filename);
51899  this._upstreamEnded = false;
51900
51901  this._bindStream(stream);
51902}
51903
51904utils.inherits(NodejsStreamInputAdapter, GenericWorker);
51905/**
51906 * Prepare the stream and bind the callbacks on it.
51907 * Do this ASAP on node 0.10 ! A lazy binding doesn't always work.
51908 * @param {Stream} stream the nodejs stream to use.
51909 */
51910
51911NodejsStreamInputAdapter.prototype._bindStream = function (stream) {
51912  var self = this;
51913  this._stream = stream;
51914  stream.pause();
51915  stream.on("data", function (chunk) {
51916    self.push({
51917      data: chunk,
51918      meta: {
51919        percent: 0
51920      }
51921    });
51922  }).on("error", function (e) {
51923    if (self.isPaused) {
51924      this.generatedError = e;
51925    } else {
51926      self.error(e);
51927    }
51928  }).on("end", function () {
51929    if (self.isPaused) {
51930      self._upstreamEnded = true;
51931    } else {
51932      self.end();
51933    }
51934  });
51935};
51936
51937NodejsStreamInputAdapter.prototype.pause = function () {
51938  if (!GenericWorker.prototype.pause.call(this)) {
51939    return false;
51940  }
51941
51942  this._stream.pause();
51943
51944  return true;
51945};
51946
51947NodejsStreamInputAdapter.prototype.resume = function () {
51948  if (!GenericWorker.prototype.resume.call(this)) {
51949    return false;
51950  }
51951
51952  if (this._upstreamEnded) {
51953    this.end();
51954  } else {
51955    this._stream.resume();
51956  }
51957
51958  return true;
51959};
51960
51961module.exports = NodejsStreamInputAdapter;
51962
51963},{"../stream/GenericWorker":417,"../utils":421}],402:[function(require,module,exports){
51964'use strict';
51965
51966var Readable = require('readable-stream').Readable;
51967
51968var utils = require('../utils');
51969
51970utils.inherits(NodejsStreamOutputAdapter, Readable);
51971/**
51972* A nodejs stream using a worker as source.
51973* @see the SourceWrapper in http://nodejs.org/api/stream.html
51974* @constructor
51975* @param {StreamHelper} helper the helper wrapping the worker
51976* @param {Object} options the nodejs stream options
51977* @param {Function} updateCb the update callback.
51978*/
51979
51980function NodejsStreamOutputAdapter(helper, options, updateCb) {
51981  Readable.call(this, options);
51982  this._helper = helper;
51983  var self = this;
51984  helper.on("data", function (data, meta) {
51985    if (!self.push(data)) {
51986      self._helper.pause();
51987    }
51988
51989    if (updateCb) {
51990      updateCb(meta);
51991    }
51992  }).on("error", function (e) {
51993    self.emit('error', e);
51994  }).on("end", function () {
51995    self.push(null);
51996  });
51997}
51998
51999NodejsStreamOutputAdapter.prototype._read = function () {
52000  this._helper.resume();
52001};
52002
52003module.exports = NodejsStreamOutputAdapter;
52004
52005},{"../utils":421,"readable-stream":405}],403:[function(require,module,exports){
52006(function (Buffer){
52007'use strict';
52008
52009module.exports = {
52010  /**
52011   * True if this is running in Nodejs, will be undefined in a browser.
52012   * In a browser, browserify won't include this file and the whole module
52013   * will be resolved an empty object.
52014   */
52015  isNode: typeof Buffer !== "undefined",
52016
52017  /**
52018   * Create a new nodejs Buffer from an existing content.
52019   * @param {Object} data the data to pass to the constructor.
52020   * @param {String} encoding the encoding to use.
52021   * @return {Buffer} a new Buffer.
52022   */
52023  newBufferFrom: function newBufferFrom(data, encoding) {
52024    if (Buffer.from && Buffer.from !== Uint8Array.from) {
52025      return Buffer.from(data, encoding);
52026    } else {
52027      if (typeof data === "number") {
52028        // Safeguard for old Node.js versions. On newer versions,
52029        // Buffer.from(number) / Buffer(number, encoding) already throw.
52030        throw new Error("The \"data\" argument must not be a number");
52031      }
52032
52033      return new Buffer(data, encoding);
52034    }
52035  },
52036
52037  /**
52038   * Create a new nodejs Buffer with the specified size.
52039   * @param {Integer} size the size of the buffer.
52040   * @return {Buffer} a new Buffer.
52041   */
52042  allocBuffer: function allocBuffer(size) {
52043    if (Buffer.alloc) {
52044      return Buffer.alloc(size);
52045    } else {
52046      var buf = new Buffer(size);
52047      buf.fill(0);
52048      return buf;
52049    }
52050  },
52051
52052  /**
52053   * Find out if an object is a Buffer.
52054   * @param {Object} b the object to test.
52055   * @return {Boolean} true if the object is a Buffer, false otherwise.
52056   */
52057  isBuffer: function isBuffer(b) {
52058    return Buffer.isBuffer(b);
52059  },
52060  isStream: function isStream(obj) {
52061    return obj && typeof obj.on === "function" && typeof obj.pause === "function" && typeof obj.resume === "function";
52062  }
52063};
52064
52065}).call(this,require("buffer").Buffer)
52066
52067},{"buffer":216}],404:[function(require,module,exports){
52068'use strict';
52069
52070var utf8 = require('./utf8');
52071
52072var utils = require('./utils');
52073
52074var GenericWorker = require('./stream/GenericWorker');
52075
52076var StreamHelper = require('./stream/StreamHelper');
52077
52078var defaults = require('./defaults');
52079
52080var CompressedObject = require('./compressedObject');
52081
52082var ZipObject = require('./zipObject');
52083
52084var generate = require("./generate");
52085
52086var nodejsUtils = require("./nodejsUtils");
52087
52088var NodejsStreamInputAdapter = require("./nodejs/NodejsStreamInputAdapter");
52089/**
52090 * Add a file in the current folder.
52091 * @private
52092 * @param {string} name the name of the file
52093 * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file
52094 * @param {Object} originalOptions the options of the file
52095 * @return {Object} the new file.
52096 */
52097
52098
52099var fileAdd = function fileAdd(name, data, originalOptions) {
52100  // be sure sub folders exist
52101  var dataType = utils.getTypeOf(data),
52102      parent;
52103  /*
52104   * Correct options.
52105   */
52106
52107  var o = utils.extend(originalOptions || {}, defaults);
52108  o.date = o.date || new Date();
52109
52110  if (o.compression !== null) {
52111    o.compression = o.compression.toUpperCase();
52112  }
52113
52114  if (typeof o.unixPermissions === "string") {
52115    o.unixPermissions = parseInt(o.unixPermissions, 8);
52116  } // UNX_IFDIR  0040000 see zipinfo.c
52117
52118
52119  if (o.unixPermissions && o.unixPermissions & 0x4000) {
52120    o.dir = true;
52121  } // Bit 4    Directory
52122
52123
52124  if (o.dosPermissions && o.dosPermissions & 0x0010) {
52125    o.dir = true;
52126  }
52127
52128  if (o.dir) {
52129    name = forceTrailingSlash(name);
52130  }
52131
52132  if (o.createFolders && (parent = parentFolder(name))) {
52133    folderAdd.call(this, parent, true);
52134  }
52135
52136  var isUnicodeString = dataType === "string" && o.binary === false && o.base64 === false;
52137
52138  if (!originalOptions || typeof originalOptions.binary === "undefined") {
52139    o.binary = !isUnicodeString;
52140  }
52141
52142  var isCompressedEmpty = data instanceof CompressedObject && data.uncompressedSize === 0;
52143
52144  if (isCompressedEmpty || o.dir || !data || data.length === 0) {
52145    o.base64 = false;
52146    o.binary = true;
52147    data = "";
52148    o.compression = "STORE";
52149    dataType = "string";
52150  }
52151  /*
52152   * Convert content to fit.
52153   */
52154
52155
52156  var zipObjectContent = null;
52157
52158  if (data instanceof CompressedObject || data instanceof GenericWorker) {
52159    zipObjectContent = data;
52160  } else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
52161    zipObjectContent = new NodejsStreamInputAdapter(name, data);
52162  } else {
52163    zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64);
52164  }
52165
52166  var object = new ZipObject(name, zipObjectContent, o);
52167  this.files[name] = object;
52168  /*
52169  TODO: we can't throw an exception because we have async promises
52170  (we can have a promise of a Date() for example) but returning a
52171  promise is useless because file(name, data) returns the JSZip
52172  object for chaining. Should we break that to allow the user
52173  to catch the error ?
52174   return external.Promise.resolve(zipObjectContent)
52175  .then(function () {
52176      return object;
52177  });
52178  */
52179};
52180/**
52181 * Find the parent folder of the path.
52182 * @private
52183 * @param {string} path the path to use
52184 * @return {string} the parent folder, or ""
52185 */
52186
52187
52188var parentFolder = function parentFolder(path) {
52189  if (path.slice(-1) === '/') {
52190    path = path.substring(0, path.length - 1);
52191  }
52192
52193  var lastSlash = path.lastIndexOf('/');
52194  return lastSlash > 0 ? path.substring(0, lastSlash) : "";
52195};
52196/**
52197 * Returns the path with a slash at the end.
52198 * @private
52199 * @param {String} path the path to check.
52200 * @return {String} the path with a trailing slash.
52201 */
52202
52203
52204var forceTrailingSlash = function forceTrailingSlash(path) {
52205  // Check the name ends with a /
52206  if (path.slice(-1) !== "/") {
52207    path += "/"; // IE doesn't like substr(-1)
52208  }
52209
52210  return path;
52211};
52212/**
52213 * Add a (sub) folder in the current folder.
52214 * @private
52215 * @param {string} name the folder's name
52216 * @param {boolean=} [createFolders] If true, automatically create sub
52217 *  folders. Defaults to false.
52218 * @return {Object} the new folder.
52219 */
52220
52221
52222var folderAdd = function folderAdd(name, createFolders) {
52223  createFolders = typeof createFolders !== 'undefined' ? createFolders : defaults.createFolders;
52224  name = forceTrailingSlash(name); // Does this folder already exist?
52225
52226  if (!this.files[name]) {
52227    fileAdd.call(this, name, null, {
52228      dir: true,
52229      createFolders: createFolders
52230    });
52231  }
52232
52233  return this.files[name];
52234};
52235/**
52236* Cross-window, cross-Node-context regular expression detection
52237* @param  {Object}  object Anything
52238* @return {Boolean}        true if the object is a regular expression,
52239* false otherwise
52240*/
52241
52242
52243function isRegExp(object) {
52244  return Object.prototype.toString.call(object) === "[object RegExp]";
52245} // return the actual prototype of JSZip
52246
52247
52248var out = {
52249  /**
52250   * @see loadAsync
52251   */
52252  load: function load() {
52253    throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
52254  },
52255
52256  /**
52257   * Call a callback function for each entry at this folder level.
52258   * @param {Function} cb the callback function:
52259   * function (relativePath, file) {...}
52260   * It takes 2 arguments : the relative path and the file.
52261   */
52262  forEach: function forEach(cb) {
52263    var filename, relativePath, file;
52264
52265    for (filename in this.files) {
52266      if (!this.files.hasOwnProperty(filename)) {
52267        continue;
52268      }
52269
52270      file = this.files[filename];
52271      relativePath = filename.slice(this.root.length, filename.length);
52272
52273      if (relativePath && filename.slice(0, this.root.length) === this.root) {
52274        // the file is in the current root
52275        cb(relativePath, file); // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...
52276      }
52277    }
52278  },
52279
52280  /**
52281   * Filter nested files/folders with the specified function.
52282   * @param {Function} search the predicate to use :
52283   * function (relativePath, file) {...}
52284   * It takes 2 arguments : the relative path and the file.
52285   * @return {Array} An array of matching elements.
52286   */
52287  filter: function filter(search) {
52288    var result = [];
52289    this.forEach(function (relativePath, entry) {
52290      if (search(relativePath, entry)) {
52291        // the file matches the function
52292        result.push(entry);
52293      }
52294    });
52295    return result;
52296  },
52297
52298  /**
52299   * Add a file to the zip file, or search a file.
52300   * @param   {string|RegExp} name The name of the file to add (if data is defined),
52301   * the name of the file to find (if no data) or a regex to match files.
52302   * @param   {String|ArrayBuffer|Uint8Array|Buffer} data  The file data, either raw or base64 encoded
52303   * @param   {Object} o     File options
52304   * @return  {JSZip|Object|Array} this JSZip object (when adding a file),
52305   * a file (when searching by string) or an array of files (when searching by regex).
52306   */
52307  file: function file(name, data, o) {
52308    if (arguments.length === 1) {
52309      if (isRegExp(name)) {
52310        var regexp = name;
52311        return this.filter(function (relativePath, file) {
52312          return !file.dir && regexp.test(relativePath);
52313        });
52314      } else {
52315        // text
52316        var obj = this.files[this.root + name];
52317
52318        if (obj && !obj.dir) {
52319          return obj;
52320        } else {
52321          return null;
52322        }
52323      }
52324    } else {
52325      // more than one argument : we have data !
52326      name = this.root + name;
52327      fileAdd.call(this, name, data, o);
52328    }
52329
52330    return this;
52331  },
52332
52333  /**
52334   * Add a directory to the zip file, or search.
52335   * @param   {String|RegExp} arg The name of the directory to add, or a regex to search folders.
52336   * @return  {JSZip} an object with the new directory as the root, or an array containing matching folders.
52337   */
52338  folder: function folder(arg) {
52339    if (!arg) {
52340      return this;
52341    }
52342
52343    if (isRegExp(arg)) {
52344      return this.filter(function (relativePath, file) {
52345        return file.dir && arg.test(relativePath);
52346      });
52347    } // else, name is a new folder
52348
52349
52350    var name = this.root + arg;
52351    var newFolder = folderAdd.call(this, name); // Allow chaining by returning a new object with this folder as the root
52352
52353    var ret = this.clone();
52354    ret.root = newFolder.name;
52355    return ret;
52356  },
52357
52358  /**
52359   * Delete a file, or a directory and all sub-files, from the zip
52360   * @param {string} name the name of the file to delete
52361   * @return {JSZip} this JSZip object
52362   */
52363  remove: function remove(name) {
52364    name = this.root + name;
52365    var file = this.files[name];
52366
52367    if (!file) {
52368      // Look for any folders
52369      if (name.slice(-1) !== "/") {
52370        name += "/";
52371      }
52372
52373      file = this.files[name];
52374    }
52375
52376    if (file && !file.dir) {
52377      // file
52378      delete this.files[name];
52379    } else {
52380      // maybe a folder, delete recursively
52381      var kids = this.filter(function (relativePath, file) {
52382        return file.name.slice(0, name.length) === name;
52383      });
52384
52385      for (var i = 0; i < kids.length; i++) {
52386        delete this.files[kids[i].name];
52387      }
52388    }
52389
52390    return this;
52391  },
52392
52393  /**
52394   * Generate the complete zip file
52395   * @param {Object} options the options to generate the zip file :
52396   * - compression, "STORE" by default.
52397   * - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
52398   * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file
52399   */
52400  generate: function generate(options) {
52401    throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
52402  },
52403
52404  /**
52405   * Generate the complete zip file as an internal stream.
52406   * @param {Object} options the options to generate the zip file :
52407   * - compression, "STORE" by default.
52408   * - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
52409   * @return {StreamHelper} the streamed zip file.
52410   */
52411  generateInternalStream: function generateInternalStream(options) {
52412    var worker,
52413        opts = {};
52414
52415    try {
52416      opts = utils.extend(options || {}, {
52417        streamFiles: false,
52418        compression: "STORE",
52419        compressionOptions: null,
52420        type: "",
52421        platform: "DOS",
52422        comment: null,
52423        mimeType: 'application/zip',
52424        encodeFileName: utf8.utf8encode
52425      });
52426      opts.type = opts.type.toLowerCase();
52427      opts.compression = opts.compression.toUpperCase(); // "binarystring" is preferred but the internals use "string".
52428
52429      if (opts.type === "binarystring") {
52430        opts.type = "string";
52431      }
52432
52433      if (!opts.type) {
52434        throw new Error("No output type specified.");
52435      }
52436
52437      utils.checkSupport(opts.type); // accept nodejs `process.platform`
52438
52439      if (opts.platform === 'darwin' || opts.platform === 'freebsd' || opts.platform === 'linux' || opts.platform === 'sunos') {
52440        opts.platform = "UNIX";
52441      }
52442
52443      if (opts.platform === 'win32') {
52444        opts.platform = "DOS";
52445      }
52446
52447      var comment = opts.comment || this.comment || "";
52448      worker = generate.generateWorker(this, opts, comment);
52449    } catch (e) {
52450      worker = new GenericWorker("error");
52451      worker.error(e);
52452    }
52453
52454    return new StreamHelper(worker, opts.type || "string", opts.mimeType);
52455  },
52456
52457  /**
52458   * Generate the complete zip file asynchronously.
52459   * @see generateInternalStream
52460   */
52461  generateAsync: function generateAsync(options, onUpdate) {
52462    return this.generateInternalStream(options).accumulate(onUpdate);
52463  },
52464
52465  /**
52466   * Generate the complete zip file asynchronously.
52467   * @see generateInternalStream
52468   */
52469  generateNodeStream: function generateNodeStream(options, onUpdate) {
52470    options = options || {};
52471
52472    if (!options.type) {
52473      options.type = "nodebuffer";
52474    }
52475
52476    return this.generateInternalStream(options).toNodejsStream(onUpdate);
52477  }
52478};
52479module.exports = out;
52480
52481},{"./compressedObject":391,"./defaults":394,"./generate":398,"./nodejs/NodejsStreamInputAdapter":401,"./nodejsUtils":403,"./stream/GenericWorker":417,"./stream/StreamHelper":418,"./utf8":420,"./utils":421,"./zipObject":424}],405:[function(require,module,exports){
52482"use strict";
52483
52484/*
52485 * This file is used by module bundlers (browserify/webpack/etc) when
52486 * including a stream implementation. We use "readable-stream" to get a
52487 * consistent behavior between nodejs versions but bundlers often have a shim
52488 * for "stream". Using this shim greatly improve the compatibility and greatly
52489 * reduce the final size of the bundle (only one stream implementation, not
52490 * two).
52491 */
52492module.exports = require("stream");
52493
52494},{"stream":506}],406:[function(require,module,exports){
52495'use strict';
52496
52497var DataReader = require('./DataReader');
52498
52499var utils = require('../utils');
52500
52501function ArrayReader(data) {
52502  DataReader.call(this, data);
52503
52504  for (var i = 0; i < this.data.length; i++) {
52505    data[i] = data[i] & 0xFF;
52506  }
52507}
52508
52509utils.inherits(ArrayReader, DataReader);
52510/**
52511 * @see DataReader.byteAt
52512 */
52513
52514ArrayReader.prototype.byteAt = function (i) {
52515  return this.data[this.zero + i];
52516};
52517/**
52518 * @see DataReader.lastIndexOfSignature
52519 */
52520
52521
52522ArrayReader.prototype.lastIndexOfSignature = function (sig) {
52523  var sig0 = sig.charCodeAt(0),
52524      sig1 = sig.charCodeAt(1),
52525      sig2 = sig.charCodeAt(2),
52526      sig3 = sig.charCodeAt(3);
52527
52528  for (var i = this.length - 4; i >= 0; --i) {
52529    if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {
52530      return i - this.zero;
52531    }
52532  }
52533
52534  return -1;
52535};
52536/**
52537 * @see DataReader.readAndCheckSignature
52538 */
52539
52540
52541ArrayReader.prototype.readAndCheckSignature = function (sig) {
52542  var sig0 = sig.charCodeAt(0),
52543      sig1 = sig.charCodeAt(1),
52544      sig2 = sig.charCodeAt(2),
52545      sig3 = sig.charCodeAt(3),
52546      data = this.readData(4);
52547  return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3];
52548};
52549/**
52550 * @see DataReader.readData
52551 */
52552
52553
52554ArrayReader.prototype.readData = function (size) {
52555  this.checkOffset(size);
52556
52557  if (size === 0) {
52558    return [];
52559  }
52560
52561  var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
52562  this.index += size;
52563  return result;
52564};
52565
52566module.exports = ArrayReader;
52567
52568},{"../utils":421,"./DataReader":407}],407:[function(require,module,exports){
52569'use strict';
52570
52571var utils = require('../utils');
52572
52573function DataReader(data) {
52574  this.data = data; // type : see implementation
52575
52576  this.length = data.length;
52577  this.index = 0;
52578  this.zero = 0;
52579}
52580
52581DataReader.prototype = {
52582  /**
52583   * Check that the offset will not go too far.
52584   * @param {string} offset the additional offset to check.
52585   * @throws {Error} an Error if the offset is out of bounds.
52586   */
52587  checkOffset: function checkOffset(offset) {
52588    this.checkIndex(this.index + offset);
52589  },
52590
52591  /**
52592   * Check that the specified index will not be too far.
52593   * @param {string} newIndex the index to check.
52594   * @throws {Error} an Error if the index is out of bounds.
52595   */
52596  checkIndex: function checkIndex(newIndex) {
52597    if (this.length < this.zero + newIndex || newIndex < 0) {
52598      throw new Error("End of data reached (data length = " + this.length + ", asked index = " + newIndex + "). Corrupted zip ?");
52599    }
52600  },
52601
52602  /**
52603   * Change the index.
52604   * @param {number} newIndex The new index.
52605   * @throws {Error} if the new index is out of the data.
52606   */
52607  setIndex: function setIndex(newIndex) {
52608    this.checkIndex(newIndex);
52609    this.index = newIndex;
52610  },
52611
52612  /**
52613   * Skip the next n bytes.
52614   * @param {number} n the number of bytes to skip.
52615   * @throws {Error} if the new index is out of the data.
52616   */
52617  skip: function skip(n) {
52618    this.setIndex(this.index + n);
52619  },
52620
52621  /**
52622   * Get the byte at the specified index.
52623   * @param {number} i the index to use.
52624   * @return {number} a byte.
52625   */
52626  byteAt: function byteAt(i) {// see implementations
52627  },
52628
52629  /**
52630   * Get the next number with a given byte size.
52631   * @param {number} size the number of bytes to read.
52632   * @return {number} the corresponding number.
52633   */
52634  readInt: function readInt(size) {
52635    var result = 0,
52636        i;
52637    this.checkOffset(size);
52638
52639    for (i = this.index + size - 1; i >= this.index; i--) {
52640      result = (result << 8) + this.byteAt(i);
52641    }
52642
52643    this.index += size;
52644    return result;
52645  },
52646
52647  /**
52648   * Get the next string with a given byte size.
52649   * @param {number} size the number of bytes to read.
52650   * @return {string} the corresponding string.
52651   */
52652  readString: function readString(size) {
52653    return utils.transformTo("string", this.readData(size));
52654  },
52655
52656  /**
52657   * Get raw data without conversion, <size> bytes.
52658   * @param {number} size the number of bytes to read.
52659   * @return {Object} the raw data, implementation specific.
52660   */
52661  readData: function readData(size) {// see implementations
52662  },
52663
52664  /**
52665   * Find the last occurrence of a zip signature (4 bytes).
52666   * @param {string} sig the signature to find.
52667   * @return {number} the index of the last occurrence, -1 if not found.
52668   */
52669  lastIndexOfSignature: function lastIndexOfSignature(sig) {// see implementations
52670  },
52671
52672  /**
52673   * Read the signature (4 bytes) at the current position and compare it with sig.
52674   * @param {string} sig the expected signature
52675   * @return {boolean} true if the signature matches, false otherwise.
52676   */
52677  readAndCheckSignature: function readAndCheckSignature(sig) {// see implementations
52678  },
52679
52680  /**
52681   * Get the next date.
52682   * @return {Date} the date.
52683   */
52684  readDate: function readDate() {
52685    var dostime = this.readInt(4);
52686    return new Date(Date.UTC((dostime >> 25 & 0x7f) + 1980, // year
52687    (dostime >> 21 & 0x0f) - 1, // month
52688    dostime >> 16 & 0x1f, // day
52689    dostime >> 11 & 0x1f, // hour
52690    dostime >> 5 & 0x3f, // minute
52691    (dostime & 0x1f) << 1)); // second
52692  }
52693};
52694module.exports = DataReader;
52695
52696},{"../utils":421}],408:[function(require,module,exports){
52697'use strict';
52698
52699var Uint8ArrayReader = require('./Uint8ArrayReader');
52700
52701var utils = require('../utils');
52702
52703function NodeBufferReader(data) {
52704  Uint8ArrayReader.call(this, data);
52705}
52706
52707utils.inherits(NodeBufferReader, Uint8ArrayReader);
52708/**
52709 * @see DataReader.readData
52710 */
52711
52712NodeBufferReader.prototype.readData = function (size) {
52713  this.checkOffset(size);
52714  var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
52715  this.index += size;
52716  return result;
52717};
52718
52719module.exports = NodeBufferReader;
52720
52721},{"../utils":421,"./Uint8ArrayReader":410}],409:[function(require,module,exports){
52722'use strict';
52723
52724var DataReader = require('./DataReader');
52725
52726var utils = require('../utils');
52727
52728function StringReader(data) {
52729  DataReader.call(this, data);
52730}
52731
52732utils.inherits(StringReader, DataReader);
52733/**
52734 * @see DataReader.byteAt
52735 */
52736
52737StringReader.prototype.byteAt = function (i) {
52738  return this.data.charCodeAt(this.zero + i);
52739};
52740/**
52741 * @see DataReader.lastIndexOfSignature
52742 */
52743
52744
52745StringReader.prototype.lastIndexOfSignature = function (sig) {
52746  return this.data.lastIndexOf(sig) - this.zero;
52747};
52748/**
52749 * @see DataReader.readAndCheckSignature
52750 */
52751
52752
52753StringReader.prototype.readAndCheckSignature = function (sig) {
52754  var data = this.readData(4);
52755  return sig === data;
52756};
52757/**
52758 * @see DataReader.readData
52759 */
52760
52761
52762StringReader.prototype.readData = function (size) {
52763  this.checkOffset(size); // this will work because the constructor applied the "& 0xff" mask.
52764
52765  var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
52766  this.index += size;
52767  return result;
52768};
52769
52770module.exports = StringReader;
52771
52772},{"../utils":421,"./DataReader":407}],410:[function(require,module,exports){
52773'use strict';
52774
52775var ArrayReader = require('./ArrayReader');
52776
52777var utils = require('../utils');
52778
52779function Uint8ArrayReader(data) {
52780  ArrayReader.call(this, data);
52781}
52782
52783utils.inherits(Uint8ArrayReader, ArrayReader);
52784/**
52785 * @see DataReader.readData
52786 */
52787
52788Uint8ArrayReader.prototype.readData = function (size) {
52789  this.checkOffset(size);
52790
52791  if (size === 0) {
52792    // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].
52793    return new Uint8Array(0);
52794  }
52795
52796  var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);
52797  this.index += size;
52798  return result;
52799};
52800
52801module.exports = Uint8ArrayReader;
52802
52803},{"../utils":421,"./ArrayReader":406}],411:[function(require,module,exports){
52804'use strict';
52805
52806var utils = require('../utils');
52807
52808var support = require('../support');
52809
52810var ArrayReader = require('./ArrayReader');
52811
52812var StringReader = require('./StringReader');
52813
52814var NodeBufferReader = require('./NodeBufferReader');
52815
52816var Uint8ArrayReader = require('./Uint8ArrayReader');
52817/**
52818 * Create a reader adapted to the data.
52819 * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read.
52820 * @return {DataReader} the data reader.
52821 */
52822
52823
52824module.exports = function (data) {
52825  var type = utils.getTypeOf(data);
52826  utils.checkSupport(type);
52827
52828  if (type === "string" && !support.uint8array) {
52829    return new StringReader(data);
52830  }
52831
52832  if (type === "nodebuffer") {
52833    return new NodeBufferReader(data);
52834  }
52835
52836  if (support.uint8array) {
52837    return new Uint8ArrayReader(utils.transformTo("uint8array", data));
52838  }
52839
52840  return new ArrayReader(utils.transformTo("array", data));
52841};
52842
52843},{"../support":419,"../utils":421,"./ArrayReader":406,"./NodeBufferReader":408,"./StringReader":409,"./Uint8ArrayReader":410}],412:[function(require,module,exports){
52844'use strict';
52845
52846exports.LOCAL_FILE_HEADER = "PK\x03\x04";
52847exports.CENTRAL_FILE_HEADER = "PK\x01\x02";
52848exports.CENTRAL_DIRECTORY_END = "PK\x05\x06";
52849exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07";
52850exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06";
52851exports.DATA_DESCRIPTOR = "PK\x07\x08";
52852
52853},{}],413:[function(require,module,exports){
52854'use strict';
52855
52856var GenericWorker = require('./GenericWorker');
52857
52858var utils = require('../utils');
52859/**
52860 * A worker which convert chunks to a specified type.
52861 * @constructor
52862 * @param {String} destType the destination type.
52863 */
52864
52865
52866function ConvertWorker(destType) {
52867  GenericWorker.call(this, "ConvertWorker to " + destType);
52868  this.destType = destType;
52869}
52870
52871utils.inherits(ConvertWorker, GenericWorker);
52872/**
52873 * @see GenericWorker.processChunk
52874 */
52875
52876ConvertWorker.prototype.processChunk = function (chunk) {
52877  this.push({
52878    data: utils.transformTo(this.destType, chunk.data),
52879    meta: chunk.meta
52880  });
52881};
52882
52883module.exports = ConvertWorker;
52884
52885},{"../utils":421,"./GenericWorker":417}],414:[function(require,module,exports){
52886'use strict';
52887
52888var GenericWorker = require('./GenericWorker');
52889
52890var crc32 = require('../crc32');
52891
52892var utils = require('../utils');
52893/**
52894 * A worker which calculate the crc32 of the data flowing through.
52895 * @constructor
52896 */
52897
52898
52899function Crc32Probe() {
52900  GenericWorker.call(this, "Crc32Probe");
52901  this.withStreamInfo("crc32", 0);
52902}
52903
52904utils.inherits(Crc32Probe, GenericWorker);
52905/**
52906 * @see GenericWorker.processChunk
52907 */
52908
52909Crc32Probe.prototype.processChunk = function (chunk) {
52910  this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);
52911  this.push(chunk);
52912};
52913
52914module.exports = Crc32Probe;
52915
52916},{"../crc32":393,"../utils":421,"./GenericWorker":417}],415:[function(require,module,exports){
52917'use strict';
52918
52919var utils = require('../utils');
52920
52921var GenericWorker = require('./GenericWorker');
52922/**
52923 * A worker which calculate the total length of the data flowing through.
52924 * @constructor
52925 * @param {String} propName the name used to expose the length
52926 */
52927
52928
52929function DataLengthProbe(propName) {
52930  GenericWorker.call(this, "DataLengthProbe for " + propName);
52931  this.propName = propName;
52932  this.withStreamInfo(propName, 0);
52933}
52934
52935utils.inherits(DataLengthProbe, GenericWorker);
52936/**
52937 * @see GenericWorker.processChunk
52938 */
52939
52940DataLengthProbe.prototype.processChunk = function (chunk) {
52941  if (chunk) {
52942    var length = this.streamInfo[this.propName] || 0;
52943    this.streamInfo[this.propName] = length + chunk.data.length;
52944  }
52945
52946  GenericWorker.prototype.processChunk.call(this, chunk);
52947};
52948
52949module.exports = DataLengthProbe;
52950
52951},{"../utils":421,"./GenericWorker":417}],416:[function(require,module,exports){
52952'use strict';
52953
52954var utils = require('../utils');
52955
52956var GenericWorker = require('./GenericWorker'); // the size of the generated chunks
52957// TODO expose this as a public variable
52958
52959
52960var DEFAULT_BLOCK_SIZE = 16 * 1024;
52961/**
52962 * A worker that reads a content and emits chunks.
52963 * @constructor
52964 * @param {Promise} dataP the promise of the data to split
52965 */
52966
52967function DataWorker(dataP) {
52968  GenericWorker.call(this, "DataWorker");
52969  var self = this;
52970  this.dataIsReady = false;
52971  this.index = 0;
52972  this.max = 0;
52973  this.data = null;
52974  this.type = "";
52975  this._tickScheduled = false;
52976  dataP.then(function (data) {
52977    self.dataIsReady = true;
52978    self.data = data;
52979    self.max = data && data.length || 0;
52980    self.type = utils.getTypeOf(data);
52981
52982    if (!self.isPaused) {
52983      self._tickAndRepeat();
52984    }
52985  }, function (e) {
52986    self.error(e);
52987  });
52988}
52989
52990utils.inherits(DataWorker, GenericWorker);
52991/**
52992 * @see GenericWorker.cleanUp
52993 */
52994
52995DataWorker.prototype.cleanUp = function () {
52996  GenericWorker.prototype.cleanUp.call(this);
52997  this.data = null;
52998};
52999/**
53000 * @see GenericWorker.resume
53001 */
53002
53003
53004DataWorker.prototype.resume = function () {
53005  if (!GenericWorker.prototype.resume.call(this)) {
53006    return false;
53007  }
53008
53009  if (!this._tickScheduled && this.dataIsReady) {
53010    this._tickScheduled = true;
53011    utils.delay(this._tickAndRepeat, [], this);
53012  }
53013
53014  return true;
53015};
53016/**
53017 * Trigger a tick a schedule an other call to this function.
53018 */
53019
53020
53021DataWorker.prototype._tickAndRepeat = function () {
53022  this._tickScheduled = false;
53023
53024  if (this.isPaused || this.isFinished) {
53025    return;
53026  }
53027
53028  this._tick();
53029
53030  if (!this.isFinished) {
53031    utils.delay(this._tickAndRepeat, [], this);
53032    this._tickScheduled = true;
53033  }
53034};
53035/**
53036 * Read and push a chunk.
53037 */
53038
53039
53040DataWorker.prototype._tick = function () {
53041  if (this.isPaused || this.isFinished) {
53042    return false;
53043  }
53044
53045  var size = DEFAULT_BLOCK_SIZE;
53046  var data = null,
53047      nextIndex = Math.min(this.max, this.index + size);
53048
53049  if (this.index >= this.max) {
53050    // EOF
53051    return this.end();
53052  } else {
53053    switch (this.type) {
53054      case "string":
53055        data = this.data.substring(this.index, nextIndex);
53056        break;
53057
53058      case "uint8array":
53059        data = this.data.subarray(this.index, nextIndex);
53060        break;
53061
53062      case "array":
53063      case "nodebuffer":
53064        data = this.data.slice(this.index, nextIndex);
53065        break;
53066    }
53067
53068    this.index = nextIndex;
53069    return this.push({
53070      data: data,
53071      meta: {
53072        percent: this.max ? this.index / this.max * 100 : 0
53073      }
53074    });
53075  }
53076};
53077
53078module.exports = DataWorker;
53079
53080},{"../utils":421,"./GenericWorker":417}],417:[function(require,module,exports){
53081'use strict';
53082/**
53083 * A worker that does nothing but passing chunks to the next one. This is like
53084 * a nodejs stream but with some differences. On the good side :
53085 * - it works on IE 6-9 without any issue / polyfill
53086 * - it weights less than the full dependencies bundled with browserify
53087 * - it forwards errors (no need to declare an error handler EVERYWHERE)
53088 *
53089 * A chunk is an object with 2 attributes : `meta` and `data`. The former is an
53090 * object containing anything (`percent` for example), see each worker for more
53091 * details. The latter is the real data (String, Uint8Array, etc).
53092 *
53093 * @constructor
53094 * @param {String} name the name of the stream (mainly used for debugging purposes)
53095 */
53096
53097function GenericWorker(name) {
53098  // the name of the worker
53099  this.name = name || "default"; // an object containing metadata about the workers chain
53100
53101  this.streamInfo = {}; // an error which happened when the worker was paused
53102
53103  this.generatedError = null; // an object containing metadata to be merged by this worker into the general metadata
53104
53105  this.extraStreamInfo = {}; // true if the stream is paused (and should not do anything), false otherwise
53106
53107  this.isPaused = true; // true if the stream is finished (and should not do anything), false otherwise
53108
53109  this.isFinished = false; // true if the stream is locked to prevent further structure updates (pipe), false otherwise
53110
53111  this.isLocked = false; // the event listeners
53112
53113  this._listeners = {
53114    'data': [],
53115    'end': [],
53116    'error': []
53117  }; // the previous worker, if any
53118
53119  this.previous = null;
53120}
53121
53122GenericWorker.prototype = {
53123  /**
53124   * Push a chunk to the next workers.
53125   * @param {Object} chunk the chunk to push
53126   */
53127  push: function push(chunk) {
53128    this.emit("data", chunk);
53129  },
53130
53131  /**
53132   * End the stream.
53133   * @return {Boolean} true if this call ended the worker, false otherwise.
53134   */
53135  end: function end() {
53136    if (this.isFinished) {
53137      return false;
53138    }
53139
53140    this.flush();
53141
53142    try {
53143      this.emit("end");
53144      this.cleanUp();
53145      this.isFinished = true;
53146    } catch (e) {
53147      this.emit("error", e);
53148    }
53149
53150    return true;
53151  },
53152
53153  /**
53154   * End the stream with an error.
53155   * @param {Error} e the error which caused the premature end.
53156   * @return {Boolean} true if this call ended the worker with an error, false otherwise.
53157   */
53158  error: function error(e) {
53159    if (this.isFinished) {
53160      return false;
53161    }
53162
53163    if (this.isPaused) {
53164      this.generatedError = e;
53165    } else {
53166      this.isFinished = true;
53167      this.emit("error", e); // in the workers chain exploded in the middle of the chain,
53168      // the error event will go downward but we also need to notify
53169      // workers upward that there has been an error.
53170
53171      if (this.previous) {
53172        this.previous.error(e);
53173      }
53174
53175      this.cleanUp();
53176    }
53177
53178    return true;
53179  },
53180
53181  /**
53182   * Add a callback on an event.
53183   * @param {String} name the name of the event (data, end, error)
53184   * @param {Function} listener the function to call when the event is triggered
53185   * @return {GenericWorker} the current object for chainability
53186   */
53187  on: function on(name, listener) {
53188    this._listeners[name].push(listener);
53189
53190    return this;
53191  },
53192
53193  /**
53194   * Clean any references when a worker is ending.
53195   */
53196  cleanUp: function cleanUp() {
53197    this.streamInfo = this.generatedError = this.extraStreamInfo = null;
53198    this._listeners = [];
53199  },
53200
53201  /**
53202   * Trigger an event. This will call registered callback with the provided arg.
53203   * @param {String} name the name of the event (data, end, error)
53204   * @param {Object} arg the argument to call the callback with.
53205   */
53206  emit: function emit(name, arg) {
53207    if (this._listeners[name]) {
53208      for (var i = 0; i < this._listeners[name].length; i++) {
53209        this._listeners[name][i].call(this, arg);
53210      }
53211    }
53212  },
53213
53214  /**
53215   * Chain a worker with an other.
53216   * @param {Worker} next the worker receiving events from the current one.
53217   * @return {worker} the next worker for chainability
53218   */
53219  pipe: function pipe(next) {
53220    return next.registerPrevious(this);
53221  },
53222
53223  /**
53224   * Same as `pipe` in the other direction.
53225   * Using an API with `pipe(next)` is very easy.
53226   * Implementing the API with the point of view of the next one registering
53227   * a source is easier, see the ZipFileWorker.
53228   * @param {Worker} previous the previous worker, sending events to this one
53229   * @return {Worker} the current worker for chainability
53230   */
53231  registerPrevious: function registerPrevious(previous) {
53232    if (this.isLocked) {
53233      throw new Error("The stream '" + this + "' has already been used.");
53234    } // sharing the streamInfo...
53235
53236
53237    this.streamInfo = previous.streamInfo; // ... and adding our own bits
53238
53239    this.mergeStreamInfo();
53240    this.previous = previous;
53241    var self = this;
53242    previous.on('data', function (chunk) {
53243      self.processChunk(chunk);
53244    });
53245    previous.on('end', function () {
53246      self.end();
53247    });
53248    previous.on('error', function (e) {
53249      self.error(e);
53250    });
53251    return this;
53252  },
53253
53254  /**
53255   * Pause the stream so it doesn't send events anymore.
53256   * @return {Boolean} true if this call paused the worker, false otherwise.
53257   */
53258  pause: function pause() {
53259    if (this.isPaused || this.isFinished) {
53260      return false;
53261    }
53262
53263    this.isPaused = true;
53264
53265    if (this.previous) {
53266      this.previous.pause();
53267    }
53268
53269    return true;
53270  },
53271
53272  /**
53273   * Resume a paused stream.
53274   * @return {Boolean} true if this call resumed the worker, false otherwise.
53275   */
53276  resume: function resume() {
53277    if (!this.isPaused || this.isFinished) {
53278      return false;
53279    }
53280
53281    this.isPaused = false; // if true, the worker tried to resume but failed
53282
53283    var withError = false;
53284
53285    if (this.generatedError) {
53286      this.error(this.generatedError);
53287      withError = true;
53288    }
53289
53290    if (this.previous) {
53291      this.previous.resume();
53292    }
53293
53294    return !withError;
53295  },
53296
53297  /**
53298   * Flush any remaining bytes as the stream is ending.
53299   */
53300  flush: function flush() {},
53301
53302  /**
53303   * Process a chunk. This is usually the method overridden.
53304   * @param {Object} chunk the chunk to process.
53305   */
53306  processChunk: function processChunk(chunk) {
53307    this.push(chunk);
53308  },
53309
53310  /**
53311   * Add a key/value to be added in the workers chain streamInfo once activated.
53312   * @param {String} key the key to use
53313   * @param {Object} value the associated value
53314   * @return {Worker} the current worker for chainability
53315   */
53316  withStreamInfo: function withStreamInfo(key, value) {
53317    this.extraStreamInfo[key] = value;
53318    this.mergeStreamInfo();
53319    return this;
53320  },
53321
53322  /**
53323   * Merge this worker's streamInfo into the chain's streamInfo.
53324   */
53325  mergeStreamInfo: function mergeStreamInfo() {
53326    for (var key in this.extraStreamInfo) {
53327      if (!this.extraStreamInfo.hasOwnProperty(key)) {
53328        continue;
53329      }
53330
53331      this.streamInfo[key] = this.extraStreamInfo[key];
53332    }
53333  },
53334
53335  /**
53336   * Lock the stream to prevent further updates on the workers chain.
53337   * After calling this method, all calls to pipe will fail.
53338   */
53339  lock: function lock() {
53340    if (this.isLocked) {
53341      throw new Error("The stream '" + this + "' has already been used.");
53342    }
53343
53344    this.isLocked = true;
53345
53346    if (this.previous) {
53347      this.previous.lock();
53348    }
53349  },
53350
53351  /**
53352   *
53353   * Pretty print the workers chain.
53354   */
53355  toString: function toString() {
53356    var me = "Worker " + this.name;
53357
53358    if (this.previous) {
53359      return this.previous + " -> " + me;
53360    } else {
53361      return me;
53362    }
53363  }
53364};
53365module.exports = GenericWorker;
53366
53367},{}],418:[function(require,module,exports){
53368(function (Buffer){
53369'use strict';
53370
53371var utils = require('../utils');
53372
53373var ConvertWorker = require('./ConvertWorker');
53374
53375var GenericWorker = require('./GenericWorker');
53376
53377var base64 = require('../base64');
53378
53379var support = require("../support");
53380
53381var external = require("../external");
53382
53383var NodejsStreamOutputAdapter = null;
53384
53385if (support.nodestream) {
53386  try {
53387    NodejsStreamOutputAdapter = require('../nodejs/NodejsStreamOutputAdapter');
53388  } catch (e) {}
53389}
53390/**
53391 * Apply the final transformation of the data. If the user wants a Blob for
53392 * example, it's easier to work with an U8intArray and finally do the
53393 * ArrayBuffer/Blob conversion.
53394 * @param {String} type the name of the final type
53395 * @param {String|Uint8Array|Buffer} content the content to transform
53396 * @param {String} mimeType the mime type of the content, if applicable.
53397 * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the content in the right format.
53398 */
53399
53400
53401function transformZipOutput(type, content, mimeType) {
53402  switch (type) {
53403    case "blob":
53404      return utils.newBlob(utils.transformTo("arraybuffer", content), mimeType);
53405
53406    case "base64":
53407      return base64.encode(content);
53408
53409    default:
53410      return utils.transformTo(type, content);
53411  }
53412}
53413/**
53414 * Concatenate an array of data of the given type.
53415 * @param {String} type the type of the data in the given array.
53416 * @param {Array} dataArray the array containing the data chunks to concatenate
53417 * @return {String|Uint8Array|Buffer} the concatenated data
53418 * @throws Error if the asked type is unsupported
53419 */
53420
53421
53422function concat(type, dataArray) {
53423  var i,
53424      index = 0,
53425      res = null,
53426      totalLength = 0;
53427
53428  for (i = 0; i < dataArray.length; i++) {
53429    totalLength += dataArray[i].length;
53430  }
53431
53432  switch (type) {
53433    case "string":
53434      return dataArray.join("");
53435
53436    case "array":
53437      return Array.prototype.concat.apply([], dataArray);
53438
53439    case "uint8array":
53440      res = new Uint8Array(totalLength);
53441
53442      for (i = 0; i < dataArray.length; i++) {
53443        res.set(dataArray[i], index);
53444        index += dataArray[i].length;
53445      }
53446
53447      return res;
53448
53449    case "nodebuffer":
53450      return Buffer.concat(dataArray);
53451
53452    default:
53453      throw new Error("concat : unsupported type '" + type + "'");
53454  }
53455}
53456/**
53457 * Listen a StreamHelper, accumulate its content and concatenate it into a
53458 * complete block.
53459 * @param {StreamHelper} helper the helper to use.
53460 * @param {Function} updateCallback a callback called on each update. Called
53461 * with one arg :
53462 * - the metadata linked to the update received.
53463 * @return Promise the promise for the accumulation.
53464 */
53465
53466
53467function _accumulate(helper, updateCallback) {
53468  return new external.Promise(function (resolve, reject) {
53469    var dataArray = [];
53470    var chunkType = helper._internalType,
53471        resultType = helper._outputType,
53472        mimeType = helper._mimeType;
53473    helper.on('data', function (data, meta) {
53474      dataArray.push(data);
53475
53476      if (updateCallback) {
53477        updateCallback(meta);
53478      }
53479    }).on('error', function (err) {
53480      dataArray = [];
53481      reject(err);
53482    }).on('end', function () {
53483      try {
53484        var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);
53485        resolve(result);
53486      } catch (e) {
53487        reject(e);
53488      }
53489
53490      dataArray = [];
53491    }).resume();
53492  });
53493}
53494/**
53495 * An helper to easily use workers outside of JSZip.
53496 * @constructor
53497 * @param {Worker} worker the worker to wrap
53498 * @param {String} outputType the type of data expected by the use
53499 * @param {String} mimeType the mime type of the content, if applicable.
53500 */
53501
53502
53503function StreamHelper(worker, outputType, mimeType) {
53504  var internalType = outputType;
53505
53506  switch (outputType) {
53507    case "blob":
53508    case "arraybuffer":
53509      internalType = "uint8array";
53510      break;
53511
53512    case "base64":
53513      internalType = "string";
53514      break;
53515  }
53516
53517  try {
53518    // the type used internally
53519    this._internalType = internalType; // the type used to output results
53520
53521    this._outputType = outputType; // the mime type
53522
53523    this._mimeType = mimeType;
53524    utils.checkSupport(internalType);
53525    this._worker = worker.pipe(new ConvertWorker(internalType)); // the last workers can be rewired without issues but we need to
53526    // prevent any updates on previous workers.
53527
53528    worker.lock();
53529  } catch (e) {
53530    this._worker = new GenericWorker("error");
53531
53532    this._worker.error(e);
53533  }
53534}
53535
53536StreamHelper.prototype = {
53537  /**
53538   * Listen a StreamHelper, accumulate its content and concatenate it into a
53539   * complete block.
53540   * @param {Function} updateCb the update callback.
53541   * @return Promise the promise for the accumulation.
53542   */
53543  accumulate: function accumulate(updateCb) {
53544    return _accumulate(this, updateCb);
53545  },
53546
53547  /**
53548   * Add a listener on an event triggered on a stream.
53549   * @param {String} evt the name of the event
53550   * @param {Function} fn the listener
53551   * @return {StreamHelper} the current helper.
53552   */
53553  on: function on(evt, fn) {
53554    var self = this;
53555
53556    if (evt === "data") {
53557      this._worker.on(evt, function (chunk) {
53558        fn.call(self, chunk.data, chunk.meta);
53559      });
53560    } else {
53561      this._worker.on(evt, function () {
53562        utils.delay(fn, arguments, self);
53563      });
53564    }
53565
53566    return this;
53567  },
53568
53569  /**
53570   * Resume the flow of chunks.
53571   * @return {StreamHelper} the current helper.
53572   */
53573  resume: function resume() {
53574    utils.delay(this._worker.resume, [], this._worker);
53575    return this;
53576  },
53577
53578  /**
53579   * Pause the flow of chunks.
53580   * @return {StreamHelper} the current helper.
53581   */
53582  pause: function pause() {
53583    this._worker.pause();
53584
53585    return this;
53586  },
53587
53588  /**
53589   * Return a nodejs stream for this helper.
53590   * @param {Function} updateCb the update callback.
53591   * @return {NodejsStreamOutputAdapter} the nodejs stream.
53592   */
53593  toNodejsStream: function toNodejsStream(updateCb) {
53594    utils.checkSupport("nodestream");
53595
53596    if (this._outputType !== "nodebuffer") {
53597      // an object stream containing blob/arraybuffer/uint8array/string
53598      // is strange and I don't know if it would be useful.
53599      // I you find this comment and have a good usecase, please open a
53600      // bug report !
53601      throw new Error(this._outputType + " is not supported by this method");
53602    }
53603
53604    return new NodejsStreamOutputAdapter(this, {
53605      objectMode: this._outputType !== "nodebuffer"
53606    }, updateCb);
53607  }
53608};
53609module.exports = StreamHelper;
53610
53611}).call(this,require("buffer").Buffer)
53612
53613},{"../base64":390,"../external":395,"../nodejs/NodejsStreamOutputAdapter":402,"../support":419,"../utils":421,"./ConvertWorker":413,"./GenericWorker":417,"buffer":216}],419:[function(require,module,exports){
53614(function (Buffer){
53615'use strict';
53616
53617exports.base64 = true;
53618exports.array = true;
53619exports.string = true;
53620exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
53621exports.nodebuffer = typeof Buffer !== "undefined"; // contains true if JSZip can read/generate Uint8Array, false otherwise.
53622
53623exports.uint8array = typeof Uint8Array !== "undefined";
53624
53625if (typeof ArrayBuffer === "undefined") {
53626  exports.blob = false;
53627} else {
53628  var buffer = new ArrayBuffer(0);
53629
53630  try {
53631    exports.blob = new Blob([buffer], {
53632      type: "application/zip"
53633    }).size === 0;
53634  } catch (e) {
53635    try {
53636      var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
53637      var builder = new Builder();
53638      builder.append(buffer);
53639      exports.blob = builder.getBlob('application/zip').size === 0;
53640    } catch (e) {
53641      exports.blob = false;
53642    }
53643  }
53644}
53645
53646try {
53647  exports.nodestream = !!require('readable-stream').Readable;
53648} catch (e) {
53649  exports.nodestream = false;
53650}
53651
53652}).call(this,require("buffer").Buffer)
53653
53654},{"buffer":216,"readable-stream":405}],420:[function(require,module,exports){
53655'use strict';
53656
53657var utils = require('./utils');
53658
53659var support = require('./support');
53660
53661var nodejsUtils = require('./nodejsUtils');
53662
53663var GenericWorker = require('./stream/GenericWorker');
53664/**
53665 * The following functions come from pako, from pako/lib/utils/strings
53666 * released under the MIT license, see pako https://github.com/nodeca/pako/
53667 */
53668// Table with utf8 lengths (calculated by first byte of sequence)
53669// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
53670// because max possible codepoint is 0x10ffff
53671
53672
53673var _utf8len = new Array(256);
53674
53675for (var i = 0; i < 256; i++) {
53676  _utf8len[i] = i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1;
53677}
53678
53679_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
53680// convert string to array (typed, when possible)
53681
53682var string2buf = function string2buf(str) {
53683  var buf,
53684      c,
53685      c2,
53686      m_pos,
53687      i,
53688      str_len = str.length,
53689      buf_len = 0; // count binary size
53690
53691  for (m_pos = 0; m_pos < str_len; m_pos++) {
53692    c = str.charCodeAt(m_pos);
53693
53694    if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {
53695      c2 = str.charCodeAt(m_pos + 1);
53696
53697      if ((c2 & 0xfc00) === 0xdc00) {
53698        c = 0x10000 + (c - 0xd800 << 10) + (c2 - 0xdc00);
53699        m_pos++;
53700      }
53701    }
53702
53703    buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
53704  } // allocate buffer
53705
53706
53707  if (support.uint8array) {
53708    buf = new Uint8Array(buf_len);
53709  } else {
53710    buf = new Array(buf_len);
53711  } // convert
53712
53713
53714  for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
53715    c = str.charCodeAt(m_pos);
53716
53717    if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {
53718      c2 = str.charCodeAt(m_pos + 1);
53719
53720      if ((c2 & 0xfc00) === 0xdc00) {
53721        c = 0x10000 + (c - 0xd800 << 10) + (c2 - 0xdc00);
53722        m_pos++;
53723      }
53724    }
53725
53726    if (c < 0x80) {
53727      /* one byte */
53728      buf[i++] = c;
53729    } else if (c < 0x800) {
53730      /* two bytes */
53731      buf[i++] = 0xC0 | c >>> 6;
53732      buf[i++] = 0x80 | c & 0x3f;
53733    } else if (c < 0x10000) {
53734      /* three bytes */
53735      buf[i++] = 0xE0 | c >>> 12;
53736      buf[i++] = 0x80 | c >>> 6 & 0x3f;
53737      buf[i++] = 0x80 | c & 0x3f;
53738    } else {
53739      /* four bytes */
53740      buf[i++] = 0xf0 | c >>> 18;
53741      buf[i++] = 0x80 | c >>> 12 & 0x3f;
53742      buf[i++] = 0x80 | c >>> 6 & 0x3f;
53743      buf[i++] = 0x80 | c & 0x3f;
53744    }
53745  }
53746
53747  return buf;
53748}; // Calculate max possible position in utf8 buffer,
53749// that will not break sequence. If that's not possible
53750// - (very small limits) return max size as is.
53751//
53752// buf[] - utf8 bytes array
53753// max   - length limit (mandatory);
53754
53755
53756var utf8border = function utf8border(buf, max) {
53757  var pos;
53758  max = max || buf.length;
53759
53760  if (max > buf.length) {
53761    max = buf.length;
53762  } // go back from last position, until start of sequence found
53763
53764
53765  pos = max - 1;
53766
53767  while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) {
53768    pos--;
53769  } // Fuckup - very small and broken sequence,
53770  // return max, because we should return something anyway.
53771
53772
53773  if (pos < 0) {
53774    return max;
53775  } // If we came to start of buffer - that means vuffer is too small,
53776  // return max too.
53777
53778
53779  if (pos === 0) {
53780    return max;
53781  }
53782
53783  return pos + _utf8len[buf[pos]] > max ? pos : max;
53784}; // convert array to string
53785
53786
53787var buf2string = function buf2string(buf) {
53788  var str, i, out, c, c_len;
53789  var len = buf.length; // Reserve max possible length (2 words per char)
53790  // NB: by unknown reasons, Array is significantly faster for
53791  //     String.fromCharCode.apply than Uint16Array.
53792
53793  var utf16buf = new Array(len * 2);
53794
53795  for (out = 0, i = 0; i < len;) {
53796    c = buf[i++]; // quick process ascii
53797
53798    if (c < 0x80) {
53799      utf16buf[out++] = c;
53800      continue;
53801    }
53802
53803    c_len = _utf8len[c]; // skip 5 & 6 byte codes
53804
53805    if (c_len > 4) {
53806      utf16buf[out++] = 0xfffd;
53807      i += c_len - 1;
53808      continue;
53809    } // apply mask on first byte
53810
53811
53812    c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; // join the rest
53813
53814    while (c_len > 1 && i < len) {
53815      c = c << 6 | buf[i++] & 0x3f;
53816      c_len--;
53817    } // terminated by end of string?
53818
53819
53820    if (c_len > 1) {
53821      utf16buf[out++] = 0xfffd;
53822      continue;
53823    }
53824
53825    if (c < 0x10000) {
53826      utf16buf[out++] = c;
53827    } else {
53828      c -= 0x10000;
53829      utf16buf[out++] = 0xd800 | c >> 10 & 0x3ff;
53830      utf16buf[out++] = 0xdc00 | c & 0x3ff;
53831    }
53832  } // shrinkBuf(utf16buf, out)
53833
53834
53835  if (utf16buf.length !== out) {
53836    if (utf16buf.subarray) {
53837      utf16buf = utf16buf.subarray(0, out);
53838    } else {
53839      utf16buf.length = out;
53840    }
53841  } // return String.fromCharCode.apply(null, utf16buf);
53842
53843
53844  return utils.applyFromCharCode(utf16buf);
53845}; // That's all for the pako functions.
53846
53847/**
53848 * Transform a javascript string into an array (typed if possible) of bytes,
53849 * UTF-8 encoded.
53850 * @param {String} str the string to encode
53851 * @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.
53852 */
53853
53854
53855exports.utf8encode = function utf8encode(str) {
53856  if (support.nodebuffer) {
53857    return nodejsUtils.newBufferFrom(str, "utf-8");
53858  }
53859
53860  return string2buf(str);
53861};
53862/**
53863 * Transform a bytes array (or a representation) representing an UTF-8 encoded
53864 * string into a javascript string.
53865 * @param {Array|Uint8Array|Buffer} buf the data de decode
53866 * @return {String} the decoded string.
53867 */
53868
53869
53870exports.utf8decode = function utf8decode(buf) {
53871  if (support.nodebuffer) {
53872    return utils.transformTo("nodebuffer", buf).toString("utf-8");
53873  }
53874
53875  buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf);
53876  return buf2string(buf);
53877};
53878/**
53879 * A worker to decode utf8 encoded binary chunks into string chunks.
53880 * @constructor
53881 */
53882
53883
53884function Utf8DecodeWorker() {
53885  GenericWorker.call(this, "utf-8 decode"); // the last bytes if a chunk didn't end with a complete codepoint.
53886
53887  this.leftOver = null;
53888}
53889
53890utils.inherits(Utf8DecodeWorker, GenericWorker);
53891/**
53892 * @see GenericWorker.processChunk
53893 */
53894
53895Utf8DecodeWorker.prototype.processChunk = function (chunk) {
53896  var data = utils.transformTo(support.uint8array ? "uint8array" : "array", chunk.data); // 1st step, re-use what's left of the previous chunk
53897
53898  if (this.leftOver && this.leftOver.length) {
53899    if (support.uint8array) {
53900      var previousData = data;
53901      data = new Uint8Array(previousData.length + this.leftOver.length);
53902      data.set(this.leftOver, 0);
53903      data.set(previousData, this.leftOver.length);
53904    } else {
53905      data = this.leftOver.concat(data);
53906    }
53907
53908    this.leftOver = null;
53909  }
53910
53911  var nextBoundary = utf8border(data);
53912  var usableData = data;
53913
53914  if (nextBoundary !== data.length) {
53915    if (support.uint8array) {
53916      usableData = data.subarray(0, nextBoundary);
53917      this.leftOver = data.subarray(nextBoundary, data.length);
53918    } else {
53919      usableData = data.slice(0, nextBoundary);
53920      this.leftOver = data.slice(nextBoundary, data.length);
53921    }
53922  }
53923
53924  this.push({
53925    data: exports.utf8decode(usableData),
53926    meta: chunk.meta
53927  });
53928};
53929/**
53930 * @see GenericWorker.flush
53931 */
53932
53933
53934Utf8DecodeWorker.prototype.flush = function () {
53935  if (this.leftOver && this.leftOver.length) {
53936    this.push({
53937      data: exports.utf8decode(this.leftOver),
53938      meta: {}
53939    });
53940    this.leftOver = null;
53941  }
53942};
53943
53944exports.Utf8DecodeWorker = Utf8DecodeWorker;
53945/**
53946 * A worker to endcode string chunks into utf8 encoded binary chunks.
53947 * @constructor
53948 */
53949
53950function Utf8EncodeWorker() {
53951  GenericWorker.call(this, "utf-8 encode");
53952}
53953
53954utils.inherits(Utf8EncodeWorker, GenericWorker);
53955/**
53956 * @see GenericWorker.processChunk
53957 */
53958
53959Utf8EncodeWorker.prototype.processChunk = function (chunk) {
53960  this.push({
53961    data: exports.utf8encode(chunk.data),
53962    meta: chunk.meta
53963  });
53964};
53965
53966exports.Utf8EncodeWorker = Utf8EncodeWorker;
53967
53968},{"./nodejsUtils":403,"./stream/GenericWorker":417,"./support":419,"./utils":421}],421:[function(require,module,exports){
53969'use strict';
53970
53971var support = require('./support');
53972
53973var base64 = require('./base64');
53974
53975var nodejsUtils = require('./nodejsUtils');
53976
53977var setImmediate = require('set-immediate-shim');
53978
53979var external = require("./external");
53980/**
53981 * Convert a string that pass as a "binary string": it should represent a byte
53982 * array but may have > 255 char codes. Be sure to take only the first byte
53983 * and returns the byte array.
53984 * @param {String} str the string to transform.
53985 * @return {Array|Uint8Array} the string in a binary format.
53986 */
53987
53988
53989function string2binary(str) {
53990  var result = null;
53991
53992  if (support.uint8array) {
53993    result = new Uint8Array(str.length);
53994  } else {
53995    result = new Array(str.length);
53996  }
53997
53998  return stringToArrayLike(str, result);
53999}
54000/**
54001 * Create a new blob with the given content and the given type.
54002 * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use
54003 * an Uint8Array because the stock browser of android 4 won't accept it (it
54004 * will be silently converted to a string, "[object Uint8Array]").
54005 *
54006 * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:
54007 * when a large amount of Array is used to create the Blob, the amount of
54008 * memory consumed is nearly 100 times the original data amount.
54009 *
54010 * @param {String} type the mime type of the blob.
54011 * @return {Blob} the created blob.
54012 */
54013
54014
54015exports.newBlob = function (part, type) {
54016  exports.checkSupport("blob");
54017
54018  try {
54019    // Blob constructor
54020    return new Blob([part], {
54021      type: type
54022    });
54023  } catch (e) {
54024    try {
54025      // deprecated, browser only, old way
54026      var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
54027      var builder = new Builder();
54028      builder.append(part);
54029      return builder.getBlob(type);
54030    } catch (e) {
54031      // well, fuck ?!
54032      throw new Error("Bug : can't construct the Blob.");
54033    }
54034  }
54035};
54036/**
54037 * The identity function.
54038 * @param {Object} input the input.
54039 * @return {Object} the same input.
54040 */
54041
54042
54043function identity(input) {
54044  return input;
54045}
54046/**
54047 * Fill in an array with a string.
54048 * @param {String} str the string to use.
54049 * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).
54050 * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.
54051 */
54052
54053
54054function stringToArrayLike(str, array) {
54055  for (var i = 0; i < str.length; ++i) {
54056    array[i] = str.charCodeAt(i) & 0xFF;
54057  }
54058
54059  return array;
54060}
54061/**
54062 * An helper for the function arrayLikeToString.
54063 * This contains static information and functions that
54064 * can be optimized by the browser JIT compiler.
54065 */
54066
54067
54068var arrayToStringHelper = {
54069  /**
54070   * Transform an array of int into a string, chunk by chunk.
54071   * See the performances notes on arrayLikeToString.
54072   * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
54073   * @param {String} type the type of the array.
54074   * @param {Integer} chunk the chunk size.
54075   * @return {String} the resulting string.
54076   * @throws Error if the chunk is too big for the stack.
54077   */
54078  stringifyByChunk: function stringifyByChunk(array, type, chunk) {
54079    var result = [],
54080        k = 0,
54081        len = array.length; // shortcut
54082
54083    if (len <= chunk) {
54084      return String.fromCharCode.apply(null, array);
54085    }
54086
54087    while (k < len) {
54088      if (type === "array" || type === "nodebuffer") {
54089        result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
54090      } else {
54091        result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
54092      }
54093
54094      k += chunk;
54095    }
54096
54097    return result.join("");
54098  },
54099
54100  /**
54101   * Call String.fromCharCode on every item in the array.
54102   * This is the naive implementation, which generate A LOT of intermediate string.
54103   * This should be used when everything else fail.
54104   * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
54105   * @return {String} the result.
54106   */
54107  stringifyByChar: function stringifyByChar(array) {
54108    var resultStr = "";
54109
54110    for (var i = 0; i < array.length; i++) {
54111      resultStr += String.fromCharCode(array[i]);
54112    }
54113
54114    return resultStr;
54115  },
54116  applyCanBeUsed: {
54117    /**
54118     * true if the browser accepts to use String.fromCharCode on Uint8Array
54119     */
54120    uint8array: function () {
54121      try {
54122        return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
54123      } catch (e) {
54124        return false;
54125      }
54126    }(),
54127
54128    /**
54129     * true if the browser accepts to use String.fromCharCode on nodejs Buffer.
54130     */
54131    nodebuffer: function () {
54132      try {
54133        return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;
54134      } catch (e) {
54135        return false;
54136      }
54137    }()
54138  }
54139};
54140/**
54141 * Transform an array-like object to a string.
54142 * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
54143 * @return {String} the result.
54144 */
54145
54146function arrayLikeToString(array) {
54147  // Performances notes :
54148  // --------------------
54149  // String.fromCharCode.apply(null, array) is the fastest, see
54150  // see http://jsperf.com/converting-a-uint8array-to-a-string/2
54151  // but the stack is limited (and we can get huge arrays !).
54152  //
54153  // result += String.fromCharCode(array[i]); generate too many strings !
54154  //
54155  // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
54156  // TODO : we now have workers that split the work. Do we still need that ?
54157  var chunk = 65536,
54158      type = exports.getTypeOf(array),
54159      canUseApply = true;
54160
54161  if (type === "uint8array") {
54162    canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;
54163  } else if (type === "nodebuffer") {
54164    canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;
54165  }
54166
54167  if (canUseApply) {
54168    while (chunk > 1) {
54169      try {
54170        return arrayToStringHelper.stringifyByChunk(array, type, chunk);
54171      } catch (e) {
54172        chunk = Math.floor(chunk / 2);
54173      }
54174    }
54175  } // no apply or chunk error : slow and painful algorithm
54176  // default browser on android 4.*
54177
54178
54179  return arrayToStringHelper.stringifyByChar(array);
54180}
54181
54182exports.applyFromCharCode = arrayLikeToString;
54183/**
54184 * Copy the data from an array-like to an other array-like.
54185 * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.
54186 * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.
54187 * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.
54188 */
54189
54190function arrayLikeToArrayLike(arrayFrom, arrayTo) {
54191  for (var i = 0; i < arrayFrom.length; i++) {
54192    arrayTo[i] = arrayFrom[i];
54193  }
54194
54195  return arrayTo;
54196} // a matrix containing functions to transform everything into everything.
54197
54198
54199var transform = {}; // string to ?
54200
54201transform["string"] = {
54202  "string": identity,
54203  "array": function array(input) {
54204    return stringToArrayLike(input, new Array(input.length));
54205  },
54206  "arraybuffer": function arraybuffer(input) {
54207    return transform["string"]["uint8array"](input).buffer;
54208  },
54209  "uint8array": function uint8array(input) {
54210    return stringToArrayLike(input, new Uint8Array(input.length));
54211  },
54212  "nodebuffer": function nodebuffer(input) {
54213    return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));
54214  }
54215}; // array to ?
54216
54217transform["array"] = {
54218  "string": arrayLikeToString,
54219  "array": identity,
54220  "arraybuffer": function arraybuffer(input) {
54221    return new Uint8Array(input).buffer;
54222  },
54223  "uint8array": function uint8array(input) {
54224    return new Uint8Array(input);
54225  },
54226  "nodebuffer": function nodebuffer(input) {
54227    return nodejsUtils.newBufferFrom(input);
54228  }
54229}; // arraybuffer to ?
54230
54231transform["arraybuffer"] = {
54232  "string": function string(input) {
54233    return arrayLikeToString(new Uint8Array(input));
54234  },
54235  "array": function array(input) {
54236    return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
54237  },
54238  "arraybuffer": identity,
54239  "uint8array": function uint8array(input) {
54240    return new Uint8Array(input);
54241  },
54242  "nodebuffer": function nodebuffer(input) {
54243    return nodejsUtils.newBufferFrom(new Uint8Array(input));
54244  }
54245}; // uint8array to ?
54246
54247transform["uint8array"] = {
54248  "string": arrayLikeToString,
54249  "array": function array(input) {
54250    return arrayLikeToArrayLike(input, new Array(input.length));
54251  },
54252  "arraybuffer": function arraybuffer(input) {
54253    return input.buffer;
54254  },
54255  "uint8array": identity,
54256  "nodebuffer": function nodebuffer(input) {
54257    return nodejsUtils.newBufferFrom(input);
54258  }
54259}; // nodebuffer to ?
54260
54261transform["nodebuffer"] = {
54262  "string": arrayLikeToString,
54263  "array": function array(input) {
54264    return arrayLikeToArrayLike(input, new Array(input.length));
54265  },
54266  "arraybuffer": function arraybuffer(input) {
54267    return transform["nodebuffer"]["uint8array"](input).buffer;
54268  },
54269  "uint8array": function uint8array(input) {
54270    return arrayLikeToArrayLike(input, new Uint8Array(input.length));
54271  },
54272  "nodebuffer": identity
54273};
54274/**
54275 * Transform an input into any type.
54276 * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.
54277 * If no output type is specified, the unmodified input will be returned.
54278 * @param {String} outputType the output type.
54279 * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.
54280 * @throws {Error} an Error if the browser doesn't support the requested output type.
54281 */
54282
54283exports.transformTo = function (outputType, input) {
54284  if (!input) {
54285    // undefined, null, etc
54286    // an empty string won't harm.
54287    input = "";
54288  }
54289
54290  if (!outputType) {
54291    return input;
54292  }
54293
54294  exports.checkSupport(outputType);
54295  var inputType = exports.getTypeOf(input);
54296  var result = transform[inputType][outputType](input);
54297  return result;
54298};
54299/**
54300 * Return the type of the input.
54301 * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.
54302 * @param {Object} input the input to identify.
54303 * @return {String} the (lowercase) type of the input.
54304 */
54305
54306
54307exports.getTypeOf = function (input) {
54308  if (typeof input === "string") {
54309    return "string";
54310  }
54311
54312  if (Object.prototype.toString.call(input) === "[object Array]") {
54313    return "array";
54314  }
54315
54316  if (support.nodebuffer && nodejsUtils.isBuffer(input)) {
54317    return "nodebuffer";
54318  }
54319
54320  if (support.uint8array && input instanceof Uint8Array) {
54321    return "uint8array";
54322  }
54323
54324  if (support.arraybuffer && input instanceof ArrayBuffer) {
54325    return "arraybuffer";
54326  }
54327};
54328/**
54329 * Throw an exception if the type is not supported.
54330 * @param {String} type the type to check.
54331 * @throws {Error} an Error if the browser doesn't support the requested type.
54332 */
54333
54334
54335exports.checkSupport = function (type) {
54336  var supported = support[type.toLowerCase()];
54337
54338  if (!supported) {
54339    throw new Error(type + " is not supported by this platform");
54340  }
54341};
54342
54343exports.MAX_VALUE_16BITS = 65535;
54344exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1
54345
54346/**
54347 * Prettify a string read as binary.
54348 * @param {string} str the string to prettify.
54349 * @return {string} a pretty string.
54350 */
54351
54352exports.pretty = function (str) {
54353  var res = '',
54354      code,
54355      i;
54356
54357  for (i = 0; i < (str || "").length; i++) {
54358    code = str.charCodeAt(i);
54359    res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
54360  }
54361
54362  return res;
54363};
54364/**
54365 * Defer the call of a function.
54366 * @param {Function} callback the function to call asynchronously.
54367 * @param {Array} args the arguments to give to the callback.
54368 */
54369
54370
54371exports.delay = function (callback, args, self) {
54372  setImmediate(function () {
54373    callback.apply(self || null, args || []);
54374  });
54375};
54376/**
54377 * Extends a prototype with an other, without calling a constructor with
54378 * side effects. Inspired by nodejs' `utils.inherits`
54379 * @param {Function} ctor the constructor to augment
54380 * @param {Function} superCtor the parent constructor to use
54381 */
54382
54383
54384exports.inherits = function (ctor, superCtor) {
54385  var Obj = function Obj() {};
54386
54387  Obj.prototype = superCtor.prototype;
54388  ctor.prototype = new Obj();
54389};
54390/**
54391 * Merge the objects passed as parameters into a new one.
54392 * @private
54393 * @param {...Object} var_args All objects to merge.
54394 * @return {Object} a new object with the data of the others.
54395 */
54396
54397
54398exports.extend = function () {
54399  var result = {},
54400      i,
54401      attr;
54402
54403  for (i = 0; i < arguments.length; i++) {
54404    // arguments is not enumerable in some browsers
54405    for (attr in arguments[i]) {
54406      if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") {
54407        result[attr] = arguments[i][attr];
54408      }
54409    }
54410  }
54411
54412  return result;
54413};
54414/**
54415 * Transform arbitrary content into a Promise.
54416 * @param {String} name a name for the content being processed.
54417 * @param {Object} inputData the content to process.
54418 * @param {Boolean} isBinary true if the content is not an unicode string
54419 * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.
54420 * @param {Boolean} isBase64 true if the string content is encoded with base64.
54421 * @return {Promise} a promise in a format usable by JSZip.
54422 */
54423
54424
54425exports.prepareContent = function (name, inputData, isBinary, isOptimizedBinaryString, isBase64) {
54426  // if inputData is already a promise, this flatten it.
54427  var promise = external.Promise.resolve(inputData).then(function (data) {
54428    var isBlob = support.blob && (data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) !== -1);
54429
54430    if (isBlob && typeof FileReader !== "undefined") {
54431      return new external.Promise(function (resolve, reject) {
54432        var reader = new FileReader();
54433
54434        reader.onload = function (e) {
54435          resolve(e.target.result);
54436        };
54437
54438        reader.onerror = function (e) {
54439          reject(e.target.error);
54440        };
54441
54442        reader.readAsArrayBuffer(data);
54443      });
54444    } else {
54445      return data;
54446    }
54447  });
54448  return promise.then(function (data) {
54449    var dataType = exports.getTypeOf(data);
54450
54451    if (!dataType) {
54452      return external.Promise.reject(new Error("Can't read the data of '" + name + "'. Is it " + "in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));
54453    } // special case : it's way easier to work with Uint8Array than with ArrayBuffer
54454
54455
54456    if (dataType === "arraybuffer") {
54457      data = exports.transformTo("uint8array", data);
54458    } else if (dataType === "string") {
54459      if (isBase64) {
54460        data = base64.decode(data);
54461      } else if (isBinary) {
54462        // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask
54463        if (isOptimizedBinaryString !== true) {
54464          // this is a string, not in a base64 format.
54465          // Be sure that this is a correct "binary string"
54466          data = string2binary(data);
54467        }
54468      }
54469    }
54470
54471    return data;
54472  });
54473};
54474
54475},{"./base64":390,"./external":395,"./nodejsUtils":403,"./support":419,"set-immediate-shim":497}],422:[function(require,module,exports){
54476'use strict';
54477
54478var readerFor = require('./reader/readerFor');
54479
54480var utils = require('./utils');
54481
54482var sig = require('./signature');
54483
54484var ZipEntry = require('./zipEntry');
54485
54486var utf8 = require('./utf8');
54487
54488var support = require('./support'); //  class ZipEntries {{{
54489
54490/**
54491 * All the entries in the zip file.
54492 * @constructor
54493 * @param {Object} loadOptions Options for loading the stream.
54494 */
54495
54496
54497function ZipEntries(loadOptions) {
54498  this.files = [];
54499  this.loadOptions = loadOptions;
54500}
54501
54502ZipEntries.prototype = {
54503  /**
54504   * Check that the reader is on the specified signature.
54505   * @param {string} expectedSignature the expected signature.
54506   * @throws {Error} if it is an other signature.
54507   */
54508  checkSignature: function checkSignature(expectedSignature) {
54509    if (!this.reader.readAndCheckSignature(expectedSignature)) {
54510      this.reader.index -= 4;
54511      var signature = this.reader.readString(4);
54512      throw new Error("Corrupted zip or bug: unexpected signature " + "(" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");
54513    }
54514  },
54515
54516  /**
54517   * Check if the given signature is at the given index.
54518   * @param {number} askedIndex the index to check.
54519   * @param {string} expectedSignature the signature to expect.
54520   * @return {boolean} true if the signature is here, false otherwise.
54521   */
54522  isSignature: function isSignature(askedIndex, expectedSignature) {
54523    var currentIndex = this.reader.index;
54524    this.reader.setIndex(askedIndex);
54525    var signature = this.reader.readString(4);
54526    var result = signature === expectedSignature;
54527    this.reader.setIndex(currentIndex);
54528    return result;
54529  },
54530
54531  /**
54532   * Read the end of the central directory.
54533   */
54534  readBlockEndOfCentral: function readBlockEndOfCentral() {
54535    this.diskNumber = this.reader.readInt(2);
54536    this.diskWithCentralDirStart = this.reader.readInt(2);
54537    this.centralDirRecordsOnThisDisk = this.reader.readInt(2);
54538    this.centralDirRecords = this.reader.readInt(2);
54539    this.centralDirSize = this.reader.readInt(4);
54540    this.centralDirOffset = this.reader.readInt(4);
54541    this.zipCommentLength = this.reader.readInt(2); // warning : the encoding depends of the system locale
54542    // On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.
54543    // On a windows machine, this field is encoded with the localized windows code page.
54544
54545    var zipComment = this.reader.readData(this.zipCommentLength);
54546    var decodeParamType = support.uint8array ? "uint8array" : "array"; // To get consistent behavior with the generation part, we will assume that
54547    // this is utf8 encoded unless specified otherwise.
54548
54549    var decodeContent = utils.transformTo(decodeParamType, zipComment);
54550    this.zipComment = this.loadOptions.decodeFileName(decodeContent);
54551  },
54552
54553  /**
54554   * Read the end of the Zip 64 central directory.
54555   * Not merged with the method readEndOfCentral :
54556   * The end of central can coexist with its Zip64 brother,
54557   * I don't want to read the wrong number of bytes !
54558   */
54559  readBlockZip64EndOfCentral: function readBlockZip64EndOfCentral() {
54560    this.zip64EndOfCentralSize = this.reader.readInt(8);
54561    this.reader.skip(4); // this.versionMadeBy = this.reader.readString(2);
54562    // this.versionNeeded = this.reader.readInt(2);
54563
54564    this.diskNumber = this.reader.readInt(4);
54565    this.diskWithCentralDirStart = this.reader.readInt(4);
54566    this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
54567    this.centralDirRecords = this.reader.readInt(8);
54568    this.centralDirSize = this.reader.readInt(8);
54569    this.centralDirOffset = this.reader.readInt(8);
54570    this.zip64ExtensibleData = {};
54571    var extraDataSize = this.zip64EndOfCentralSize - 44,
54572        index = 0,
54573        extraFieldId,
54574        extraFieldLength,
54575        extraFieldValue;
54576
54577    while (index < extraDataSize) {
54578      extraFieldId = this.reader.readInt(2);
54579      extraFieldLength = this.reader.readInt(4);
54580      extraFieldValue = this.reader.readData(extraFieldLength);
54581      this.zip64ExtensibleData[extraFieldId] = {
54582        id: extraFieldId,
54583        length: extraFieldLength,
54584        value: extraFieldValue
54585      };
54586    }
54587  },
54588
54589  /**
54590   * Read the end of the Zip 64 central directory locator.
54591   */
54592  readBlockZip64EndOfCentralLocator: function readBlockZip64EndOfCentralLocator() {
54593    this.diskWithZip64CentralDirStart = this.reader.readInt(4);
54594    this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);
54595    this.disksCount = this.reader.readInt(4);
54596
54597    if (this.disksCount > 1) {
54598      throw new Error("Multi-volumes zip are not supported");
54599    }
54600  },
54601
54602  /**
54603   * Read the local files, based on the offset read in the central part.
54604   */
54605  readLocalFiles: function readLocalFiles() {
54606    var i, file;
54607
54608    for (i = 0; i < this.files.length; i++) {
54609      file = this.files[i];
54610      this.reader.setIndex(file.localHeaderOffset);
54611      this.checkSignature(sig.LOCAL_FILE_HEADER);
54612      file.readLocalPart(this.reader);
54613      file.handleUTF8();
54614      file.processAttributes();
54615    }
54616  },
54617
54618  /**
54619   * Read the central directory.
54620   */
54621  readCentralDir: function readCentralDir() {
54622    var file;
54623    this.reader.setIndex(this.centralDirOffset);
54624
54625    while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {
54626      file = new ZipEntry({
54627        zip64: this.zip64
54628      }, this.loadOptions);
54629      file.readCentralPart(this.reader);
54630      this.files.push(file);
54631    }
54632
54633    if (this.centralDirRecords !== this.files.length) {
54634      if (this.centralDirRecords !== 0 && this.files.length === 0) {
54635        // We expected some records but couldn't find ANY.
54636        // This is really suspicious, as if something went wrong.
54637        throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
54638      } else {// We found some records but not all.
54639        // Something is wrong but we got something for the user: no error here.
54640        // console.warn("expected", this.centralDirRecords, "records in central dir, got", this.files.length);
54641      }
54642    }
54643  },
54644
54645  /**
54646   * Read the end of central directory.
54647   */
54648  readEndOfCentral: function readEndOfCentral() {
54649    var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
54650
54651    if (offset < 0) {
54652      // Check if the content is a truncated zip or complete garbage.
54653      // A "LOCAL_FILE_HEADER" is not required at the beginning (auto
54654      // extractible zip for example) but it can give a good hint.
54655      // If an ajax request was used without responseType, we will also
54656      // get unreadable data.
54657      var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);
54658
54659      if (isGarbage) {
54660        throw new Error("Can't find end of central directory : is this a zip file ? " + "If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");
54661      } else {
54662        throw new Error("Corrupted zip: can't find end of central directory");
54663      }
54664    }
54665
54666    this.reader.setIndex(offset);
54667    var endOfCentralDirOffset = offset;
54668    this.checkSignature(sig.CENTRAL_DIRECTORY_END);
54669    this.readBlockEndOfCentral();
54670    /* extract from the zip spec :
54671        4)  If one of the fields in the end of central directory
54672            record is too small to hold required data, the field
54673            should be set to -1 (0xFFFF or 0xFFFFFFFF) and the
54674            ZIP64 format record should be created.
54675        5)  The end of central directory record and the
54676            Zip64 end of central directory locator record must
54677            reside on the same disk when splitting or spanning
54678            an archive.
54679     */
54680
54681    if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {
54682      this.zip64 = true;
54683      /*
54684      Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from
54685      the zip file can fit into a 32bits integer. This cannot be solved : JavaScript represents
54686      all numbers as 64-bit double precision IEEE 754 floating point numbers.
54687      So, we have 53bits for integers and bitwise operations treat everything as 32bits.
54688      see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators
54689      and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5
54690      */
54691      // should look for a zip64 EOCD locator
54692
54693      offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
54694
54695      if (offset < 0) {
54696        throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");
54697      }
54698
54699      this.reader.setIndex(offset);
54700      this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
54701      this.readBlockZip64EndOfCentralLocator(); // now the zip64 EOCD record
54702
54703      if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {
54704        // console.warn("ZIP64 end of central directory not where expected.");
54705        this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
54706
54707        if (this.relativeOffsetEndOfZip64CentralDir < 0) {
54708          throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");
54709        }
54710      }
54711
54712      this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);
54713      this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
54714      this.readBlockZip64EndOfCentral();
54715    }
54716
54717    var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;
54718
54719    if (this.zip64) {
54720      expectedEndOfCentralDirOffset += 20; // end of central dir 64 locator
54721
54722      expectedEndOfCentralDirOffset += 12
54723      /* should not include the leading 12 bytes */
54724      + this.zip64EndOfCentralSize;
54725    }
54726
54727    var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;
54728
54729    if (extraBytes > 0) {
54730      // console.warn(extraBytes, "extra bytes at beginning or within zipfile");
54731      if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {// The offsets seem wrong, but we have something at the specified offset.
54732        // So… we keep it.
54733      } else {
54734        // the offset is wrong, update the "zero" of the reader
54735        // this happens if data has been prepended (crx files for example)
54736        this.reader.zero = extraBytes;
54737      }
54738    } else if (extraBytes < 0) {
54739      throw new Error("Corrupted zip: missing " + Math.abs(extraBytes) + " bytes.");
54740    }
54741  },
54742  prepareReader: function prepareReader(data) {
54743    this.reader = readerFor(data);
54744  },
54745
54746  /**
54747   * Read a zip file and create ZipEntries.
54748   * @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.
54749   */
54750  load: function load(data) {
54751    this.prepareReader(data);
54752    this.readEndOfCentral();
54753    this.readCentralDir();
54754    this.readLocalFiles();
54755  }
54756}; // }}} end of ZipEntries
54757
54758module.exports = ZipEntries;
54759
54760},{"./reader/readerFor":411,"./signature":412,"./support":419,"./utf8":420,"./utils":421,"./zipEntry":423}],423:[function(require,module,exports){
54761'use strict';
54762
54763var readerFor = require('./reader/readerFor');
54764
54765var utils = require('./utils');
54766
54767var CompressedObject = require('./compressedObject');
54768
54769var crc32fn = require('./crc32');
54770
54771var utf8 = require('./utf8');
54772
54773var compressions = require('./compressions');
54774
54775var support = require('./support');
54776
54777var MADE_BY_DOS = 0x00;
54778var MADE_BY_UNIX = 0x03;
54779/**
54780 * Find a compression registered in JSZip.
54781 * @param {string} compressionMethod the method magic to find.
54782 * @return {Object|null} the JSZip compression object, null if none found.
54783 */
54784
54785var findCompression = function findCompression(compressionMethod) {
54786  for (var method in compressions) {
54787    if (!compressions.hasOwnProperty(method)) {
54788      continue;
54789    }
54790
54791    if (compressions[method].magic === compressionMethod) {
54792      return compressions[method];
54793    }
54794  }
54795
54796  return null;
54797}; // class ZipEntry {{{
54798
54799/**
54800 * An entry in the zip file.
54801 * @constructor
54802 * @param {Object} options Options of the current file.
54803 * @param {Object} loadOptions Options for loading the stream.
54804 */
54805
54806
54807function ZipEntry(options, loadOptions) {
54808  this.options = options;
54809  this.loadOptions = loadOptions;
54810}
54811
54812ZipEntry.prototype = {
54813  /**
54814   * say if the file is encrypted.
54815   * @return {boolean} true if the file is encrypted, false otherwise.
54816   */
54817  isEncrypted: function isEncrypted() {
54818    // bit 1 is set
54819    return (this.bitFlag & 0x0001) === 0x0001;
54820  },
54821
54822  /**
54823   * say if the file has utf-8 filename/comment.
54824   * @return {boolean} true if the filename/comment is in utf-8, false otherwise.
54825   */
54826  useUTF8: function useUTF8() {
54827    // bit 11 is set
54828    return (this.bitFlag & 0x0800) === 0x0800;
54829  },
54830
54831  /**
54832   * Read the local part of a zip file and add the info in this object.
54833   * @param {DataReader} reader the reader to use.
54834   */
54835  readLocalPart: function readLocalPart(reader) {
54836    var compression, localExtraFieldsLength; // we already know everything from the central dir !
54837    // If the central dir data are false, we are doomed.
54838    // On the bright side, the local part is scary  : zip64, data descriptors, both, etc.
54839    // The less data we get here, the more reliable this should be.
54840    // Let's skip the whole header and dash to the data !
54841
54842    reader.skip(22); // in some zip created on windows, the filename stored in the central dir contains \ instead of /.
54843    // Strangely, the filename here is OK.
54844    // I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes
54845    // or APPNOTE#4.4.17.1, "All slashes MUST be forward slashes '/'") but there are a lot of bad zip generators...
54846    // Search "unzip mismatching "local" filename continuing with "central" filename version" on
54847    // the internet.
54848    //
54849    // I think I see the logic here : the central directory is used to display
54850    // content and the local directory is used to extract the files. Mixing / and \
54851    // may be used to display \ to windows users and use / when extracting the files.
54852    // Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394
54853
54854    this.fileNameLength = reader.readInt(2);
54855    localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir
54856    // the fileName is stored as binary data, the handleUTF8 method will take care of the encoding.
54857
54858    this.fileName = reader.readData(this.fileNameLength);
54859    reader.skip(localExtraFieldsLength);
54860
54861    if (this.compressedSize === -1 || this.uncompressedSize === -1) {
54862      throw new Error("Bug or corrupted zip : didn't get enough information from the central directory " + "(compressedSize === -1 || uncompressedSize === -1)");
54863    }
54864
54865    compression = findCompression(this.compressionMethod);
54866
54867    if (compression === null) {
54868      // no compression found
54869      throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + utils.transformTo("string", this.fileName) + ")");
54870    }
54871
54872    this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));
54873  },
54874
54875  /**
54876   * Read the central part of a zip file and add the info in this object.
54877   * @param {DataReader} reader the reader to use.
54878   */
54879  readCentralPart: function readCentralPart(reader) {
54880    this.versionMadeBy = reader.readInt(2);
54881    reader.skip(2); // this.versionNeeded = reader.readInt(2);
54882
54883    this.bitFlag = reader.readInt(2);
54884    this.compressionMethod = reader.readString(2);
54885    this.date = reader.readDate();
54886    this.crc32 = reader.readInt(4);
54887    this.compressedSize = reader.readInt(4);
54888    this.uncompressedSize = reader.readInt(4);
54889    var fileNameLength = reader.readInt(2);
54890    this.extraFieldsLength = reader.readInt(2);
54891    this.fileCommentLength = reader.readInt(2);
54892    this.diskNumberStart = reader.readInt(2);
54893    this.internalFileAttributes = reader.readInt(2);
54894    this.externalFileAttributes = reader.readInt(4);
54895    this.localHeaderOffset = reader.readInt(4);
54896
54897    if (this.isEncrypted()) {
54898      throw new Error("Encrypted zip are not supported");
54899    } // will be read in the local part, see the comments there
54900
54901
54902    reader.skip(fileNameLength);
54903    this.readExtraFields(reader);
54904    this.parseZIP64ExtraField(reader);
54905    this.fileComment = reader.readData(this.fileCommentLength);
54906  },
54907
54908  /**
54909   * Parse the external file attributes and get the unix/dos permissions.
54910   */
54911  processAttributes: function processAttributes() {
54912    this.unixPermissions = null;
54913    this.dosPermissions = null;
54914    var madeBy = this.versionMadeBy >> 8; // Check if we have the DOS directory flag set.
54915    // We look for it in the DOS and UNIX permissions
54916    // but some unknown platform could set it as a compatibility flag.
54917
54918    this.dir = this.externalFileAttributes & 0x0010 ? true : false;
54919
54920    if (madeBy === MADE_BY_DOS) {
54921      // first 6 bits (0 to 5)
54922      this.dosPermissions = this.externalFileAttributes & 0x3F;
54923    }
54924
54925    if (madeBy === MADE_BY_UNIX) {
54926      this.unixPermissions = this.externalFileAttributes >> 16 & 0xFFFF; // the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);
54927    } // fail safe : if the name ends with a / it probably means a folder
54928
54929
54930    if (!this.dir && this.fileNameStr.slice(-1) === '/') {
54931      this.dir = true;
54932    }
54933  },
54934
54935  /**
54936   * Parse the ZIP64 extra field and merge the info in the current ZipEntry.
54937   * @param {DataReader} reader the reader to use.
54938   */
54939  parseZIP64ExtraField: function parseZIP64ExtraField(reader) {
54940    if (!this.extraFields[0x0001]) {
54941      return;
54942    } // should be something, preparing the extra reader
54943
54944
54945    var extraReader = readerFor(this.extraFields[0x0001].value); // I really hope that these 64bits integer can fit in 32 bits integer, because js
54946    // won't let us have more.
54947
54948    if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
54949      this.uncompressedSize = extraReader.readInt(8);
54950    }
54951
54952    if (this.compressedSize === utils.MAX_VALUE_32BITS) {
54953      this.compressedSize = extraReader.readInt(8);
54954    }
54955
54956    if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
54957      this.localHeaderOffset = extraReader.readInt(8);
54958    }
54959
54960    if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
54961      this.diskNumberStart = extraReader.readInt(4);
54962    }
54963  },
54964
54965  /**
54966   * Read the central part of a zip file and add the info in this object.
54967   * @param {DataReader} reader the reader to use.
54968   */
54969  readExtraFields: function readExtraFields(reader) {
54970    var end = reader.index + this.extraFieldsLength,
54971        extraFieldId,
54972        extraFieldLength,
54973        extraFieldValue;
54974
54975    if (!this.extraFields) {
54976      this.extraFields = {};
54977    }
54978
54979    while (reader.index + 4 < end) {
54980      extraFieldId = reader.readInt(2);
54981      extraFieldLength = reader.readInt(2);
54982      extraFieldValue = reader.readData(extraFieldLength);
54983      this.extraFields[extraFieldId] = {
54984        id: extraFieldId,
54985        length: extraFieldLength,
54986        value: extraFieldValue
54987      };
54988    }
54989
54990    reader.setIndex(end);
54991  },
54992
54993  /**
54994   * Apply an UTF8 transformation if needed.
54995   */
54996  handleUTF8: function handleUTF8() {
54997    var decodeParamType = support.uint8array ? "uint8array" : "array";
54998
54999    if (this.useUTF8()) {
55000      this.fileNameStr = utf8.utf8decode(this.fileName);
55001      this.fileCommentStr = utf8.utf8decode(this.fileComment);
55002    } else {
55003      var upath = this.findExtraFieldUnicodePath();
55004
55005      if (upath !== null) {
55006        this.fileNameStr = upath;
55007      } else {
55008        // ASCII text or unsupported code page
55009        var fileNameByteArray = utils.transformTo(decodeParamType, this.fileName);
55010        this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);
55011      }
55012
55013      var ucomment = this.findExtraFieldUnicodeComment();
55014
55015      if (ucomment !== null) {
55016        this.fileCommentStr = ucomment;
55017      } else {
55018        // ASCII text or unsupported code page
55019        var commentByteArray = utils.transformTo(decodeParamType, this.fileComment);
55020        this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);
55021      }
55022    }
55023  },
55024
55025  /**
55026   * Find the unicode path declared in the extra field, if any.
55027   * @return {String} the unicode path, null otherwise.
55028   */
55029  findExtraFieldUnicodePath: function findExtraFieldUnicodePath() {
55030    var upathField = this.extraFields[0x7075];
55031
55032    if (upathField) {
55033      var extraReader = readerFor(upathField.value); // wrong version
55034
55035      if (extraReader.readInt(1) !== 1) {
55036        return null;
55037      } // the crc of the filename changed, this field is out of date.
55038
55039
55040      if (crc32fn(this.fileName) !== extraReader.readInt(4)) {
55041        return null;
55042      }
55043
55044      return utf8.utf8decode(extraReader.readData(upathField.length - 5));
55045    }
55046
55047    return null;
55048  },
55049
55050  /**
55051   * Find the unicode comment declared in the extra field, if any.
55052   * @return {String} the unicode comment, null otherwise.
55053   */
55054  findExtraFieldUnicodeComment: function findExtraFieldUnicodeComment() {
55055    var ucommentField = this.extraFields[0x6375];
55056
55057    if (ucommentField) {
55058      var extraReader = readerFor(ucommentField.value); // wrong version
55059
55060      if (extraReader.readInt(1) !== 1) {
55061        return null;
55062      } // the crc of the comment changed, this field is out of date.
55063
55064
55065      if (crc32fn(this.fileComment) !== extraReader.readInt(4)) {
55066        return null;
55067      }
55068
55069      return utf8.utf8decode(extraReader.readData(ucommentField.length - 5));
55070    }
55071
55072    return null;
55073  }
55074};
55075module.exports = ZipEntry;
55076
55077},{"./compressedObject":391,"./compressions":392,"./crc32":393,"./reader/readerFor":411,"./support":419,"./utf8":420,"./utils":421}],424:[function(require,module,exports){
55078'use strict';
55079
55080var StreamHelper = require('./stream/StreamHelper');
55081
55082var DataWorker = require('./stream/DataWorker');
55083
55084var utf8 = require('./utf8');
55085
55086var CompressedObject = require('./compressedObject');
55087
55088var GenericWorker = require('./stream/GenericWorker');
55089/**
55090 * A simple object representing a file in the zip file.
55091 * @constructor
55092 * @param {string} name the name of the file
55093 * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data
55094 * @param {Object} options the options of the file
55095 */
55096
55097
55098var ZipObject = function ZipObject(name, data, options) {
55099  this.name = name;
55100  this.dir = options.dir;
55101  this.date = options.date;
55102  this.comment = options.comment;
55103  this.unixPermissions = options.unixPermissions;
55104  this.dosPermissions = options.dosPermissions;
55105  this._data = data;
55106  this._dataBinary = options.binary; // keep only the compression
55107
55108  this.options = {
55109    compression: options.compression,
55110    compressionOptions: options.compressionOptions
55111  };
55112};
55113
55114ZipObject.prototype = {
55115  /**
55116   * Create an internal stream for the content of this object.
55117   * @param {String} type the type of each chunk.
55118   * @return StreamHelper the stream.
55119   */
55120  internalStream: function internalStream(type) {
55121    var result = null,
55122        outputType = "string";
55123
55124    try {
55125      if (!type) {
55126        throw new Error("No output type specified.");
55127      }
55128
55129      outputType = type.toLowerCase();
55130      var askUnicodeString = outputType === "string" || outputType === "text";
55131
55132      if (outputType === "binarystring" || outputType === "text") {
55133        outputType = "string";
55134      }
55135
55136      result = this._decompressWorker();
55137      var isUnicodeString = !this._dataBinary;
55138
55139      if (isUnicodeString && !askUnicodeString) {
55140        result = result.pipe(new utf8.Utf8EncodeWorker());
55141      }
55142
55143      if (!isUnicodeString && askUnicodeString) {
55144        result = result.pipe(new utf8.Utf8DecodeWorker());
55145      }
55146    } catch (e) {
55147      result = new GenericWorker("error");
55148      result.error(e);
55149    }
55150
55151    return new StreamHelper(result, outputType, "");
55152  },
55153
55154  /**
55155   * Prepare the content in the asked type.
55156   * @param {String} type the type of the result.
55157   * @param {Function} onUpdate a function to call on each internal update.
55158   * @return Promise the promise of the result.
55159   */
55160  async: function async(type, onUpdate) {
55161    return this.internalStream(type).accumulate(onUpdate);
55162  },
55163
55164  /**
55165   * Prepare the content as a nodejs stream.
55166   * @param {String} type the type of each chunk.
55167   * @param {Function} onUpdate a function to call on each internal update.
55168   * @return Stream the stream.
55169   */
55170  nodeStream: function nodeStream(type, onUpdate) {
55171    return this.internalStream(type || "nodebuffer").toNodejsStream(onUpdate);
55172  },
55173
55174  /**
55175   * Return a worker for the compressed content.
55176   * @private
55177   * @param {Object} compression the compression object to use.
55178   * @param {Object} compressionOptions the options to use when compressing.
55179   * @return Worker the worker.
55180   */
55181  _compressWorker: function _compressWorker(compression, compressionOptions) {
55182    if (this._data instanceof CompressedObject && this._data.compression.magic === compression.magic) {
55183      return this._data.getCompressedWorker();
55184    } else {
55185      var result = this._decompressWorker();
55186
55187      if (!this._dataBinary) {
55188        result = result.pipe(new utf8.Utf8EncodeWorker());
55189      }
55190
55191      return CompressedObject.createWorkerFrom(result, compression, compressionOptions);
55192    }
55193  },
55194
55195  /**
55196   * Return a worker for the decompressed content.
55197   * @private
55198   * @return Worker the worker.
55199   */
55200  _decompressWorker: function _decompressWorker() {
55201    if (this._data instanceof CompressedObject) {
55202      return this._data.getContentWorker();
55203    } else if (this._data instanceof GenericWorker) {
55204      return this._data;
55205    } else {
55206      return new DataWorker(this._data);
55207    }
55208  }
55209};
55210var removedMethods = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"];
55211
55212var removedFn = function removedFn() {
55213  throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
55214};
55215
55216for (var i = 0; i < removedMethods.length; i++) {
55217  ZipObject.prototype[removedMethods[i]] = removedFn;
55218}
55219
55220module.exports = ZipObject;
55221
55222},{"./compressedObject":391,"./stream/DataWorker":416,"./stream/GenericWorker":417,"./stream/StreamHelper":418,"./utf8":420}],425:[function(require,module,exports){
55223'use strict';
55224
55225function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
55226
55227var immediate = require('immediate');
55228/* istanbul ignore next */
55229
55230
55231function INTERNAL() {}
55232
55233var handlers = {};
55234var REJECTED = ['REJECTED'];
55235var FULFILLED = ['FULFILLED'];
55236var PENDING = ['PENDING'];
55237module.exports = Promise;
55238
55239function Promise(resolver) {
55240  if (typeof resolver !== 'function') {
55241    throw new TypeError('resolver must be a function');
55242  }
55243
55244  this.state = PENDING;
55245  this.queue = [];
55246  this.outcome = void 0;
55247
55248  if (resolver !== INTERNAL) {
55249    safelyResolveThenable(this, resolver);
55250  }
55251}
55252
55253Promise.prototype["finally"] = function (callback) {
55254  if (typeof callback !== 'function') {
55255    return this;
55256  }
55257
55258  var p = this.constructor;
55259  return this.then(resolve, reject);
55260
55261  function resolve(value) {
55262    function yes() {
55263      return value;
55264    }
55265
55266    return p.resolve(callback()).then(yes);
55267  }
55268
55269  function reject(reason) {
55270    function no() {
55271      throw reason;
55272    }
55273
55274    return p.resolve(callback()).then(no);
55275  }
55276};
55277
55278Promise.prototype["catch"] = function (onRejected) {
55279  return this.then(null, onRejected);
55280};
55281
55282Promise.prototype.then = function (onFulfilled, onRejected) {
55283  if (typeof onFulfilled !== 'function' && this.state === FULFILLED || typeof onRejected !== 'function' && this.state === REJECTED) {
55284    return this;
55285  }
55286
55287  var promise = new this.constructor(INTERNAL);
55288
55289  if (this.state !== PENDING) {
55290    var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
55291    unwrap(promise, resolver, this.outcome);
55292  } else {
55293    this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
55294  }
55295
55296  return promise;
55297};
55298
55299function QueueItem(promise, onFulfilled, onRejected) {
55300  this.promise = promise;
55301
55302  if (typeof onFulfilled === 'function') {
55303    this.onFulfilled = onFulfilled;
55304    this.callFulfilled = this.otherCallFulfilled;
55305  }
55306
55307  if (typeof onRejected === 'function') {
55308    this.onRejected = onRejected;
55309    this.callRejected = this.otherCallRejected;
55310  }
55311}
55312
55313QueueItem.prototype.callFulfilled = function (value) {
55314  handlers.resolve(this.promise, value);
55315};
55316
55317QueueItem.prototype.otherCallFulfilled = function (value) {
55318  unwrap(this.promise, this.onFulfilled, value);
55319};
55320
55321QueueItem.prototype.callRejected = function (value) {
55322  handlers.reject(this.promise, value);
55323};
55324
55325QueueItem.prototype.otherCallRejected = function (value) {
55326  unwrap(this.promise, this.onRejected, value);
55327};
55328
55329function unwrap(promise, func, value) {
55330  immediate(function () {
55331    var returnValue;
55332
55333    try {
55334      returnValue = func(value);
55335    } catch (e) {
55336      return handlers.reject(promise, e);
55337    }
55338
55339    if (returnValue === promise) {
55340      handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));
55341    } else {
55342      handlers.resolve(promise, returnValue);
55343    }
55344  });
55345}
55346
55347handlers.resolve = function (self, value) {
55348  var result = tryCatch(getThen, value);
55349
55350  if (result.status === 'error') {
55351    return handlers.reject(self, result.value);
55352  }
55353
55354  var thenable = result.value;
55355
55356  if (thenable) {
55357    safelyResolveThenable(self, thenable);
55358  } else {
55359    self.state = FULFILLED;
55360    self.outcome = value;
55361    var i = -1;
55362    var len = self.queue.length;
55363
55364    while (++i < len) {
55365      self.queue[i].callFulfilled(value);
55366    }
55367  }
55368
55369  return self;
55370};
55371
55372handlers.reject = function (self, error) {
55373  self.state = REJECTED;
55374  self.outcome = error;
55375  var i = -1;
55376  var len = self.queue.length;
55377
55378  while (++i < len) {
55379    self.queue[i].callRejected(error);
55380  }
55381
55382  return self;
55383};
55384
55385function getThen(obj) {
55386  // Make sure we only access the accessor once as required by the spec
55387  var then = obj && obj.then;
55388
55389  if (obj && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof then === 'function') {
55390    return function appyThen() {
55391      then.apply(obj, arguments);
55392    };
55393  }
55394}
55395
55396function safelyResolveThenable(self, thenable) {
55397  // Either fulfill, reject or reject with error
55398  var called = false;
55399
55400  function onError(value) {
55401    if (called) {
55402      return;
55403    }
55404
55405    called = true;
55406    handlers.reject(self, value);
55407  }
55408
55409  function onSuccess(value) {
55410    if (called) {
55411      return;
55412    }
55413
55414    called = true;
55415    handlers.resolve(self, value);
55416  }
55417
55418  function tryToUnwrap() {
55419    thenable(onSuccess, onError);
55420  }
55421
55422  var result = tryCatch(tryToUnwrap);
55423
55424  if (result.status === 'error') {
55425    onError(result.value);
55426  }
55427}
55428
55429function tryCatch(func, value) {
55430  var out = {};
55431
55432  try {
55433    out.value = func(value);
55434    out.status = 'success';
55435  } catch (e) {
55436    out.status = 'error';
55437    out.value = e;
55438  }
55439
55440  return out;
55441}
55442
55443Promise.resolve = resolve;
55444
55445function resolve(value) {
55446  if (value instanceof this) {
55447    return value;
55448  }
55449
55450  return handlers.resolve(new this(INTERNAL), value);
55451}
55452
55453Promise.reject = reject;
55454
55455function reject(reason) {
55456  var promise = new this(INTERNAL);
55457  return handlers.reject(promise, reason);
55458}
55459
55460Promise.all = all;
55461
55462function all(iterable) {
55463  var self = this;
55464
55465  if (Object.prototype.toString.call(iterable) !== '[object Array]') {
55466    return this.reject(new TypeError('must be an array'));
55467  }
55468
55469  var len = iterable.length;
55470  var called = false;
55471
55472  if (!len) {
55473    return this.resolve([]);
55474  }
55475
55476  var values = new Array(len);
55477  var resolved = 0;
55478  var i = -1;
55479  var promise = new this(INTERNAL);
55480
55481  while (++i < len) {
55482    allResolver(iterable[i], i);
55483  }
55484
55485  return promise;
55486
55487  function allResolver(value, i) {
55488    self.resolve(value).then(resolveFromAll, function (error) {
55489      if (!called) {
55490        called = true;
55491        handlers.reject(promise, error);
55492      }
55493    });
55494
55495    function resolveFromAll(outValue) {
55496      values[i] = outValue;
55497
55498      if (++resolved === len && !called) {
55499        called = true;
55500        handlers.resolve(promise, values);
55501      }
55502    }
55503  }
55504}
55505
55506Promise.race = race;
55507
55508function race(iterable) {
55509  var self = this;
55510
55511  if (Object.prototype.toString.call(iterable) !== '[object Array]') {
55512    return this.reject(new TypeError('must be an array'));
55513  }
55514
55515  var len = iterable.length;
55516  var called = false;
55517
55518  if (!len) {
55519    return this.resolve([]);
55520  }
55521
55522  var i = -1;
55523  var promise = new this(INTERNAL);
55524
55525  while (++i < len) {
55526    resolver(iterable[i]);
55527  }
55528
55529  return promise;
55530
55531  function resolver(value) {
55532    self.resolve(value).then(function (response) {
55533      if (!called) {
55534        called = true;
55535        handlers.resolve(promise, response);
55536      }
55537    }, function (error) {
55538      if (!called) {
55539        called = true;
55540        handlers.reject(promise, error);
55541      }
55542    });
55543  }
55544}
55545
55546},{"immediate":386}],426:[function(require,module,exports){
55547(function (global){
55548"use strict";
55549
55550function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
55551
55552/**
55553 * lodash (Custom Build) <https://lodash.com/>
55554 * Build: `lodash modularize exports="npm" -o ./`
55555 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
55556 * Released under MIT license <https://lodash.com/license>
55557 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
55558 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
55559 */
55560
55561/** Used as references for various `Number` constants. */
55562var INFINITY = 1 / 0;
55563/** `Object#toString` result references. */
55564
55565var symbolTag = '[object Symbol]';
55566/**
55567 * Used to match `RegExp`
55568 * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
55569 */
55570
55571var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
55572    reHasRegExpChar = RegExp(reRegExpChar.source);
55573/** Detect free variable `global` from Node.js. */
55574
55575var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
55576/** Detect free variable `self`. */
55577
55578var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
55579/** Used as a reference to the global object. */
55580
55581var root = freeGlobal || freeSelf || Function('return this')();
55582/** Used for built-in method references. */
55583
55584var objectProto = Object.prototype;
55585/**
55586 * Used to resolve the
55587 * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
55588 * of values.
55589 */
55590
55591var objectToString = objectProto.toString;
55592/** Built-in value references. */
55593
55594var _Symbol = root.Symbol;
55595/** Used to convert symbols to primitives and strings. */
55596
55597var symbolProto = _Symbol ? _Symbol.prototype : undefined,
55598    symbolToString = symbolProto ? symbolProto.toString : undefined;
55599/**
55600 * The base implementation of `_.toString` which doesn't convert nullish
55601 * values to empty strings.
55602 *
55603 * @private
55604 * @param {*} value The value to process.
55605 * @returns {string} Returns the string.
55606 */
55607
55608function baseToString(value) {
55609  // Exit early for strings to avoid a performance hit in some environments.
55610  if (typeof value == 'string') {
55611    return value;
55612  }
55613
55614  if (isSymbol(value)) {
55615    return symbolToString ? symbolToString.call(value) : '';
55616  }
55617
55618  var result = value + '';
55619  return result == '0' && 1 / value == -INFINITY ? '-0' : result;
55620}
55621/**
55622 * Checks if `value` is object-like. A value is object-like if it's not `null`
55623 * and has a `typeof` result of "object".
55624 *
55625 * @static
55626 * @memberOf _
55627 * @since 4.0.0
55628 * @category Lang
55629 * @param {*} value The value to check.
55630 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
55631 * @example
55632 *
55633 * _.isObjectLike({});
55634 * // => true
55635 *
55636 * _.isObjectLike([1, 2, 3]);
55637 * // => true
55638 *
55639 * _.isObjectLike(_.noop);
55640 * // => false
55641 *
55642 * _.isObjectLike(null);
55643 * // => false
55644 */
55645
55646
55647function isObjectLike(value) {
55648  return !!value && _typeof(value) == 'object';
55649}
55650/**
55651 * Checks if `value` is classified as a `Symbol` primitive or object.
55652 *
55653 * @static
55654 * @memberOf _
55655 * @since 4.0.0
55656 * @category Lang
55657 * @param {*} value The value to check.
55658 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
55659 * @example
55660 *
55661 * _.isSymbol(Symbol.iterator);
55662 * // => true
55663 *
55664 * _.isSymbol('abc');
55665 * // => false
55666 */
55667
55668
55669function isSymbol(value) {
55670  return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
55671}
55672/**
55673 * Converts `value` to a string. An empty string is returned for `null`
55674 * and `undefined` values. The sign of `-0` is preserved.
55675 *
55676 * @static
55677 * @memberOf _
55678 * @since 4.0.0
55679 * @category Lang
55680 * @param {*} value The value to process.
55681 * @returns {string} Returns the string.
55682 * @example
55683 *
55684 * _.toString(null);
55685 * // => ''
55686 *
55687 * _.toString(-0);
55688 * // => '-0'
55689 *
55690 * _.toString([1, 2, 3]);
55691 * // => '1,2,3'
55692 */
55693
55694
55695function toString(value) {
55696  return value == null ? '' : baseToString(value);
55697}
55698/**
55699 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
55700 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
55701 *
55702 * @static
55703 * @memberOf _
55704 * @since 3.0.0
55705 * @category String
55706 * @param {string} [string=''] The string to escape.
55707 * @returns {string} Returns the escaped string.
55708 * @example
55709 *
55710 * _.escapeRegExp('[lodash](https://lodash.com/)');
55711 * // => '\[lodash\]\(https://lodash\.com/\)'
55712 */
55713
55714
55715function escapeRegExp(string) {
55716  string = toString(string);
55717  return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, '\\$&') : string;
55718}
55719
55720module.exports = escapeRegExp;
55721
55722}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
55723
55724},{}],427:[function(require,module,exports){
55725(function (global){
55726"use strict";
55727
55728function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
55729
55730/**
55731 * lodash (Custom Build) <https://lodash.com/>
55732 * Build: `lodash modularize exports="npm" -o ./`
55733 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
55734 * Released under MIT license <https://lodash.com/license>
55735 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
55736 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
55737 */
55738
55739/** Used as the size to enable large array optimizations. */
55740var LARGE_ARRAY_SIZE = 200;
55741/** Used as the `TypeError` message for "Functions" methods. */
55742
55743var FUNC_ERROR_TEXT = 'Expected a function';
55744/** Used to stand-in for `undefined` hash values. */
55745
55746var HASH_UNDEFINED = '__lodash_hash_undefined__';
55747/** Used to compose bitmasks for comparison styles. */
55748
55749var UNORDERED_COMPARE_FLAG = 1,
55750    PARTIAL_COMPARE_FLAG = 2;
55751/** Used as references for various `Number` constants. */
55752
55753var INFINITY = 1 / 0,
55754    MAX_SAFE_INTEGER = 9007199254740991;
55755/** `Object#toString` result references. */
55756
55757var argsTag = '[object Arguments]',
55758    arrayTag = '[object Array]',
55759    boolTag = '[object Boolean]',
55760    dateTag = '[object Date]',
55761    errorTag = '[object Error]',
55762    funcTag = '[object Function]',
55763    genTag = '[object GeneratorFunction]',
55764    mapTag = '[object Map]',
55765    numberTag = '[object Number]',
55766    objectTag = '[object Object]',
55767    promiseTag = '[object Promise]',
55768    regexpTag = '[object RegExp]',
55769    setTag = '[object Set]',
55770    stringTag = '[object String]',
55771    symbolTag = '[object Symbol]',
55772    weakMapTag = '[object WeakMap]';
55773var arrayBufferTag = '[object ArrayBuffer]',
55774    dataViewTag = '[object DataView]',
55775    float32Tag = '[object Float32Array]',
55776    float64Tag = '[object Float64Array]',
55777    int8Tag = '[object Int8Array]',
55778    int16Tag = '[object Int16Array]',
55779    int32Tag = '[object Int32Array]',
55780    uint8Tag = '[object Uint8Array]',
55781    uint8ClampedTag = '[object Uint8ClampedArray]',
55782    uint16Tag = '[object Uint16Array]',
55783    uint32Tag = '[object Uint32Array]';
55784/** Used to match property names within property paths. */
55785
55786var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
55787    reIsPlainProp = /^\w*$/,
55788    reLeadingDot = /^\./,
55789    rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
55790/**
55791 * Used to match `RegExp`
55792 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
55793 */
55794
55795var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
55796/** Used to match backslashes in property paths. */
55797
55798var reEscapeChar = /\\(\\)?/g;
55799/** Used to detect host constructors (Safari). */
55800
55801var reIsHostCtor = /^\[object .+?Constructor\]$/;
55802/** Used to detect unsigned integer values. */
55803
55804var reIsUint = /^(?:0|[1-9]\d*)$/;
55805/** Used to identify `toStringTag` values of typed arrays. */
55806
55807var typedArrayTags = {};
55808typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
55809typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
55810/** Detect free variable `global` from Node.js. */
55811
55812var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
55813/** Detect free variable `self`. */
55814
55815var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
55816/** Used as a reference to the global object. */
55817
55818var root = freeGlobal || freeSelf || Function('return this')();
55819/** Detect free variable `exports`. */
55820
55821var freeExports = (typeof exports === "undefined" ? "undefined" : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;
55822/** Detect free variable `module`. */
55823
55824var freeModule = freeExports && (typeof module === "undefined" ? "undefined" : _typeof(module)) == 'object' && module && !module.nodeType && module;
55825/** Detect the popular CommonJS extension `module.exports`. */
55826
55827var moduleExports = freeModule && freeModule.exports === freeExports;
55828/** Detect free variable `process` from Node.js. */
55829
55830var freeProcess = moduleExports && freeGlobal.process;
55831/** Used to access faster Node.js helpers. */
55832
55833var nodeUtil = function () {
55834  try {
55835    return freeProcess && freeProcess.binding('util');
55836  } catch (e) {}
55837}();
55838/* Node.js helper references. */
55839
55840
55841var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
55842/**
55843 * A specialized version of `baseAggregator` for arrays.
55844 *
55845 * @private
55846 * @param {Array} [array] The array to iterate over.
55847 * @param {Function} setter The function to set `accumulator` values.
55848 * @param {Function} iteratee The iteratee to transform keys.
55849 * @param {Object} accumulator The initial aggregated object.
55850 * @returns {Function} Returns `accumulator`.
55851 */
55852
55853function arrayAggregator(array, setter, iteratee, accumulator) {
55854  var index = -1,
55855      length = array ? array.length : 0;
55856
55857  while (++index < length) {
55858    var value = array[index];
55859    setter(accumulator, value, iteratee(value), array);
55860  }
55861
55862  return accumulator;
55863}
55864/**
55865 * A specialized version of `_.some` for arrays without support for iteratee
55866 * shorthands.
55867 *
55868 * @private
55869 * @param {Array} [array] The array to iterate over.
55870 * @param {Function} predicate The function invoked per iteration.
55871 * @returns {boolean} Returns `true` if any element passes the predicate check,
55872 *  else `false`.
55873 */
55874
55875
55876function arraySome(array, predicate) {
55877  var index = -1,
55878      length = array ? array.length : 0;
55879
55880  while (++index < length) {
55881    if (predicate(array[index], index, array)) {
55882      return true;
55883    }
55884  }
55885
55886  return false;
55887}
55888/**
55889 * The base implementation of `_.property` without support for deep paths.
55890 *
55891 * @private
55892 * @param {string} key The key of the property to get.
55893 * @returns {Function} Returns the new accessor function.
55894 */
55895
55896
55897function baseProperty(key) {
55898  return function (object) {
55899    return object == null ? undefined : object[key];
55900  };
55901}
55902/**
55903 * The base implementation of `_.times` without support for iteratee shorthands
55904 * or max array length checks.
55905 *
55906 * @private
55907 * @param {number} n The number of times to invoke `iteratee`.
55908 * @param {Function} iteratee The function invoked per iteration.
55909 * @returns {Array} Returns the array of results.
55910 */
55911
55912
55913function baseTimes(n, iteratee) {
55914  var index = -1,
55915      result = Array(n);
55916
55917  while (++index < n) {
55918    result[index] = iteratee(index);
55919  }
55920
55921  return result;
55922}
55923/**
55924 * The base implementation of `_.unary` without support for storing metadata.
55925 *
55926 * @private
55927 * @param {Function} func The function to cap arguments for.
55928 * @returns {Function} Returns the new capped function.
55929 */
55930
55931
55932function baseUnary(func) {
55933  return function (value) {
55934    return func(value);
55935  };
55936}
55937/**
55938 * Gets the value at `key` of `object`.
55939 *
55940 * @private
55941 * @param {Object} [object] The object to query.
55942 * @param {string} key The key of the property to get.
55943 * @returns {*} Returns the property value.
55944 */
55945
55946
55947function getValue(object, key) {
55948  return object == null ? undefined : object[key];
55949}
55950/**
55951 * Checks if `value` is a host object in IE < 9.
55952 *
55953 * @private
55954 * @param {*} value The value to check.
55955 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
55956 */
55957
55958
55959function isHostObject(value) {
55960  // Many host objects are `Object` objects that can coerce to strings
55961  // despite having improperly defined `toString` methods.
55962  var result = false;
55963
55964  if (value != null && typeof value.toString != 'function') {
55965    try {
55966      result = !!(value + '');
55967    } catch (e) {}
55968  }
55969
55970  return result;
55971}
55972/**
55973 * Converts `map` to its key-value pairs.
55974 *
55975 * @private
55976 * @param {Object} map The map to convert.
55977 * @returns {Array} Returns the key-value pairs.
55978 */
55979
55980
55981function mapToArray(map) {
55982  var index = -1,
55983      result = Array(map.size);
55984  map.forEach(function (value, key) {
55985    result[++index] = [key, value];
55986  });
55987  return result;
55988}
55989/**
55990 * Creates a unary function that invokes `func` with its argument transformed.
55991 *
55992 * @private
55993 * @param {Function} func The function to wrap.
55994 * @param {Function} transform The argument transform.
55995 * @returns {Function} Returns the new function.
55996 */
55997
55998
55999function overArg(func, transform) {
56000  return function (arg) {
56001    return func(transform(arg));
56002  };
56003}
56004/**
56005 * Converts `set` to an array of its values.
56006 *
56007 * @private
56008 * @param {Object} set The set to convert.
56009 * @returns {Array} Returns the values.
56010 */
56011
56012
56013function setToArray(set) {
56014  var index = -1,
56015      result = Array(set.size);
56016  set.forEach(function (value) {
56017    result[++index] = value;
56018  });
56019  return result;
56020}
56021/** Used for built-in method references. */
56022
56023
56024var arrayProto = Array.prototype,
56025    funcProto = Function.prototype,
56026    objectProto = Object.prototype;
56027/** Used to detect overreaching core-js shims. */
56028
56029var coreJsData = root['__core-js_shared__'];
56030/** Used to detect methods masquerading as native. */
56031
56032var maskSrcKey = function () {
56033  var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
56034  return uid ? 'Symbol(src)_1.' + uid : '';
56035}();
56036/** Used to resolve the decompiled source of functions. */
56037
56038
56039var funcToString = funcProto.toString;
56040/** Used to check objects for own properties. */
56041
56042var hasOwnProperty = objectProto.hasOwnProperty;
56043/**
56044 * Used to resolve the
56045 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
56046 * of values.
56047 */
56048
56049var objectToString = objectProto.toString;
56050/** Used to detect if a method is native. */
56051
56052var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
56053/** Built-in value references. */
56054
56055var _Symbol = root.Symbol,
56056    Uint8Array = root.Uint8Array,
56057    propertyIsEnumerable = objectProto.propertyIsEnumerable,
56058    splice = arrayProto.splice;
56059/* Built-in method references for those with the same name as other `lodash` methods. */
56060
56061var nativeKeys = overArg(Object.keys, Object);
56062/* Built-in method references that are verified to be native. */
56063
56064var DataView = getNative(root, 'DataView'),
56065    Map = getNative(root, 'Map'),
56066    Promise = getNative(root, 'Promise'),
56067    Set = getNative(root, 'Set'),
56068    WeakMap = getNative(root, 'WeakMap'),
56069    nativeCreate = getNative(Object, 'create');
56070/** Used to detect maps, sets, and weakmaps. */
56071
56072var dataViewCtorString = toSource(DataView),
56073    mapCtorString = toSource(Map),
56074    promiseCtorString = toSource(Promise),
56075    setCtorString = toSource(Set),
56076    weakMapCtorString = toSource(WeakMap);
56077/** Used to convert symbols to primitives and strings. */
56078
56079var symbolProto = _Symbol ? _Symbol.prototype : undefined,
56080    symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
56081    symbolToString = symbolProto ? symbolProto.toString : undefined;
56082/**
56083 * Creates a hash object.
56084 *
56085 * @private
56086 * @constructor
56087 * @param {Array} [entries] The key-value pairs to cache.
56088 */
56089
56090function Hash(entries) {
56091  var index = -1,
56092      length = entries ? entries.length : 0;
56093  this.clear();
56094
56095  while (++index < length) {
56096    var entry = entries[index];
56097    this.set(entry[0], entry[1]);
56098  }
56099}
56100/**
56101 * Removes all key-value entries from the hash.
56102 *
56103 * @private
56104 * @name clear
56105 * @memberOf Hash
56106 */
56107
56108
56109function hashClear() {
56110  this.__data__ = nativeCreate ? nativeCreate(null) : {};
56111}
56112/**
56113 * Removes `key` and its value from the hash.
56114 *
56115 * @private
56116 * @name delete
56117 * @memberOf Hash
56118 * @param {Object} hash The hash to modify.
56119 * @param {string} key The key of the value to remove.
56120 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
56121 */
56122
56123
56124function hashDelete(key) {
56125  return this.has(key) && delete this.__data__[key];
56126}
56127/**
56128 * Gets the hash value for `key`.
56129 *
56130 * @private
56131 * @name get
56132 * @memberOf Hash
56133 * @param {string} key The key of the value to get.
56134 * @returns {*} Returns the entry value.
56135 */
56136
56137
56138function hashGet(key) {
56139  var data = this.__data__;
56140
56141  if (nativeCreate) {
56142    var result = data[key];
56143    return result === HASH_UNDEFINED ? undefined : result;
56144  }
56145
56146  return hasOwnProperty.call(data, key) ? data[key] : undefined;
56147}
56148/**
56149 * Checks if a hash value for `key` exists.
56150 *
56151 * @private
56152 * @name has
56153 * @memberOf Hash
56154 * @param {string} key The key of the entry to check.
56155 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
56156 */
56157
56158
56159function hashHas(key) {
56160  var data = this.__data__;
56161  return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
56162}
56163/**
56164 * Sets the hash `key` to `value`.
56165 *
56166 * @private
56167 * @name set
56168 * @memberOf Hash
56169 * @param {string} key The key of the value to set.
56170 * @param {*} value The value to set.
56171 * @returns {Object} Returns the hash instance.
56172 */
56173
56174
56175function hashSet(key, value) {
56176  var data = this.__data__;
56177  data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
56178  return this;
56179} // Add methods to `Hash`.
56180
56181
56182Hash.prototype.clear = hashClear;
56183Hash.prototype['delete'] = hashDelete;
56184Hash.prototype.get = hashGet;
56185Hash.prototype.has = hashHas;
56186Hash.prototype.set = hashSet;
56187/**
56188 * Creates an list cache object.
56189 *
56190 * @private
56191 * @constructor
56192 * @param {Array} [entries] The key-value pairs to cache.
56193 */
56194
56195function ListCache(entries) {
56196  var index = -1,
56197      length = entries ? entries.length : 0;
56198  this.clear();
56199
56200  while (++index < length) {
56201    var entry = entries[index];
56202    this.set(entry[0], entry[1]);
56203  }
56204}
56205/**
56206 * Removes all key-value entries from the list cache.
56207 *
56208 * @private
56209 * @name clear
56210 * @memberOf ListCache
56211 */
56212
56213
56214function listCacheClear() {
56215  this.__data__ = [];
56216}
56217/**
56218 * Removes `key` and its value from the list cache.
56219 *
56220 * @private
56221 * @name delete
56222 * @memberOf ListCache
56223 * @param {string} key The key of the value to remove.
56224 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
56225 */
56226
56227
56228function listCacheDelete(key) {
56229  var data = this.__data__,
56230      index = assocIndexOf(data, key);
56231
56232  if (index < 0) {
56233    return false;
56234  }
56235
56236  var lastIndex = data.length - 1;
56237
56238  if (index == lastIndex) {
56239    data.pop();
56240  } else {
56241    splice.call(data, index, 1);
56242  }
56243
56244  return true;
56245}
56246/**
56247 * Gets the list cache value for `key`.
56248 *
56249 * @private
56250 * @name get
56251 * @memberOf ListCache
56252 * @param {string} key The key of the value to get.
56253 * @returns {*} Returns the entry value.
56254 */
56255
56256
56257function listCacheGet(key) {
56258  var data = this.__data__,
56259      index = assocIndexOf(data, key);
56260  return index < 0 ? undefined : data[index][1];
56261}
56262/**
56263 * Checks if a list cache value for `key` exists.
56264 *
56265 * @private
56266 * @name has
56267 * @memberOf ListCache
56268 * @param {string} key The key of the entry to check.
56269 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
56270 */
56271
56272
56273function listCacheHas(key) {
56274  return assocIndexOf(this.__data__, key) > -1;
56275}
56276/**
56277 * Sets the list cache `key` to `value`.
56278 *
56279 * @private
56280 * @name set
56281 * @memberOf ListCache
56282 * @param {string} key The key of the value to set.
56283 * @param {*} value The value to set.
56284 * @returns {Object} Returns the list cache instance.
56285 */
56286
56287
56288function listCacheSet(key, value) {
56289  var data = this.__data__,
56290      index = assocIndexOf(data, key);
56291
56292  if (index < 0) {
56293    data.push([key, value]);
56294  } else {
56295    data[index][1] = value;
56296  }
56297
56298  return this;
56299} // Add methods to `ListCache`.
56300
56301
56302ListCache.prototype.clear = listCacheClear;
56303ListCache.prototype['delete'] = listCacheDelete;
56304ListCache.prototype.get = listCacheGet;
56305ListCache.prototype.has = listCacheHas;
56306ListCache.prototype.set = listCacheSet;
56307/**
56308 * Creates a map cache object to store key-value pairs.
56309 *
56310 * @private
56311 * @constructor
56312 * @param {Array} [entries] The key-value pairs to cache.
56313 */
56314
56315function MapCache(entries) {
56316  var index = -1,
56317      length = entries ? entries.length : 0;
56318  this.clear();
56319
56320  while (++index < length) {
56321    var entry = entries[index];
56322    this.set(entry[0], entry[1]);
56323  }
56324}
56325/**
56326 * Removes all key-value entries from the map.
56327 *
56328 * @private
56329 * @name clear
56330 * @memberOf MapCache
56331 */
56332
56333
56334function mapCacheClear() {
56335  this.__data__ = {
56336    'hash': new Hash(),
56337    'map': new (Map || ListCache)(),
56338    'string': new Hash()
56339  };
56340}
56341/**
56342 * Removes `key` and its value from the map.
56343 *
56344 * @private
56345 * @name delete
56346 * @memberOf MapCache
56347 * @param {string} key The key of the value to remove.
56348 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
56349 */
56350
56351
56352function mapCacheDelete(key) {
56353  return getMapData(this, key)['delete'](key);
56354}
56355/**
56356 * Gets the map value for `key`.
56357 *
56358 * @private
56359 * @name get
56360 * @memberOf MapCache
56361 * @param {string} key The key of the value to get.
56362 * @returns {*} Returns the entry value.
56363 */
56364
56365
56366function mapCacheGet(key) {
56367  return getMapData(this, key).get(key);
56368}
56369/**
56370 * Checks if a map value for `key` exists.
56371 *
56372 * @private
56373 * @name has
56374 * @memberOf MapCache
56375 * @param {string} key The key of the entry to check.
56376 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
56377 */
56378
56379
56380function mapCacheHas(key) {
56381  return getMapData(this, key).has(key);
56382}
56383/**
56384 * Sets the map `key` to `value`.
56385 *
56386 * @private
56387 * @name set
56388 * @memberOf MapCache
56389 * @param {string} key The key of the value to set.
56390 * @param {*} value The value to set.
56391 * @returns {Object} Returns the map cache instance.
56392 */
56393
56394
56395function mapCacheSet(key, value) {
56396  getMapData(this, key).set(key, value);
56397  return this;
56398} // Add methods to `MapCache`.
56399
56400
56401MapCache.prototype.clear = mapCacheClear;
56402MapCache.prototype['delete'] = mapCacheDelete;
56403MapCache.prototype.get = mapCacheGet;
56404MapCache.prototype.has = mapCacheHas;
56405MapCache.prototype.set = mapCacheSet;
56406/**
56407 *
56408 * Creates an array cache object to store unique values.
56409 *
56410 * @private
56411 * @constructor
56412 * @param {Array} [values] The values to cache.
56413 */
56414
56415function SetCache(values) {
56416  var index = -1,
56417      length = values ? values.length : 0;
56418  this.__data__ = new MapCache();
56419
56420  while (++index < length) {
56421    this.add(values[index]);
56422  }
56423}
56424/**
56425 * Adds `value` to the array cache.
56426 *
56427 * @private
56428 * @name add
56429 * @memberOf SetCache
56430 * @alias push
56431 * @param {*} value The value to cache.
56432 * @returns {Object} Returns the cache instance.
56433 */
56434
56435
56436function setCacheAdd(value) {
56437  this.__data__.set(value, HASH_UNDEFINED);
56438
56439  return this;
56440}
56441/**
56442 * Checks if `value` is in the array cache.
56443 *
56444 * @private
56445 * @name has
56446 * @memberOf SetCache
56447 * @param {*} value The value to search for.
56448 * @returns {number} Returns `true` if `value` is found, else `false`.
56449 */
56450
56451
56452function setCacheHas(value) {
56453  return this.__data__.has(value);
56454} // Add methods to `SetCache`.
56455
56456
56457SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
56458SetCache.prototype.has = setCacheHas;
56459/**
56460 * Creates a stack cache object to store key-value pairs.
56461 *
56462 * @private
56463 * @constructor
56464 * @param {Array} [entries] The key-value pairs to cache.
56465 */
56466
56467function Stack(entries) {
56468  this.__data__ = new ListCache(entries);
56469}
56470/**
56471 * Removes all key-value entries from the stack.
56472 *
56473 * @private
56474 * @name clear
56475 * @memberOf Stack
56476 */
56477
56478
56479function stackClear() {
56480  this.__data__ = new ListCache();
56481}
56482/**
56483 * Removes `key` and its value from the stack.
56484 *
56485 * @private
56486 * @name delete
56487 * @memberOf Stack
56488 * @param {string} key The key of the value to remove.
56489 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
56490 */
56491
56492
56493function stackDelete(key) {
56494  return this.__data__['delete'](key);
56495}
56496/**
56497 * Gets the stack value for `key`.
56498 *
56499 * @private
56500 * @name get
56501 * @memberOf Stack
56502 * @param {string} key The key of the value to get.
56503 * @returns {*} Returns the entry value.
56504 */
56505
56506
56507function stackGet(key) {
56508  return this.__data__.get(key);
56509}
56510/**
56511 * Checks if a stack value for `key` exists.
56512 *
56513 * @private
56514 * @name has
56515 * @memberOf Stack
56516 * @param {string} key The key of the entry to check.
56517 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
56518 */
56519
56520
56521function stackHas(key) {
56522  return this.__data__.has(key);
56523}
56524/**
56525 * Sets the stack `key` to `value`.
56526 *
56527 * @private
56528 * @name set
56529 * @memberOf Stack
56530 * @param {string} key The key of the value to set.
56531 * @param {*} value The value to set.
56532 * @returns {Object} Returns the stack cache instance.
56533 */
56534
56535
56536function stackSet(key, value) {
56537  var cache = this.__data__;
56538
56539  if (cache instanceof ListCache) {
56540    var pairs = cache.__data__;
56541
56542    if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
56543      pairs.push([key, value]);
56544      return this;
56545    }
56546
56547    cache = this.__data__ = new MapCache(pairs);
56548  }
56549
56550  cache.set(key, value);
56551  return this;
56552} // Add methods to `Stack`.
56553
56554
56555Stack.prototype.clear = stackClear;
56556Stack.prototype['delete'] = stackDelete;
56557Stack.prototype.get = stackGet;
56558Stack.prototype.has = stackHas;
56559Stack.prototype.set = stackSet;
56560/**
56561 * Creates an array of the enumerable property names of the array-like `value`.
56562 *
56563 * @private
56564 * @param {*} value The value to query.
56565 * @param {boolean} inherited Specify returning inherited property names.
56566 * @returns {Array} Returns the array of property names.
56567 */
56568
56569function arrayLikeKeys(value, inherited) {
56570  // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
56571  // Safari 9 makes `arguments.length` enumerable in strict mode.
56572  var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : [];
56573  var length = result.length,
56574      skipIndexes = !!length;
56575
56576  for (var key in value) {
56577    if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
56578      result.push(key);
56579    }
56580  }
56581
56582  return result;
56583}
56584/**
56585 * Gets the index at which the `key` is found in `array` of key-value pairs.
56586 *
56587 * @private
56588 * @param {Array} array The array to inspect.
56589 * @param {*} key The key to search for.
56590 * @returns {number} Returns the index of the matched value, else `-1`.
56591 */
56592
56593
56594function assocIndexOf(array, key) {
56595  var length = array.length;
56596
56597  while (length--) {
56598    if (eq(array[length][0], key)) {
56599      return length;
56600    }
56601  }
56602
56603  return -1;
56604}
56605/**
56606 * Aggregates elements of `collection` on `accumulator` with keys transformed
56607 * by `iteratee` and values set by `setter`.
56608 *
56609 * @private
56610 * @param {Array|Object} collection The collection to iterate over.
56611 * @param {Function} setter The function to set `accumulator` values.
56612 * @param {Function} iteratee The iteratee to transform keys.
56613 * @param {Object} accumulator The initial aggregated object.
56614 * @returns {Function} Returns `accumulator`.
56615 */
56616
56617
56618function baseAggregator(collection, setter, iteratee, accumulator) {
56619  baseEach(collection, function (value, key, collection) {
56620    setter(accumulator, value, iteratee(value), collection);
56621  });
56622  return accumulator;
56623}
56624/**
56625 * The base implementation of `_.forEach` without support for iteratee shorthands.
56626 *
56627 * @private
56628 * @param {Array|Object} collection The collection to iterate over.
56629 * @param {Function} iteratee The function invoked per iteration.
56630 * @returns {Array|Object} Returns `collection`.
56631 */
56632
56633
56634var baseEach = createBaseEach(baseForOwn);
56635/**
56636 * The base implementation of `baseForOwn` which iterates over `object`
56637 * properties returned by `keysFunc` and invokes `iteratee` for each property.
56638 * Iteratee functions may exit iteration early by explicitly returning `false`.
56639 *
56640 * @private
56641 * @param {Object} object The object to iterate over.
56642 * @param {Function} iteratee The function invoked per iteration.
56643 * @param {Function} keysFunc The function to get the keys of `object`.
56644 * @returns {Object} Returns `object`.
56645 */
56646
56647var baseFor = createBaseFor();
56648/**
56649 * The base implementation of `_.forOwn` without support for iteratee shorthands.
56650 *
56651 * @private
56652 * @param {Object} object The object to iterate over.
56653 * @param {Function} iteratee The function invoked per iteration.
56654 * @returns {Object} Returns `object`.
56655 */
56656
56657function baseForOwn(object, iteratee) {
56658  return object && baseFor(object, iteratee, keys);
56659}
56660/**
56661 * The base implementation of `_.get` without support for default values.
56662 *
56663 * @private
56664 * @param {Object} object The object to query.
56665 * @param {Array|string} path The path of the property to get.
56666 * @returns {*} Returns the resolved value.
56667 */
56668
56669
56670function baseGet(object, path) {
56671  path = isKey(path, object) ? [path] : castPath(path);
56672  var index = 0,
56673      length = path.length;
56674
56675  while (object != null && index < length) {
56676    object = object[toKey(path[index++])];
56677  }
56678
56679  return index && index == length ? object : undefined;
56680}
56681/**
56682 * The base implementation of `getTag`.
56683 *
56684 * @private
56685 * @param {*} value The value to query.
56686 * @returns {string} Returns the `toStringTag`.
56687 */
56688
56689
56690function baseGetTag(value) {
56691  return objectToString.call(value);
56692}
56693/**
56694 * The base implementation of `_.hasIn` without support for deep paths.
56695 *
56696 * @private
56697 * @param {Object} [object] The object to query.
56698 * @param {Array|string} key The key to check.
56699 * @returns {boolean} Returns `true` if `key` exists, else `false`.
56700 */
56701
56702
56703function baseHasIn(object, key) {
56704  return object != null && key in Object(object);
56705}
56706/**
56707 * The base implementation of `_.isEqual` which supports partial comparisons
56708 * and tracks traversed objects.
56709 *
56710 * @private
56711 * @param {*} value The value to compare.
56712 * @param {*} other The other value to compare.
56713 * @param {Function} [customizer] The function to customize comparisons.
56714 * @param {boolean} [bitmask] The bitmask of comparison flags.
56715 *  The bitmask may be composed of the following flags:
56716 *     1 - Unordered comparison
56717 *     2 - Partial comparison
56718 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
56719 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
56720 */
56721
56722
56723function baseIsEqual(value, other, customizer, bitmask, stack) {
56724  if (value === other) {
56725    return true;
56726  }
56727
56728  if (value == null || other == null || !isObject(value) && !isObjectLike(other)) {
56729    return value !== value && other !== other;
56730  }
56731
56732  return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
56733}
56734/**
56735 * A specialized version of `baseIsEqual` for arrays and objects which performs
56736 * deep comparisons and tracks traversed objects enabling objects with circular
56737 * references to be compared.
56738 *
56739 * @private
56740 * @param {Object} object The object to compare.
56741 * @param {Object} other The other object to compare.
56742 * @param {Function} equalFunc The function to determine equivalents of values.
56743 * @param {Function} [customizer] The function to customize comparisons.
56744 * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
56745 *  for more details.
56746 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
56747 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
56748 */
56749
56750
56751function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
56752  var objIsArr = isArray(object),
56753      othIsArr = isArray(other),
56754      objTag = arrayTag,
56755      othTag = arrayTag;
56756
56757  if (!objIsArr) {
56758    objTag = getTag(object);
56759    objTag = objTag == argsTag ? objectTag : objTag;
56760  }
56761
56762  if (!othIsArr) {
56763    othTag = getTag(other);
56764    othTag = othTag == argsTag ? objectTag : othTag;
56765  }
56766
56767  var objIsObj = objTag == objectTag && !isHostObject(object),
56768      othIsObj = othTag == objectTag && !isHostObject(other),
56769      isSameTag = objTag == othTag;
56770
56771  if (isSameTag && !objIsObj) {
56772    stack || (stack = new Stack());
56773    return objIsArr || isTypedArray(object) ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
56774  }
56775
56776  if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
56777    var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
56778        othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
56779
56780    if (objIsWrapped || othIsWrapped) {
56781      var objUnwrapped = objIsWrapped ? object.value() : object,
56782          othUnwrapped = othIsWrapped ? other.value() : other;
56783      stack || (stack = new Stack());
56784      return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
56785    }
56786  }
56787
56788  if (!isSameTag) {
56789    return false;
56790  }
56791
56792  stack || (stack = new Stack());
56793  return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
56794}
56795/**
56796 * The base implementation of `_.isMatch` without support for iteratee shorthands.
56797 *
56798 * @private
56799 * @param {Object} object The object to inspect.
56800 * @param {Object} source The object of property values to match.
56801 * @param {Array} matchData The property names, values, and compare flags to match.
56802 * @param {Function} [customizer] The function to customize comparisons.
56803 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
56804 */
56805
56806
56807function baseIsMatch(object, source, matchData, customizer) {
56808  var index = matchData.length,
56809      length = index,
56810      noCustomizer = !customizer;
56811
56812  if (object == null) {
56813    return !length;
56814  }
56815
56816  object = Object(object);
56817
56818  while (index--) {
56819    var data = matchData[index];
56820
56821    if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
56822      return false;
56823    }
56824  }
56825
56826  while (++index < length) {
56827    data = matchData[index];
56828    var key = data[0],
56829        objValue = object[key],
56830        srcValue = data[1];
56831
56832    if (noCustomizer && data[2]) {
56833      if (objValue === undefined && !(key in object)) {
56834        return false;
56835      }
56836    } else {
56837      var stack = new Stack();
56838
56839      if (customizer) {
56840        var result = customizer(objValue, srcValue, key, object, source, stack);
56841      }
56842
56843      if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
56844        return false;
56845      }
56846    }
56847  }
56848
56849  return true;
56850}
56851/**
56852 * The base implementation of `_.isNative` without bad shim checks.
56853 *
56854 * @private
56855 * @param {*} value The value to check.
56856 * @returns {boolean} Returns `true` if `value` is a native function,
56857 *  else `false`.
56858 */
56859
56860
56861function baseIsNative(value) {
56862  if (!isObject(value) || isMasked(value)) {
56863    return false;
56864  }
56865
56866  var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
56867  return pattern.test(toSource(value));
56868}
56869/**
56870 * The base implementation of `_.isTypedArray` without Node.js optimizations.
56871 *
56872 * @private
56873 * @param {*} value The value to check.
56874 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
56875 */
56876
56877
56878function baseIsTypedArray(value) {
56879  return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
56880}
56881/**
56882 * The base implementation of `_.iteratee`.
56883 *
56884 * @private
56885 * @param {*} [value=_.identity] The value to convert to an iteratee.
56886 * @returns {Function} Returns the iteratee.
56887 */
56888
56889
56890function baseIteratee(value) {
56891  // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
56892  // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
56893  if (typeof value == 'function') {
56894    return value;
56895  }
56896
56897  if (value == null) {
56898    return identity;
56899  }
56900
56901  if (_typeof(value) == 'object') {
56902    return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
56903  }
56904
56905  return property(value);
56906}
56907/**
56908 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
56909 *
56910 * @private
56911 * @param {Object} object The object to query.
56912 * @returns {Array} Returns the array of property names.
56913 */
56914
56915
56916function baseKeys(object) {
56917  if (!isPrototype(object)) {
56918    return nativeKeys(object);
56919  }
56920
56921  var result = [];
56922
56923  for (var key in Object(object)) {
56924    if (hasOwnProperty.call(object, key) && key != 'constructor') {
56925      result.push(key);
56926    }
56927  }
56928
56929  return result;
56930}
56931/**
56932 * The base implementation of `_.matches` which doesn't clone `source`.
56933 *
56934 * @private
56935 * @param {Object} source The object of property values to match.
56936 * @returns {Function} Returns the new spec function.
56937 */
56938
56939
56940function baseMatches(source) {
56941  var matchData = getMatchData(source);
56942
56943  if (matchData.length == 1 && matchData[0][2]) {
56944    return matchesStrictComparable(matchData[0][0], matchData[0][1]);
56945  }
56946
56947  return function (object) {
56948    return object === source || baseIsMatch(object, source, matchData);
56949  };
56950}
56951/**
56952 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
56953 *
56954 * @private
56955 * @param {string} path The path of the property to get.
56956 * @param {*} srcValue The value to match.
56957 * @returns {Function} Returns the new spec function.
56958 */
56959
56960
56961function baseMatchesProperty(path, srcValue) {
56962  if (isKey(path) && isStrictComparable(srcValue)) {
56963    return matchesStrictComparable(toKey(path), srcValue);
56964  }
56965
56966  return function (object) {
56967    var objValue = get(object, path);
56968    return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
56969  };
56970}
56971/**
56972 * A specialized version of `baseProperty` which supports deep paths.
56973 *
56974 * @private
56975 * @param {Array|string} path The path of the property to get.
56976 * @returns {Function} Returns the new accessor function.
56977 */
56978
56979
56980function basePropertyDeep(path) {
56981  return function (object) {
56982    return baseGet(object, path);
56983  };
56984}
56985/**
56986 * The base implementation of `_.toString` which doesn't convert nullish
56987 * values to empty strings.
56988 *
56989 * @private
56990 * @param {*} value The value to process.
56991 * @returns {string} Returns the string.
56992 */
56993
56994
56995function baseToString(value) {
56996  // Exit early for strings to avoid a performance hit in some environments.
56997  if (typeof value == 'string') {
56998    return value;
56999  }
57000
57001  if (isSymbol(value)) {
57002    return symbolToString ? symbolToString.call(value) : '';
57003  }
57004
57005  var result = value + '';
57006  return result == '0' && 1 / value == -INFINITY ? '-0' : result;
57007}
57008/**
57009 * Casts `value` to a path array if it's not one.
57010 *
57011 * @private
57012 * @param {*} value The value to inspect.
57013 * @returns {Array} Returns the cast property path array.
57014 */
57015
57016
57017function castPath(value) {
57018  return isArray(value) ? value : stringToPath(value);
57019}
57020/**
57021 * Creates a function like `_.groupBy`.
57022 *
57023 * @private
57024 * @param {Function} setter The function to set accumulator values.
57025 * @param {Function} [initializer] The accumulator object initializer.
57026 * @returns {Function} Returns the new aggregator function.
57027 */
57028
57029
57030function createAggregator(setter, initializer) {
57031  return function (collection, iteratee) {
57032    var func = isArray(collection) ? arrayAggregator : baseAggregator,
57033        accumulator = initializer ? initializer() : {};
57034    return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
57035  };
57036}
57037/**
57038 * Creates a `baseEach` or `baseEachRight` function.
57039 *
57040 * @private
57041 * @param {Function} eachFunc The function to iterate over a collection.
57042 * @param {boolean} [fromRight] Specify iterating from right to left.
57043 * @returns {Function} Returns the new base function.
57044 */
57045
57046
57047function createBaseEach(eachFunc, fromRight) {
57048  return function (collection, iteratee) {
57049    if (collection == null) {
57050      return collection;
57051    }
57052
57053    if (!isArrayLike(collection)) {
57054      return eachFunc(collection, iteratee);
57055    }
57056
57057    var length = collection.length,
57058        index = fromRight ? length : -1,
57059        iterable = Object(collection);
57060
57061    while (fromRight ? index-- : ++index < length) {
57062      if (iteratee(iterable[index], index, iterable) === false) {
57063        break;
57064      }
57065    }
57066
57067    return collection;
57068  };
57069}
57070/**
57071 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
57072 *
57073 * @private
57074 * @param {boolean} [fromRight] Specify iterating from right to left.
57075 * @returns {Function} Returns the new base function.
57076 */
57077
57078
57079function createBaseFor(fromRight) {
57080  return function (object, iteratee, keysFunc) {
57081    var index = -1,
57082        iterable = Object(object),
57083        props = keysFunc(object),
57084        length = props.length;
57085
57086    while (length--) {
57087      var key = props[fromRight ? length : ++index];
57088
57089      if (iteratee(iterable[key], key, iterable) === false) {
57090        break;
57091      }
57092    }
57093
57094    return object;
57095  };
57096}
57097/**
57098 * A specialized version of `baseIsEqualDeep` for arrays with support for
57099 * partial deep comparisons.
57100 *
57101 * @private
57102 * @param {Array} array The array to compare.
57103 * @param {Array} other The other array to compare.
57104 * @param {Function} equalFunc The function to determine equivalents of values.
57105 * @param {Function} customizer The function to customize comparisons.
57106 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
57107 *  for more details.
57108 * @param {Object} stack Tracks traversed `array` and `other` objects.
57109 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
57110 */
57111
57112
57113function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
57114  var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
57115      arrLength = array.length,
57116      othLength = other.length;
57117
57118  if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
57119    return false;
57120  } // Assume cyclic values are equal.
57121
57122
57123  var stacked = stack.get(array);
57124
57125  if (stacked && stack.get(other)) {
57126    return stacked == other;
57127  }
57128
57129  var index = -1,
57130      result = true,
57131      seen = bitmask & UNORDERED_COMPARE_FLAG ? new SetCache() : undefined;
57132  stack.set(array, other);
57133  stack.set(other, array); // Ignore non-index properties.
57134
57135  while (++index < arrLength) {
57136    var arrValue = array[index],
57137        othValue = other[index];
57138
57139    if (customizer) {
57140      var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
57141    }
57142
57143    if (compared !== undefined) {
57144      if (compared) {
57145        continue;
57146      }
57147
57148      result = false;
57149      break;
57150    } // Recursively compare arrays (susceptible to call stack limits).
57151
57152
57153    if (seen) {
57154      if (!arraySome(other, function (othValue, othIndex) {
57155        if (!seen.has(othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
57156          return seen.add(othIndex);
57157        }
57158      })) {
57159        result = false;
57160        break;
57161      }
57162    } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
57163      result = false;
57164      break;
57165    }
57166  }
57167
57168  stack['delete'](array);
57169  stack['delete'](other);
57170  return result;
57171}
57172/**
57173 * A specialized version of `baseIsEqualDeep` for comparing objects of
57174 * the same `toStringTag`.
57175 *
57176 * **Note:** This function only supports comparing values with tags of
57177 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
57178 *
57179 * @private
57180 * @param {Object} object The object to compare.
57181 * @param {Object} other The other object to compare.
57182 * @param {string} tag The `toStringTag` of the objects to compare.
57183 * @param {Function} equalFunc The function to determine equivalents of values.
57184 * @param {Function} customizer The function to customize comparisons.
57185 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
57186 *  for more details.
57187 * @param {Object} stack Tracks traversed `object` and `other` objects.
57188 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
57189 */
57190
57191
57192function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
57193  switch (tag) {
57194    case dataViewTag:
57195      if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
57196        return false;
57197      }
57198
57199      object = object.buffer;
57200      other = other.buffer;
57201
57202    case arrayBufferTag:
57203      if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
57204        return false;
57205      }
57206
57207      return true;
57208
57209    case boolTag:
57210    case dateTag:
57211    case numberTag:
57212      // Coerce booleans to `1` or `0` and dates to milliseconds.
57213      // Invalid dates are coerced to `NaN`.
57214      return eq(+object, +other);
57215
57216    case errorTag:
57217      return object.name == other.name && object.message == other.message;
57218
57219    case regexpTag:
57220    case stringTag:
57221      // Coerce regexes to strings and treat strings, primitives and objects,
57222      // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
57223      // for more details.
57224      return object == other + '';
57225
57226    case mapTag:
57227      var convert = mapToArray;
57228
57229    case setTag:
57230      var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
57231      convert || (convert = setToArray);
57232
57233      if (object.size != other.size && !isPartial) {
57234        return false;
57235      } // Assume cyclic values are equal.
57236
57237
57238      var stacked = stack.get(object);
57239
57240      if (stacked) {
57241        return stacked == other;
57242      }
57243
57244      bitmask |= UNORDERED_COMPARE_FLAG; // Recursively compare objects (susceptible to call stack limits).
57245
57246      stack.set(object, other);
57247      var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
57248      stack['delete'](object);
57249      return result;
57250
57251    case symbolTag:
57252      if (symbolValueOf) {
57253        return symbolValueOf.call(object) == symbolValueOf.call(other);
57254      }
57255
57256  }
57257
57258  return false;
57259}
57260/**
57261 * A specialized version of `baseIsEqualDeep` for objects with support for
57262 * partial deep comparisons.
57263 *
57264 * @private
57265 * @param {Object} object The object to compare.
57266 * @param {Object} other The other object to compare.
57267 * @param {Function} equalFunc The function to determine equivalents of values.
57268 * @param {Function} customizer The function to customize comparisons.
57269 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
57270 *  for more details.
57271 * @param {Object} stack Tracks traversed `object` and `other` objects.
57272 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
57273 */
57274
57275
57276function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
57277  var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
57278      objProps = keys(object),
57279      objLength = objProps.length,
57280      othProps = keys(other),
57281      othLength = othProps.length;
57282
57283  if (objLength != othLength && !isPartial) {
57284    return false;
57285  }
57286
57287  var index = objLength;
57288
57289  while (index--) {
57290    var key = objProps[index];
57291
57292    if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
57293      return false;
57294    }
57295  } // Assume cyclic values are equal.
57296
57297
57298  var stacked = stack.get(object);
57299
57300  if (stacked && stack.get(other)) {
57301    return stacked == other;
57302  }
57303
57304  var result = true;
57305  stack.set(object, other);
57306  stack.set(other, object);
57307  var skipCtor = isPartial;
57308
57309  while (++index < objLength) {
57310    key = objProps[index];
57311    var objValue = object[key],
57312        othValue = other[key];
57313
57314    if (customizer) {
57315      var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
57316    } // Recursively compare objects (susceptible to call stack limits).
57317
57318
57319    if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack) : compared)) {
57320      result = false;
57321      break;
57322    }
57323
57324    skipCtor || (skipCtor = key == 'constructor');
57325  }
57326
57327  if (result && !skipCtor) {
57328    var objCtor = object.constructor,
57329        othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
57330
57331    if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
57332      result = false;
57333    }
57334  }
57335
57336  stack['delete'](object);
57337  stack['delete'](other);
57338  return result;
57339}
57340/**
57341 * Gets the data for `map`.
57342 *
57343 * @private
57344 * @param {Object} map The map to query.
57345 * @param {string} key The reference key.
57346 * @returns {*} Returns the map data.
57347 */
57348
57349
57350function getMapData(map, key) {
57351  var data = map.__data__;
57352  return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
57353}
57354/**
57355 * Gets the property names, values, and compare flags of `object`.
57356 *
57357 * @private
57358 * @param {Object} object The object to query.
57359 * @returns {Array} Returns the match data of `object`.
57360 */
57361
57362
57363function getMatchData(object) {
57364  var result = keys(object),
57365      length = result.length;
57366
57367  while (length--) {
57368    var key = result[length],
57369        value = object[key];
57370    result[length] = [key, value, isStrictComparable(value)];
57371  }
57372
57373  return result;
57374}
57375/**
57376 * Gets the native function at `key` of `object`.
57377 *
57378 * @private
57379 * @param {Object} object The object to query.
57380 * @param {string} key The key of the method to get.
57381 * @returns {*} Returns the function if it's native, else `undefined`.
57382 */
57383
57384
57385function getNative(object, key) {
57386  var value = getValue(object, key);
57387  return baseIsNative(value) ? value : undefined;
57388}
57389/**
57390 * Gets the `toStringTag` of `value`.
57391 *
57392 * @private
57393 * @param {*} value The value to query.
57394 * @returns {string} Returns the `toStringTag`.
57395 */
57396
57397
57398var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11,
57399// for data views in Edge < 14, and promises in Node.js.
57400
57401if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise && getTag(Promise.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
57402  getTag = function getTag(value) {
57403    var result = objectToString.call(value),
57404        Ctor = result == objectTag ? value.constructor : undefined,
57405        ctorString = Ctor ? toSource(Ctor) : undefined;
57406
57407    if (ctorString) {
57408      switch (ctorString) {
57409        case dataViewCtorString:
57410          return dataViewTag;
57411
57412        case mapCtorString:
57413          return mapTag;
57414
57415        case promiseCtorString:
57416          return promiseTag;
57417
57418        case setCtorString:
57419          return setTag;
57420
57421        case weakMapCtorString:
57422          return weakMapTag;
57423      }
57424    }
57425
57426    return result;
57427  };
57428}
57429/**
57430 * Checks if `path` exists on `object`.
57431 *
57432 * @private
57433 * @param {Object} object The object to query.
57434 * @param {Array|string} path The path to check.
57435 * @param {Function} hasFunc The function to check properties.
57436 * @returns {boolean} Returns `true` if `path` exists, else `false`.
57437 */
57438
57439
57440function hasPath(object, path, hasFunc) {
57441  path = isKey(path, object) ? [path] : castPath(path);
57442  var result,
57443      index = -1,
57444      length = path.length;
57445
57446  while (++index < length) {
57447    var key = toKey(path[index]);
57448
57449    if (!(result = object != null && hasFunc(object, key))) {
57450      break;
57451    }
57452
57453    object = object[key];
57454  }
57455
57456  if (result) {
57457    return result;
57458  }
57459
57460  var length = object ? object.length : 0;
57461  return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
57462}
57463/**
57464 * Checks if `value` is a valid array-like index.
57465 *
57466 * @private
57467 * @param {*} value The value to check.
57468 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
57469 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
57470 */
57471
57472
57473function isIndex(value, length) {
57474  length = length == null ? MAX_SAFE_INTEGER : length;
57475  return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
57476}
57477/**
57478 * Checks if `value` is a property name and not a property path.
57479 *
57480 * @private
57481 * @param {*} value The value to check.
57482 * @param {Object} [object] The object to query keys on.
57483 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
57484 */
57485
57486
57487function isKey(value, object) {
57488  if (isArray(value)) {
57489    return false;
57490  }
57491
57492  var type = _typeof(value);
57493
57494  if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
57495    return true;
57496  }
57497
57498  return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
57499}
57500/**
57501 * Checks if `value` is suitable for use as unique object key.
57502 *
57503 * @private
57504 * @param {*} value The value to check.
57505 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
57506 */
57507
57508
57509function isKeyable(value) {
57510  var type = _typeof(value);
57511
57512  return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
57513}
57514/**
57515 * Checks if `func` has its source masked.
57516 *
57517 * @private
57518 * @param {Function} func The function to check.
57519 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
57520 */
57521
57522
57523function isMasked(func) {
57524  return !!maskSrcKey && maskSrcKey in func;
57525}
57526/**
57527 * Checks if `value` is likely a prototype object.
57528 *
57529 * @private
57530 * @param {*} value The value to check.
57531 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
57532 */
57533
57534
57535function isPrototype(value) {
57536  var Ctor = value && value.constructor,
57537      proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;
57538  return value === proto;
57539}
57540/**
57541 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
57542 *
57543 * @private
57544 * @param {*} value The value to check.
57545 * @returns {boolean} Returns `true` if `value` if suitable for strict
57546 *  equality comparisons, else `false`.
57547 */
57548
57549
57550function isStrictComparable(value) {
57551  return value === value && !isObject(value);
57552}
57553/**
57554 * A specialized version of `matchesProperty` for source values suitable
57555 * for strict equality comparisons, i.e. `===`.
57556 *
57557 * @private
57558 * @param {string} key The key of the property to get.
57559 * @param {*} srcValue The value to match.
57560 * @returns {Function} Returns the new spec function.
57561 */
57562
57563
57564function matchesStrictComparable(key, srcValue) {
57565  return function (object) {
57566    if (object == null) {
57567      return false;
57568    }
57569
57570    return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
57571  };
57572}
57573/**
57574 * Converts `string` to a property path array.
57575 *
57576 * @private
57577 * @param {string} string The string to convert.
57578 * @returns {Array} Returns the property path array.
57579 */
57580
57581
57582var stringToPath = memoize(function (string) {
57583  string = toString(string);
57584  var result = [];
57585
57586  if (reLeadingDot.test(string)) {
57587    result.push('');
57588  }
57589
57590  string.replace(rePropName, function (match, number, quote, string) {
57591    result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
57592  });
57593  return result;
57594});
57595/**
57596 * Converts `value` to a string key if it's not a string or symbol.
57597 *
57598 * @private
57599 * @param {*} value The value to inspect.
57600 * @returns {string|symbol} Returns the key.
57601 */
57602
57603function toKey(value) {
57604  if (typeof value == 'string' || isSymbol(value)) {
57605    return value;
57606  }
57607
57608  var result = value + '';
57609  return result == '0' && 1 / value == -INFINITY ? '-0' : result;
57610}
57611/**
57612 * Converts `func` to its source code.
57613 *
57614 * @private
57615 * @param {Function} func The function to process.
57616 * @returns {string} Returns the source code.
57617 */
57618
57619
57620function toSource(func) {
57621  if (func != null) {
57622    try {
57623      return funcToString.call(func);
57624    } catch (e) {}
57625
57626    try {
57627      return func + '';
57628    } catch (e) {}
57629  }
57630
57631  return '';
57632}
57633/**
57634 * Creates an object composed of keys generated from the results of running
57635 * each element of `collection` thru `iteratee`. The order of grouped values
57636 * is determined by the order they occur in `collection`. The corresponding
57637 * value of each key is an array of elements responsible for generating the
57638 * key. The iteratee is invoked with one argument: (value).
57639 *
57640 * @static
57641 * @memberOf _
57642 * @since 0.1.0
57643 * @category Collection
57644 * @param {Array|Object} collection The collection to iterate over.
57645 * @param {Function} [iteratee=_.identity]
57646 *  The iteratee to transform keys.
57647 * @returns {Object} Returns the composed aggregate object.
57648 * @example
57649 *
57650 * _.groupBy([6.1, 4.2, 6.3], Math.floor);
57651 * // => { '4': [4.2], '6': [6.1, 6.3] }
57652 *
57653 * // The `_.property` iteratee shorthand.
57654 * _.groupBy(['one', 'two', 'three'], 'length');
57655 * // => { '3': ['one', 'two'], '5': ['three'] }
57656 */
57657
57658
57659var groupBy = createAggregator(function (result, value, key) {
57660  if (hasOwnProperty.call(result, key)) {
57661    result[key].push(value);
57662  } else {
57663    result[key] = [value];
57664  }
57665});
57666/**
57667 * Creates a function that memoizes the result of `func`. If `resolver` is
57668 * provided, it determines the cache key for storing the result based on the
57669 * arguments provided to the memoized function. By default, the first argument
57670 * provided to the memoized function is used as the map cache key. The `func`
57671 * is invoked with the `this` binding of the memoized function.
57672 *
57673 * **Note:** The cache is exposed as the `cache` property on the memoized
57674 * function. Its creation may be customized by replacing the `_.memoize.Cache`
57675 * constructor with one whose instances implement the
57676 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
57677 * method interface of `delete`, `get`, `has`, and `set`.
57678 *
57679 * @static
57680 * @memberOf _
57681 * @since 0.1.0
57682 * @category Function
57683 * @param {Function} func The function to have its output memoized.
57684 * @param {Function} [resolver] The function to resolve the cache key.
57685 * @returns {Function} Returns the new memoized function.
57686 * @example
57687 *
57688 * var object = { 'a': 1, 'b': 2 };
57689 * var other = { 'c': 3, 'd': 4 };
57690 *
57691 * var values = _.memoize(_.values);
57692 * values(object);
57693 * // => [1, 2]
57694 *
57695 * values(other);
57696 * // => [3, 4]
57697 *
57698 * object.a = 2;
57699 * values(object);
57700 * // => [1, 2]
57701 *
57702 * // Modify the result cache.
57703 * values.cache.set(object, ['a', 'b']);
57704 * values(object);
57705 * // => ['a', 'b']
57706 *
57707 * // Replace `_.memoize.Cache`.
57708 * _.memoize.Cache = WeakMap;
57709 */
57710
57711function memoize(func, resolver) {
57712  if (typeof func != 'function' || resolver && typeof resolver != 'function') {
57713    throw new TypeError(FUNC_ERROR_TEXT);
57714  }
57715
57716  var memoized = function memoized() {
57717    var args = arguments,
57718        key = resolver ? resolver.apply(this, args) : args[0],
57719        cache = memoized.cache;
57720
57721    if (cache.has(key)) {
57722      return cache.get(key);
57723    }
57724
57725    var result = func.apply(this, args);
57726    memoized.cache = cache.set(key, result);
57727    return result;
57728  };
57729
57730  memoized.cache = new (memoize.Cache || MapCache)();
57731  return memoized;
57732} // Assign cache to `_.memoize`.
57733
57734
57735memoize.Cache = MapCache;
57736/**
57737 * Performs a
57738 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
57739 * comparison between two values to determine if they are equivalent.
57740 *
57741 * @static
57742 * @memberOf _
57743 * @since 4.0.0
57744 * @category Lang
57745 * @param {*} value The value to compare.
57746 * @param {*} other The other value to compare.
57747 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
57748 * @example
57749 *
57750 * var object = { 'a': 1 };
57751 * var other = { 'a': 1 };
57752 *
57753 * _.eq(object, object);
57754 * // => true
57755 *
57756 * _.eq(object, other);
57757 * // => false
57758 *
57759 * _.eq('a', 'a');
57760 * // => true
57761 *
57762 * _.eq('a', Object('a'));
57763 * // => false
57764 *
57765 * _.eq(NaN, NaN);
57766 * // => true
57767 */
57768
57769function eq(value, other) {
57770  return value === other || value !== value && other !== other;
57771}
57772/**
57773 * Checks if `value` is likely an `arguments` object.
57774 *
57775 * @static
57776 * @memberOf _
57777 * @since 0.1.0
57778 * @category Lang
57779 * @param {*} value The value to check.
57780 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
57781 *  else `false`.
57782 * @example
57783 *
57784 * _.isArguments(function() { return arguments; }());
57785 * // => true
57786 *
57787 * _.isArguments([1, 2, 3]);
57788 * // => false
57789 */
57790
57791
57792function isArguments(value) {
57793  // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
57794  return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
57795}
57796/**
57797 * Checks if `value` is classified as an `Array` object.
57798 *
57799 * @static
57800 * @memberOf _
57801 * @since 0.1.0
57802 * @category Lang
57803 * @param {*} value The value to check.
57804 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
57805 * @example
57806 *
57807 * _.isArray([1, 2, 3]);
57808 * // => true
57809 *
57810 * _.isArray(document.body.children);
57811 * // => false
57812 *
57813 * _.isArray('abc');
57814 * // => false
57815 *
57816 * _.isArray(_.noop);
57817 * // => false
57818 */
57819
57820
57821var isArray = Array.isArray;
57822/**
57823 * Checks if `value` is array-like. A value is considered array-like if it's
57824 * not a function and has a `value.length` that's an integer greater than or
57825 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
57826 *
57827 * @static
57828 * @memberOf _
57829 * @since 4.0.0
57830 * @category Lang
57831 * @param {*} value The value to check.
57832 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
57833 * @example
57834 *
57835 * _.isArrayLike([1, 2, 3]);
57836 * // => true
57837 *
57838 * _.isArrayLike(document.body.children);
57839 * // => true
57840 *
57841 * _.isArrayLike('abc');
57842 * // => true
57843 *
57844 * _.isArrayLike(_.noop);
57845 * // => false
57846 */
57847
57848function isArrayLike(value) {
57849  return value != null && isLength(value.length) && !isFunction(value);
57850}
57851/**
57852 * This method is like `_.isArrayLike` except that it also checks if `value`
57853 * is an object.
57854 *
57855 * @static
57856 * @memberOf _
57857 * @since 4.0.0
57858 * @category Lang
57859 * @param {*} value The value to check.
57860 * @returns {boolean} Returns `true` if `value` is an array-like object,
57861 *  else `false`.
57862 * @example
57863 *
57864 * _.isArrayLikeObject([1, 2, 3]);
57865 * // => true
57866 *
57867 * _.isArrayLikeObject(document.body.children);
57868 * // => true
57869 *
57870 * _.isArrayLikeObject('abc');
57871 * // => false
57872 *
57873 * _.isArrayLikeObject(_.noop);
57874 * // => false
57875 */
57876
57877
57878function isArrayLikeObject(value) {
57879  return isObjectLike(value) && isArrayLike(value);
57880}
57881/**
57882 * Checks if `value` is classified as a `Function` object.
57883 *
57884 * @static
57885 * @memberOf _
57886 * @since 0.1.0
57887 * @category Lang
57888 * @param {*} value The value to check.
57889 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
57890 * @example
57891 *
57892 * _.isFunction(_);
57893 * // => true
57894 *
57895 * _.isFunction(/abc/);
57896 * // => false
57897 */
57898
57899
57900function isFunction(value) {
57901  // The use of `Object#toString` avoids issues with the `typeof` operator
57902  // in Safari 8-9 which returns 'object' for typed array and other constructors.
57903  var tag = isObject(value) ? objectToString.call(value) : '';
57904  return tag == funcTag || tag == genTag;
57905}
57906/**
57907 * Checks if `value` is a valid array-like length.
57908 *
57909 * **Note:** This method is loosely based on
57910 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
57911 *
57912 * @static
57913 * @memberOf _
57914 * @since 4.0.0
57915 * @category Lang
57916 * @param {*} value The value to check.
57917 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
57918 * @example
57919 *
57920 * _.isLength(3);
57921 * // => true
57922 *
57923 * _.isLength(Number.MIN_VALUE);
57924 * // => false
57925 *
57926 * _.isLength(Infinity);
57927 * // => false
57928 *
57929 * _.isLength('3');
57930 * // => false
57931 */
57932
57933
57934function isLength(value) {
57935  return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
57936}
57937/**
57938 * Checks if `value` is the
57939 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
57940 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
57941 *
57942 * @static
57943 * @memberOf _
57944 * @since 0.1.0
57945 * @category Lang
57946 * @param {*} value The value to check.
57947 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
57948 * @example
57949 *
57950 * _.isObject({});
57951 * // => true
57952 *
57953 * _.isObject([1, 2, 3]);
57954 * // => true
57955 *
57956 * _.isObject(_.noop);
57957 * // => true
57958 *
57959 * _.isObject(null);
57960 * // => false
57961 */
57962
57963
57964function isObject(value) {
57965  var type = _typeof(value);
57966
57967  return !!value && (type == 'object' || type == 'function');
57968}
57969/**
57970 * Checks if `value` is object-like. A value is object-like if it's not `null`
57971 * and has a `typeof` result of "object".
57972 *
57973 * @static
57974 * @memberOf _
57975 * @since 4.0.0
57976 * @category Lang
57977 * @param {*} value The value to check.
57978 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
57979 * @example
57980 *
57981 * _.isObjectLike({});
57982 * // => true
57983 *
57984 * _.isObjectLike([1, 2, 3]);
57985 * // => true
57986 *
57987 * _.isObjectLike(_.noop);
57988 * // => false
57989 *
57990 * _.isObjectLike(null);
57991 * // => false
57992 */
57993
57994
57995function isObjectLike(value) {
57996  return !!value && _typeof(value) == 'object';
57997}
57998/**
57999 * Checks if `value` is classified as a `Symbol` primitive or object.
58000 *
58001 * @static
58002 * @memberOf _
58003 * @since 4.0.0
58004 * @category Lang
58005 * @param {*} value The value to check.
58006 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
58007 * @example
58008 *
58009 * _.isSymbol(Symbol.iterator);
58010 * // => true
58011 *
58012 * _.isSymbol('abc');
58013 * // => false
58014 */
58015
58016
58017function isSymbol(value) {
58018  return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
58019}
58020/**
58021 * Checks if `value` is classified as a typed array.
58022 *
58023 * @static
58024 * @memberOf _
58025 * @since 3.0.0
58026 * @category Lang
58027 * @param {*} value The value to check.
58028 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
58029 * @example
58030 *
58031 * _.isTypedArray(new Uint8Array);
58032 * // => true
58033 *
58034 * _.isTypedArray([]);
58035 * // => false
58036 */
58037
58038
58039var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
58040/**
58041 * Converts `value` to a string. An empty string is returned for `null`
58042 * and `undefined` values. The sign of `-0` is preserved.
58043 *
58044 * @static
58045 * @memberOf _
58046 * @since 4.0.0
58047 * @category Lang
58048 * @param {*} value The value to process.
58049 * @returns {string} Returns the string.
58050 * @example
58051 *
58052 * _.toString(null);
58053 * // => ''
58054 *
58055 * _.toString(-0);
58056 * // => '-0'
58057 *
58058 * _.toString([1, 2, 3]);
58059 * // => '1,2,3'
58060 */
58061
58062function toString(value) {
58063  return value == null ? '' : baseToString(value);
58064}
58065/**
58066 * Gets the value at `path` of `object`. If the resolved value is
58067 * `undefined`, the `defaultValue` is returned in its place.
58068 *
58069 * @static
58070 * @memberOf _
58071 * @since 3.7.0
58072 * @category Object
58073 * @param {Object} object The object to query.
58074 * @param {Array|string} path The path of the property to get.
58075 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
58076 * @returns {*} Returns the resolved value.
58077 * @example
58078 *
58079 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
58080 *
58081 * _.get(object, 'a[0].b.c');
58082 * // => 3
58083 *
58084 * _.get(object, ['a', '0', 'b', 'c']);
58085 * // => 3
58086 *
58087 * _.get(object, 'a.b.c', 'default');
58088 * // => 'default'
58089 */
58090
58091
58092function get(object, path, defaultValue) {
58093  var result = object == null ? undefined : baseGet(object, path);
58094  return result === undefined ? defaultValue : result;
58095}
58096/**
58097 * Checks if `path` is a direct or inherited property of `object`.
58098 *
58099 * @static
58100 * @memberOf _
58101 * @since 4.0.0
58102 * @category Object
58103 * @param {Object} object The object to query.
58104 * @param {Array|string} path The path to check.
58105 * @returns {boolean} Returns `true` if `path` exists, else `false`.
58106 * @example
58107 *
58108 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
58109 *
58110 * _.hasIn(object, 'a');
58111 * // => true
58112 *
58113 * _.hasIn(object, 'a.b');
58114 * // => true
58115 *
58116 * _.hasIn(object, ['a', 'b']);
58117 * // => true
58118 *
58119 * _.hasIn(object, 'b');
58120 * // => false
58121 */
58122
58123
58124function hasIn(object, path) {
58125  return object != null && hasPath(object, path, baseHasIn);
58126}
58127/**
58128 * Creates an array of the own enumerable property names of `object`.
58129 *
58130 * **Note:** Non-object values are coerced to objects. See the
58131 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
58132 * for more details.
58133 *
58134 * @static
58135 * @since 0.1.0
58136 * @memberOf _
58137 * @category Object
58138 * @param {Object} object The object to query.
58139 * @returns {Array} Returns the array of property names.
58140 * @example
58141 *
58142 * function Foo() {
58143 *   this.a = 1;
58144 *   this.b = 2;
58145 * }
58146 *
58147 * Foo.prototype.c = 3;
58148 *
58149 * _.keys(new Foo);
58150 * // => ['a', 'b'] (iteration order is not guaranteed)
58151 *
58152 * _.keys('hi');
58153 * // => ['0', '1']
58154 */
58155
58156
58157function keys(object) {
58158  return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
58159}
58160/**
58161 * This method returns the first argument it receives.
58162 *
58163 * @static
58164 * @since 0.1.0
58165 * @memberOf _
58166 * @category Util
58167 * @param {*} value Any value.
58168 * @returns {*} Returns `value`.
58169 * @example
58170 *
58171 * var object = { 'a': 1 };
58172 *
58173 * console.log(_.identity(object) === object);
58174 * // => true
58175 */
58176
58177
58178function identity(value) {
58179  return value;
58180}
58181/**
58182 * Creates a function that returns the value at `path` of a given object.
58183 *
58184 * @static
58185 * @memberOf _
58186 * @since 2.4.0
58187 * @category Util
58188 * @param {Array|string} path The path of the property to get.
58189 * @returns {Function} Returns the new accessor function.
58190 * @example
58191 *
58192 * var objects = [
58193 *   { 'a': { 'b': 2 } },
58194 *   { 'a': { 'b': 1 } }
58195 * ];
58196 *
58197 * _.map(objects, _.property('a.b'));
58198 * // => [2, 1]
58199 *
58200 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
58201 * // => [1, 2]
58202 */
58203
58204
58205function property(path) {
58206  return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
58207}
58208
58209module.exports = groupBy;
58210
58211}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
58212
58213},{}],428:[function(require,module,exports){
58214"use strict";
58215
58216function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
58217
58218/**
58219 * lodash 3.0.3 (Custom Build) <https://lodash.com/>
58220 * Build: `lodash modularize exports="npm" -o ./`
58221 * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
58222 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
58223 * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
58224 * Available under MIT license <https://lodash.com/license>
58225 */
58226
58227/** `Object#toString` result references. */
58228var boolTag = '[object Boolean]';
58229/** Used for built-in method references. */
58230
58231var objectProto = Object.prototype;
58232/**
58233 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
58234 * of values.
58235 */
58236
58237var objectToString = objectProto.toString;
58238/**
58239 * Checks if `value` is classified as a boolean primitive or object.
58240 *
58241 * @static
58242 * @memberOf _
58243 * @category Lang
58244 * @param {*} value The value to check.
58245 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
58246 * @example
58247 *
58248 * _.isBoolean(false);
58249 * // => true
58250 *
58251 * _.isBoolean(null);
58252 * // => false
58253 */
58254
58255function isBoolean(value) {
58256  return value === true || value === false || isObjectLike(value) && objectToString.call(value) == boolTag;
58257}
58258/**
58259 * Checks if `value` is object-like. A value is object-like if it's not `null`
58260 * and has a `typeof` result of "object".
58261 *
58262 * @static
58263 * @memberOf _
58264 * @category Lang
58265 * @param {*} value The value to check.
58266 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
58267 * @example
58268 *
58269 * _.isObjectLike({});
58270 * // => true
58271 *
58272 * _.isObjectLike([1, 2, 3]);
58273 * // => true
58274 *
58275 * _.isObjectLike(_.noop);
58276 * // => false
58277 *
58278 * _.isObjectLike(null);
58279 * // => false
58280 */
58281
58282
58283function isObjectLike(value) {
58284  return !!value && _typeof(value) == 'object';
58285}
58286
58287module.exports = isBoolean;
58288
58289},{}],429:[function(require,module,exports){
58290(function (global){
58291"use strict";
58292
58293function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
58294
58295/**
58296 * Lodash (Custom Build) <https://lodash.com/>
58297 * Build: `lodash modularize exports="npm" -o ./`
58298 * Copyright JS Foundation and other contributors <https://js.foundation/>
58299 * Released under MIT license <https://lodash.com/license>
58300 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
58301 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
58302 */
58303
58304/** Used as the size to enable large array optimizations. */
58305var LARGE_ARRAY_SIZE = 200;
58306/** Used to stand-in for `undefined` hash values. */
58307
58308var HASH_UNDEFINED = '__lodash_hash_undefined__';
58309/** Used to compose bitmasks for value comparisons. */
58310
58311var COMPARE_PARTIAL_FLAG = 1,
58312    COMPARE_UNORDERED_FLAG = 2;
58313/** Used as references for various `Number` constants. */
58314
58315var MAX_SAFE_INTEGER = 9007199254740991;
58316/** `Object#toString` result references. */
58317
58318var argsTag = '[object Arguments]',
58319    arrayTag = '[object Array]',
58320    asyncTag = '[object AsyncFunction]',
58321    boolTag = '[object Boolean]',
58322    dateTag = '[object Date]',
58323    errorTag = '[object Error]',
58324    funcTag = '[object Function]',
58325    genTag = '[object GeneratorFunction]',
58326    mapTag = '[object Map]',
58327    numberTag = '[object Number]',
58328    nullTag = '[object Null]',
58329    objectTag = '[object Object]',
58330    promiseTag = '[object Promise]',
58331    proxyTag = '[object Proxy]',
58332    regexpTag = '[object RegExp]',
58333    setTag = '[object Set]',
58334    stringTag = '[object String]',
58335    symbolTag = '[object Symbol]',
58336    undefinedTag = '[object Undefined]',
58337    weakMapTag = '[object WeakMap]';
58338var arrayBufferTag = '[object ArrayBuffer]',
58339    dataViewTag = '[object DataView]',
58340    float32Tag = '[object Float32Array]',
58341    float64Tag = '[object Float64Array]',
58342    int8Tag = '[object Int8Array]',
58343    int16Tag = '[object Int16Array]',
58344    int32Tag = '[object Int32Array]',
58345    uint8Tag = '[object Uint8Array]',
58346    uint8ClampedTag = '[object Uint8ClampedArray]',
58347    uint16Tag = '[object Uint16Array]',
58348    uint32Tag = '[object Uint32Array]';
58349/**
58350 * Used to match `RegExp`
58351 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
58352 */
58353
58354var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
58355/** Used to detect host constructors (Safari). */
58356
58357var reIsHostCtor = /^\[object .+?Constructor\]$/;
58358/** Used to detect unsigned integer values. */
58359
58360var reIsUint = /^(?:0|[1-9]\d*)$/;
58361/** Used to identify `toStringTag` values of typed arrays. */
58362
58363var typedArrayTags = {};
58364typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
58365typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
58366/** Detect free variable `global` from Node.js. */
58367
58368var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
58369/** Detect free variable `self`. */
58370
58371var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
58372/** Used as a reference to the global object. */
58373
58374var root = freeGlobal || freeSelf || Function('return this')();
58375/** Detect free variable `exports`. */
58376
58377var freeExports = (typeof exports === "undefined" ? "undefined" : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;
58378/** Detect free variable `module`. */
58379
58380var freeModule = freeExports && (typeof module === "undefined" ? "undefined" : _typeof(module)) == 'object' && module && !module.nodeType && module;
58381/** Detect the popular CommonJS extension `module.exports`. */
58382
58383var moduleExports = freeModule && freeModule.exports === freeExports;
58384/** Detect free variable `process` from Node.js. */
58385
58386var freeProcess = moduleExports && freeGlobal.process;
58387/** Used to access faster Node.js helpers. */
58388
58389var nodeUtil = function () {
58390  try {
58391    return freeProcess && freeProcess.binding && freeProcess.binding('util');
58392  } catch (e) {}
58393}();
58394/* Node.js helper references. */
58395
58396
58397var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
58398/**
58399 * A specialized version of `_.filter` for arrays without support for
58400 * iteratee shorthands.
58401 *
58402 * @private
58403 * @param {Array} [array] The array to iterate over.
58404 * @param {Function} predicate The function invoked per iteration.
58405 * @returns {Array} Returns the new filtered array.
58406 */
58407
58408function arrayFilter(array, predicate) {
58409  var index = -1,
58410      length = array == null ? 0 : array.length,
58411      resIndex = 0,
58412      result = [];
58413
58414  while (++index < length) {
58415    var value = array[index];
58416
58417    if (predicate(value, index, array)) {
58418      result[resIndex++] = value;
58419    }
58420  }
58421
58422  return result;
58423}
58424/**
58425 * Appends the elements of `values` to `array`.
58426 *
58427 * @private
58428 * @param {Array} array The array to modify.
58429 * @param {Array} values The values to append.
58430 * @returns {Array} Returns `array`.
58431 */
58432
58433
58434function arrayPush(array, values) {
58435  var index = -1,
58436      length = values.length,
58437      offset = array.length;
58438
58439  while (++index < length) {
58440    array[offset + index] = values[index];
58441  }
58442
58443  return array;
58444}
58445/**
58446 * A specialized version of `_.some` for arrays without support for iteratee
58447 * shorthands.
58448 *
58449 * @private
58450 * @param {Array} [array] The array to iterate over.
58451 * @param {Function} predicate The function invoked per iteration.
58452 * @returns {boolean} Returns `true` if any element passes the predicate check,
58453 *  else `false`.
58454 */
58455
58456
58457function arraySome(array, predicate) {
58458  var index = -1,
58459      length = array == null ? 0 : array.length;
58460
58461  while (++index < length) {
58462    if (predicate(array[index], index, array)) {
58463      return true;
58464    }
58465  }
58466
58467  return false;
58468}
58469/**
58470 * The base implementation of `_.times` without support for iteratee shorthands
58471 * or max array length checks.
58472 *
58473 * @private
58474 * @param {number} n The number of times to invoke `iteratee`.
58475 * @param {Function} iteratee The function invoked per iteration.
58476 * @returns {Array} Returns the array of results.
58477 */
58478
58479
58480function baseTimes(n, iteratee) {
58481  var index = -1,
58482      result = Array(n);
58483
58484  while (++index < n) {
58485    result[index] = iteratee(index);
58486  }
58487
58488  return result;
58489}
58490/**
58491 * The base implementation of `_.unary` without support for storing metadata.
58492 *
58493 * @private
58494 * @param {Function} func The function to cap arguments for.
58495 * @returns {Function} Returns the new capped function.
58496 */
58497
58498
58499function baseUnary(func) {
58500  return function (value) {
58501    return func(value);
58502  };
58503}
58504/**
58505 * Checks if a `cache` value for `key` exists.
58506 *
58507 * @private
58508 * @param {Object} cache The cache to query.
58509 * @param {string} key The key of the entry to check.
58510 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
58511 */
58512
58513
58514function cacheHas(cache, key) {
58515  return cache.has(key);
58516}
58517/**
58518 * Gets the value at `key` of `object`.
58519 *
58520 * @private
58521 * @param {Object} [object] The object to query.
58522 * @param {string} key The key of the property to get.
58523 * @returns {*} Returns the property value.
58524 */
58525
58526
58527function getValue(object, key) {
58528  return object == null ? undefined : object[key];
58529}
58530/**
58531 * Converts `map` to its key-value pairs.
58532 *
58533 * @private
58534 * @param {Object} map The map to convert.
58535 * @returns {Array} Returns the key-value pairs.
58536 */
58537
58538
58539function mapToArray(map) {
58540  var index = -1,
58541      result = Array(map.size);
58542  map.forEach(function (value, key) {
58543    result[++index] = [key, value];
58544  });
58545  return result;
58546}
58547/**
58548 * Creates a unary function that invokes `func` with its argument transformed.
58549 *
58550 * @private
58551 * @param {Function} func The function to wrap.
58552 * @param {Function} transform The argument transform.
58553 * @returns {Function} Returns the new function.
58554 */
58555
58556
58557function overArg(func, transform) {
58558  return function (arg) {
58559    return func(transform(arg));
58560  };
58561}
58562/**
58563 * Converts `set` to an array of its values.
58564 *
58565 * @private
58566 * @param {Object} set The set to convert.
58567 * @returns {Array} Returns the values.
58568 */
58569
58570
58571function setToArray(set) {
58572  var index = -1,
58573      result = Array(set.size);
58574  set.forEach(function (value) {
58575    result[++index] = value;
58576  });
58577  return result;
58578}
58579/** Used for built-in method references. */
58580
58581
58582var arrayProto = Array.prototype,
58583    funcProto = Function.prototype,
58584    objectProto = Object.prototype;
58585/** Used to detect overreaching core-js shims. */
58586
58587var coreJsData = root['__core-js_shared__'];
58588/** Used to resolve the decompiled source of functions. */
58589
58590var funcToString = funcProto.toString;
58591/** Used to check objects for own properties. */
58592
58593var hasOwnProperty = objectProto.hasOwnProperty;
58594/** Used to detect methods masquerading as native. */
58595
58596var maskSrcKey = function () {
58597  var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
58598  return uid ? 'Symbol(src)_1.' + uid : '';
58599}();
58600/**
58601 * Used to resolve the
58602 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
58603 * of values.
58604 */
58605
58606
58607var nativeObjectToString = objectProto.toString;
58608/** Used to detect if a method is native. */
58609
58610var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
58611/** Built-in value references. */
58612
58613var Buffer = moduleExports ? root.Buffer : undefined,
58614    _Symbol = root.Symbol,
58615    Uint8Array = root.Uint8Array,
58616    propertyIsEnumerable = objectProto.propertyIsEnumerable,
58617    splice = arrayProto.splice,
58618    symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
58619/* Built-in method references for those with the same name as other `lodash` methods. */
58620
58621var nativeGetSymbols = Object.getOwnPropertySymbols,
58622    nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
58623    nativeKeys = overArg(Object.keys, Object);
58624/* Built-in method references that are verified to be native. */
58625
58626var DataView = getNative(root, 'DataView'),
58627    Map = getNative(root, 'Map'),
58628    Promise = getNative(root, 'Promise'),
58629    Set = getNative(root, 'Set'),
58630    WeakMap = getNative(root, 'WeakMap'),
58631    nativeCreate = getNative(Object, 'create');
58632/** Used to detect maps, sets, and weakmaps. */
58633
58634var dataViewCtorString = toSource(DataView),
58635    mapCtorString = toSource(Map),
58636    promiseCtorString = toSource(Promise),
58637    setCtorString = toSource(Set),
58638    weakMapCtorString = toSource(WeakMap);
58639/** Used to convert symbols to primitives and strings. */
58640
58641var symbolProto = _Symbol ? _Symbol.prototype : undefined,
58642    symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
58643/**
58644 * Creates a hash object.
58645 *
58646 * @private
58647 * @constructor
58648 * @param {Array} [entries] The key-value pairs to cache.
58649 */
58650
58651function Hash(entries) {
58652  var index = -1,
58653      length = entries == null ? 0 : entries.length;
58654  this.clear();
58655
58656  while (++index < length) {
58657    var entry = entries[index];
58658    this.set(entry[0], entry[1]);
58659  }
58660}
58661/**
58662 * Removes all key-value entries from the hash.
58663 *
58664 * @private
58665 * @name clear
58666 * @memberOf Hash
58667 */
58668
58669
58670function hashClear() {
58671  this.__data__ = nativeCreate ? nativeCreate(null) : {};
58672  this.size = 0;
58673}
58674/**
58675 * Removes `key` and its value from the hash.
58676 *
58677 * @private
58678 * @name delete
58679 * @memberOf Hash
58680 * @param {Object} hash The hash to modify.
58681 * @param {string} key The key of the value to remove.
58682 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
58683 */
58684
58685
58686function hashDelete(key) {
58687  var result = this.has(key) && delete this.__data__[key];
58688  this.size -= result ? 1 : 0;
58689  return result;
58690}
58691/**
58692 * Gets the hash value for `key`.
58693 *
58694 * @private
58695 * @name get
58696 * @memberOf Hash
58697 * @param {string} key The key of the value to get.
58698 * @returns {*} Returns the entry value.
58699 */
58700
58701
58702function hashGet(key) {
58703  var data = this.__data__;
58704
58705  if (nativeCreate) {
58706    var result = data[key];
58707    return result === HASH_UNDEFINED ? undefined : result;
58708  }
58709
58710  return hasOwnProperty.call(data, key) ? data[key] : undefined;
58711}
58712/**
58713 * Checks if a hash value for `key` exists.
58714 *
58715 * @private
58716 * @name has
58717 * @memberOf Hash
58718 * @param {string} key The key of the entry to check.
58719 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
58720 */
58721
58722
58723function hashHas(key) {
58724  var data = this.__data__;
58725  return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
58726}
58727/**
58728 * Sets the hash `key` to `value`.
58729 *
58730 * @private
58731 * @name set
58732 * @memberOf Hash
58733 * @param {string} key The key of the value to set.
58734 * @param {*} value The value to set.
58735 * @returns {Object} Returns the hash instance.
58736 */
58737
58738
58739function hashSet(key, value) {
58740  var data = this.__data__;
58741  this.size += this.has(key) ? 0 : 1;
58742  data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
58743  return this;
58744} // Add methods to `Hash`.
58745
58746
58747Hash.prototype.clear = hashClear;
58748Hash.prototype['delete'] = hashDelete;
58749Hash.prototype.get = hashGet;
58750Hash.prototype.has = hashHas;
58751Hash.prototype.set = hashSet;
58752/**
58753 * Creates an list cache object.
58754 *
58755 * @private
58756 * @constructor
58757 * @param {Array} [entries] The key-value pairs to cache.
58758 */
58759
58760function ListCache(entries) {
58761  var index = -1,
58762      length = entries == null ? 0 : entries.length;
58763  this.clear();
58764
58765  while (++index < length) {
58766    var entry = entries[index];
58767    this.set(entry[0], entry[1]);
58768  }
58769}
58770/**
58771 * Removes all key-value entries from the list cache.
58772 *
58773 * @private
58774 * @name clear
58775 * @memberOf ListCache
58776 */
58777
58778
58779function listCacheClear() {
58780  this.__data__ = [];
58781  this.size = 0;
58782}
58783/**
58784 * Removes `key` and its value from the list cache.
58785 *
58786 * @private
58787 * @name delete
58788 * @memberOf ListCache
58789 * @param {string} key The key of the value to remove.
58790 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
58791 */
58792
58793
58794function listCacheDelete(key) {
58795  var data = this.__data__,
58796      index = assocIndexOf(data, key);
58797
58798  if (index < 0) {
58799    return false;
58800  }
58801
58802  var lastIndex = data.length - 1;
58803
58804  if (index == lastIndex) {
58805    data.pop();
58806  } else {
58807    splice.call(data, index, 1);
58808  }
58809
58810  --this.size;
58811  return true;
58812}
58813/**
58814 * Gets the list cache value for `key`.
58815 *
58816 * @private
58817 * @name get
58818 * @memberOf ListCache
58819 * @param {string} key The key of the value to get.
58820 * @returns {*} Returns the entry value.
58821 */
58822
58823
58824function listCacheGet(key) {
58825  var data = this.__data__,
58826      index = assocIndexOf(data, key);
58827  return index < 0 ? undefined : data[index][1];
58828}
58829/**
58830 * Checks if a list cache value for `key` exists.
58831 *
58832 * @private
58833 * @name has
58834 * @memberOf ListCache
58835 * @param {string} key The key of the entry to check.
58836 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
58837 */
58838
58839
58840function listCacheHas(key) {
58841  return assocIndexOf(this.__data__, key) > -1;
58842}
58843/**
58844 * Sets the list cache `key` to `value`.
58845 *
58846 * @private
58847 * @name set
58848 * @memberOf ListCache
58849 * @param {string} key The key of the value to set.
58850 * @param {*} value The value to set.
58851 * @returns {Object} Returns the list cache instance.
58852 */
58853
58854
58855function listCacheSet(key, value) {
58856  var data = this.__data__,
58857      index = assocIndexOf(data, key);
58858
58859  if (index < 0) {
58860    ++this.size;
58861    data.push([key, value]);
58862  } else {
58863    data[index][1] = value;
58864  }
58865
58866  return this;
58867} // Add methods to `ListCache`.
58868
58869
58870ListCache.prototype.clear = listCacheClear;
58871ListCache.prototype['delete'] = listCacheDelete;
58872ListCache.prototype.get = listCacheGet;
58873ListCache.prototype.has = listCacheHas;
58874ListCache.prototype.set = listCacheSet;
58875/**
58876 * Creates a map cache object to store key-value pairs.
58877 *
58878 * @private
58879 * @constructor
58880 * @param {Array} [entries] The key-value pairs to cache.
58881 */
58882
58883function MapCache(entries) {
58884  var index = -1,
58885      length = entries == null ? 0 : entries.length;
58886  this.clear();
58887
58888  while (++index < length) {
58889    var entry = entries[index];
58890    this.set(entry[0], entry[1]);
58891  }
58892}
58893/**
58894 * Removes all key-value entries from the map.
58895 *
58896 * @private
58897 * @name clear
58898 * @memberOf MapCache
58899 */
58900
58901
58902function mapCacheClear() {
58903  this.size = 0;
58904  this.__data__ = {
58905    'hash': new Hash(),
58906    'map': new (Map || ListCache)(),
58907    'string': new Hash()
58908  };
58909}
58910/**
58911 * Removes `key` and its value from the map.
58912 *
58913 * @private
58914 * @name delete
58915 * @memberOf MapCache
58916 * @param {string} key The key of the value to remove.
58917 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
58918 */
58919
58920
58921function mapCacheDelete(key) {
58922  var result = getMapData(this, key)['delete'](key);
58923  this.size -= result ? 1 : 0;
58924  return result;
58925}
58926/**
58927 * Gets the map value for `key`.
58928 *
58929 * @private
58930 * @name get
58931 * @memberOf MapCache
58932 * @param {string} key The key of the value to get.
58933 * @returns {*} Returns the entry value.
58934 */
58935
58936
58937function mapCacheGet(key) {
58938  return getMapData(this, key).get(key);
58939}
58940/**
58941 * Checks if a map value for `key` exists.
58942 *
58943 * @private
58944 * @name has
58945 * @memberOf MapCache
58946 * @param {string} key The key of the entry to check.
58947 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
58948 */
58949
58950
58951function mapCacheHas(key) {
58952  return getMapData(this, key).has(key);
58953}
58954/**
58955 * Sets the map `key` to `value`.
58956 *
58957 * @private
58958 * @name set
58959 * @memberOf MapCache
58960 * @param {string} key The key of the value to set.
58961 * @param {*} value The value to set.
58962 * @returns {Object} Returns the map cache instance.
58963 */
58964
58965
58966function mapCacheSet(key, value) {
58967  var data = getMapData(this, key),
58968      size = data.size;
58969  data.set(key, value);
58970  this.size += data.size == size ? 0 : 1;
58971  return this;
58972} // Add methods to `MapCache`.
58973
58974
58975MapCache.prototype.clear = mapCacheClear;
58976MapCache.prototype['delete'] = mapCacheDelete;
58977MapCache.prototype.get = mapCacheGet;
58978MapCache.prototype.has = mapCacheHas;
58979MapCache.prototype.set = mapCacheSet;
58980/**
58981 *
58982 * Creates an array cache object to store unique values.
58983 *
58984 * @private
58985 * @constructor
58986 * @param {Array} [values] The values to cache.
58987 */
58988
58989function SetCache(values) {
58990  var index = -1,
58991      length = values == null ? 0 : values.length;
58992  this.__data__ = new MapCache();
58993
58994  while (++index < length) {
58995    this.add(values[index]);
58996  }
58997}
58998/**
58999 * Adds `value` to the array cache.
59000 *
59001 * @private
59002 * @name add
59003 * @memberOf SetCache
59004 * @alias push
59005 * @param {*} value The value to cache.
59006 * @returns {Object} Returns the cache instance.
59007 */
59008
59009
59010function setCacheAdd(value) {
59011  this.__data__.set(value, HASH_UNDEFINED);
59012
59013  return this;
59014}
59015/**
59016 * Checks if `value` is in the array cache.
59017 *
59018 * @private
59019 * @name has
59020 * @memberOf SetCache
59021 * @param {*} value The value to search for.
59022 * @returns {number} Returns `true` if `value` is found, else `false`.
59023 */
59024
59025
59026function setCacheHas(value) {
59027  return this.__data__.has(value);
59028} // Add methods to `SetCache`.
59029
59030
59031SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
59032SetCache.prototype.has = setCacheHas;
59033/**
59034 * Creates a stack cache object to store key-value pairs.
59035 *
59036 * @private
59037 * @constructor
59038 * @param {Array} [entries] The key-value pairs to cache.
59039 */
59040
59041function Stack(entries) {
59042  var data = this.__data__ = new ListCache(entries);
59043  this.size = data.size;
59044}
59045/**
59046 * Removes all key-value entries from the stack.
59047 *
59048 * @private
59049 * @name clear
59050 * @memberOf Stack
59051 */
59052
59053
59054function stackClear() {
59055  this.__data__ = new ListCache();
59056  this.size = 0;
59057}
59058/**
59059 * Removes `key` and its value from the stack.
59060 *
59061 * @private
59062 * @name delete
59063 * @memberOf Stack
59064 * @param {string} key The key of the value to remove.
59065 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
59066 */
59067
59068
59069function stackDelete(key) {
59070  var data = this.__data__,
59071      result = data['delete'](key);
59072  this.size = data.size;
59073  return result;
59074}
59075/**
59076 * Gets the stack value for `key`.
59077 *
59078 * @private
59079 * @name get
59080 * @memberOf Stack
59081 * @param {string} key The key of the value to get.
59082 * @returns {*} Returns the entry value.
59083 */
59084
59085
59086function stackGet(key) {
59087  return this.__data__.get(key);
59088}
59089/**
59090 * Checks if a stack value for `key` exists.
59091 *
59092 * @private
59093 * @name has
59094 * @memberOf Stack
59095 * @param {string} key The key of the entry to check.
59096 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
59097 */
59098
59099
59100function stackHas(key) {
59101  return this.__data__.has(key);
59102}
59103/**
59104 * Sets the stack `key` to `value`.
59105 *
59106 * @private
59107 * @name set
59108 * @memberOf Stack
59109 * @param {string} key The key of the value to set.
59110 * @param {*} value The value to set.
59111 * @returns {Object} Returns the stack cache instance.
59112 */
59113
59114
59115function stackSet(key, value) {
59116  var data = this.__data__;
59117
59118  if (data instanceof ListCache) {
59119    var pairs = data.__data__;
59120
59121    if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
59122      pairs.push([key, value]);
59123      this.size = ++data.size;
59124      return this;
59125    }
59126
59127    data = this.__data__ = new MapCache(pairs);
59128  }
59129
59130  data.set(key, value);
59131  this.size = data.size;
59132  return this;
59133} // Add methods to `Stack`.
59134
59135
59136Stack.prototype.clear = stackClear;
59137Stack.prototype['delete'] = stackDelete;
59138Stack.prototype.get = stackGet;
59139Stack.prototype.has = stackHas;
59140Stack.prototype.set = stackSet;
59141/**
59142 * Creates an array of the enumerable property names of the array-like `value`.
59143 *
59144 * @private
59145 * @param {*} value The value to query.
59146 * @param {boolean} inherited Specify returning inherited property names.
59147 * @returns {Array} Returns the array of property names.
59148 */
59149
59150function arrayLikeKeys(value, inherited) {
59151  var isArr = isArray(value),
59152      isArg = !isArr && isArguments(value),
59153      isBuff = !isArr && !isArg && isBuffer(value),
59154      isType = !isArr && !isArg && !isBuff && isTypedArray(value),
59155      skipIndexes = isArr || isArg || isBuff || isType,
59156      result = skipIndexes ? baseTimes(value.length, String) : [],
59157      length = result.length;
59158
59159  for (var key in value) {
59160    if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode.
59161    key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers.
59162    isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays.
59163    isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties.
59164    isIndex(key, length)))) {
59165      result.push(key);
59166    }
59167  }
59168
59169  return result;
59170}
59171/**
59172 * Gets the index at which the `key` is found in `array` of key-value pairs.
59173 *
59174 * @private
59175 * @param {Array} array The array to inspect.
59176 * @param {*} key The key to search for.
59177 * @returns {number} Returns the index of the matched value, else `-1`.
59178 */
59179
59180
59181function assocIndexOf(array, key) {
59182  var length = array.length;
59183
59184  while (length--) {
59185    if (eq(array[length][0], key)) {
59186      return length;
59187    }
59188  }
59189
59190  return -1;
59191}
59192/**
59193 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
59194 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
59195 * symbols of `object`.
59196 *
59197 * @private
59198 * @param {Object} object The object to query.
59199 * @param {Function} keysFunc The function to get the keys of `object`.
59200 * @param {Function} symbolsFunc The function to get the symbols of `object`.
59201 * @returns {Array} Returns the array of property names and symbols.
59202 */
59203
59204
59205function baseGetAllKeys(object, keysFunc, symbolsFunc) {
59206  var result = keysFunc(object);
59207  return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
59208}
59209/**
59210 * The base implementation of `getTag` without fallbacks for buggy environments.
59211 *
59212 * @private
59213 * @param {*} value The value to query.
59214 * @returns {string} Returns the `toStringTag`.
59215 */
59216
59217
59218function baseGetTag(value) {
59219  if (value == null) {
59220    return value === undefined ? undefinedTag : nullTag;
59221  }
59222
59223  return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
59224}
59225/**
59226 * The base implementation of `_.isArguments`.
59227 *
59228 * @private
59229 * @param {*} value The value to check.
59230 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
59231 */
59232
59233
59234function baseIsArguments(value) {
59235  return isObjectLike(value) && baseGetTag(value) == argsTag;
59236}
59237/**
59238 * The base implementation of `_.isEqual` which supports partial comparisons
59239 * and tracks traversed objects.
59240 *
59241 * @private
59242 * @param {*} value The value to compare.
59243 * @param {*} other The other value to compare.
59244 * @param {boolean} bitmask The bitmask flags.
59245 *  1 - Unordered comparison
59246 *  2 - Partial comparison
59247 * @param {Function} [customizer] The function to customize comparisons.
59248 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
59249 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
59250 */
59251
59252
59253function baseIsEqual(value, other, bitmask, customizer, stack) {
59254  if (value === other) {
59255    return true;
59256  }
59257
59258  if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
59259    return value !== value && other !== other;
59260  }
59261
59262  return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
59263}
59264/**
59265 * A specialized version of `baseIsEqual` for arrays and objects which performs
59266 * deep comparisons and tracks traversed objects enabling objects with circular
59267 * references to be compared.
59268 *
59269 * @private
59270 * @param {Object} object The object to compare.
59271 * @param {Object} other The other object to compare.
59272 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
59273 * @param {Function} customizer The function to customize comparisons.
59274 * @param {Function} equalFunc The function to determine equivalents of values.
59275 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
59276 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
59277 */
59278
59279
59280function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
59281  var objIsArr = isArray(object),
59282      othIsArr = isArray(other),
59283      objTag = objIsArr ? arrayTag : getTag(object),
59284      othTag = othIsArr ? arrayTag : getTag(other);
59285  objTag = objTag == argsTag ? objectTag : objTag;
59286  othTag = othTag == argsTag ? objectTag : othTag;
59287  var objIsObj = objTag == objectTag,
59288      othIsObj = othTag == objectTag,
59289      isSameTag = objTag == othTag;
59290
59291  if (isSameTag && isBuffer(object)) {
59292    if (!isBuffer(other)) {
59293      return false;
59294    }
59295
59296    objIsArr = true;
59297    objIsObj = false;
59298  }
59299
59300  if (isSameTag && !objIsObj) {
59301    stack || (stack = new Stack());
59302    return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
59303  }
59304
59305  if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
59306    var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
59307        othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
59308
59309    if (objIsWrapped || othIsWrapped) {
59310      var objUnwrapped = objIsWrapped ? object.value() : object,
59311          othUnwrapped = othIsWrapped ? other.value() : other;
59312      stack || (stack = new Stack());
59313      return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
59314    }
59315  }
59316
59317  if (!isSameTag) {
59318    return false;
59319  }
59320
59321  stack || (stack = new Stack());
59322  return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
59323}
59324/**
59325 * The base implementation of `_.isNative` without bad shim checks.
59326 *
59327 * @private
59328 * @param {*} value The value to check.
59329 * @returns {boolean} Returns `true` if `value` is a native function,
59330 *  else `false`.
59331 */
59332
59333
59334function baseIsNative(value) {
59335  if (!isObject(value) || isMasked(value)) {
59336    return false;
59337  }
59338
59339  var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
59340  return pattern.test(toSource(value));
59341}
59342/**
59343 * The base implementation of `_.isTypedArray` without Node.js optimizations.
59344 *
59345 * @private
59346 * @param {*} value The value to check.
59347 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
59348 */
59349
59350
59351function baseIsTypedArray(value) {
59352  return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
59353}
59354/**
59355 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
59356 *
59357 * @private
59358 * @param {Object} object The object to query.
59359 * @returns {Array} Returns the array of property names.
59360 */
59361
59362
59363function baseKeys(object) {
59364  if (!isPrototype(object)) {
59365    return nativeKeys(object);
59366  }
59367
59368  var result = [];
59369
59370  for (var key in Object(object)) {
59371    if (hasOwnProperty.call(object, key) && key != 'constructor') {
59372      result.push(key);
59373    }
59374  }
59375
59376  return result;
59377}
59378/**
59379 * A specialized version of `baseIsEqualDeep` for arrays with support for
59380 * partial deep comparisons.
59381 *
59382 * @private
59383 * @param {Array} array The array to compare.
59384 * @param {Array} other The other array to compare.
59385 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
59386 * @param {Function} customizer The function to customize comparisons.
59387 * @param {Function} equalFunc The function to determine equivalents of values.
59388 * @param {Object} stack Tracks traversed `array` and `other` objects.
59389 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
59390 */
59391
59392
59393function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
59394  var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
59395      arrLength = array.length,
59396      othLength = other.length;
59397
59398  if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
59399    return false;
59400  } // Assume cyclic values are equal.
59401
59402
59403  var stacked = stack.get(array);
59404
59405  if (stacked && stack.get(other)) {
59406    return stacked == other;
59407  }
59408
59409  var index = -1,
59410      result = true,
59411      seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : undefined;
59412  stack.set(array, other);
59413  stack.set(other, array); // Ignore non-index properties.
59414
59415  while (++index < arrLength) {
59416    var arrValue = array[index],
59417        othValue = other[index];
59418
59419    if (customizer) {
59420      var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
59421    }
59422
59423    if (compared !== undefined) {
59424      if (compared) {
59425        continue;
59426      }
59427
59428      result = false;
59429      break;
59430    } // Recursively compare arrays (susceptible to call stack limits).
59431
59432
59433    if (seen) {
59434      if (!arraySome(other, function (othValue, othIndex) {
59435        if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
59436          return seen.push(othIndex);
59437        }
59438      })) {
59439        result = false;
59440        break;
59441      }
59442    } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
59443      result = false;
59444      break;
59445    }
59446  }
59447
59448  stack['delete'](array);
59449  stack['delete'](other);
59450  return result;
59451}
59452/**
59453 * A specialized version of `baseIsEqualDeep` for comparing objects of
59454 * the same `toStringTag`.
59455 *
59456 * **Note:** This function only supports comparing values with tags of
59457 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
59458 *
59459 * @private
59460 * @param {Object} object The object to compare.
59461 * @param {Object} other The other object to compare.
59462 * @param {string} tag The `toStringTag` of the objects to compare.
59463 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
59464 * @param {Function} customizer The function to customize comparisons.
59465 * @param {Function} equalFunc The function to determine equivalents of values.
59466 * @param {Object} stack Tracks traversed `object` and `other` objects.
59467 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
59468 */
59469
59470
59471function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
59472  switch (tag) {
59473    case dataViewTag:
59474      if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
59475        return false;
59476      }
59477
59478      object = object.buffer;
59479      other = other.buffer;
59480
59481    case arrayBufferTag:
59482      if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
59483        return false;
59484      }
59485
59486      return true;
59487
59488    case boolTag:
59489    case dateTag:
59490    case numberTag:
59491      // Coerce booleans to `1` or `0` and dates to milliseconds.
59492      // Invalid dates are coerced to `NaN`.
59493      return eq(+object, +other);
59494
59495    case errorTag:
59496      return object.name == other.name && object.message == other.message;
59497
59498    case regexpTag:
59499    case stringTag:
59500      // Coerce regexes to strings and treat strings, primitives and objects,
59501      // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
59502      // for more details.
59503      return object == other + '';
59504
59505    case mapTag:
59506      var convert = mapToArray;
59507
59508    case setTag:
59509      var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
59510      convert || (convert = setToArray);
59511
59512      if (object.size != other.size && !isPartial) {
59513        return false;
59514      } // Assume cyclic values are equal.
59515
59516
59517      var stacked = stack.get(object);
59518
59519      if (stacked) {
59520        return stacked == other;
59521      }
59522
59523      bitmask |= COMPARE_UNORDERED_FLAG; // Recursively compare objects (susceptible to call stack limits).
59524
59525      stack.set(object, other);
59526      var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
59527      stack['delete'](object);
59528      return result;
59529
59530    case symbolTag:
59531      if (symbolValueOf) {
59532        return symbolValueOf.call(object) == symbolValueOf.call(other);
59533      }
59534
59535  }
59536
59537  return false;
59538}
59539/**
59540 * A specialized version of `baseIsEqualDeep` for objects with support for
59541 * partial deep comparisons.
59542 *
59543 * @private
59544 * @param {Object} object The object to compare.
59545 * @param {Object} other The other object to compare.
59546 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
59547 * @param {Function} customizer The function to customize comparisons.
59548 * @param {Function} equalFunc The function to determine equivalents of values.
59549 * @param {Object} stack Tracks traversed `object` and `other` objects.
59550 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
59551 */
59552
59553
59554function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
59555  var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
59556      objProps = getAllKeys(object),
59557      objLength = objProps.length,
59558      othProps = getAllKeys(other),
59559      othLength = othProps.length;
59560
59561  if (objLength != othLength && !isPartial) {
59562    return false;
59563  }
59564
59565  var index = objLength;
59566
59567  while (index--) {
59568    var key = objProps[index];
59569
59570    if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
59571      return false;
59572    }
59573  } // Assume cyclic values are equal.
59574
59575
59576  var stacked = stack.get(object);
59577
59578  if (stacked && stack.get(other)) {
59579    return stacked == other;
59580  }
59581
59582  var result = true;
59583  stack.set(object, other);
59584  stack.set(other, object);
59585  var skipCtor = isPartial;
59586
59587  while (++index < objLength) {
59588    key = objProps[index];
59589    var objValue = object[key],
59590        othValue = other[key];
59591
59592    if (customizer) {
59593      var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
59594    } // Recursively compare objects (susceptible to call stack limits).
59595
59596
59597    if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
59598      result = false;
59599      break;
59600    }
59601
59602    skipCtor || (skipCtor = key == 'constructor');
59603  }
59604
59605  if (result && !skipCtor) {
59606    var objCtor = object.constructor,
59607        othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
59608
59609    if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
59610      result = false;
59611    }
59612  }
59613
59614  stack['delete'](object);
59615  stack['delete'](other);
59616  return result;
59617}
59618/**
59619 * Creates an array of own enumerable property names and symbols of `object`.
59620 *
59621 * @private
59622 * @param {Object} object The object to query.
59623 * @returns {Array} Returns the array of property names and symbols.
59624 */
59625
59626
59627function getAllKeys(object) {
59628  return baseGetAllKeys(object, keys, getSymbols);
59629}
59630/**
59631 * Gets the data for `map`.
59632 *
59633 * @private
59634 * @param {Object} map The map to query.
59635 * @param {string} key The reference key.
59636 * @returns {*} Returns the map data.
59637 */
59638
59639
59640function getMapData(map, key) {
59641  var data = map.__data__;
59642  return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
59643}
59644/**
59645 * Gets the native function at `key` of `object`.
59646 *
59647 * @private
59648 * @param {Object} object The object to query.
59649 * @param {string} key The key of the method to get.
59650 * @returns {*} Returns the function if it's native, else `undefined`.
59651 */
59652
59653
59654function getNative(object, key) {
59655  var value = getValue(object, key);
59656  return baseIsNative(value) ? value : undefined;
59657}
59658/**
59659 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
59660 *
59661 * @private
59662 * @param {*} value The value to query.
59663 * @returns {string} Returns the raw `toStringTag`.
59664 */
59665
59666
59667function getRawTag(value) {
59668  var isOwn = hasOwnProperty.call(value, symToStringTag),
59669      tag = value[symToStringTag];
59670
59671  try {
59672    value[symToStringTag] = undefined;
59673    var unmasked = true;
59674  } catch (e) {}
59675
59676  var result = nativeObjectToString.call(value);
59677
59678  if (unmasked) {
59679    if (isOwn) {
59680      value[symToStringTag] = tag;
59681    } else {
59682      delete value[symToStringTag];
59683    }
59684  }
59685
59686  return result;
59687}
59688/**
59689 * Creates an array of the own enumerable symbols of `object`.
59690 *
59691 * @private
59692 * @param {Object} object The object to query.
59693 * @returns {Array} Returns the array of symbols.
59694 */
59695
59696
59697var getSymbols = !nativeGetSymbols ? stubArray : function (object) {
59698  if (object == null) {
59699    return [];
59700  }
59701
59702  object = Object(object);
59703  return arrayFilter(nativeGetSymbols(object), function (symbol) {
59704    return propertyIsEnumerable.call(object, symbol);
59705  });
59706};
59707/**
59708 * Gets the `toStringTag` of `value`.
59709 *
59710 * @private
59711 * @param {*} value The value to query.
59712 * @returns {string} Returns the `toStringTag`.
59713 */
59714
59715var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
59716
59717if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise && getTag(Promise.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
59718  getTag = function getTag(value) {
59719    var result = baseGetTag(value),
59720        Ctor = result == objectTag ? value.constructor : undefined,
59721        ctorString = Ctor ? toSource(Ctor) : '';
59722
59723    if (ctorString) {
59724      switch (ctorString) {
59725        case dataViewCtorString:
59726          return dataViewTag;
59727
59728        case mapCtorString:
59729          return mapTag;
59730
59731        case promiseCtorString:
59732          return promiseTag;
59733
59734        case setCtorString:
59735          return setTag;
59736
59737        case weakMapCtorString:
59738          return weakMapTag;
59739      }
59740    }
59741
59742    return result;
59743  };
59744}
59745/**
59746 * Checks if `value` is a valid array-like index.
59747 *
59748 * @private
59749 * @param {*} value The value to check.
59750 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
59751 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
59752 */
59753
59754
59755function isIndex(value, length) {
59756  length = length == null ? MAX_SAFE_INTEGER : length;
59757  return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
59758}
59759/**
59760 * Checks if `value` is suitable for use as unique object key.
59761 *
59762 * @private
59763 * @param {*} value The value to check.
59764 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
59765 */
59766
59767
59768function isKeyable(value) {
59769  var type = _typeof(value);
59770
59771  return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
59772}
59773/**
59774 * Checks if `func` has its source masked.
59775 *
59776 * @private
59777 * @param {Function} func The function to check.
59778 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
59779 */
59780
59781
59782function isMasked(func) {
59783  return !!maskSrcKey && maskSrcKey in func;
59784}
59785/**
59786 * Checks if `value` is likely a prototype object.
59787 *
59788 * @private
59789 * @param {*} value The value to check.
59790 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
59791 */
59792
59793
59794function isPrototype(value) {
59795  var Ctor = value && value.constructor,
59796      proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;
59797  return value === proto;
59798}
59799/**
59800 * Converts `value` to a string using `Object.prototype.toString`.
59801 *
59802 * @private
59803 * @param {*} value The value to convert.
59804 * @returns {string} Returns the converted string.
59805 */
59806
59807
59808function objectToString(value) {
59809  return nativeObjectToString.call(value);
59810}
59811/**
59812 * Converts `func` to its source code.
59813 *
59814 * @private
59815 * @param {Function} func The function to convert.
59816 * @returns {string} Returns the source code.
59817 */
59818
59819
59820function toSource(func) {
59821  if (func != null) {
59822    try {
59823      return funcToString.call(func);
59824    } catch (e) {}
59825
59826    try {
59827      return func + '';
59828    } catch (e) {}
59829  }
59830
59831  return '';
59832}
59833/**
59834 * Performs a
59835 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
59836 * comparison between two values to determine if they are equivalent.
59837 *
59838 * @static
59839 * @memberOf _
59840 * @since 4.0.0
59841 * @category Lang
59842 * @param {*} value The value to compare.
59843 * @param {*} other The other value to compare.
59844 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
59845 * @example
59846 *
59847 * var object = { 'a': 1 };
59848 * var other = { 'a': 1 };
59849 *
59850 * _.eq(object, object);
59851 * // => true
59852 *
59853 * _.eq(object, other);
59854 * // => false
59855 *
59856 * _.eq('a', 'a');
59857 * // => true
59858 *
59859 * _.eq('a', Object('a'));
59860 * // => false
59861 *
59862 * _.eq(NaN, NaN);
59863 * // => true
59864 */
59865
59866
59867function eq(value, other) {
59868  return value === other || value !== value && other !== other;
59869}
59870/**
59871 * Checks if `value` is likely an `arguments` object.
59872 *
59873 * @static
59874 * @memberOf _
59875 * @since 0.1.0
59876 * @category Lang
59877 * @param {*} value The value to check.
59878 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
59879 *  else `false`.
59880 * @example
59881 *
59882 * _.isArguments(function() { return arguments; }());
59883 * // => true
59884 *
59885 * _.isArguments([1, 2, 3]);
59886 * // => false
59887 */
59888
59889
59890var isArguments = baseIsArguments(function () {
59891  return arguments;
59892}()) ? baseIsArguments : function (value) {
59893  return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
59894};
59895/**
59896 * Checks if `value` is classified as an `Array` object.
59897 *
59898 * @static
59899 * @memberOf _
59900 * @since 0.1.0
59901 * @category Lang
59902 * @param {*} value The value to check.
59903 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
59904 * @example
59905 *
59906 * _.isArray([1, 2, 3]);
59907 * // => true
59908 *
59909 * _.isArray(document.body.children);
59910 * // => false
59911 *
59912 * _.isArray('abc');
59913 * // => false
59914 *
59915 * _.isArray(_.noop);
59916 * // => false
59917 */
59918
59919var isArray = Array.isArray;
59920/**
59921 * Checks if `value` is array-like. A value is considered array-like if it's
59922 * not a function and has a `value.length` that's an integer greater than or
59923 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
59924 *
59925 * @static
59926 * @memberOf _
59927 * @since 4.0.0
59928 * @category Lang
59929 * @param {*} value The value to check.
59930 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
59931 * @example
59932 *
59933 * _.isArrayLike([1, 2, 3]);
59934 * // => true
59935 *
59936 * _.isArrayLike(document.body.children);
59937 * // => true
59938 *
59939 * _.isArrayLike('abc');
59940 * // => true
59941 *
59942 * _.isArrayLike(_.noop);
59943 * // => false
59944 */
59945
59946function isArrayLike(value) {
59947  return value != null && isLength(value.length) && !isFunction(value);
59948}
59949/**
59950 * Checks if `value` is a buffer.
59951 *
59952 * @static
59953 * @memberOf _
59954 * @since 4.3.0
59955 * @category Lang
59956 * @param {*} value The value to check.
59957 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
59958 * @example
59959 *
59960 * _.isBuffer(new Buffer(2));
59961 * // => true
59962 *
59963 * _.isBuffer(new Uint8Array(2));
59964 * // => false
59965 */
59966
59967
59968var isBuffer = nativeIsBuffer || stubFalse;
59969/**
59970 * Performs a deep comparison between two values to determine if they are
59971 * equivalent.
59972 *
59973 * **Note:** This method supports comparing arrays, array buffers, booleans,
59974 * date objects, error objects, maps, numbers, `Object` objects, regexes,
59975 * sets, strings, symbols, and typed arrays. `Object` objects are compared
59976 * by their own, not inherited, enumerable properties. Functions and DOM
59977 * nodes are compared by strict equality, i.e. `===`.
59978 *
59979 * @static
59980 * @memberOf _
59981 * @since 0.1.0
59982 * @category Lang
59983 * @param {*} value The value to compare.
59984 * @param {*} other The other value to compare.
59985 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
59986 * @example
59987 *
59988 * var object = { 'a': 1 };
59989 * var other = { 'a': 1 };
59990 *
59991 * _.isEqual(object, other);
59992 * // => true
59993 *
59994 * object === other;
59995 * // => false
59996 */
59997
59998function isEqual(value, other) {
59999  return baseIsEqual(value, other);
60000}
60001/**
60002 * Checks if `value` is classified as a `Function` object.
60003 *
60004 * @static
60005 * @memberOf _
60006 * @since 0.1.0
60007 * @category Lang
60008 * @param {*} value The value to check.
60009 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
60010 * @example
60011 *
60012 * _.isFunction(_);
60013 * // => true
60014 *
60015 * _.isFunction(/abc/);
60016 * // => false
60017 */
60018
60019
60020function isFunction(value) {
60021  if (!isObject(value)) {
60022    return false;
60023  } // The use of `Object#toString` avoids issues with the `typeof` operator
60024  // in Safari 9 which returns 'object' for typed arrays and other constructors.
60025
60026
60027  var tag = baseGetTag(value);
60028  return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
60029}
60030/**
60031 * Checks if `value` is a valid array-like length.
60032 *
60033 * **Note:** This method is loosely based on
60034 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
60035 *
60036 * @static
60037 * @memberOf _
60038 * @since 4.0.0
60039 * @category Lang
60040 * @param {*} value The value to check.
60041 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
60042 * @example
60043 *
60044 * _.isLength(3);
60045 * // => true
60046 *
60047 * _.isLength(Number.MIN_VALUE);
60048 * // => false
60049 *
60050 * _.isLength(Infinity);
60051 * // => false
60052 *
60053 * _.isLength('3');
60054 * // => false
60055 */
60056
60057
60058function isLength(value) {
60059  return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
60060}
60061/**
60062 * Checks if `value` is the
60063 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
60064 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
60065 *
60066 * @static
60067 * @memberOf _
60068 * @since 0.1.0
60069 * @category Lang
60070 * @param {*} value The value to check.
60071 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
60072 * @example
60073 *
60074 * _.isObject({});
60075 * // => true
60076 *
60077 * _.isObject([1, 2, 3]);
60078 * // => true
60079 *
60080 * _.isObject(_.noop);
60081 * // => true
60082 *
60083 * _.isObject(null);
60084 * // => false
60085 */
60086
60087
60088function isObject(value) {
60089  var type = _typeof(value);
60090
60091  return value != null && (type == 'object' || type == 'function');
60092}
60093/**
60094 * Checks if `value` is object-like. A value is object-like if it's not `null`
60095 * and has a `typeof` result of "object".
60096 *
60097 * @static
60098 * @memberOf _
60099 * @since 4.0.0
60100 * @category Lang
60101 * @param {*} value The value to check.
60102 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
60103 * @example
60104 *
60105 * _.isObjectLike({});
60106 * // => true
60107 *
60108 * _.isObjectLike([1, 2, 3]);
60109 * // => true
60110 *
60111 * _.isObjectLike(_.noop);
60112 * // => false
60113 *
60114 * _.isObjectLike(null);
60115 * // => false
60116 */
60117
60118
60119function isObjectLike(value) {
60120  return value != null && _typeof(value) == 'object';
60121}
60122/**
60123 * Checks if `value` is classified as a typed array.
60124 *
60125 * @static
60126 * @memberOf _
60127 * @since 3.0.0
60128 * @category Lang
60129 * @param {*} value The value to check.
60130 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
60131 * @example
60132 *
60133 * _.isTypedArray(new Uint8Array);
60134 * // => true
60135 *
60136 * _.isTypedArray([]);
60137 * // => false
60138 */
60139
60140
60141var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
60142/**
60143 * Creates an array of the own enumerable property names of `object`.
60144 *
60145 * **Note:** Non-object values are coerced to objects. See the
60146 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
60147 * for more details.
60148 *
60149 * @static
60150 * @since 0.1.0
60151 * @memberOf _
60152 * @category Object
60153 * @param {Object} object The object to query.
60154 * @returns {Array} Returns the array of property names.
60155 * @example
60156 *
60157 * function Foo() {
60158 *   this.a = 1;
60159 *   this.b = 2;
60160 * }
60161 *
60162 * Foo.prototype.c = 3;
60163 *
60164 * _.keys(new Foo);
60165 * // => ['a', 'b'] (iteration order is not guaranteed)
60166 *
60167 * _.keys('hi');
60168 * // => ['0', '1']
60169 */
60170
60171function keys(object) {
60172  return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
60173}
60174/**
60175 * This method returns a new empty array.
60176 *
60177 * @static
60178 * @memberOf _
60179 * @since 4.13.0
60180 * @category Util
60181 * @returns {Array} Returns the new empty array.
60182 * @example
60183 *
60184 * var arrays = _.times(2, _.stubArray);
60185 *
60186 * console.log(arrays);
60187 * // => [[], []]
60188 *
60189 * console.log(arrays[0] === arrays[1]);
60190 * // => false
60191 */
60192
60193
60194function stubArray() {
60195  return [];
60196}
60197/**
60198 * This method returns `false`.
60199 *
60200 * @static
60201 * @memberOf _
60202 * @since 4.13.0
60203 * @category Util
60204 * @returns {boolean} Returns `false`.
60205 * @example
60206 *
60207 * _.times(2, _.stubFalse);
60208 * // => [false, false]
60209 */
60210
60211
60212function stubFalse() {
60213  return false;
60214}
60215
60216module.exports = isEqual;
60217
60218}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
60219
60220},{}],430:[function(require,module,exports){
60221(function (global){
60222"use strict";
60223
60224function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
60225
60226/**
60227 * Lodash (Custom Build) <https://lodash.com/>
60228 * Build: `lodash modularize exports="npm" -o ./`
60229 * Copyright JS Foundation and other contributors <https://js.foundation/>
60230 * Released under MIT license <https://lodash.com/license>
60231 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
60232 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
60233 */
60234
60235/** `Object#toString` result references. */
60236var asyncTag = '[object AsyncFunction]',
60237    funcTag = '[object Function]',
60238    genTag = '[object GeneratorFunction]',
60239    nullTag = '[object Null]',
60240    proxyTag = '[object Proxy]',
60241    undefinedTag = '[object Undefined]';
60242/** Detect free variable `global` from Node.js. */
60243
60244var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
60245/** Detect free variable `self`. */
60246
60247var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
60248/** Used as a reference to the global object. */
60249
60250var root = freeGlobal || freeSelf || Function('return this')();
60251/** Used for built-in method references. */
60252
60253var objectProto = Object.prototype;
60254/** Used to check objects for own properties. */
60255
60256var hasOwnProperty = objectProto.hasOwnProperty;
60257/**
60258 * Used to resolve the
60259 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
60260 * of values.
60261 */
60262
60263var nativeObjectToString = objectProto.toString;
60264/** Built-in value references. */
60265
60266var _Symbol = root.Symbol,
60267    symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
60268/**
60269 * The base implementation of `getTag` without fallbacks for buggy environments.
60270 *
60271 * @private
60272 * @param {*} value The value to query.
60273 * @returns {string} Returns the `toStringTag`.
60274 */
60275
60276function baseGetTag(value) {
60277  if (value == null) {
60278    return value === undefined ? undefinedTag : nullTag;
60279  }
60280
60281  return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
60282}
60283/**
60284 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
60285 *
60286 * @private
60287 * @param {*} value The value to query.
60288 * @returns {string} Returns the raw `toStringTag`.
60289 */
60290
60291
60292function getRawTag(value) {
60293  var isOwn = hasOwnProperty.call(value, symToStringTag),
60294      tag = value[symToStringTag];
60295
60296  try {
60297    value[symToStringTag] = undefined;
60298    var unmasked = true;
60299  } catch (e) {}
60300
60301  var result = nativeObjectToString.call(value);
60302
60303  if (unmasked) {
60304    if (isOwn) {
60305      value[symToStringTag] = tag;
60306    } else {
60307      delete value[symToStringTag];
60308    }
60309  }
60310
60311  return result;
60312}
60313/**
60314 * Converts `value` to a string using `Object.prototype.toString`.
60315 *
60316 * @private
60317 * @param {*} value The value to convert.
60318 * @returns {string} Returns the converted string.
60319 */
60320
60321
60322function objectToString(value) {
60323  return nativeObjectToString.call(value);
60324}
60325/**
60326 * Checks if `value` is classified as a `Function` object.
60327 *
60328 * @static
60329 * @memberOf _
60330 * @since 0.1.0
60331 * @category Lang
60332 * @param {*} value The value to check.
60333 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
60334 * @example
60335 *
60336 * _.isFunction(_);
60337 * // => true
60338 *
60339 * _.isFunction(/abc/);
60340 * // => false
60341 */
60342
60343
60344function isFunction(value) {
60345  if (!isObject(value)) {
60346    return false;
60347  } // The use of `Object#toString` avoids issues with the `typeof` operator
60348  // in Safari 9 which returns 'object' for typed arrays and other constructors.
60349
60350
60351  var tag = baseGetTag(value);
60352  return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
60353}
60354/**
60355 * Checks if `value` is the
60356 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
60357 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
60358 *
60359 * @static
60360 * @memberOf _
60361 * @since 0.1.0
60362 * @category Lang
60363 * @param {*} value The value to check.
60364 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
60365 * @example
60366 *
60367 * _.isObject({});
60368 * // => true
60369 *
60370 * _.isObject([1, 2, 3]);
60371 * // => true
60372 *
60373 * _.isObject(_.noop);
60374 * // => true
60375 *
60376 * _.isObject(null);
60377 * // => false
60378 */
60379
60380
60381function isObject(value) {
60382  var type = _typeof(value);
60383
60384  return value != null && (type == 'object' || type == 'function');
60385}
60386
60387module.exports = isFunction;
60388
60389}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
60390
60391},{}],431:[function(require,module,exports){
60392"use strict";
60393
60394/**
60395 * lodash 4.0.0 (Custom Build) <https://lodash.com/>
60396 * Build: `lodash modularize exports="npm" -o ./`
60397 * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
60398 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
60399 * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
60400 * Available under MIT license <https://lodash.com/license>
60401 */
60402
60403/**
60404 * Checks if `value` is `null` or `undefined`.
60405 *
60406 * @static
60407 * @memberOf _
60408 * @category Lang
60409 * @param {*} value The value to check.
60410 * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
60411 * @example
60412 *
60413 * _.isNil(null);
60414 * // => true
60415 *
60416 * _.isNil(void 0);
60417 * // => true
60418 *
60419 * _.isNil(NaN);
60420 * // => false
60421 */
60422function isNil(value) {
60423  return value == null;
60424}
60425
60426module.exports = isNil;
60427
60428},{}],432:[function(require,module,exports){
60429"use strict";
60430
60431/**
60432 * lodash 3.0.1 (Custom Build) <https://lodash.com/>
60433 * Build: `lodash modern modularize exports="npm" -o ./`
60434 * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
60435 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
60436 * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
60437 * Available under MIT license <https://lodash.com/license>
60438 */
60439
60440/**
60441 * Checks if `value` is `undefined`.
60442 *
60443 * @static
60444 * @memberOf _
60445 * @category Lang
60446 * @param {*} value The value to check.
60447 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
60448 * @example
60449 *
60450 * _.isUndefined(void 0);
60451 * // => true
60452 *
60453 * _.isUndefined(null);
60454 * // => false
60455 */
60456function isUndefined(value) {
60457  return value === undefined;
60458}
60459
60460module.exports = isUndefined;
60461
60462},{}],433:[function(require,module,exports){
60463(function (global){
60464"use strict";
60465
60466function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
60467
60468/**
60469 * lodash (Custom Build) <https://lodash.com/>
60470 * Build: `lodash modularize exports="npm" -o ./`
60471 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
60472 * Released under MIT license <https://lodash.com/license>
60473 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
60474 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
60475 */
60476
60477/** Used as the size to enable large array optimizations. */
60478var LARGE_ARRAY_SIZE = 200;
60479/** Used to stand-in for `undefined` hash values. */
60480
60481var HASH_UNDEFINED = '__lodash_hash_undefined__';
60482/** Used as references for various `Number` constants. */
60483
60484var INFINITY = 1 / 0;
60485/** `Object#toString` result references. */
60486
60487var funcTag = '[object Function]',
60488    genTag = '[object GeneratorFunction]';
60489/**
60490 * Used to match `RegExp`
60491 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
60492 */
60493
60494var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
60495/** Used to detect host constructors (Safari). */
60496
60497var reIsHostCtor = /^\[object .+?Constructor\]$/;
60498/** Detect free variable `global` from Node.js. */
60499
60500var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof(global)) == 'object' && global && global.Object === Object && global;
60501/** Detect free variable `self`. */
60502
60503var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
60504/** Used as a reference to the global object. */
60505
60506var root = freeGlobal || freeSelf || Function('return this')();
60507/**
60508 * A specialized version of `_.includes` for arrays without support for
60509 * specifying an index to search from.
60510 *
60511 * @private
60512 * @param {Array} [array] The array to inspect.
60513 * @param {*} target The value to search for.
60514 * @returns {boolean} Returns `true` if `target` is found, else `false`.
60515 */
60516
60517function arrayIncludes(array, value) {
60518  var length = array ? array.length : 0;
60519  return !!length && baseIndexOf(array, value, 0) > -1;
60520}
60521/**
60522 * This function is like `arrayIncludes` except that it accepts a comparator.
60523 *
60524 * @private
60525 * @param {Array} [array] The array to inspect.
60526 * @param {*} target The value to search for.
60527 * @param {Function} comparator The comparator invoked per element.
60528 * @returns {boolean} Returns `true` if `target` is found, else `false`.
60529 */
60530
60531
60532function arrayIncludesWith(array, value, comparator) {
60533  var index = -1,
60534      length = array ? array.length : 0;
60535
60536  while (++index < length) {
60537    if (comparator(value, array[index])) {
60538      return true;
60539    }
60540  }
60541
60542  return false;
60543}
60544/**
60545 * The base implementation of `_.findIndex` and `_.findLastIndex` without
60546 * support for iteratee shorthands.
60547 *
60548 * @private
60549 * @param {Array} array The array to inspect.
60550 * @param {Function} predicate The function invoked per iteration.
60551 * @param {number} fromIndex The index to search from.
60552 * @param {boolean} [fromRight] Specify iterating from right to left.
60553 * @returns {number} Returns the index of the matched value, else `-1`.
60554 */
60555
60556
60557function baseFindIndex(array, predicate, fromIndex, fromRight) {
60558  var length = array.length,
60559      index = fromIndex + (fromRight ? 1 : -1);
60560
60561  while (fromRight ? index-- : ++index < length) {
60562    if (predicate(array[index], index, array)) {
60563      return index;
60564    }
60565  }
60566
60567  return -1;
60568}
60569/**
60570 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
60571 *
60572 * @private
60573 * @param {Array} array The array to inspect.
60574 * @param {*} value The value to search for.
60575 * @param {number} fromIndex The index to search from.
60576 * @returns {number} Returns the index of the matched value, else `-1`.
60577 */
60578
60579
60580function baseIndexOf(array, value, fromIndex) {
60581  if (value !== value) {
60582    return baseFindIndex(array, baseIsNaN, fromIndex);
60583  }
60584
60585  var index = fromIndex - 1,
60586      length = array.length;
60587
60588  while (++index < length) {
60589    if (array[index] === value) {
60590      return index;
60591    }
60592  }
60593
60594  return -1;
60595}
60596/**
60597 * The base implementation of `_.isNaN` without support for number objects.
60598 *
60599 * @private
60600 * @param {*} value The value to check.
60601 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
60602 */
60603
60604
60605function baseIsNaN(value) {
60606  return value !== value;
60607}
60608/**
60609 * Checks if a cache value for `key` exists.
60610 *
60611 * @private
60612 * @param {Object} cache The cache to query.
60613 * @param {string} key The key of the entry to check.
60614 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
60615 */
60616
60617
60618function cacheHas(cache, key) {
60619  return cache.has(key);
60620}
60621/**
60622 * Gets the value at `key` of `object`.
60623 *
60624 * @private
60625 * @param {Object} [object] The object to query.
60626 * @param {string} key The key of the property to get.
60627 * @returns {*} Returns the property value.
60628 */
60629
60630
60631function getValue(object, key) {
60632  return object == null ? undefined : object[key];
60633}
60634/**
60635 * Checks if `value` is a host object in IE < 9.
60636 *
60637 * @private
60638 * @param {*} value The value to check.
60639 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
60640 */
60641
60642
60643function isHostObject(value) {
60644  // Many host objects are `Object` objects that can coerce to strings
60645  // despite having improperly defined `toString` methods.
60646  var result = false;
60647
60648  if (value != null && typeof value.toString != 'function') {
60649    try {
60650      result = !!(value + '');
60651    } catch (e) {}
60652  }
60653
60654  return result;
60655}
60656/**
60657 * Converts `set` to an array of its values.
60658 *
60659 * @private
60660 * @param {Object} set The set to convert.
60661 * @returns {Array} Returns the values.
60662 */
60663
60664
60665function setToArray(set) {
60666  var index = -1,
60667      result = Array(set.size);
60668  set.forEach(function (value) {
60669    result[++index] = value;
60670  });
60671  return result;
60672}
60673/** Used for built-in method references. */
60674
60675
60676var arrayProto = Array.prototype,
60677    funcProto = Function.prototype,
60678    objectProto = Object.prototype;
60679/** Used to detect overreaching core-js shims. */
60680
60681var coreJsData = root['__core-js_shared__'];
60682/** Used to detect methods masquerading as native. */
60683
60684var maskSrcKey = function () {
60685  var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
60686  return uid ? 'Symbol(src)_1.' + uid : '';
60687}();
60688/** Used to resolve the decompiled source of functions. */
60689
60690
60691var funcToString = funcProto.toString;
60692/** Used to check objects for own properties. */
60693
60694var hasOwnProperty = objectProto.hasOwnProperty;
60695/**
60696 * Used to resolve the
60697 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
60698 * of values.
60699 */
60700
60701var objectToString = objectProto.toString;
60702/** Used to detect if a method is native. */
60703
60704var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
60705/** Built-in value references. */
60706
60707var splice = arrayProto.splice;
60708/* Built-in method references that are verified to be native. */
60709
60710var Map = getNative(root, 'Map'),
60711    Set = getNative(root, 'Set'),
60712    nativeCreate = getNative(Object, 'create');
60713/**
60714 * Creates a hash object.
60715 *
60716 * @private
60717 * @constructor
60718 * @param {Array} [entries] The key-value pairs to cache.
60719 */
60720
60721function Hash(entries) {
60722  var index = -1,
60723      length = entries ? entries.length : 0;
60724  this.clear();
60725
60726  while (++index < length) {
60727    var entry = entries[index];
60728    this.set(entry[0], entry[1]);
60729  }
60730}
60731/**
60732 * Removes all key-value entries from the hash.
60733 *
60734 * @private
60735 * @name clear
60736 * @memberOf Hash
60737 */
60738
60739
60740function hashClear() {
60741  this.__data__ = nativeCreate ? nativeCreate(null) : {};
60742}
60743/**
60744 * Removes `key` and its value from the hash.
60745 *
60746 * @private
60747 * @name delete
60748 * @memberOf Hash
60749 * @param {Object} hash The hash to modify.
60750 * @param {string} key The key of the value to remove.
60751 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
60752 */
60753
60754
60755function hashDelete(key) {
60756  return this.has(key) && delete this.__data__[key];
60757}
60758/**
60759 * Gets the hash value for `key`.
60760 *
60761 * @private
60762 * @name get
60763 * @memberOf Hash
60764 * @param {string} key The key of the value to get.
60765 * @returns {*} Returns the entry value.
60766 */
60767
60768
60769function hashGet(key) {
60770  var data = this.__data__;
60771
60772  if (nativeCreate) {
60773    var result = data[key];
60774    return result === HASH_UNDEFINED ? undefined : result;
60775  }
60776
60777  return hasOwnProperty.call(data, key) ? data[key] : undefined;
60778}
60779/**
60780 * Checks if a hash value for `key` exists.
60781 *
60782 * @private
60783 * @name has
60784 * @memberOf Hash
60785 * @param {string} key The key of the entry to check.
60786 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
60787 */
60788
60789
60790function hashHas(key) {
60791  var data = this.__data__;
60792  return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
60793}
60794/**
60795 * Sets the hash `key` to `value`.
60796 *
60797 * @private
60798 * @name set
60799 * @memberOf Hash
60800 * @param {string} key The key of the value to set.
60801 * @param {*} value The value to set.
60802 * @returns {Object} Returns the hash instance.
60803 */
60804
60805
60806function hashSet(key, value) {
60807  var data = this.__data__;
60808  data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
60809  return this;
60810} // Add methods to `Hash`.
60811
60812
60813Hash.prototype.clear = hashClear;
60814Hash.prototype['delete'] = hashDelete;
60815Hash.prototype.get = hashGet;
60816Hash.prototype.has = hashHas;
60817Hash.prototype.set = hashSet;
60818/**
60819 * Creates an list cache object.
60820 *
60821 * @private
60822 * @constructor
60823 * @param {Array} [entries] The key-value pairs to cache.
60824 */
60825
60826function ListCache(entries) {
60827  var index = -1,
60828      length = entries ? entries.length : 0;
60829  this.clear();
60830
60831  while (++index < length) {
60832    var entry = entries[index];
60833    this.set(entry[0], entry[1]);
60834  }
60835}
60836/**
60837 * Removes all key-value entries from the list cache.
60838 *
60839 * @private
60840 * @name clear
60841 * @memberOf ListCache
60842 */
60843
60844
60845function listCacheClear() {
60846  this.__data__ = [];
60847}
60848/**
60849 * Removes `key` and its value from the list cache.
60850 *
60851 * @private
60852 * @name delete
60853 * @memberOf ListCache
60854 * @param {string} key The key of the value to remove.
60855 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
60856 */
60857
60858
60859function listCacheDelete(key) {
60860  var data = this.__data__,
60861      index = assocIndexOf(data, key);
60862
60863  if (index < 0) {
60864    return false;
60865  }
60866
60867  var lastIndex = data.length - 1;
60868
60869  if (index == lastIndex) {
60870    data.pop();
60871  } else {
60872    splice.call(data, index, 1);
60873  }
60874
60875  return true;
60876}
60877/**
60878 * Gets the list cache value for `key`.
60879 *
60880 * @private
60881 * @name get
60882 * @memberOf ListCache
60883 * @param {string} key The key of the value to get.
60884 * @returns {*} Returns the entry value.
60885 */
60886
60887
60888function listCacheGet(key) {
60889  var data = this.__data__,
60890      index = assocIndexOf(data, key);
60891  return index < 0 ? undefined : data[index][1];
60892}
60893/**
60894 * Checks if a list cache value for `key` exists.
60895 *
60896 * @private
60897 * @name has
60898 * @memberOf ListCache
60899 * @param {string} key The key of the entry to check.
60900 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
60901 */
60902
60903
60904function listCacheHas(key) {
60905  return assocIndexOf(this.__data__, key) > -1;
60906}
60907/**
60908 * Sets the list cache `key` to `value`.
60909 *
60910 * @private
60911 * @name set
60912 * @memberOf ListCache
60913 * @param {string} key The key of the value to set.
60914 * @param {*} value The value to set.
60915 * @returns {Object} Returns the list cache instance.
60916 */
60917
60918
60919function listCacheSet(key, value) {
60920  var data = this.__data__,
60921      index = assocIndexOf(data, key);
60922
60923  if (index < 0) {
60924    data.push([key, value]);
60925  } else {
60926    data[index][1] = value;
60927  }
60928
60929  return this;
60930} // Add methods to `ListCache`.
60931
60932
60933ListCache.prototype.clear = listCacheClear;
60934ListCache.prototype['delete'] = listCacheDelete;
60935ListCache.prototype.get = listCacheGet;
60936ListCache.prototype.has = listCacheHas;
60937ListCache.prototype.set = listCacheSet;
60938/**
60939 * Creates a map cache object to store key-value pairs.
60940 *
60941 * @private
60942 * @constructor
60943 * @param {Array} [entries] The key-value pairs to cache.
60944 */
60945
60946function MapCache(entries) {
60947  var index = -1,
60948      length = entries ? entries.length : 0;
60949  this.clear();
60950
60951  while (++index < length) {
60952    var entry = entries[index];
60953    this.set(entry[0], entry[1]);
60954  }
60955}
60956/**
60957 * Removes all key-value entries from the map.
60958 *
60959 * @private
60960 * @name clear
60961 * @memberOf MapCache
60962 */
60963
60964
60965function mapCacheClear() {
60966  this.__data__ = {
60967    'hash': new Hash(),
60968    'map': new (Map || ListCache)(),
60969    'string': new Hash()
60970  };
60971}
60972/**
60973 * Removes `key` and its value from the map.
60974 *
60975 * @private
60976 * @name delete
60977 * @memberOf MapCache
60978 * @param {string} key The key of the value to remove.
60979 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
60980 */
60981
60982
60983function mapCacheDelete(key) {
60984  return getMapData(this, key)['delete'](key);
60985}
60986/**
60987 * Gets the map value for `key`.
60988 *
60989 * @private
60990 * @name get
60991 * @memberOf MapCache
60992 * @param {string} key The key of the value to get.
60993 * @returns {*} Returns the entry value.
60994 */
60995
60996
60997function mapCacheGet(key) {
60998  return getMapData(this, key).get(key);
60999}
61000/**
61001 * Checks if a map value for `key` exists.
61002 *
61003 * @private
61004 * @name has
61005 * @memberOf MapCache
61006 * @param {string} key The key of the entry to check.
61007 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
61008 */
61009
61010
61011function mapCacheHas(key) {
61012  return getMapData(this, key).has(key);
61013}
61014/**
61015 * Sets the map `key` to `value`.
61016 *
61017 * @private
61018 * @name set
61019 * @memberOf MapCache
61020 * @param {string} key The key of the value to set.
61021 * @param {*} value The value to set.
61022 * @returns {Object} Returns the map cache instance.
61023 */
61024
61025
61026function mapCacheSet(key, value) {
61027  getMapData(this, key).set(key, value);
61028  return this;
61029} // Add methods to `MapCache`.
61030
61031
61032MapCache.prototype.clear = mapCacheClear;
61033MapCache.prototype['delete'] = mapCacheDelete;
61034MapCache.prototype.get = mapCacheGet;
61035MapCache.prototype.has = mapCacheHas;
61036MapCache.prototype.set = mapCacheSet;
61037/**
61038 *
61039 * Creates an array cache object to store unique values.
61040 *
61041 * @private
61042 * @constructor
61043 * @param {Array} [values] The values to cache.
61044 */
61045
61046function SetCache(values) {
61047  var index = -1,
61048      length = values ? values.length : 0;
61049  this.__data__ = new MapCache();
61050
61051  while (++index < length) {
61052    this.add(values[index]);
61053  }
61054}
61055/**
61056 * Adds `value` to the array cache.
61057 *
61058 * @private
61059 * @name add
61060 * @memberOf SetCache
61061 * @alias push
61062 * @param {*} value The value to cache.
61063 * @returns {Object} Returns the cache instance.
61064 */
61065
61066
61067function setCacheAdd(value) {
61068  this.__data__.set(value, HASH_UNDEFINED);
61069
61070  return this;
61071}
61072/**
61073 * Checks if `value` is in the array cache.
61074 *
61075 * @private
61076 * @name has
61077 * @memberOf SetCache
61078 * @param {*} value The value to search for.
61079 * @returns {number} Returns `true` if `value` is found, else `false`.
61080 */
61081
61082
61083function setCacheHas(value) {
61084  return this.__data__.has(value);
61085} // Add methods to `SetCache`.
61086
61087
61088SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
61089SetCache.prototype.has = setCacheHas;
61090/**
61091 * Gets the index at which the `key` is found in `array` of key-value pairs.
61092 *
61093 * @private
61094 * @param {Array} array The array to inspect.
61095 * @param {*} key The key to search for.
61096 * @returns {number} Returns the index of the matched value, else `-1`.
61097 */
61098
61099function assocIndexOf(array, key) {
61100  var length = array.length;
61101
61102  while (length--) {
61103    if (eq(array[length][0], key)) {
61104      return length;
61105    }
61106  }
61107
61108  return -1;
61109}
61110/**
61111 * The base implementation of `_.isNative` without bad shim checks.
61112 *
61113 * @private
61114 * @param {*} value The value to check.
61115 * @returns {boolean} Returns `true` if `value` is a native function,
61116 *  else `false`.
61117 */
61118
61119
61120function baseIsNative(value) {
61121  if (!isObject(value) || isMasked(value)) {
61122    return false;
61123  }
61124
61125  var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
61126  return pattern.test(toSource(value));
61127}
61128/**
61129 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
61130 *
61131 * @private
61132 * @param {Array} array The array to inspect.
61133 * @param {Function} [iteratee] The iteratee invoked per element.
61134 * @param {Function} [comparator] The comparator invoked per element.
61135 * @returns {Array} Returns the new duplicate free array.
61136 */
61137
61138
61139function baseUniq(array, iteratee, comparator) {
61140  var index = -1,
61141      includes = arrayIncludes,
61142      length = array.length,
61143      isCommon = true,
61144      result = [],
61145      seen = result;
61146
61147  if (comparator) {
61148    isCommon = false;
61149    includes = arrayIncludesWith;
61150  } else if (length >= LARGE_ARRAY_SIZE) {
61151    var set = iteratee ? null : createSet(array);
61152
61153    if (set) {
61154      return setToArray(set);
61155    }
61156
61157    isCommon = false;
61158    includes = cacheHas;
61159    seen = new SetCache();
61160  } else {
61161    seen = iteratee ? [] : result;
61162  }
61163
61164  outer: while (++index < length) {
61165    var value = array[index],
61166        computed = iteratee ? iteratee(value) : value;
61167    value = comparator || value !== 0 ? value : 0;
61168
61169    if (isCommon && computed === computed) {
61170      var seenIndex = seen.length;
61171
61172      while (seenIndex--) {
61173        if (seen[seenIndex] === computed) {
61174          continue outer;
61175        }
61176      }
61177
61178      if (iteratee) {
61179        seen.push(computed);
61180      }
61181
61182      result.push(value);
61183    } else if (!includes(seen, computed, comparator)) {
61184      if (seen !== result) {
61185        seen.push(computed);
61186      }
61187
61188      result.push(value);
61189    }
61190  }
61191
61192  return result;
61193}
61194/**
61195 * Creates a set object of `values`.
61196 *
61197 * @private
61198 * @param {Array} values The values to add to the set.
61199 * @returns {Object} Returns the new set.
61200 */
61201
61202
61203var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function (values) {
61204  return new Set(values);
61205};
61206/**
61207 * Gets the data for `map`.
61208 *
61209 * @private
61210 * @param {Object} map The map to query.
61211 * @param {string} key The reference key.
61212 * @returns {*} Returns the map data.
61213 */
61214
61215function getMapData(map, key) {
61216  var data = map.__data__;
61217  return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
61218}
61219/**
61220 * Gets the native function at `key` of `object`.
61221 *
61222 * @private
61223 * @param {Object} object The object to query.
61224 * @param {string} key The key of the method to get.
61225 * @returns {*} Returns the function if it's native, else `undefined`.
61226 */
61227
61228
61229function getNative(object, key) {
61230  var value = getValue(object, key);
61231  return baseIsNative(value) ? value : undefined;
61232}
61233/**
61234 * Checks if `value` is suitable for use as unique object key.
61235 *
61236 * @private
61237 * @param {*} value The value to check.
61238 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
61239 */
61240
61241
61242function isKeyable(value) {
61243  var type = _typeof(value);
61244
61245  return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
61246}
61247/**
61248 * Checks if `func` has its source masked.
61249 *
61250 * @private
61251 * @param {Function} func The function to check.
61252 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
61253 */
61254
61255
61256function isMasked(func) {
61257  return !!maskSrcKey && maskSrcKey in func;
61258}
61259/**
61260 * Converts `func` to its source code.
61261 *
61262 * @private
61263 * @param {Function} func The function to process.
61264 * @returns {string} Returns the source code.
61265 */
61266
61267
61268function toSource(func) {
61269  if (func != null) {
61270    try {
61271      return funcToString.call(func);
61272    } catch (e) {}
61273
61274    try {
61275      return func + '';
61276    } catch (e) {}
61277  }
61278
61279  return '';
61280}
61281/**
61282 * Creates a duplicate-free version of an array, using
61283 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
61284 * for equality comparisons, in which only the first occurrence of each
61285 * element is kept.
61286 *
61287 * @static
61288 * @memberOf _
61289 * @since 0.1.0
61290 * @category Array
61291 * @param {Array} array The array to inspect.
61292 * @returns {Array} Returns the new duplicate free array.
61293 * @example
61294 *
61295 * _.uniq([2, 1, 2]);
61296 * // => [2, 1]
61297 */
61298
61299
61300function uniq(array) {
61301  return array && array.length ? baseUniq(array) : [];
61302}
61303/**
61304 * Performs a
61305 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
61306 * comparison between two values to determine if they are equivalent.
61307 *
61308 * @static
61309 * @memberOf _
61310 * @since 4.0.0
61311 * @category Lang
61312 * @param {*} value The value to compare.
61313 * @param {*} other The other value to compare.
61314 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
61315 * @example
61316 *
61317 * var object = { 'a': 1 };
61318 * var other = { 'a': 1 };
61319 *
61320 * _.eq(object, object);
61321 * // => true
61322 *
61323 * _.eq(object, other);
61324 * // => false
61325 *
61326 * _.eq('a', 'a');
61327 * // => true
61328 *
61329 * _.eq('a', Object('a'));
61330 * // => false
61331 *
61332 * _.eq(NaN, NaN);
61333 * // => true
61334 */
61335
61336
61337function eq(value, other) {
61338  return value === other || value !== value && other !== other;
61339}
61340/**
61341 * Checks if `value` is classified as a `Function` object.
61342 *
61343 * @static
61344 * @memberOf _
61345 * @since 0.1.0
61346 * @category Lang
61347 * @param {*} value The value to check.
61348 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
61349 * @example
61350 *
61351 * _.isFunction(_);
61352 * // => true
61353 *
61354 * _.isFunction(/abc/);
61355 * // => false
61356 */
61357
61358
61359function isFunction(value) {
61360  // The use of `Object#toString` avoids issues with the `typeof` operator
61361  // in Safari 8-9 which returns 'object' for typed array and other constructors.
61362  var tag = isObject(value) ? objectToString.call(value) : '';
61363  return tag == funcTag || tag == genTag;
61364}
61365/**
61366 * Checks if `value` is the
61367 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
61368 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
61369 *
61370 * @static
61371 * @memberOf _
61372 * @since 0.1.0
61373 * @category Lang
61374 * @param {*} value The value to check.
61375 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
61376 * @example
61377 *
61378 * _.isObject({});
61379 * // => true
61380 *
61381 * _.isObject([1, 2, 3]);
61382 * // => true
61383 *
61384 * _.isObject(_.noop);
61385 * // => true
61386 *
61387 * _.isObject(null);
61388 * // => false
61389 */
61390
61391
61392function isObject(value) {
61393  var type = _typeof(value);
61394
61395  return !!value && (type == 'object' || type == 'function');
61396}
61397/**
61398 * This method returns `undefined`.
61399 *
61400 * @static
61401 * @memberOf _
61402 * @since 2.3.0
61403 * @category Util
61404 * @example
61405 *
61406 * _.times(2, _.noop);
61407 * // => [undefined, undefined]
61408 */
61409
61410
61411function noop() {// No operation performed.
61412}
61413
61414module.exports = uniq;
61415
61416}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
61417
61418},{}],434:[function(require,module,exports){
61419'use strict';
61420
61421var inherits = require('inherits');
61422
61423var HashBase = require('hash-base');
61424
61425var Buffer = require('safe-buffer').Buffer;
61426
61427var ARRAY16 = new Array(16);
61428
61429function MD5() {
61430  HashBase.call(this, 64); // state
61431
61432  this._a = 0x67452301;
61433  this._b = 0xefcdab89;
61434  this._c = 0x98badcfe;
61435  this._d = 0x10325476;
61436}
61437
61438inherits(MD5, HashBase);
61439
61440MD5.prototype._update = function () {
61441  var M = ARRAY16;
61442
61443  for (var i = 0; i < 16; ++i) {
61444    M[i] = this._block.readInt32LE(i * 4);
61445  }
61446
61447  var a = this._a;
61448  var b = this._b;
61449  var c = this._c;
61450  var d = this._d;
61451  a = fnF(a, b, c, d, M[0], 0xd76aa478, 7);
61452  d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12);
61453  c = fnF(c, d, a, b, M[2], 0x242070db, 17);
61454  b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22);
61455  a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7);
61456  d = fnF(d, a, b, c, M[5], 0x4787c62a, 12);
61457  c = fnF(c, d, a, b, M[6], 0xa8304613, 17);
61458  b = fnF(b, c, d, a, M[7], 0xfd469501, 22);
61459  a = fnF(a, b, c, d, M[8], 0x698098d8, 7);
61460  d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12);
61461  c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17);
61462  b = fnF(b, c, d, a, M[11], 0x895cd7be, 22);
61463  a = fnF(a, b, c, d, M[12], 0x6b901122, 7);
61464  d = fnF(d, a, b, c, M[13], 0xfd987193, 12);
61465  c = fnF(c, d, a, b, M[14], 0xa679438e, 17);
61466  b = fnF(b, c, d, a, M[15], 0x49b40821, 22);
61467  a = fnG(a, b, c, d, M[1], 0xf61e2562, 5);
61468  d = fnG(d, a, b, c, M[6], 0xc040b340, 9);
61469  c = fnG(c, d, a, b, M[11], 0x265e5a51, 14);
61470  b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20);
61471  a = fnG(a, b, c, d, M[5], 0xd62f105d, 5);
61472  d = fnG(d, a, b, c, M[10], 0x02441453, 9);
61473  c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14);
61474  b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20);
61475  a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5);
61476  d = fnG(d, a, b, c, M[14], 0xc33707d6, 9);
61477  c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14);
61478  b = fnG(b, c, d, a, M[8], 0x455a14ed, 20);
61479  a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5);
61480  d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9);
61481  c = fnG(c, d, a, b, M[7], 0x676f02d9, 14);
61482  b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20);
61483  a = fnH(a, b, c, d, M[5], 0xfffa3942, 4);
61484  d = fnH(d, a, b, c, M[8], 0x8771f681, 11);
61485  c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16);
61486  b = fnH(b, c, d, a, M[14], 0xfde5380c, 23);
61487  a = fnH(a, b, c, d, M[1], 0xa4beea44, 4);
61488  d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11);
61489  c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16);
61490  b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23);
61491  a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4);
61492  d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11);
61493  c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16);
61494  b = fnH(b, c, d, a, M[6], 0x04881d05, 23);
61495  a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4);
61496  d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11);
61497  c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16);
61498  b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23);
61499  a = fnI(a, b, c, d, M[0], 0xf4292244, 6);
61500  d = fnI(d, a, b, c, M[7], 0x432aff97, 10);
61501  c = fnI(c, d, a, b, M[14], 0xab9423a7, 15);
61502  b = fnI(b, c, d, a, M[5], 0xfc93a039, 21);
61503  a = fnI(a, b, c, d, M[12], 0x655b59c3, 6);
61504  d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10);
61505  c = fnI(c, d, a, b, M[10], 0xffeff47d, 15);
61506  b = fnI(b, c, d, a, M[1], 0x85845dd1, 21);
61507  a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6);
61508  d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10);
61509  c = fnI(c, d, a, b, M[6], 0xa3014314, 15);
61510  b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21);
61511  a = fnI(a, b, c, d, M[4], 0xf7537e82, 6);
61512  d = fnI(d, a, b, c, M[11], 0xbd3af235, 10);
61513  c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15);
61514  b = fnI(b, c, d, a, M[9], 0xeb86d391, 21);
61515  this._a = this._a + a | 0;
61516  this._b = this._b + b | 0;
61517  this._c = this._c + c | 0;
61518  this._d = this._d + d | 0;
61519};
61520
61521MD5.prototype._digest = function () {
61522  // create padding and handle blocks
61523  this._block[this._blockOffset++] = 0x80;
61524
61525  if (this._blockOffset > 56) {
61526    this._block.fill(0, this._blockOffset, 64);
61527
61528    this._update();
61529
61530    this._blockOffset = 0;
61531  }
61532
61533  this._block.fill(0, this._blockOffset, 56);
61534
61535  this._block.writeUInt32LE(this._length[0], 56);
61536
61537  this._block.writeUInt32LE(this._length[1], 60);
61538
61539  this._update(); // produce result
61540
61541
61542  var buffer = Buffer.allocUnsafe(16);
61543  buffer.writeInt32LE(this._a, 0);
61544  buffer.writeInt32LE(this._b, 4);
61545  buffer.writeInt32LE(this._c, 8);
61546  buffer.writeInt32LE(this._d, 12);
61547  return buffer;
61548};
61549
61550function rotl(x, n) {
61551  return x << n | x >>> 32 - n;
61552}
61553
61554function fnF(a, b, c, d, m, k, s) {
61555  return rotl(a + (b & c | ~b & d) + m + k | 0, s) + b | 0;
61556}
61557
61558function fnG(a, b, c, d, m, k, s) {
61559  return rotl(a + (b & d | c & ~d) + m + k | 0, s) + b | 0;
61560}
61561
61562function fnH(a, b, c, d, m, k, s) {
61563  return rotl(a + (b ^ c ^ d) + m + k | 0, s) + b | 0;
61564}
61565
61566function fnI(a, b, c, d, m, k, s) {
61567  return rotl(a + (c ^ (b | ~d)) + m + k | 0, s) + b | 0;
61568}
61569
61570module.exports = MD5;
61571
61572},{"hash-base":370,"inherits":387,"safe-buffer":494}],435:[function(require,module,exports){
61573"use strict";
61574
61575var bn = require('bn.js');
61576
61577var brorand = require('brorand');
61578
61579function MillerRabin(rand) {
61580  this.rand = rand || new brorand.Rand();
61581}
61582
61583module.exports = MillerRabin;
61584
61585MillerRabin.create = function create(rand) {
61586  return new MillerRabin(rand);
61587};
61588
61589MillerRabin.prototype._randbelow = function _randbelow(n) {
61590  var len = n.bitLength();
61591  var min_bytes = Math.ceil(len / 8); // Generage random bytes until a number less than n is found.
61592  // This ensures that 0..n-1 have an equal probability of being selected.
61593
61594  do {
61595    var a = new bn(this.rand.generate(min_bytes));
61596  } while (a.cmp(n) >= 0);
61597
61598  return a;
61599};
61600
61601MillerRabin.prototype._randrange = function _randrange(start, stop) {
61602  // Generate a random number greater than or equal to start and less than stop.
61603  var size = stop.sub(start);
61604  return start.add(this._randbelow(size));
61605};
61606
61607MillerRabin.prototype.test = function test(n, k, cb) {
61608  var len = n.bitLength();
61609  var red = bn.mont(n);
61610  var rone = new bn(1).toRed(red);
61611  if (!k) k = Math.max(1, len / 48 | 0); // Find d and s, (n - 1) = (2 ^ s) * d;
61612
61613  var n1 = n.subn(1);
61614
61615  for (var s = 0; !n1.testn(s); s++) {}
61616
61617  var d = n.shrn(s);
61618  var rn1 = n1.toRed(red);
61619  var prime = true;
61620
61621  for (; k > 0; k--) {
61622    var a = this._randrange(new bn(2), n1);
61623
61624    if (cb) cb(a);
61625    var x = a.toRed(red).redPow(d);
61626    if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) continue;
61627
61628    for (var i = 1; i < s; i++) {
61629      x = x.redSqr();
61630      if (x.cmp(rone) === 0) return false;
61631      if (x.cmp(rn1) === 0) break;
61632    }
61633
61634    if (i === s) return false;
61635  }
61636
61637  return prime;
61638};
61639
61640MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
61641  var len = n.bitLength();
61642  var red = bn.mont(n);
61643  var rone = new bn(1).toRed(red);
61644  if (!k) k = Math.max(1, len / 48 | 0); // Find d and s, (n - 1) = (2 ^ s) * d;
61645
61646  var n1 = n.subn(1);
61647
61648  for (var s = 0; !n1.testn(s); s++) {}
61649
61650  var d = n.shrn(s);
61651  var rn1 = n1.toRed(red);
61652
61653  for (; k > 0; k--) {
61654    var a = this._randrange(new bn(2), n1);
61655
61656    var g = n.gcd(a);
61657    if (g.cmpn(1) !== 0) return g;
61658    var x = a.toRed(red).redPow(d);
61659    if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) continue;
61660
61661    for (var i = 1; i < s; i++) {
61662      x = x.redSqr();
61663      if (x.cmp(rone) === 0) return x.fromRed().subn(1).gcd(n);
61664      if (x.cmp(rn1) === 0) break;
61665    }
61666
61667    if (i === s) {
61668      x = x.redSqr();
61669      return x.fromRed().subn(1).gcd(n);
61670    }
61671  }
61672
61673  return false;
61674};
61675
61676},{"bn.js":436,"brorand":184}],436:[function(require,module,exports){
61677arguments[4][181][0].apply(exports,arguments)
61678},{"buffer":185,"dup":181}],437:[function(require,module,exports){
61679"use strict";
61680
61681module.exports = assert;
61682
61683function assert(val, msg) {
61684  if (!val) throw new Error(msg || 'Assertion failed');
61685}
61686
61687assert.equal = function assertEqual(l, r, msg) {
61688  if (l != r) throw new Error(msg || 'Assertion failed: ' + l + ' != ' + r);
61689};
61690
61691},{}],438:[function(require,module,exports){
61692'use strict';
61693
61694var utils = exports;
61695
61696function toArray(msg, enc) {
61697  if (Array.isArray(msg)) return msg.slice();
61698  if (!msg) return [];
61699  var res = [];
61700
61701  if (typeof msg !== 'string') {
61702    for (var i = 0; i < msg.length; i++) {
61703      res[i] = msg[i] | 0;
61704    }
61705
61706    return res;
61707  }
61708
61709  if (enc === 'hex') {
61710    msg = msg.replace(/[^a-z0-9]+/ig, '');
61711    if (msg.length % 2 !== 0) msg = '0' + msg;
61712
61713    for (var i = 0; i < msg.length; i += 2) {
61714      res.push(parseInt(msg[i] + msg[i + 1], 16));
61715    }
61716  } else {
61717    for (var i = 0; i < msg.length; i++) {
61718      var c = msg.charCodeAt(i);
61719      var hi = c >> 8;
61720      var lo = c & 0xff;
61721      if (hi) res.push(hi, lo);else res.push(lo);
61722    }
61723  }
61724
61725  return res;
61726}
61727
61728utils.toArray = toArray;
61729
61730function zero2(word) {
61731  if (word.length === 1) return '0' + word;else return word;
61732}
61733
61734utils.zero2 = zero2;
61735
61736function toHex(msg) {
61737  var res = '';
61738
61739  for (var i = 0; i < msg.length; i++) {
61740    res += zero2(msg[i].toString(16));
61741  }
61742
61743  return res;
61744}
61745
61746utils.toHex = toHex;
61747
61748utils.encode = function encode(arr, enc) {
61749  if (enc === 'hex') return toHex(arr);else return arr;
61750};
61751
61752},{}],439:[function(require,module,exports){
61753// Top level file is just a mixin of submodules & constants
61754'use strict';
61755
61756var assign = require('./lib/utils/common').assign;
61757
61758var deflate = require('./lib/deflate');
61759
61760var inflate = require('./lib/inflate');
61761
61762var constants = require('./lib/zlib/constants');
61763
61764var pako = {};
61765assign(pako, deflate, inflate, constants);
61766module.exports = pako;
61767
61768},{"./lib/deflate":440,"./lib/inflate":441,"./lib/utils/common":442,"./lib/zlib/constants":445}],440:[function(require,module,exports){
61769'use strict';
61770
61771var zlib_deflate = require('./zlib/deflate');
61772
61773var utils = require('./utils/common');
61774
61775var strings = require('./utils/strings');
61776
61777var msg = require('./zlib/messages');
61778
61779var ZStream = require('./zlib/zstream');
61780
61781var toString = Object.prototype.toString;
61782/* Public constants ==========================================================*/
61783
61784/* ===========================================================================*/
61785
61786var Z_NO_FLUSH = 0;
61787var Z_FINISH = 4;
61788var Z_OK = 0;
61789var Z_STREAM_END = 1;
61790var Z_SYNC_FLUSH = 2;
61791var Z_DEFAULT_COMPRESSION = -1;
61792var Z_DEFAULT_STRATEGY = 0;
61793var Z_DEFLATED = 8;
61794/* ===========================================================================*/
61795
61796/**
61797 * class Deflate
61798 *
61799 * Generic JS-style wrapper for zlib calls. If you don't need
61800 * streaming behaviour - use more simple functions: [[deflate]],
61801 * [[deflateRaw]] and [[gzip]].
61802 **/
61803
61804/* internal
61805 * Deflate.chunks -> Array
61806 *
61807 * Chunks of output data, if [[Deflate#onData]] not overridden.
61808 **/
61809
61810/**
61811 * Deflate.result -> Uint8Array|Array
61812 *
61813 * Compressed result, generated by default [[Deflate#onData]]
61814 * and [[Deflate#onEnd]] handlers. Filled after you push last chunk
61815 * (call [[Deflate#push]] with `Z_FINISH` / `true` param)  or if you
61816 * push a chunk with explicit flush (call [[Deflate#push]] with
61817 * `Z_SYNC_FLUSH` param).
61818 **/
61819
61820/**
61821 * Deflate.err -> Number
61822 *
61823 * Error code after deflate finished. 0 (Z_OK) on success.
61824 * You will not need it in real life, because deflate errors
61825 * are possible only on wrong options or bad `onData` / `onEnd`
61826 * custom handlers.
61827 **/
61828
61829/**
61830 * Deflate.msg -> String
61831 *
61832 * Error message, if [[Deflate.err]] != 0
61833 **/
61834
61835/**
61836 * new Deflate(options)
61837 * - options (Object): zlib deflate options.
61838 *
61839 * Creates new deflator instance with specified params. Throws exception
61840 * on bad params. Supported options:
61841 *
61842 * - `level`
61843 * - `windowBits`
61844 * - `memLevel`
61845 * - `strategy`
61846 * - `dictionary`
61847 *
61848 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
61849 * for more information on these.
61850 *
61851 * Additional options, for internal needs:
61852 *
61853 * - `chunkSize` - size of generated data chunks (16K by default)
61854 * - `raw` (Boolean) - do raw deflate
61855 * - `gzip` (Boolean) - create gzip wrapper
61856 * - `to` (String) - if equal to 'string', then result will be "binary string"
61857 *    (each char code [0..255])
61858 * - `header` (Object) - custom header for gzip
61859 *   - `text` (Boolean) - true if compressed data believed to be text
61860 *   - `time` (Number) - modification time, unix timestamp
61861 *   - `os` (Number) - operation system code
61862 *   - `extra` (Array) - array of bytes with extra data (max 65536)
61863 *   - `name` (String) - file name (binary string)
61864 *   - `comment` (String) - comment (binary string)
61865 *   - `hcrc` (Boolean) - true if header crc should be added
61866 *
61867 * ##### Example:
61868 *
61869 * ```javascript
61870 * var pako = require('pako')
61871 *   , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
61872 *   , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
61873 *
61874 * var deflate = new pako.Deflate({ level: 3});
61875 *
61876 * deflate.push(chunk1, false);
61877 * deflate.push(chunk2, true);  // true -> last chunk
61878 *
61879 * if (deflate.err) { throw new Error(deflate.err); }
61880 *
61881 * console.log(deflate.result);
61882 * ```
61883 **/
61884
61885function Deflate(options) {
61886  if (!(this instanceof Deflate)) return new Deflate(options);
61887  this.options = utils.assign({
61888    level: Z_DEFAULT_COMPRESSION,
61889    method: Z_DEFLATED,
61890    chunkSize: 16384,
61891    windowBits: 15,
61892    memLevel: 8,
61893    strategy: Z_DEFAULT_STRATEGY,
61894    to: ''
61895  }, options || {});
61896  var opt = this.options;
61897
61898  if (opt.raw && opt.windowBits > 0) {
61899    opt.windowBits = -opt.windowBits;
61900  } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {
61901    opt.windowBits += 16;
61902  }
61903
61904  this.err = 0; // error code, if happens (0 = Z_OK)
61905
61906  this.msg = ''; // error message
61907
61908  this.ended = false; // used to avoid multiple onEnd() calls
61909
61910  this.chunks = []; // chunks of compressed data
61911
61912  this.strm = new ZStream();
61913  this.strm.avail_out = 0;
61914  var status = zlib_deflate.deflateInit2(this.strm, opt.level, opt.method, opt.windowBits, opt.memLevel, opt.strategy);
61915
61916  if (status !== Z_OK) {
61917    throw new Error(msg[status]);
61918  }
61919
61920  if (opt.header) {
61921    zlib_deflate.deflateSetHeader(this.strm, opt.header);
61922  }
61923
61924  if (opt.dictionary) {
61925    var dict; // Convert data if needed
61926
61927    if (typeof opt.dictionary === 'string') {
61928      // If we need to compress text, change encoding to utf8.
61929      dict = strings.string2buf(opt.dictionary);
61930    } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
61931      dict = new Uint8Array(opt.dictionary);
61932    } else {
61933      dict = opt.dictionary;
61934    }
61935
61936    status = zlib_deflate.deflateSetDictionary(this.strm, dict);
61937
61938    if (status !== Z_OK) {
61939      throw new Error(msg[status]);
61940    }
61941
61942    this._dict_set = true;
61943  }
61944}
61945/**
61946 * Deflate#push(data[, mode]) -> Boolean
61947 * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be
61948 *   converted to utf8 byte sequence.
61949 * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
61950 *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
61951 *
61952 * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with
61953 * new compressed chunks. Returns `true` on success. The last data block must have
61954 * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
61955 * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you
61956 * can use mode Z_SYNC_FLUSH, keeping the compression context.
61957 *
61958 * On fail call [[Deflate#onEnd]] with error code and return false.
61959 *
61960 * We strongly recommend to use `Uint8Array` on input for best speed (output
61961 * array format is detected automatically). Also, don't skip last param and always
61962 * use the same type in your code (boolean or number). That will improve JS speed.
61963 *
61964 * For regular `Array`-s make sure all elements are [0..255].
61965 *
61966 * ##### Example
61967 *
61968 * ```javascript
61969 * push(chunk, false); // push one of data chunks
61970 * ...
61971 * push(chunk, true);  // push last chunk
61972 * ```
61973 **/
61974
61975
61976Deflate.prototype.push = function (data, mode) {
61977  var strm = this.strm;
61978  var chunkSize = this.options.chunkSize;
61979
61980  var status, _mode;
61981
61982  if (this.ended) {
61983    return false;
61984  }
61985
61986  _mode = mode === ~~mode ? mode : mode === true ? Z_FINISH : Z_NO_FLUSH; // Convert data if needed
61987
61988  if (typeof data === 'string') {
61989    // If we need to compress text, change encoding to utf8.
61990    strm.input = strings.string2buf(data);
61991  } else if (toString.call(data) === '[object ArrayBuffer]') {
61992    strm.input = new Uint8Array(data);
61993  } else {
61994    strm.input = data;
61995  }
61996
61997  strm.next_in = 0;
61998  strm.avail_in = strm.input.length;
61999
62000  do {
62001    if (strm.avail_out === 0) {
62002      strm.output = new utils.Buf8(chunkSize);
62003      strm.next_out = 0;
62004      strm.avail_out = chunkSize;
62005    }
62006
62007    status = zlib_deflate.deflate(strm, _mode);
62008    /* no bad return value */
62009
62010    if (status !== Z_STREAM_END && status !== Z_OK) {
62011      this.onEnd(status);
62012      this.ended = true;
62013      return false;
62014    }
62015
62016    if (strm.avail_out === 0 || strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH)) {
62017      if (this.options.to === 'string') {
62018        this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));
62019      } else {
62020        this.onData(utils.shrinkBuf(strm.output, strm.next_out));
62021      }
62022    }
62023  } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END); // Finalize on the last chunk.
62024
62025
62026  if (_mode === Z_FINISH) {
62027    status = zlib_deflate.deflateEnd(this.strm);
62028    this.onEnd(status);
62029    this.ended = true;
62030    return status === Z_OK;
62031  } // callback interim results if Z_SYNC_FLUSH.
62032
62033
62034  if (_mode === Z_SYNC_FLUSH) {
62035    this.onEnd(Z_OK);
62036    strm.avail_out = 0;
62037    return true;
62038  }
62039
62040  return true;
62041};
62042/**
62043 * Deflate#onData(chunk) -> Void
62044 * - chunk (Uint8Array|Array|String): output data. Type of array depends
62045 *   on js engine support. When string output requested, each chunk
62046 *   will be string.
62047 *
62048 * By default, stores data blocks in `chunks[]` property and glue
62049 * those in `onEnd`. Override this handler, if you need another behaviour.
62050 **/
62051
62052
62053Deflate.prototype.onData = function (chunk) {
62054  this.chunks.push(chunk);
62055};
62056/**
62057 * Deflate#onEnd(status) -> Void
62058 * - status (Number): deflate status. 0 (Z_OK) on success,
62059 *   other if not.
62060 *
62061 * Called once after you tell deflate that the input stream is
62062 * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
62063 * or if an error happened. By default - join collected chunks,
62064 * free memory and fill `results` / `err` properties.
62065 **/
62066
62067
62068Deflate.prototype.onEnd = function (status) {
62069  // On success - join
62070  if (status === Z_OK) {
62071    if (this.options.to === 'string') {
62072      this.result = this.chunks.join('');
62073    } else {
62074      this.result = utils.flattenChunks(this.chunks);
62075    }
62076  }
62077
62078  this.chunks = [];
62079  this.err = status;
62080  this.msg = this.strm.msg;
62081};
62082/**
62083 * deflate(data[, options]) -> Uint8Array|Array|String
62084 * - data (Uint8Array|Array|String): input data to compress.
62085 * - options (Object): zlib deflate options.
62086 *
62087 * Compress `data` with deflate algorithm and `options`.
62088 *
62089 * Supported options are:
62090 *
62091 * - level
62092 * - windowBits
62093 * - memLevel
62094 * - strategy
62095 * - dictionary
62096 *
62097 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
62098 * for more information on these.
62099 *
62100 * Sugar (options):
62101 *
62102 * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
62103 *   negative windowBits implicitly.
62104 * - `to` (String) - if equal to 'string', then result will be "binary string"
62105 *    (each char code [0..255])
62106 *
62107 * ##### Example:
62108 *
62109 * ```javascript
62110 * var pako = require('pako')
62111 *   , data = Uint8Array([1,2,3,4,5,6,7,8,9]);
62112 *
62113 * console.log(pako.deflate(data));
62114 * ```
62115 **/
62116
62117
62118function deflate(input, options) {
62119  var deflator = new Deflate(options);
62120  deflator.push(input, true); // That will never happens, if you don't cheat with options :)
62121
62122  if (deflator.err) {
62123    throw deflator.msg || msg[deflator.err];
62124  }
62125
62126  return deflator.result;
62127}
62128/**
62129 * deflateRaw(data[, options]) -> Uint8Array|Array|String
62130 * - data (Uint8Array|Array|String): input data to compress.
62131 * - options (Object): zlib deflate options.
62132 *
62133 * The same as [[deflate]], but creates raw data, without wrapper
62134 * (header and adler32 crc).
62135 **/
62136
62137
62138function deflateRaw(input, options) {
62139  options = options || {};
62140  options.raw = true;
62141  return deflate(input, options);
62142}
62143/**
62144 * gzip(data[, options]) -> Uint8Array|Array|String
62145 * - data (Uint8Array|Array|String): input data to compress.
62146 * - options (Object): zlib deflate options.
62147 *
62148 * The same as [[deflate]], but create gzip wrapper instead of
62149 * deflate one.
62150 **/
62151
62152
62153function gzip(input, options) {
62154  options = options || {};
62155  options.gzip = true;
62156  return deflate(input, options);
62157}
62158
62159exports.Deflate = Deflate;
62160exports.deflate = deflate;
62161exports.deflateRaw = deflateRaw;
62162exports.gzip = gzip;
62163
62164},{"./utils/common":442,"./utils/strings":443,"./zlib/deflate":447,"./zlib/messages":452,"./zlib/zstream":454}],441:[function(require,module,exports){
62165'use strict';
62166
62167var zlib_inflate = require('./zlib/inflate');
62168
62169var utils = require('./utils/common');
62170
62171var strings = require('./utils/strings');
62172
62173var c = require('./zlib/constants');
62174
62175var msg = require('./zlib/messages');
62176
62177var ZStream = require('./zlib/zstream');
62178
62179var GZheader = require('./zlib/gzheader');
62180
62181var toString = Object.prototype.toString;
62182/**
62183 * class Inflate
62184 *
62185 * Generic JS-style wrapper for zlib calls. If you don't need
62186 * streaming behaviour - use more simple functions: [[inflate]]
62187 * and [[inflateRaw]].
62188 **/
62189
62190/* internal
62191 * inflate.chunks -> Array
62192 *
62193 * Chunks of output data, if [[Inflate#onData]] not overridden.
62194 **/
62195
62196/**
62197 * Inflate.result -> Uint8Array|Array|String
62198 *
62199 * Uncompressed result, generated by default [[Inflate#onData]]
62200 * and [[Inflate#onEnd]] handlers. Filled after you push last chunk
62201 * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you
62202 * push a chunk with explicit flush (call [[Inflate#push]] with
62203 * `Z_SYNC_FLUSH` param).
62204 **/
62205
62206/**
62207 * Inflate.err -> Number
62208 *
62209 * Error code after inflate finished. 0 (Z_OK) on success.
62210 * Should be checked if broken data possible.
62211 **/
62212
62213/**
62214 * Inflate.msg -> String
62215 *
62216 * Error message, if [[Inflate.err]] != 0
62217 **/
62218
62219/**
62220 * new Inflate(options)
62221 * - options (Object): zlib inflate options.
62222 *
62223 * Creates new inflator instance with specified params. Throws exception
62224 * on bad params. Supported options:
62225 *
62226 * - `windowBits`
62227 * - `dictionary`
62228 *
62229 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
62230 * for more information on these.
62231 *
62232 * Additional options, for internal needs:
62233 *
62234 * - `chunkSize` - size of generated data chunks (16K by default)
62235 * - `raw` (Boolean) - do raw inflate
62236 * - `to` (String) - if equal to 'string', then result will be converted
62237 *   from utf8 to utf16 (javascript) string. When string output requested,
62238 *   chunk length can differ from `chunkSize`, depending on content.
62239 *
62240 * By default, when no options set, autodetect deflate/gzip data format via
62241 * wrapper header.
62242 *
62243 * ##### Example:
62244 *
62245 * ```javascript
62246 * var pako = require('pako')
62247 *   , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
62248 *   , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
62249 *
62250 * var inflate = new pako.Inflate({ level: 3});
62251 *
62252 * inflate.push(chunk1, false);
62253 * inflate.push(chunk2, true);  // true -> last chunk
62254 *
62255 * if (inflate.err) { throw new Error(inflate.err); }
62256 *
62257 * console.log(inflate.result);
62258 * ```
62259 **/
62260
62261function Inflate(options) {
62262  if (!(this instanceof Inflate)) return new Inflate(options);
62263  this.options = utils.assign({
62264    chunkSize: 16384,
62265    windowBits: 0,
62266    to: ''
62267  }, options || {});
62268  var opt = this.options; // Force window size for `raw` data, if not set directly,
62269  // because we have no header for autodetect.
62270
62271  if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
62272    opt.windowBits = -opt.windowBits;
62273
62274    if (opt.windowBits === 0) {
62275      opt.windowBits = -15;
62276    }
62277  } // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
62278
62279
62280  if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
62281    opt.windowBits += 32;
62282  } // Gzip header has no info about windows size, we can do autodetect only
62283  // for deflate. So, if window size not set, force it to max when gzip possible
62284
62285
62286  if (opt.windowBits > 15 && opt.windowBits < 48) {
62287    // bit 3 (16) -> gzipped data
62288    // bit 4 (32) -> autodetect gzip/deflate
62289    if ((opt.windowBits & 15) === 0) {
62290      opt.windowBits |= 15;
62291    }
62292  }
62293
62294  this.err = 0; // error code, if happens (0 = Z_OK)
62295
62296  this.msg = ''; // error message
62297
62298  this.ended = false; // used to avoid multiple onEnd() calls
62299
62300  this.chunks = []; // chunks of compressed data
62301
62302  this.strm = new ZStream();
62303  this.strm.avail_out = 0;
62304  var status = zlib_inflate.inflateInit2(this.strm, opt.windowBits);
62305
62306  if (status !== c.Z_OK) {
62307    throw new Error(msg[status]);
62308  }
62309
62310  this.header = new GZheader();
62311  zlib_inflate.inflateGetHeader(this.strm, this.header); // Setup dictionary
62312
62313  if (opt.dictionary) {
62314    // Convert data if needed
62315    if (typeof opt.dictionary === 'string') {
62316      opt.dictionary = strings.string2buf(opt.dictionary);
62317    } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
62318      opt.dictionary = new Uint8Array(opt.dictionary);
62319    }
62320
62321    if (opt.raw) {
62322      //In raw mode we need to set the dictionary early
62323      status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);
62324
62325      if (status !== c.Z_OK) {
62326        throw new Error(msg[status]);
62327      }
62328    }
62329  }
62330}
62331/**
62332 * Inflate#push(data[, mode]) -> Boolean
62333 * - data (Uint8Array|Array|ArrayBuffer|String): input data
62334 * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
62335 *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
62336 *
62337 * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with
62338 * new output chunks. Returns `true` on success. The last data block must have
62339 * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
62340 * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you
62341 * can use mode Z_SYNC_FLUSH, keeping the decompression context.
62342 *
62343 * On fail call [[Inflate#onEnd]] with error code and return false.
62344 *
62345 * We strongly recommend to use `Uint8Array` on input for best speed (output
62346 * format is detected automatically). Also, don't skip last param and always
62347 * use the same type in your code (boolean or number). That will improve JS speed.
62348 *
62349 * For regular `Array`-s make sure all elements are [0..255].
62350 *
62351 * ##### Example
62352 *
62353 * ```javascript
62354 * push(chunk, false); // push one of data chunks
62355 * ...
62356 * push(chunk, true);  // push last chunk
62357 * ```
62358 **/
62359
62360
62361Inflate.prototype.push = function (data, mode) {
62362  var strm = this.strm;
62363  var chunkSize = this.options.chunkSize;
62364  var dictionary = this.options.dictionary;
62365
62366  var status, _mode;
62367
62368  var next_out_utf8, tail, utf8str; // Flag to properly process Z_BUF_ERROR on testing inflate call
62369  // when we check that all output data was flushed.
62370
62371  var allowBufError = false;
62372
62373  if (this.ended) {
62374    return false;
62375  }
62376
62377  _mode = mode === ~~mode ? mode : mode === true ? c.Z_FINISH : c.Z_NO_FLUSH; // Convert data if needed
62378
62379  if (typeof data === 'string') {
62380    // Only binary strings can be decompressed on practice
62381    strm.input = strings.binstring2buf(data);
62382  } else if (toString.call(data) === '[object ArrayBuffer]') {
62383    strm.input = new Uint8Array(data);
62384  } else {
62385    strm.input = data;
62386  }
62387
62388  strm.next_in = 0;
62389  strm.avail_in = strm.input.length;
62390
62391  do {
62392    if (strm.avail_out === 0) {
62393      strm.output = new utils.Buf8(chunkSize);
62394      strm.next_out = 0;
62395      strm.avail_out = chunkSize;
62396    }
62397
62398    status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH);
62399    /* no bad return value */
62400
62401    if (status === c.Z_NEED_DICT && dictionary) {
62402      status = zlib_inflate.inflateSetDictionary(this.strm, dictionary);
62403    }
62404
62405    if (status === c.Z_BUF_ERROR && allowBufError === true) {
62406      status = c.Z_OK;
62407      allowBufError = false;
62408    }
62409
62410    if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
62411      this.onEnd(status);
62412      this.ended = true;
62413      return false;
62414    }
62415
62416    if (strm.next_out) {
62417      if (strm.avail_out === 0 || status === c.Z_STREAM_END || strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH)) {
62418        if (this.options.to === 'string') {
62419          next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
62420          tail = strm.next_out - next_out_utf8;
62421          utf8str = strings.buf2string(strm.output, next_out_utf8); // move tail
62422
62423          strm.next_out = tail;
62424          strm.avail_out = chunkSize - tail;
62425
62426          if (tail) {
62427            utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0);
62428          }
62429
62430          this.onData(utf8str);
62431        } else {
62432          this.onData(utils.shrinkBuf(strm.output, strm.next_out));
62433        }
62434      }
62435    } // When no more input data, we should check that internal inflate buffers
62436    // are flushed. The only way to do it when avail_out = 0 - run one more
62437    // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
62438    // Here we set flag to process this error properly.
62439    //
62440    // NOTE. Deflate does not return error in this case and does not needs such
62441    // logic.
62442
62443
62444    if (strm.avail_in === 0 && strm.avail_out === 0) {
62445      allowBufError = true;
62446    }
62447  } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
62448
62449  if (status === c.Z_STREAM_END) {
62450    _mode = c.Z_FINISH;
62451  } // Finalize on the last chunk.
62452
62453
62454  if (_mode === c.Z_FINISH) {
62455    status = zlib_inflate.inflateEnd(this.strm);
62456    this.onEnd(status);
62457    this.ended = true;
62458    return status === c.Z_OK;
62459  } // callback interim results if Z_SYNC_FLUSH.
62460
62461
62462  if (_mode === c.Z_SYNC_FLUSH) {
62463    this.onEnd(c.Z_OK);
62464    strm.avail_out = 0;
62465    return true;
62466  }
62467
62468  return true;
62469};
62470/**
62471 * Inflate#onData(chunk) -> Void
62472 * - chunk (Uint8Array|Array|String): output data. Type of array depends
62473 *   on js engine support. When string output requested, each chunk
62474 *   will be string.
62475 *
62476 * By default, stores data blocks in `chunks[]` property and glue
62477 * those in `onEnd`. Override this handler, if you need another behaviour.
62478 **/
62479
62480
62481Inflate.prototype.onData = function (chunk) {
62482  this.chunks.push(chunk);
62483};
62484/**
62485 * Inflate#onEnd(status) -> Void
62486 * - status (Number): inflate status. 0 (Z_OK) on success,
62487 *   other if not.
62488 *
62489 * Called either after you tell inflate that the input stream is
62490 * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
62491 * or if an error happened. By default - join collected chunks,
62492 * free memory and fill `results` / `err` properties.
62493 **/
62494
62495
62496Inflate.prototype.onEnd = function (status) {
62497  // On success - join
62498  if (status === c.Z_OK) {
62499    if (this.options.to === 'string') {
62500      // Glue & convert here, until we teach pako to send
62501      // utf8 aligned strings to onData
62502      this.result = this.chunks.join('');
62503    } else {
62504      this.result = utils.flattenChunks(this.chunks);
62505    }
62506  }
62507
62508  this.chunks = [];
62509  this.err = status;
62510  this.msg = this.strm.msg;
62511};
62512/**
62513 * inflate(data[, options]) -> Uint8Array|Array|String
62514 * - data (Uint8Array|Array|String): input data to decompress.
62515 * - options (Object): zlib inflate options.
62516 *
62517 * Decompress `data` with inflate/ungzip and `options`. Autodetect
62518 * format via wrapper header by default. That's why we don't provide
62519 * separate `ungzip` method.
62520 *
62521 * Supported options are:
62522 *
62523 * - windowBits
62524 *
62525 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
62526 * for more information.
62527 *
62528 * Sugar (options):
62529 *
62530 * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
62531 *   negative windowBits implicitly.
62532 * - `to` (String) - if equal to 'string', then result will be converted
62533 *   from utf8 to utf16 (javascript) string. When string output requested,
62534 *   chunk length can differ from `chunkSize`, depending on content.
62535 *
62536 *
62537 * ##### Example:
62538 *
62539 * ```javascript
62540 * var pako = require('pako')
62541 *   , input = pako.deflate([1,2,3,4,5,6,7,8,9])
62542 *   , output;
62543 *
62544 * try {
62545 *   output = pako.inflate(input);
62546 * } catch (err)
62547 *   console.log(err);
62548 * }
62549 * ```
62550 **/
62551
62552
62553function inflate(input, options) {
62554  var inflator = new Inflate(options);
62555  inflator.push(input, true); // That will never happens, if you don't cheat with options :)
62556
62557  if (inflator.err) {
62558    throw inflator.msg || msg[inflator.err];
62559  }
62560
62561  return inflator.result;
62562}
62563/**
62564 * inflateRaw(data[, options]) -> Uint8Array|Array|String
62565 * - data (Uint8Array|Array|String): input data to decompress.
62566 * - options (Object): zlib inflate options.
62567 *
62568 * The same as [[inflate]], but creates raw data, without wrapper
62569 * (header and adler32 crc).
62570 **/
62571
62572
62573function inflateRaw(input, options) {
62574  options = options || {};
62575  options.raw = true;
62576  return inflate(input, options);
62577}
62578/**
62579 * ungzip(data[, options]) -> Uint8Array|Array|String
62580 * - data (Uint8Array|Array|String): input data to decompress.
62581 * - options (Object): zlib inflate options.
62582 *
62583 * Just shortcut to [[inflate]], because it autodetects format
62584 * by header.content. Done for convenience.
62585 **/
62586
62587
62588exports.Inflate = Inflate;
62589exports.inflate = inflate;
62590exports.inflateRaw = inflateRaw;
62591exports.ungzip = inflate;
62592
62593},{"./utils/common":442,"./utils/strings":443,"./zlib/constants":445,"./zlib/gzheader":448,"./zlib/inflate":450,"./zlib/messages":452,"./zlib/zstream":454}],442:[function(require,module,exports){
62594'use strict';
62595
62596function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
62597
62598var TYPED_OK = typeof Uint8Array !== 'undefined' && typeof Uint16Array !== 'undefined' && typeof Int32Array !== 'undefined';
62599
62600function _has(obj, key) {
62601  return Object.prototype.hasOwnProperty.call(obj, key);
62602}
62603
62604exports.assign = function (obj
62605/*from1, from2, from3, ...*/
62606) {
62607  var sources = Array.prototype.slice.call(arguments, 1);
62608
62609  while (sources.length) {
62610    var source = sources.shift();
62611
62612    if (!source) {
62613      continue;
62614    }
62615
62616    if (_typeof(source) !== 'object') {
62617      throw new TypeError(source + 'must be non-object');
62618    }
62619
62620    for (var p in source) {
62621      if (_has(source, p)) {
62622        obj[p] = source[p];
62623      }
62624    }
62625  }
62626
62627  return obj;
62628}; // reduce buffer size, avoiding mem copy
62629
62630
62631exports.shrinkBuf = function (buf, size) {
62632  if (buf.length === size) {
62633    return buf;
62634  }
62635
62636  if (buf.subarray) {
62637    return buf.subarray(0, size);
62638  }
62639
62640  buf.length = size;
62641  return buf;
62642};
62643
62644var fnTyped = {
62645  arraySet: function arraySet(dest, src, src_offs, len, dest_offs) {
62646    if (src.subarray && dest.subarray) {
62647      dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
62648      return;
62649    } // Fallback to ordinary array
62650
62651
62652    for (var i = 0; i < len; i++) {
62653      dest[dest_offs + i] = src[src_offs + i];
62654    }
62655  },
62656  // Join array of chunks to single array.
62657  flattenChunks: function flattenChunks(chunks) {
62658    var i, l, len, pos, chunk, result; // calculate data length
62659
62660    len = 0;
62661
62662    for (i = 0, l = chunks.length; i < l; i++) {
62663      len += chunks[i].length;
62664    } // join chunks
62665
62666
62667    result = new Uint8Array(len);
62668    pos = 0;
62669
62670    for (i = 0, l = chunks.length; i < l; i++) {
62671      chunk = chunks[i];
62672      result.set(chunk, pos);
62673      pos += chunk.length;
62674    }
62675
62676    return result;
62677  }
62678};
62679var fnUntyped = {
62680  arraySet: function arraySet(dest, src, src_offs, len, dest_offs) {
62681    for (var i = 0; i < len; i++) {
62682      dest[dest_offs + i] = src[src_offs + i];
62683    }
62684  },
62685  // Join array of chunks to single array.
62686  flattenChunks: function flattenChunks(chunks) {
62687    return [].concat.apply([], chunks);
62688  }
62689}; // Enable/Disable typed arrays use, for testing
62690//
62691
62692exports.setTyped = function (on) {
62693  if (on) {
62694    exports.Buf8 = Uint8Array;
62695    exports.Buf16 = Uint16Array;
62696    exports.Buf32 = Int32Array;
62697    exports.assign(exports, fnTyped);
62698  } else {
62699    exports.Buf8 = Array;
62700    exports.Buf16 = Array;
62701    exports.Buf32 = Array;
62702    exports.assign(exports, fnUntyped);
62703  }
62704};
62705
62706exports.setTyped(TYPED_OK);
62707
62708},{}],443:[function(require,module,exports){
62709// String encode/decode helpers
62710'use strict';
62711
62712var utils = require('./common'); // Quick check if we can use fast array to bin string conversion
62713//
62714// - apply(Array) can fail on Android 2.2
62715// - apply(Uint8Array) can fail on iOS 5.1 Safari
62716//
62717
62718
62719var STR_APPLY_OK = true;
62720var STR_APPLY_UIA_OK = true;
62721
62722try {
62723  String.fromCharCode.apply(null, [0]);
62724} catch (__) {
62725  STR_APPLY_OK = false;
62726}
62727
62728try {
62729  String.fromCharCode.apply(null, new Uint8Array(1));
62730} catch (__) {
62731  STR_APPLY_UIA_OK = false;
62732} // Table with utf8 lengths (calculated by first byte of sequence)
62733// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
62734// because max possible codepoint is 0x10ffff
62735
62736
62737var _utf8len = new utils.Buf8(256);
62738
62739for (var q = 0; q < 256; q++) {
62740  _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
62741}
62742
62743_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
62744// convert string to array (typed, when possible)
62745
62746exports.string2buf = function (str) {
62747  var buf,
62748      c,
62749      c2,
62750      m_pos,
62751      i,
62752      str_len = str.length,
62753      buf_len = 0; // count binary size
62754
62755  for (m_pos = 0; m_pos < str_len; m_pos++) {
62756    c = str.charCodeAt(m_pos);
62757
62758    if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {
62759      c2 = str.charCodeAt(m_pos + 1);
62760
62761      if ((c2 & 0xfc00) === 0xdc00) {
62762        c = 0x10000 + (c - 0xd800 << 10) + (c2 - 0xdc00);
62763        m_pos++;
62764      }
62765    }
62766
62767    buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
62768  } // allocate buffer
62769
62770
62771  buf = new utils.Buf8(buf_len); // convert
62772
62773  for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
62774    c = str.charCodeAt(m_pos);
62775
62776    if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {
62777      c2 = str.charCodeAt(m_pos + 1);
62778
62779      if ((c2 & 0xfc00) === 0xdc00) {
62780        c = 0x10000 + (c - 0xd800 << 10) + (c2 - 0xdc00);
62781        m_pos++;
62782      }
62783    }
62784
62785    if (c < 0x80) {
62786      /* one byte */
62787      buf[i++] = c;
62788    } else if (c < 0x800) {
62789      /* two bytes */
62790      buf[i++] = 0xC0 | c >>> 6;
62791      buf[i++] = 0x80 | c & 0x3f;
62792    } else if (c < 0x10000) {
62793      /* three bytes */
62794      buf[i++] = 0xE0 | c >>> 12;
62795      buf[i++] = 0x80 | c >>> 6 & 0x3f;
62796      buf[i++] = 0x80 | c & 0x3f;
62797    } else {
62798      /* four bytes */
62799      buf[i++] = 0xf0 | c >>> 18;
62800      buf[i++] = 0x80 | c >>> 12 & 0x3f;
62801      buf[i++] = 0x80 | c >>> 6 & 0x3f;
62802      buf[i++] = 0x80 | c & 0x3f;
62803    }
62804  }
62805
62806  return buf;
62807}; // Helper (used in 2 places)
62808
62809
62810function buf2binstring(buf, len) {
62811  // On Chrome, the arguments in a function call that are allowed is `65534`.
62812  // If the length of the buffer is smaller than that, we can use this optimization,
62813  // otherwise we will take a slower path.
62814  if (len < 65534) {
62815    if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) {
62816      return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
62817    }
62818  }
62819
62820  var result = '';
62821
62822  for (var i = 0; i < len; i++) {
62823    result += String.fromCharCode(buf[i]);
62824  }
62825
62826  return result;
62827} // Convert byte array to binary string
62828
62829
62830exports.buf2binstring = function (buf) {
62831  return buf2binstring(buf, buf.length);
62832}; // Convert binary string (typed, when possible)
62833
62834
62835exports.binstring2buf = function (str) {
62836  var buf = new utils.Buf8(str.length);
62837
62838  for (var i = 0, len = buf.length; i < len; i++) {
62839    buf[i] = str.charCodeAt(i);
62840  }
62841
62842  return buf;
62843}; // convert array to string
62844
62845
62846exports.buf2string = function (buf, max) {
62847  var i, out, c, c_len;
62848  var len = max || buf.length; // Reserve max possible length (2 words per char)
62849  // NB: by unknown reasons, Array is significantly faster for
62850  //     String.fromCharCode.apply than Uint16Array.
62851
62852  var utf16buf = new Array(len * 2);
62853
62854  for (out = 0, i = 0; i < len;) {
62855    c = buf[i++]; // quick process ascii
62856
62857    if (c < 0x80) {
62858      utf16buf[out++] = c;
62859      continue;
62860    }
62861
62862    c_len = _utf8len[c]; // skip 5 & 6 byte codes
62863
62864    if (c_len > 4) {
62865      utf16buf[out++] = 0xfffd;
62866      i += c_len - 1;
62867      continue;
62868    } // apply mask on first byte
62869
62870
62871    c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; // join the rest
62872
62873    while (c_len > 1 && i < len) {
62874      c = c << 6 | buf[i++] & 0x3f;
62875      c_len--;
62876    } // terminated by end of string?
62877
62878
62879    if (c_len > 1) {
62880      utf16buf[out++] = 0xfffd;
62881      continue;
62882    }
62883
62884    if (c < 0x10000) {
62885      utf16buf[out++] = c;
62886    } else {
62887      c -= 0x10000;
62888      utf16buf[out++] = 0xd800 | c >> 10 & 0x3ff;
62889      utf16buf[out++] = 0xdc00 | c & 0x3ff;
62890    }
62891  }
62892
62893  return buf2binstring(utf16buf, out);
62894}; // Calculate max possible position in utf8 buffer,
62895// that will not break sequence. If that's not possible
62896// - (very small limits) return max size as is.
62897//
62898// buf[] - utf8 bytes array
62899// max   - length limit (mandatory);
62900
62901
62902exports.utf8border = function (buf, max) {
62903  var pos;
62904  max = max || buf.length;
62905
62906  if (max > buf.length) {
62907    max = buf.length;
62908  } // go back from last position, until start of sequence found
62909
62910
62911  pos = max - 1;
62912
62913  while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) {
62914    pos--;
62915  } // Very small and broken sequence,
62916  // return max, because we should return something anyway.
62917
62918
62919  if (pos < 0) {
62920    return max;
62921  } // If we came to start of buffer - that means buffer is too small,
62922  // return max too.
62923
62924
62925  if (pos === 0) {
62926    return max;
62927  }
62928
62929  return pos + _utf8len[buf[pos]] > max ? pos : max;
62930};
62931
62932},{"./common":442}],444:[function(require,module,exports){
62933'use strict'; // Note: adler32 takes 12% for level 0 and 2% for level 6.
62934// It isn't worth it to make additional optimizations as in original.
62935// Small size is preferable.
62936// (C) 1995-2013 Jean-loup Gailly and Mark Adler
62937// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
62938//
62939// This software is provided 'as-is', without any express or implied
62940// warranty. In no event will the authors be held liable for any damages
62941// arising from the use of this software.
62942//
62943// Permission is granted to anyone to use this software for any purpose,
62944// including commercial applications, and to alter it and redistribute it
62945// freely, subject to the following restrictions:
62946//
62947// 1. The origin of this software must not be misrepresented; you must not
62948//   claim that you wrote the original software. If you use this software
62949//   in a product, an acknowledgment in the product documentation would be
62950//   appreciated but is not required.
62951// 2. Altered source versions must be plainly marked as such, and must not be
62952//   misrepresented as being the original software.
62953// 3. This notice may not be removed or altered from any source distribution.
62954
62955function adler32(adler, buf, len, pos) {
62956  var s1 = adler & 0xffff | 0,
62957      s2 = adler >>> 16 & 0xffff | 0,
62958      n = 0;
62959
62960  while (len !== 0) {
62961    // Set limit ~ twice less than 5552, to keep
62962    // s2 in 31-bits, because we force signed ints.
62963    // in other case %= will fail.
62964    n = len > 2000 ? 2000 : len;
62965    len -= n;
62966
62967    do {
62968      s1 = s1 + buf[pos++] | 0;
62969      s2 = s2 + s1 | 0;
62970    } while (--n);
62971
62972    s1 %= 65521;
62973    s2 %= 65521;
62974  }
62975
62976  return s1 | s2 << 16 | 0;
62977}
62978
62979module.exports = adler32;
62980
62981},{}],445:[function(require,module,exports){
62982'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
62983// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
62984//
62985// This software is provided 'as-is', without any express or implied
62986// warranty. In no event will the authors be held liable for any damages
62987// arising from the use of this software.
62988//
62989// Permission is granted to anyone to use this software for any purpose,
62990// including commercial applications, and to alter it and redistribute it
62991// freely, subject to the following restrictions:
62992//
62993// 1. The origin of this software must not be misrepresented; you must not
62994//   claim that you wrote the original software. If you use this software
62995//   in a product, an acknowledgment in the product documentation would be
62996//   appreciated but is not required.
62997// 2. Altered source versions must be plainly marked as such, and must not be
62998//   misrepresented as being the original software.
62999// 3. This notice may not be removed or altered from any source distribution.
63000
63001module.exports = {
63002  /* Allowed flush values; see deflate() and inflate() below for details */
63003  Z_NO_FLUSH: 0,
63004  Z_PARTIAL_FLUSH: 1,
63005  Z_SYNC_FLUSH: 2,
63006  Z_FULL_FLUSH: 3,
63007  Z_FINISH: 4,
63008  Z_BLOCK: 5,
63009  Z_TREES: 6,
63010
63011  /* Return codes for the compression/decompression functions. Negative values
63012  * are errors, positive values are used for special but normal events.
63013  */
63014  Z_OK: 0,
63015  Z_STREAM_END: 1,
63016  Z_NEED_DICT: 2,
63017  Z_ERRNO: -1,
63018  Z_STREAM_ERROR: -2,
63019  Z_DATA_ERROR: -3,
63020  //Z_MEM_ERROR:     -4,
63021  Z_BUF_ERROR: -5,
63022  //Z_VERSION_ERROR: -6,
63023
63024  /* compression levels */
63025  Z_NO_COMPRESSION: 0,
63026  Z_BEST_SPEED: 1,
63027  Z_BEST_COMPRESSION: 9,
63028  Z_DEFAULT_COMPRESSION: -1,
63029  Z_FILTERED: 1,
63030  Z_HUFFMAN_ONLY: 2,
63031  Z_RLE: 3,
63032  Z_FIXED: 4,
63033  Z_DEFAULT_STRATEGY: 0,
63034
63035  /* Possible values of the data_type field (though see inflate()) */
63036  Z_BINARY: 0,
63037  Z_TEXT: 1,
63038  //Z_ASCII:                1, // = Z_TEXT (deprecated)
63039  Z_UNKNOWN: 2,
63040
63041  /* The deflate compression method */
63042  Z_DEFLATED: 8 //Z_NULL:                 null // Use -1 or null inline, depending on var type
63043
63044};
63045
63046},{}],446:[function(require,module,exports){
63047'use strict'; // Note: we can't get significant speed boost here.
63048// So write code to minimize size - no pregenerated tables
63049// and array tools dependencies.
63050// (C) 1995-2013 Jean-loup Gailly and Mark Adler
63051// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
63052//
63053// This software is provided 'as-is', without any express or implied
63054// warranty. In no event will the authors be held liable for any damages
63055// arising from the use of this software.
63056//
63057// Permission is granted to anyone to use this software for any purpose,
63058// including commercial applications, and to alter it and redistribute it
63059// freely, subject to the following restrictions:
63060//
63061// 1. The origin of this software must not be misrepresented; you must not
63062//   claim that you wrote the original software. If you use this software
63063//   in a product, an acknowledgment in the product documentation would be
63064//   appreciated but is not required.
63065// 2. Altered source versions must be plainly marked as such, and must not be
63066//   misrepresented as being the original software.
63067// 3. This notice may not be removed or altered from any source distribution.
63068// Use ordinary array, since untyped makes no boost here
63069
63070function makeTable() {
63071  var c,
63072      table = [];
63073
63074  for (var n = 0; n < 256; n++) {
63075    c = n;
63076
63077    for (var k = 0; k < 8; k++) {
63078      c = c & 1 ? 0xEDB88320 ^ c >>> 1 : c >>> 1;
63079    }
63080
63081    table[n] = c;
63082  }
63083
63084  return table;
63085} // Create table on load. Just 255 signed longs. Not a problem.
63086
63087
63088var crcTable = makeTable();
63089
63090function crc32(crc, buf, len, pos) {
63091  var t = crcTable,
63092      end = pos + len;
63093  crc ^= -1;
63094
63095  for (var i = pos; i < end; i++) {
63096    crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 0xFF];
63097  }
63098
63099  return crc ^ -1; // >>> 0;
63100}
63101
63102module.exports = crc32;
63103
63104},{}],447:[function(require,module,exports){
63105'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
63106// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
63107//
63108// This software is provided 'as-is', without any express or implied
63109// warranty. In no event will the authors be held liable for any damages
63110// arising from the use of this software.
63111//
63112// Permission is granted to anyone to use this software for any purpose,
63113// including commercial applications, and to alter it and redistribute it
63114// freely, subject to the following restrictions:
63115//
63116// 1. The origin of this software must not be misrepresented; you must not
63117//   claim that you wrote the original software. If you use this software
63118//   in a product, an acknowledgment in the product documentation would be
63119//   appreciated but is not required.
63120// 2. Altered source versions must be plainly marked as such, and must not be
63121//   misrepresented as being the original software.
63122// 3. This notice may not be removed or altered from any source distribution.
63123
63124var utils = require('../utils/common');
63125
63126var trees = require('./trees');
63127
63128var adler32 = require('./adler32');
63129
63130var crc32 = require('./crc32');
63131
63132var msg = require('./messages');
63133/* Public constants ==========================================================*/
63134
63135/* ===========================================================================*/
63136
63137/* Allowed flush values; see deflate() and inflate() below for details */
63138
63139
63140var Z_NO_FLUSH = 0;
63141var Z_PARTIAL_FLUSH = 1; //var Z_SYNC_FLUSH    = 2;
63142
63143var Z_FULL_FLUSH = 3;
63144var Z_FINISH = 4;
63145var Z_BLOCK = 5; //var Z_TREES         = 6;
63146
63147/* Return codes for the compression/decompression functions. Negative values
63148 * are errors, positive values are used for special but normal events.
63149 */
63150
63151var Z_OK = 0;
63152var Z_STREAM_END = 1; //var Z_NEED_DICT     = 2;
63153//var Z_ERRNO         = -1;
63154
63155var Z_STREAM_ERROR = -2;
63156var Z_DATA_ERROR = -3; //var Z_MEM_ERROR     = -4;
63157
63158var Z_BUF_ERROR = -5; //var Z_VERSION_ERROR = -6;
63159
63160/* compression levels */
63161//var Z_NO_COMPRESSION      = 0;
63162//var Z_BEST_SPEED          = 1;
63163//var Z_BEST_COMPRESSION    = 9;
63164
63165var Z_DEFAULT_COMPRESSION = -1;
63166var Z_FILTERED = 1;
63167var Z_HUFFMAN_ONLY = 2;
63168var Z_RLE = 3;
63169var Z_FIXED = 4;
63170var Z_DEFAULT_STRATEGY = 0;
63171/* Possible values of the data_type field (though see inflate()) */
63172//var Z_BINARY              = 0;
63173//var Z_TEXT                = 1;
63174//var Z_ASCII               = 1; // = Z_TEXT
63175
63176var Z_UNKNOWN = 2;
63177/* The deflate compression method */
63178
63179var Z_DEFLATED = 8;
63180/*============================================================================*/
63181
63182var MAX_MEM_LEVEL = 9;
63183/* Maximum value for memLevel in deflateInit2 */
63184
63185var MAX_WBITS = 15;
63186/* 32K LZ77 window */
63187
63188var DEF_MEM_LEVEL = 8;
63189var LENGTH_CODES = 29;
63190/* number of length codes, not counting the special END_BLOCK code */
63191
63192var LITERALS = 256;
63193/* number of literal bytes 0..255 */
63194
63195var L_CODES = LITERALS + 1 + LENGTH_CODES;
63196/* number of Literal or Length codes, including the END_BLOCK code */
63197
63198var D_CODES = 30;
63199/* number of distance codes */
63200
63201var BL_CODES = 19;
63202/* number of codes used to transfer the bit lengths */
63203
63204var HEAP_SIZE = 2 * L_CODES + 1;
63205/* maximum heap size */
63206
63207var MAX_BITS = 15;
63208/* All codes must not exceed MAX_BITS bits */
63209
63210var MIN_MATCH = 3;
63211var MAX_MATCH = 258;
63212var MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;
63213var PRESET_DICT = 0x20;
63214var INIT_STATE = 42;
63215var EXTRA_STATE = 69;
63216var NAME_STATE = 73;
63217var COMMENT_STATE = 91;
63218var HCRC_STATE = 103;
63219var BUSY_STATE = 113;
63220var FINISH_STATE = 666;
63221var BS_NEED_MORE = 1;
63222/* block not completed, need more input or more output */
63223
63224var BS_BLOCK_DONE = 2;
63225/* block flush performed */
63226
63227var BS_FINISH_STARTED = 3;
63228/* finish started, need only more output at next deflate */
63229
63230var BS_FINISH_DONE = 4;
63231/* finish done, accept no more input or output */
63232
63233var OS_CODE = 0x03; // Unix :) . Don't detect, use this default.
63234
63235function err(strm, errorCode) {
63236  strm.msg = msg[errorCode];
63237  return errorCode;
63238}
63239
63240function rank(f) {
63241  return (f << 1) - (f > 4 ? 9 : 0);
63242}
63243
63244function zero(buf) {
63245  var len = buf.length;
63246
63247  while (--len >= 0) {
63248    buf[len] = 0;
63249  }
63250}
63251/* =========================================================================
63252 * Flush as much pending output as possible. All deflate() output goes
63253 * through this function so some applications may wish to modify it
63254 * to avoid allocating a large strm->output buffer and copying into it.
63255 * (See also read_buf()).
63256 */
63257
63258
63259function flush_pending(strm) {
63260  var s = strm.state; //_tr_flush_bits(s);
63261
63262  var len = s.pending;
63263
63264  if (len > strm.avail_out) {
63265    len = strm.avail_out;
63266  }
63267
63268  if (len === 0) {
63269    return;
63270  }
63271
63272  utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);
63273  strm.next_out += len;
63274  s.pending_out += len;
63275  strm.total_out += len;
63276  strm.avail_out -= len;
63277  s.pending -= len;
63278
63279  if (s.pending === 0) {
63280    s.pending_out = 0;
63281  }
63282}
63283
63284function flush_block_only(s, last) {
63285  trees._tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);
63286
63287  s.block_start = s.strstart;
63288  flush_pending(s.strm);
63289}
63290
63291function put_byte(s, b) {
63292  s.pending_buf[s.pending++] = b;
63293}
63294/* =========================================================================
63295 * Put a short in the pending buffer. The 16-bit value is put in MSB order.
63296 * IN assertion: the stream state is correct and there is enough room in
63297 * pending_buf.
63298 */
63299
63300
63301function putShortMSB(s, b) {
63302  //  put_byte(s, (Byte)(b >> 8));
63303  //  put_byte(s, (Byte)(b & 0xff));
63304  s.pending_buf[s.pending++] = b >>> 8 & 0xff;
63305  s.pending_buf[s.pending++] = b & 0xff;
63306}
63307/* ===========================================================================
63308 * Read a new buffer from the current input stream, update the adler32
63309 * and total number of bytes read.  All deflate() input goes through
63310 * this function so some applications may wish to modify it to avoid
63311 * allocating a large strm->input buffer and copying from it.
63312 * (See also flush_pending()).
63313 */
63314
63315
63316function read_buf(strm, buf, start, size) {
63317  var len = strm.avail_in;
63318
63319  if (len > size) {
63320    len = size;
63321  }
63322
63323  if (len === 0) {
63324    return 0;
63325  }
63326
63327  strm.avail_in -= len; // zmemcpy(buf, strm->next_in, len);
63328
63329  utils.arraySet(buf, strm.input, strm.next_in, len, start);
63330
63331  if (strm.state.wrap === 1) {
63332    strm.adler = adler32(strm.adler, buf, len, start);
63333  } else if (strm.state.wrap === 2) {
63334    strm.adler = crc32(strm.adler, buf, len, start);
63335  }
63336
63337  strm.next_in += len;
63338  strm.total_in += len;
63339  return len;
63340}
63341/* ===========================================================================
63342 * Set match_start to the longest match starting at the given string and
63343 * return its length. Matches shorter or equal to prev_length are discarded,
63344 * in which case the result is equal to prev_length and match_start is
63345 * garbage.
63346 * IN assertions: cur_match is the head of the hash chain for the current
63347 *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
63348 * OUT assertion: the match length is not greater than s->lookahead.
63349 */
63350
63351
63352function longest_match(s, cur_match) {
63353  var chain_length = s.max_chain_length;
63354  /* max hash chain length */
63355
63356  var scan = s.strstart;
63357  /* current string */
63358
63359  var match;
63360  /* matched string */
63361
63362  var len;
63363  /* length of current match */
63364
63365  var best_len = s.prev_length;
63366  /* best match length so far */
63367
63368  var nice_match = s.nice_match;
63369  /* stop if match long enough */
63370
63371  var limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0
63372  /*NIL*/
63373  ;
63374  var _win = s.window; // shortcut
63375
63376  var wmask = s.w_mask;
63377  var prev = s.prev;
63378  /* Stop when cur_match becomes <= limit. To simplify the code,
63379   * we prevent matches with the string of window index 0.
63380   */
63381
63382  var strend = s.strstart + MAX_MATCH;
63383  var scan_end1 = _win[scan + best_len - 1];
63384  var scan_end = _win[scan + best_len];
63385  /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
63386   * It is easy to get rid of this optimization if necessary.
63387   */
63388  // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
63389
63390  /* Do not waste too much time if we already have a good match: */
63391
63392  if (s.prev_length >= s.good_match) {
63393    chain_length >>= 2;
63394  }
63395  /* Do not look for matches beyond the end of the input. This is necessary
63396   * to make deflate deterministic.
63397   */
63398
63399
63400  if (nice_match > s.lookahead) {
63401    nice_match = s.lookahead;
63402  } // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
63403
63404
63405  do {
63406    // Assert(cur_match < s->strstart, "no future");
63407    match = cur_match;
63408    /* Skip to next match if the match length cannot increase
63409     * or if the match length is less than 2.  Note that the checks below
63410     * for insufficient lookahead only occur occasionally for performance
63411     * reasons.  Therefore uninitialized memory will be accessed, and
63412     * conditional jumps will be made that depend on those values.
63413     * However the length of the match is limited to the lookahead, so
63414     * the output of deflate is not affected by the uninitialized values.
63415     */
63416
63417    if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {
63418      continue;
63419    }
63420    /* The check at best_len-1 can be removed because it will be made
63421     * again later. (This heuristic is not always a win.)
63422     * It is not necessary to compare scan[2] and match[2] since they
63423     * are always equal when the other bytes match, given that
63424     * the hash keys are equal and that HASH_BITS >= 8.
63425     */
63426
63427
63428    scan += 2;
63429    match++; // Assert(*scan == *match, "match[2]?");
63430
63431    /* We check for insufficient lookahead only every 8th comparison;
63432     * the 256th check will be made at strstart+258.
63433     */
63434
63435    do {
63436      /*jshint noempty:false*/
63437    } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend); // Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
63438
63439
63440    len = MAX_MATCH - (strend - scan);
63441    scan = strend - MAX_MATCH;
63442
63443    if (len > best_len) {
63444      s.match_start = cur_match;
63445      best_len = len;
63446
63447      if (len >= nice_match) {
63448        break;
63449      }
63450
63451      scan_end1 = _win[scan + best_len - 1];
63452      scan_end = _win[scan + best_len];
63453    }
63454  } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);
63455
63456  if (best_len <= s.lookahead) {
63457    return best_len;
63458  }
63459
63460  return s.lookahead;
63461}
63462/* ===========================================================================
63463 * Fill the window when the lookahead becomes insufficient.
63464 * Updates strstart and lookahead.
63465 *
63466 * IN assertion: lookahead < MIN_LOOKAHEAD
63467 * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
63468 *    At least one byte has been read, or avail_in == 0; reads are
63469 *    performed for at least two bytes (required for the zip translate_eol
63470 *    option -- not supported here).
63471 */
63472
63473
63474function fill_window(s) {
63475  var _w_size = s.w_size;
63476  var p, n, m, more, str; //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
63477
63478  do {
63479    more = s.window_size - s.lookahead - s.strstart; // JS ints have 32 bit, block below not needed
63480
63481    /* Deal with !@#$% 64K limit: */
63482    //if (sizeof(int) <= 2) {
63483    //    if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
63484    //        more = wsize;
63485    //
63486    //  } else if (more == (unsigned)(-1)) {
63487    //        /* Very unlikely, but possible on 16 bit machine if
63488    //         * strstart == 0 && lookahead == 1 (input done a byte at time)
63489    //         */
63490    //        more--;
63491    //    }
63492    //}
63493
63494    /* If the window is almost full and there is insufficient lookahead,
63495     * move the upper half to the lower one to make room in the upper half.
63496     */
63497
63498    if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
63499      utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
63500      s.match_start -= _w_size;
63501      s.strstart -= _w_size;
63502      /* we now have strstart >= MAX_DIST */
63503
63504      s.block_start -= _w_size;
63505      /* Slide the hash table (could be avoided with 32 bit values
63506       at the expense of memory usage). We slide even when level == 0
63507       to keep the hash table consistent if we switch back to level > 0
63508       later. (Using level 0 permanently is not an optimal usage of
63509       zlib, so we don't care about this pathological case.)
63510       */
63511
63512      n = s.hash_size;
63513      p = n;
63514
63515      do {
63516        m = s.head[--p];
63517        s.head[p] = m >= _w_size ? m - _w_size : 0;
63518      } while (--n);
63519
63520      n = _w_size;
63521      p = n;
63522
63523      do {
63524        m = s.prev[--p];
63525        s.prev[p] = m >= _w_size ? m - _w_size : 0;
63526        /* If n is not on any hash chain, prev[n] is garbage but
63527         * its value will never be used.
63528         */
63529      } while (--n);
63530
63531      more += _w_size;
63532    }
63533
63534    if (s.strm.avail_in === 0) {
63535      break;
63536    }
63537    /* If there was no sliding:
63538     *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
63539     *    more == window_size - lookahead - strstart
63540     * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
63541     * => more >= window_size - 2*WSIZE + 2
63542     * In the BIG_MEM or MMAP case (not yet supported),
63543     *   window_size == input_size + MIN_LOOKAHEAD  &&
63544     *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
63545     * Otherwise, window_size == 2*WSIZE so more >= 2.
63546     * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
63547     */
63548    //Assert(more >= 2, "more < 2");
63549
63550
63551    n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
63552    s.lookahead += n;
63553    /* Initialize the hash value now that we have some input: */
63554
63555    if (s.lookahead + s.insert >= MIN_MATCH) {
63556      str = s.strstart - s.insert;
63557      s.ins_h = s.window[str];
63558      /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */
63559
63560      s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + 1]) & s.hash_mask; //#if MIN_MATCH != 3
63561      //        Call update_hash() MIN_MATCH-3 more times
63562      //#endif
63563
63564      while (s.insert) {
63565        /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
63566        s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
63567        s.prev[str & s.w_mask] = s.head[s.ins_h];
63568        s.head[s.ins_h] = str;
63569        str++;
63570        s.insert--;
63571
63572        if (s.lookahead + s.insert < MIN_MATCH) {
63573          break;
63574        }
63575      }
63576    }
63577    /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
63578     * but this is not important since only literal bytes will be emitted.
63579     */
63580
63581  } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
63582  /* If the WIN_INIT bytes after the end of the current data have never been
63583   * written, then zero those bytes in order to avoid memory check reports of
63584   * the use of uninitialized (or uninitialised as Julian writes) bytes by
63585   * the longest match routines.  Update the high water mark for the next
63586   * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
63587   * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
63588   */
63589  //  if (s.high_water < s.window_size) {
63590  //    var curr = s.strstart + s.lookahead;
63591  //    var init = 0;
63592  //
63593  //    if (s.high_water < curr) {
63594  //      /* Previous high water mark below current data -- zero WIN_INIT
63595  //       * bytes or up to end of window, whichever is less.
63596  //       */
63597  //      init = s.window_size - curr;
63598  //      if (init > WIN_INIT)
63599  //        init = WIN_INIT;
63600  //      zmemzero(s->window + curr, (unsigned)init);
63601  //      s->high_water = curr + init;
63602  //    }
63603  //    else if (s->high_water < (ulg)curr + WIN_INIT) {
63604  //      /* High water mark at or above current data, but below current data
63605  //       * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
63606  //       * to end of window, whichever is less.
63607  //       */
63608  //      init = (ulg)curr + WIN_INIT - s->high_water;
63609  //      if (init > s->window_size - s->high_water)
63610  //        init = s->window_size - s->high_water;
63611  //      zmemzero(s->window + s->high_water, (unsigned)init);
63612  //      s->high_water += init;
63613  //    }
63614  //  }
63615  //
63616  //  Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
63617  //    "not enough room for search");
63618
63619}
63620/* ===========================================================================
63621 * Copy without compression as much as possible from the input stream, return
63622 * the current block state.
63623 * This function does not insert new strings in the dictionary since
63624 * uncompressible data is probably not useful. This function is used
63625 * only for the level=0 compression option.
63626 * NOTE: this function should be optimized to avoid extra copying from
63627 * window to pending_buf.
63628 */
63629
63630
63631function deflate_stored(s, flush) {
63632  /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
63633   * to pending_buf_size, and each stored block has a 5 byte header:
63634   */
63635  var max_block_size = 0xffff;
63636
63637  if (max_block_size > s.pending_buf_size - 5) {
63638    max_block_size = s.pending_buf_size - 5;
63639  }
63640  /* Copy as much as possible from input to output: */
63641
63642
63643  for (;;) {
63644    /* Fill the window as much as possible: */
63645    if (s.lookahead <= 1) {
63646      //Assert(s->strstart < s->w_size+MAX_DIST(s) ||
63647      //  s->block_start >= (long)s->w_size, "slide too late");
63648      //      if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||
63649      //        s.block_start >= s.w_size)) {
63650      //        throw  new Error("slide too late");
63651      //      }
63652      fill_window(s);
63653
63654      if (s.lookahead === 0 && flush === Z_NO_FLUSH) {
63655        return BS_NEED_MORE;
63656      }
63657
63658      if (s.lookahead === 0) {
63659        break;
63660      }
63661      /* flush the current block */
63662
63663    } //Assert(s->block_start >= 0L, "block gone");
63664    //    if (s.block_start < 0) throw new Error("block gone");
63665
63666
63667    s.strstart += s.lookahead;
63668    s.lookahead = 0;
63669    /* Emit a stored block if pending_buf will be full: */
63670
63671    var max_start = s.block_start + max_block_size;
63672
63673    if (s.strstart === 0 || s.strstart >= max_start) {
63674      /* strstart == 0 is possible when wraparound on 16-bit machine */
63675      s.lookahead = s.strstart - max_start;
63676      s.strstart = max_start;
63677      /*** FLUSH_BLOCK(s, 0); ***/
63678
63679      flush_block_only(s, false);
63680
63681      if (s.strm.avail_out === 0) {
63682        return BS_NEED_MORE;
63683      }
63684      /***/
63685
63686    }
63687    /* Flush if we may have to slide, otherwise block_start may become
63688     * negative and the data will be gone:
63689     */
63690
63691
63692    if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) {
63693      /*** FLUSH_BLOCK(s, 0); ***/
63694      flush_block_only(s, false);
63695
63696      if (s.strm.avail_out === 0) {
63697        return BS_NEED_MORE;
63698      }
63699      /***/
63700
63701    }
63702  }
63703
63704  s.insert = 0;
63705
63706  if (flush === Z_FINISH) {
63707    /*** FLUSH_BLOCK(s, 1); ***/
63708    flush_block_only(s, true);
63709
63710    if (s.strm.avail_out === 0) {
63711      return BS_FINISH_STARTED;
63712    }
63713    /***/
63714
63715
63716    return BS_FINISH_DONE;
63717  }
63718
63719  if (s.strstart > s.block_start) {
63720    /*** FLUSH_BLOCK(s, 0); ***/
63721    flush_block_only(s, false);
63722
63723    if (s.strm.avail_out === 0) {
63724      return BS_NEED_MORE;
63725    }
63726    /***/
63727
63728  }
63729
63730  return BS_NEED_MORE;
63731}
63732/* ===========================================================================
63733 * Compress as much as possible from the input stream, return the current
63734 * block state.
63735 * This function does not perform lazy evaluation of matches and inserts
63736 * new strings in the dictionary only for unmatched strings or for short
63737 * matches. It is used only for the fast compression options.
63738 */
63739
63740
63741function deflate_fast(s, flush) {
63742  var hash_head;
63743  /* head of the hash chain */
63744
63745  var bflush;
63746  /* set if current block must be flushed */
63747
63748  for (;;) {
63749    /* Make sure that we always have enough lookahead, except
63750     * at the end of the input file. We need MAX_MATCH bytes
63751     * for the next match, plus MIN_MATCH bytes to insert the
63752     * string following the next match.
63753     */
63754    if (s.lookahead < MIN_LOOKAHEAD) {
63755      fill_window(s);
63756
63757      if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
63758        return BS_NEED_MORE;
63759      }
63760
63761      if (s.lookahead === 0) {
63762        break;
63763        /* flush the current block */
63764      }
63765    }
63766    /* Insert the string window[strstart .. strstart+2] in the
63767     * dictionary, and set hash_head to the head of the hash chain:
63768     */
63769
63770
63771    hash_head = 0
63772    /*NIL*/
63773    ;
63774
63775    if (s.lookahead >= MIN_MATCH) {
63776      /*** INSERT_STRING(s, s.strstart, hash_head); ***/
63777      s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
63778      hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
63779      s.head[s.ins_h] = s.strstart;
63780      /***/
63781    }
63782    /* Find the longest match, discarding those <= prev_length.
63783     * At this point we have always match_length < MIN_MATCH
63784     */
63785
63786
63787    if (hash_head !== 0
63788    /*NIL*/
63789    && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {
63790      /* To simplify the code, we prevent matches with the string
63791       * of window index 0 (in particular we have to avoid a match
63792       * of the string with itself at the start of the input file).
63793       */
63794      s.match_length = longest_match(s, hash_head);
63795      /* longest_match() sets match_start */
63796    }
63797
63798    if (s.match_length >= MIN_MATCH) {
63799      // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only
63800
63801      /*** _tr_tally_dist(s, s.strstart - s.match_start,
63802                     s.match_length - MIN_MATCH, bflush); ***/
63803      bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);
63804      s.lookahead -= s.match_length;
63805      /* Insert new strings in the hash table only if the match length
63806       * is not too large. This saves time but degrades compression.
63807       */
63808
63809      if (s.match_length <= s.max_lazy_match
63810      /*max_insert_length*/
63811      && s.lookahead >= MIN_MATCH) {
63812        s.match_length--;
63813        /* string at strstart already in table */
63814
63815        do {
63816          s.strstart++;
63817          /*** INSERT_STRING(s, s.strstart, hash_head); ***/
63818
63819          s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
63820          hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
63821          s.head[s.ins_h] = s.strstart;
63822          /***/
63823
63824          /* strstart never exceeds WSIZE-MAX_MATCH, so there are
63825           * always MIN_MATCH bytes ahead.
63826           */
63827        } while (--s.match_length !== 0);
63828
63829        s.strstart++;
63830      } else {
63831        s.strstart += s.match_length;
63832        s.match_length = 0;
63833        s.ins_h = s.window[s.strstart];
63834        /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
63835
63836        s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + 1]) & s.hash_mask; //#if MIN_MATCH != 3
63837        //                Call UPDATE_HASH() MIN_MATCH-3 more times
63838        //#endif
63839
63840        /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
63841         * matter since it will be recomputed at next deflate call.
63842         */
63843      }
63844    } else {
63845      /* No match, output a literal byte */
63846      //Tracevv((stderr,"%c", s.window[s.strstart]));
63847
63848      /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
63849      bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
63850      s.lookahead--;
63851      s.strstart++;
63852    }
63853
63854    if (bflush) {
63855      /*** FLUSH_BLOCK(s, 0); ***/
63856      flush_block_only(s, false);
63857
63858      if (s.strm.avail_out === 0) {
63859        return BS_NEED_MORE;
63860      }
63861      /***/
63862
63863    }
63864  }
63865
63866  s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
63867
63868  if (flush === Z_FINISH) {
63869    /*** FLUSH_BLOCK(s, 1); ***/
63870    flush_block_only(s, true);
63871
63872    if (s.strm.avail_out === 0) {
63873      return BS_FINISH_STARTED;
63874    }
63875    /***/
63876
63877
63878    return BS_FINISH_DONE;
63879  }
63880
63881  if (s.last_lit) {
63882    /*** FLUSH_BLOCK(s, 0); ***/
63883    flush_block_only(s, false);
63884
63885    if (s.strm.avail_out === 0) {
63886      return BS_NEED_MORE;
63887    }
63888    /***/
63889
63890  }
63891
63892  return BS_BLOCK_DONE;
63893}
63894/* ===========================================================================
63895 * Same as above, but achieves better compression. We use a lazy
63896 * evaluation for matches: a match is finally adopted only if there is
63897 * no better match at the next window position.
63898 */
63899
63900
63901function deflate_slow(s, flush) {
63902  var hash_head;
63903  /* head of hash chain */
63904
63905  var bflush;
63906  /* set if current block must be flushed */
63907
63908  var max_insert;
63909  /* Process the input block. */
63910
63911  for (;;) {
63912    /* Make sure that we always have enough lookahead, except
63913     * at the end of the input file. We need MAX_MATCH bytes
63914     * for the next match, plus MIN_MATCH bytes to insert the
63915     * string following the next match.
63916     */
63917    if (s.lookahead < MIN_LOOKAHEAD) {
63918      fill_window(s);
63919
63920      if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
63921        return BS_NEED_MORE;
63922      }
63923
63924      if (s.lookahead === 0) {
63925        break;
63926      }
63927      /* flush the current block */
63928
63929    }
63930    /* Insert the string window[strstart .. strstart+2] in the
63931     * dictionary, and set hash_head to the head of the hash chain:
63932     */
63933
63934
63935    hash_head = 0
63936    /*NIL*/
63937    ;
63938
63939    if (s.lookahead >= MIN_MATCH) {
63940      /*** INSERT_STRING(s, s.strstart, hash_head); ***/
63941      s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
63942      hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
63943      s.head[s.ins_h] = s.strstart;
63944      /***/
63945    }
63946    /* Find the longest match, discarding those <= prev_length.
63947     */
63948
63949
63950    s.prev_length = s.match_length;
63951    s.prev_match = s.match_start;
63952    s.match_length = MIN_MATCH - 1;
63953
63954    if (hash_head !== 0
63955    /*NIL*/
63956    && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD
63957    /*MAX_DIST(s)*/
63958    ) {
63959        /* To simplify the code, we prevent matches with the string
63960         * of window index 0 (in particular we have to avoid a match
63961         * of the string with itself at the start of the input file).
63962         */
63963        s.match_length = longest_match(s, hash_head);
63964        /* longest_match() sets match_start */
63965
63966        if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096
63967        /*TOO_FAR*/
63968        )) {
63969          /* If prev_match is also MIN_MATCH, match_start is garbage
63970           * but we will ignore the current match anyway.
63971           */
63972          s.match_length = MIN_MATCH - 1;
63973        }
63974      }
63975    /* If there was a match at the previous step and the current
63976     * match is not better, output the previous match:
63977     */
63978
63979
63980    if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {
63981      max_insert = s.strstart + s.lookahead - MIN_MATCH;
63982      /* Do not insert strings in hash table beyond this. */
63983      //check_match(s, s.strstart-1, s.prev_match, s.prev_length);
63984
63985      /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,
63986                     s.prev_length - MIN_MATCH, bflush);***/
63987
63988      bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);
63989      /* Insert in hash table all strings up to the end of the match.
63990       * strstart-1 and strstart are already inserted. If there is not
63991       * enough lookahead, the last two strings are not inserted in
63992       * the hash table.
63993       */
63994
63995      s.lookahead -= s.prev_length - 1;
63996      s.prev_length -= 2;
63997
63998      do {
63999        if (++s.strstart <= max_insert) {
64000          /*** INSERT_STRING(s, s.strstart, hash_head); ***/
64001          s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
64002          hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
64003          s.head[s.ins_h] = s.strstart;
64004          /***/
64005        }
64006      } while (--s.prev_length !== 0);
64007
64008      s.match_available = 0;
64009      s.match_length = MIN_MATCH - 1;
64010      s.strstart++;
64011
64012      if (bflush) {
64013        /*** FLUSH_BLOCK(s, 0); ***/
64014        flush_block_only(s, false);
64015
64016        if (s.strm.avail_out === 0) {
64017          return BS_NEED_MORE;
64018        }
64019        /***/
64020
64021      }
64022    } else if (s.match_available) {
64023      /* If there was no match at the previous position, output a
64024       * single literal. If there was a match but the current match
64025       * is longer, truncate the previous match to a single literal.
64026       */
64027      //Tracevv((stderr,"%c", s->window[s->strstart-1]));
64028
64029      /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
64030      bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
64031
64032      if (bflush) {
64033        /*** FLUSH_BLOCK_ONLY(s, 0) ***/
64034        flush_block_only(s, false);
64035        /***/
64036      }
64037
64038      s.strstart++;
64039      s.lookahead--;
64040
64041      if (s.strm.avail_out === 0) {
64042        return BS_NEED_MORE;
64043      }
64044    } else {
64045      /* There is no previous match to compare with, wait for
64046       * the next step to decide.
64047       */
64048      s.match_available = 1;
64049      s.strstart++;
64050      s.lookahead--;
64051    }
64052  } //Assert (flush != Z_NO_FLUSH, "no flush?");
64053
64054
64055  if (s.match_available) {
64056    //Tracevv((stderr,"%c", s->window[s->strstart-1]));
64057
64058    /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
64059    bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
64060    s.match_available = 0;
64061  }
64062
64063  s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
64064
64065  if (flush === Z_FINISH) {
64066    /*** FLUSH_BLOCK(s, 1); ***/
64067    flush_block_only(s, true);
64068
64069    if (s.strm.avail_out === 0) {
64070      return BS_FINISH_STARTED;
64071    }
64072    /***/
64073
64074
64075    return BS_FINISH_DONE;
64076  }
64077
64078  if (s.last_lit) {
64079    /*** FLUSH_BLOCK(s, 0); ***/
64080    flush_block_only(s, false);
64081
64082    if (s.strm.avail_out === 0) {
64083      return BS_NEED_MORE;
64084    }
64085    /***/
64086
64087  }
64088
64089  return BS_BLOCK_DONE;
64090}
64091/* ===========================================================================
64092 * For Z_RLE, simply look for runs of bytes, generate matches only of distance
64093 * one.  Do not maintain a hash table.  (It will be regenerated if this run of
64094 * deflate switches away from Z_RLE.)
64095 */
64096
64097
64098function deflate_rle(s, flush) {
64099  var bflush;
64100  /* set if current block must be flushed */
64101
64102  var prev;
64103  /* byte at distance one to match */
64104
64105  var scan, strend;
64106  /* scan goes up to strend for length of run */
64107
64108  var _win = s.window;
64109
64110  for (;;) {
64111    /* Make sure that we always have enough lookahead, except
64112     * at the end of the input file. We need MAX_MATCH bytes
64113     * for the longest run, plus one for the unrolled loop.
64114     */
64115    if (s.lookahead <= MAX_MATCH) {
64116      fill_window(s);
64117
64118      if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {
64119        return BS_NEED_MORE;
64120      }
64121
64122      if (s.lookahead === 0) {
64123        break;
64124      }
64125      /* flush the current block */
64126
64127    }
64128    /* See how many times the previous byte repeats */
64129
64130
64131    s.match_length = 0;
64132
64133    if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
64134      scan = s.strstart - 1;
64135      prev = _win[scan];
64136
64137      if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {
64138        strend = s.strstart + MAX_MATCH;
64139
64140        do {
64141          /*jshint noempty:false*/
64142        } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);
64143
64144        s.match_length = MAX_MATCH - (strend - scan);
64145
64146        if (s.match_length > s.lookahead) {
64147          s.match_length = s.lookahead;
64148        }
64149      } //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
64150
64151    }
64152    /* Emit match if have run of MIN_MATCH or longer, else emit literal */
64153
64154
64155    if (s.match_length >= MIN_MATCH) {
64156      //check_match(s, s.strstart, s.strstart - 1, s.match_length);
64157
64158      /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/
64159      bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
64160      s.lookahead -= s.match_length;
64161      s.strstart += s.match_length;
64162      s.match_length = 0;
64163    } else {
64164      /* No match, output a literal byte */
64165      //Tracevv((stderr,"%c", s->window[s->strstart]));
64166
64167      /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
64168      bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
64169      s.lookahead--;
64170      s.strstart++;
64171    }
64172
64173    if (bflush) {
64174      /*** FLUSH_BLOCK(s, 0); ***/
64175      flush_block_only(s, false);
64176
64177      if (s.strm.avail_out === 0) {
64178        return BS_NEED_MORE;
64179      }
64180      /***/
64181
64182    }
64183  }
64184
64185  s.insert = 0;
64186
64187  if (flush === Z_FINISH) {
64188    /*** FLUSH_BLOCK(s, 1); ***/
64189    flush_block_only(s, true);
64190
64191    if (s.strm.avail_out === 0) {
64192      return BS_FINISH_STARTED;
64193    }
64194    /***/
64195
64196
64197    return BS_FINISH_DONE;
64198  }
64199
64200  if (s.last_lit) {
64201    /*** FLUSH_BLOCK(s, 0); ***/
64202    flush_block_only(s, false);
64203
64204    if (s.strm.avail_out === 0) {
64205      return BS_NEED_MORE;
64206    }
64207    /***/
64208
64209  }
64210
64211  return BS_BLOCK_DONE;
64212}
64213/* ===========================================================================
64214 * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
64215 * (It will be regenerated if this run of deflate switches away from Huffman.)
64216 */
64217
64218
64219function deflate_huff(s, flush) {
64220  var bflush;
64221  /* set if current block must be flushed */
64222
64223  for (;;) {
64224    /* Make sure that we have a literal to write. */
64225    if (s.lookahead === 0) {
64226      fill_window(s);
64227
64228      if (s.lookahead === 0) {
64229        if (flush === Z_NO_FLUSH) {
64230          return BS_NEED_MORE;
64231        }
64232
64233        break;
64234        /* flush the current block */
64235      }
64236    }
64237    /* Output a literal byte */
64238
64239
64240    s.match_length = 0; //Tracevv((stderr,"%c", s->window[s->strstart]));
64241
64242    /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
64243
64244    bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
64245    s.lookahead--;
64246    s.strstart++;
64247
64248    if (bflush) {
64249      /*** FLUSH_BLOCK(s, 0); ***/
64250      flush_block_only(s, false);
64251
64252      if (s.strm.avail_out === 0) {
64253        return BS_NEED_MORE;
64254      }
64255      /***/
64256
64257    }
64258  }
64259
64260  s.insert = 0;
64261
64262  if (flush === Z_FINISH) {
64263    /*** FLUSH_BLOCK(s, 1); ***/
64264    flush_block_only(s, true);
64265
64266    if (s.strm.avail_out === 0) {
64267      return BS_FINISH_STARTED;
64268    }
64269    /***/
64270
64271
64272    return BS_FINISH_DONE;
64273  }
64274
64275  if (s.last_lit) {
64276    /*** FLUSH_BLOCK(s, 0); ***/
64277    flush_block_only(s, false);
64278
64279    if (s.strm.avail_out === 0) {
64280      return BS_NEED_MORE;
64281    }
64282    /***/
64283
64284  }
64285
64286  return BS_BLOCK_DONE;
64287}
64288/* Values for max_lazy_match, good_match and max_chain_length, depending on
64289 * the desired pack level (0..9). The values given below have been tuned to
64290 * exclude worst case performance for pathological files. Better values may be
64291 * found for specific files.
64292 */
64293
64294
64295function Config(good_length, max_lazy, nice_length, max_chain, func) {
64296  this.good_length = good_length;
64297  this.max_lazy = max_lazy;
64298  this.nice_length = nice_length;
64299  this.max_chain = max_chain;
64300  this.func = func;
64301}
64302
64303var configuration_table;
64304configuration_table = [
64305/*      good lazy nice chain */
64306new Config(0, 0, 0, 0, deflate_stored),
64307/* 0 store only */
64308new Config(4, 4, 8, 4, deflate_fast),
64309/* 1 max speed, no lazy matches */
64310new Config(4, 5, 16, 8, deflate_fast),
64311/* 2 */
64312new Config(4, 6, 32, 32, deflate_fast),
64313/* 3 */
64314new Config(4, 4, 16, 16, deflate_slow),
64315/* 4 lazy matches */
64316new Config(8, 16, 32, 32, deflate_slow),
64317/* 5 */
64318new Config(8, 16, 128, 128, deflate_slow),
64319/* 6 */
64320new Config(8, 32, 128, 256, deflate_slow),
64321/* 7 */
64322new Config(32, 128, 258, 1024, deflate_slow),
64323/* 8 */
64324new Config(32, 258, 258, 4096, deflate_slow)
64325/* 9 max compression */
64326];
64327/* ===========================================================================
64328 * Initialize the "longest match" routines for a new zlib stream
64329 */
64330
64331function lm_init(s) {
64332  s.window_size = 2 * s.w_size;
64333  /*** CLEAR_HASH(s); ***/
64334
64335  zero(s.head); // Fill with NIL (= 0);
64336
64337  /* Set the default configuration parameters:
64338   */
64339
64340  s.max_lazy_match = configuration_table[s.level].max_lazy;
64341  s.good_match = configuration_table[s.level].good_length;
64342  s.nice_match = configuration_table[s.level].nice_length;
64343  s.max_chain_length = configuration_table[s.level].max_chain;
64344  s.strstart = 0;
64345  s.block_start = 0;
64346  s.lookahead = 0;
64347  s.insert = 0;
64348  s.match_length = s.prev_length = MIN_MATCH - 1;
64349  s.match_available = 0;
64350  s.ins_h = 0;
64351}
64352
64353function DeflateState() {
64354  this.strm = null;
64355  /* pointer back to this zlib stream */
64356
64357  this.status = 0;
64358  /* as the name implies */
64359
64360  this.pending_buf = null;
64361  /* output still pending */
64362
64363  this.pending_buf_size = 0;
64364  /* size of pending_buf */
64365
64366  this.pending_out = 0;
64367  /* next pending byte to output to the stream */
64368
64369  this.pending = 0;
64370  /* nb of bytes in the pending buffer */
64371
64372  this.wrap = 0;
64373  /* bit 0 true for zlib, bit 1 true for gzip */
64374
64375  this.gzhead = null;
64376  /* gzip header information to write */
64377
64378  this.gzindex = 0;
64379  /* where in extra, name, or comment */
64380
64381  this.method = Z_DEFLATED;
64382  /* can only be DEFLATED */
64383
64384  this.last_flush = -1;
64385  /* value of flush param for previous deflate call */
64386
64387  this.w_size = 0;
64388  /* LZ77 window size (32K by default) */
64389
64390  this.w_bits = 0;
64391  /* log2(w_size)  (8..16) */
64392
64393  this.w_mask = 0;
64394  /* w_size - 1 */
64395
64396  this.window = null;
64397  /* Sliding window. Input bytes are read into the second half of the window,
64398   * and move to the first half later to keep a dictionary of at least wSize
64399   * bytes. With this organization, matches are limited to a distance of
64400   * wSize-MAX_MATCH bytes, but this ensures that IO is always
64401   * performed with a length multiple of the block size.
64402   */
64403
64404  this.window_size = 0;
64405  /* Actual size of window: 2*wSize, except when the user input buffer
64406   * is directly used as sliding window.
64407   */
64408
64409  this.prev = null;
64410  /* Link to older string with same hash index. To limit the size of this
64411   * array to 64K, this link is maintained only for the last 32K strings.
64412   * An index in this array is thus a window index modulo 32K.
64413   */
64414
64415  this.head = null;
64416  /* Heads of the hash chains or NIL. */
64417
64418  this.ins_h = 0;
64419  /* hash index of string to be inserted */
64420
64421  this.hash_size = 0;
64422  /* number of elements in hash table */
64423
64424  this.hash_bits = 0;
64425  /* log2(hash_size) */
64426
64427  this.hash_mask = 0;
64428  /* hash_size-1 */
64429
64430  this.hash_shift = 0;
64431  /* Number of bits by which ins_h must be shifted at each input
64432   * step. It must be such that after MIN_MATCH steps, the oldest
64433   * byte no longer takes part in the hash key, that is:
64434   *   hash_shift * MIN_MATCH >= hash_bits
64435   */
64436
64437  this.block_start = 0;
64438  /* Window position at the beginning of the current output block. Gets
64439   * negative when the window is moved backwards.
64440   */
64441
64442  this.match_length = 0;
64443  /* length of best match */
64444
64445  this.prev_match = 0;
64446  /* previous match */
64447
64448  this.match_available = 0;
64449  /* set if previous match exists */
64450
64451  this.strstart = 0;
64452  /* start of string to insert */
64453
64454  this.match_start = 0;
64455  /* start of matching string */
64456
64457  this.lookahead = 0;
64458  /* number of valid bytes ahead in window */
64459
64460  this.prev_length = 0;
64461  /* Length of the best match at previous step. Matches not greater than this
64462   * are discarded. This is used in the lazy match evaluation.
64463   */
64464
64465  this.max_chain_length = 0;
64466  /* To speed up deflation, hash chains are never searched beyond this
64467   * length.  A higher limit improves compression ratio but degrades the
64468   * speed.
64469   */
64470
64471  this.max_lazy_match = 0;
64472  /* Attempt to find a better match only when the current match is strictly
64473   * smaller than this value. This mechanism is used only for compression
64474   * levels >= 4.
64475   */
64476  // That's alias to max_lazy_match, don't use directly
64477  //this.max_insert_length = 0;
64478
64479  /* Insert new strings in the hash table only if the match length is not
64480   * greater than this length. This saves time but degrades compression.
64481   * max_insert_length is used only for compression levels <= 3.
64482   */
64483
64484  this.level = 0;
64485  /* compression level (1..9) */
64486
64487  this.strategy = 0;
64488  /* favor or force Huffman coding*/
64489
64490  this.good_match = 0;
64491  /* Use a faster search when the previous match is longer than this */
64492
64493  this.nice_match = 0;
64494  /* Stop searching when current match exceeds this */
64495
64496  /* used by trees.c: */
64497
64498  /* Didn't use ct_data typedef below to suppress compiler warning */
64499  // struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */
64500  // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
64501  // struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */
64502  // Use flat array of DOUBLE size, with interleaved fata,
64503  // because JS does not support effective
64504
64505  this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);
64506  this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);
64507  this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);
64508  zero(this.dyn_ltree);
64509  zero(this.dyn_dtree);
64510  zero(this.bl_tree);
64511  this.l_desc = null;
64512  /* desc. for literal tree */
64513
64514  this.d_desc = null;
64515  /* desc. for distance tree */
64516
64517  this.bl_desc = null;
64518  /* desc. for bit length tree */
64519  //ush bl_count[MAX_BITS+1];
64520
64521  this.bl_count = new utils.Buf16(MAX_BITS + 1);
64522  /* number of codes at each bit length for an optimal tree */
64523  //int heap[2*L_CODES+1];      /* heap used to build the Huffman trees */
64524
64525  this.heap = new utils.Buf16(2 * L_CODES + 1);
64526  /* heap used to build the Huffman trees */
64527
64528  zero(this.heap);
64529  this.heap_len = 0;
64530  /* number of elements in the heap */
64531
64532  this.heap_max = 0;
64533  /* element of largest frequency */
64534
64535  /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
64536   * The same heap array is used to build all trees.
64537   */
64538
64539  this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];
64540
64541  zero(this.depth);
64542  /* Depth of each subtree used as tie breaker for trees of equal frequency
64543   */
64544
64545  this.l_buf = 0;
64546  /* buffer index for literals or lengths */
64547
64548  this.lit_bufsize = 0;
64549  /* Size of match buffer for literals/lengths.  There are 4 reasons for
64550   * limiting lit_bufsize to 64K:
64551   *   - frequencies can be kept in 16 bit counters
64552   *   - if compression is not successful for the first block, all input
64553   *     data is still in the window so we can still emit a stored block even
64554   *     when input comes from standard input.  (This can also be done for
64555   *     all blocks if lit_bufsize is not greater than 32K.)
64556   *   - if compression is not successful for a file smaller than 64K, we can
64557   *     even emit a stored file instead of a stored block (saving 5 bytes).
64558   *     This is applicable only for zip (not gzip or zlib).
64559   *   - creating new Huffman trees less frequently may not provide fast
64560   *     adaptation to changes in the input data statistics. (Take for
64561   *     example a binary file with poorly compressible code followed by
64562   *     a highly compressible string table.) Smaller buffer sizes give
64563   *     fast adaptation but have of course the overhead of transmitting
64564   *     trees more frequently.
64565   *   - I can't count above 4
64566   */
64567
64568  this.last_lit = 0;
64569  /* running index in l_buf */
64570
64571  this.d_buf = 0;
64572  /* Buffer index for distances. To simplify the code, d_buf and l_buf have
64573   * the same number of elements. To use different lengths, an extra flag
64574   * array would be necessary.
64575   */
64576
64577  this.opt_len = 0;
64578  /* bit length of current block with optimal trees */
64579
64580  this.static_len = 0;
64581  /* bit length of current block with static trees */
64582
64583  this.matches = 0;
64584  /* number of string matches in current block */
64585
64586  this.insert = 0;
64587  /* bytes at end of window left to insert */
64588
64589  this.bi_buf = 0;
64590  /* Output buffer. bits are inserted starting at the bottom (least
64591   * significant bits).
64592   */
64593
64594  this.bi_valid = 0;
64595  /* Number of valid bits in bi_buf.  All bits above the last valid bit
64596   * are always zero.
64597   */
64598  // Used for window memory init. We safely ignore it for JS. That makes
64599  // sense only for pointers and memory check tools.
64600  //this.high_water = 0;
64601
64602  /* High water mark offset in window for initialized bytes -- bytes above
64603   * this are set to zero in order to avoid memory check warnings when
64604   * longest match routines access bytes past the input.  This is then
64605   * updated to the new high water mark.
64606   */
64607}
64608
64609function deflateResetKeep(strm) {
64610  var s;
64611
64612  if (!strm || !strm.state) {
64613    return err(strm, Z_STREAM_ERROR);
64614  }
64615
64616  strm.total_in = strm.total_out = 0;
64617  strm.data_type = Z_UNKNOWN;
64618  s = strm.state;
64619  s.pending = 0;
64620  s.pending_out = 0;
64621
64622  if (s.wrap < 0) {
64623    s.wrap = -s.wrap;
64624    /* was made negative by deflate(..., Z_FINISH); */
64625  }
64626
64627  s.status = s.wrap ? INIT_STATE : BUSY_STATE;
64628  strm.adler = s.wrap === 2 ? 0 // crc32(0, Z_NULL, 0)
64629  : 1; // adler32(0, Z_NULL, 0)
64630
64631  s.last_flush = Z_NO_FLUSH;
64632
64633  trees._tr_init(s);
64634
64635  return Z_OK;
64636}
64637
64638function deflateReset(strm) {
64639  var ret = deflateResetKeep(strm);
64640
64641  if (ret === Z_OK) {
64642    lm_init(strm.state);
64643  }
64644
64645  return ret;
64646}
64647
64648function deflateSetHeader(strm, head) {
64649  if (!strm || !strm.state) {
64650    return Z_STREAM_ERROR;
64651  }
64652
64653  if (strm.state.wrap !== 2) {
64654    return Z_STREAM_ERROR;
64655  }
64656
64657  strm.state.gzhead = head;
64658  return Z_OK;
64659}
64660
64661function deflateInit2(strm, level, method, windowBits, memLevel, strategy) {
64662  if (!strm) {
64663    // === Z_NULL
64664    return Z_STREAM_ERROR;
64665  }
64666
64667  var wrap = 1;
64668
64669  if (level === Z_DEFAULT_COMPRESSION) {
64670    level = 6;
64671  }
64672
64673  if (windowBits < 0) {
64674    /* suppress zlib wrapper */
64675    wrap = 0;
64676    windowBits = -windowBits;
64677  } else if (windowBits > 15) {
64678    wrap = 2;
64679    /* write gzip wrapper instead */
64680
64681    windowBits -= 16;
64682  }
64683
64684  if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
64685    return err(strm, Z_STREAM_ERROR);
64686  }
64687
64688  if (windowBits === 8) {
64689    windowBits = 9;
64690  }
64691  /* until 256-byte window bug fixed */
64692
64693
64694  var s = new DeflateState();
64695  strm.state = s;
64696  s.strm = strm;
64697  s.wrap = wrap;
64698  s.gzhead = null;
64699  s.w_bits = windowBits;
64700  s.w_size = 1 << s.w_bits;
64701  s.w_mask = s.w_size - 1;
64702  s.hash_bits = memLevel + 7;
64703  s.hash_size = 1 << s.hash_bits;
64704  s.hash_mask = s.hash_size - 1;
64705  s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
64706  s.window = new utils.Buf8(s.w_size * 2);
64707  s.head = new utils.Buf16(s.hash_size);
64708  s.prev = new utils.Buf16(s.w_size); // Don't need mem init magic for JS.
64709  //s.high_water = 0;  /* nothing written to s->window yet */
64710
64711  s.lit_bufsize = 1 << memLevel + 6;
64712  /* 16K elements by default */
64713
64714  s.pending_buf_size = s.lit_bufsize * 4; //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
64715  //s->pending_buf = (uchf *) overlay;
64716
64717  s.pending_buf = new utils.Buf8(s.pending_buf_size); // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)
64718  //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
64719
64720  s.d_buf = 1 * s.lit_bufsize; //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
64721
64722  s.l_buf = (1 + 2) * s.lit_bufsize;
64723  s.level = level;
64724  s.strategy = strategy;
64725  s.method = method;
64726  return deflateReset(strm);
64727}
64728
64729function deflateInit(strm, level) {
64730  return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
64731}
64732
64733function deflate(strm, flush) {
64734  var old_flush, s;
64735  var beg, val; // for gzip header write only
64736
64737  if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) {
64738    return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
64739  }
64740
64741  s = strm.state;
64742
64743  if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE && flush !== Z_FINISH) {
64744    return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR);
64745  }
64746
64747  s.strm = strm;
64748  /* just in case */
64749
64750  old_flush = s.last_flush;
64751  s.last_flush = flush;
64752  /* Write the header */
64753
64754  if (s.status === INIT_STATE) {
64755    if (s.wrap === 2) {
64756      // GZIP header
64757      strm.adler = 0; //crc32(0L, Z_NULL, 0);
64758
64759      put_byte(s, 31);
64760      put_byte(s, 139);
64761      put_byte(s, 8);
64762
64763      if (!s.gzhead) {
64764        // s->gzhead == Z_NULL
64765        put_byte(s, 0);
64766        put_byte(s, 0);
64767        put_byte(s, 0);
64768        put_byte(s, 0);
64769        put_byte(s, 0);
64770        put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);
64771        put_byte(s, OS_CODE);
64772        s.status = BUSY_STATE;
64773      } else {
64774        put_byte(s, (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16));
64775        put_byte(s, s.gzhead.time & 0xff);
64776        put_byte(s, s.gzhead.time >> 8 & 0xff);
64777        put_byte(s, s.gzhead.time >> 16 & 0xff);
64778        put_byte(s, s.gzhead.time >> 24 & 0xff);
64779        put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);
64780        put_byte(s, s.gzhead.os & 0xff);
64781
64782        if (s.gzhead.extra && s.gzhead.extra.length) {
64783          put_byte(s, s.gzhead.extra.length & 0xff);
64784          put_byte(s, s.gzhead.extra.length >> 8 & 0xff);
64785        }
64786
64787        if (s.gzhead.hcrc) {
64788          strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);
64789        }
64790
64791        s.gzindex = 0;
64792        s.status = EXTRA_STATE;
64793      }
64794    } else // DEFLATE header
64795      {
64796        var header = Z_DEFLATED + (s.w_bits - 8 << 4) << 8;
64797        var level_flags = -1;
64798
64799        if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
64800          level_flags = 0;
64801        } else if (s.level < 6) {
64802          level_flags = 1;
64803        } else if (s.level === 6) {
64804          level_flags = 2;
64805        } else {
64806          level_flags = 3;
64807        }
64808
64809        header |= level_flags << 6;
64810
64811        if (s.strstart !== 0) {
64812          header |= PRESET_DICT;
64813        }
64814
64815        header += 31 - header % 31;
64816        s.status = BUSY_STATE;
64817        putShortMSB(s, header);
64818        /* Save the adler32 of the preset dictionary: */
64819
64820        if (s.strstart !== 0) {
64821          putShortMSB(s, strm.adler >>> 16);
64822          putShortMSB(s, strm.adler & 0xffff);
64823        }
64824
64825        strm.adler = 1; // adler32(0L, Z_NULL, 0);
64826      }
64827  } //#ifdef GZIP
64828
64829
64830  if (s.status === EXTRA_STATE) {
64831    if (s.gzhead.extra
64832    /* != Z_NULL*/
64833    ) {
64834        beg = s.pending;
64835        /* start of bytes to update crc */
64836
64837        while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {
64838          if (s.pending === s.pending_buf_size) {
64839            if (s.gzhead.hcrc && s.pending > beg) {
64840              strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
64841            }
64842
64843            flush_pending(strm);
64844            beg = s.pending;
64845
64846            if (s.pending === s.pending_buf_size) {
64847              break;
64848            }
64849          }
64850
64851          put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);
64852          s.gzindex++;
64853        }
64854
64855        if (s.gzhead.hcrc && s.pending > beg) {
64856          strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
64857        }
64858
64859        if (s.gzindex === s.gzhead.extra.length) {
64860          s.gzindex = 0;
64861          s.status = NAME_STATE;
64862        }
64863      } else {
64864      s.status = NAME_STATE;
64865    }
64866  }
64867
64868  if (s.status === NAME_STATE) {
64869    if (s.gzhead.name
64870    /* != Z_NULL*/
64871    ) {
64872        beg = s.pending;
64873        /* start of bytes to update crc */
64874        //int val;
64875
64876        do {
64877          if (s.pending === s.pending_buf_size) {
64878            if (s.gzhead.hcrc && s.pending > beg) {
64879              strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
64880            }
64881
64882            flush_pending(strm);
64883            beg = s.pending;
64884
64885            if (s.pending === s.pending_buf_size) {
64886              val = 1;
64887              break;
64888            }
64889          } // JS specific: little magic to add zero terminator to end of string
64890
64891
64892          if (s.gzindex < s.gzhead.name.length) {
64893            val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;
64894          } else {
64895            val = 0;
64896          }
64897
64898          put_byte(s, val);
64899        } while (val !== 0);
64900
64901        if (s.gzhead.hcrc && s.pending > beg) {
64902          strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
64903        }
64904
64905        if (val === 0) {
64906          s.gzindex = 0;
64907          s.status = COMMENT_STATE;
64908        }
64909      } else {
64910      s.status = COMMENT_STATE;
64911    }
64912  }
64913
64914  if (s.status === COMMENT_STATE) {
64915    if (s.gzhead.comment
64916    /* != Z_NULL*/
64917    ) {
64918        beg = s.pending;
64919        /* start of bytes to update crc */
64920        //int val;
64921
64922        do {
64923          if (s.pending === s.pending_buf_size) {
64924            if (s.gzhead.hcrc && s.pending > beg) {
64925              strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
64926            }
64927
64928            flush_pending(strm);
64929            beg = s.pending;
64930
64931            if (s.pending === s.pending_buf_size) {
64932              val = 1;
64933              break;
64934            }
64935          } // JS specific: little magic to add zero terminator to end of string
64936
64937
64938          if (s.gzindex < s.gzhead.comment.length) {
64939            val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;
64940          } else {
64941            val = 0;
64942          }
64943
64944          put_byte(s, val);
64945        } while (val !== 0);
64946
64947        if (s.gzhead.hcrc && s.pending > beg) {
64948          strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
64949        }
64950
64951        if (val === 0) {
64952          s.status = HCRC_STATE;
64953        }
64954      } else {
64955      s.status = HCRC_STATE;
64956    }
64957  }
64958
64959  if (s.status === HCRC_STATE) {
64960    if (s.gzhead.hcrc) {
64961      if (s.pending + 2 > s.pending_buf_size) {
64962        flush_pending(strm);
64963      }
64964
64965      if (s.pending + 2 <= s.pending_buf_size) {
64966        put_byte(s, strm.adler & 0xff);
64967        put_byte(s, strm.adler >> 8 & 0xff);
64968        strm.adler = 0; //crc32(0L, Z_NULL, 0);
64969
64970        s.status = BUSY_STATE;
64971      }
64972    } else {
64973      s.status = BUSY_STATE;
64974    }
64975  } //#endif
64976
64977  /* Flush as much pending output as possible */
64978
64979
64980  if (s.pending !== 0) {
64981    flush_pending(strm);
64982
64983    if (strm.avail_out === 0) {
64984      /* Since avail_out is 0, deflate will be called again with
64985       * more output space, but possibly with both pending and
64986       * avail_in equal to zero. There won't be anything to do,
64987       * but this is not an error situation so make sure we
64988       * return OK instead of BUF_ERROR at next call of deflate:
64989       */
64990      s.last_flush = -1;
64991      return Z_OK;
64992    }
64993    /* Make sure there is something to do and avoid duplicate consecutive
64994     * flushes. For repeated and useless calls with Z_FINISH, we keep
64995     * returning Z_STREAM_END instead of Z_BUF_ERROR.
64996     */
64997
64998  } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) {
64999    return err(strm, Z_BUF_ERROR);
65000  }
65001  /* User must not provide more input after the first FINISH: */
65002
65003
65004  if (s.status === FINISH_STATE && strm.avail_in !== 0) {
65005    return err(strm, Z_BUF_ERROR);
65006  }
65007  /* Start a new block or continue the current one.
65008   */
65009
65010
65011  if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH && s.status !== FINISH_STATE) {
65012    var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);
65013
65014    if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
65015      s.status = FINISH_STATE;
65016    }
65017
65018    if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {
65019      if (strm.avail_out === 0) {
65020        s.last_flush = -1;
65021        /* avoid BUF_ERROR next call, see above */
65022      }
65023
65024      return Z_OK;
65025      /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
65026       * of deflate should use the same flush parameter to make sure
65027       * that the flush is complete. So we don't have to output an
65028       * empty block here, this will be done at next call. This also
65029       * ensures that for a very small output buffer, we emit at most
65030       * one empty block.
65031       */
65032    }
65033
65034    if (bstate === BS_BLOCK_DONE) {
65035      if (flush === Z_PARTIAL_FLUSH) {
65036        trees._tr_align(s);
65037      } else if (flush !== Z_BLOCK) {
65038        /* FULL_FLUSH or SYNC_FLUSH */
65039        trees._tr_stored_block(s, 0, 0, false);
65040        /* For a full flush, this empty block will be recognized
65041         * as a special marker by inflate_sync().
65042         */
65043
65044
65045        if (flush === Z_FULL_FLUSH) {
65046          /*** CLEAR_HASH(s); ***/
65047
65048          /* forget history */
65049          zero(s.head); // Fill with NIL (= 0);
65050
65051          if (s.lookahead === 0) {
65052            s.strstart = 0;
65053            s.block_start = 0;
65054            s.insert = 0;
65055          }
65056        }
65057      }
65058
65059      flush_pending(strm);
65060
65061      if (strm.avail_out === 0) {
65062        s.last_flush = -1;
65063        /* avoid BUF_ERROR at next call, see above */
65064
65065        return Z_OK;
65066      }
65067    }
65068  } //Assert(strm->avail_out > 0, "bug2");
65069  //if (strm.avail_out <= 0) { throw new Error("bug2");}
65070
65071
65072  if (flush !== Z_FINISH) {
65073    return Z_OK;
65074  }
65075
65076  if (s.wrap <= 0) {
65077    return Z_STREAM_END;
65078  }
65079  /* Write the trailer */
65080
65081
65082  if (s.wrap === 2) {
65083    put_byte(s, strm.adler & 0xff);
65084    put_byte(s, strm.adler >> 8 & 0xff);
65085    put_byte(s, strm.adler >> 16 & 0xff);
65086    put_byte(s, strm.adler >> 24 & 0xff);
65087    put_byte(s, strm.total_in & 0xff);
65088    put_byte(s, strm.total_in >> 8 & 0xff);
65089    put_byte(s, strm.total_in >> 16 & 0xff);
65090    put_byte(s, strm.total_in >> 24 & 0xff);
65091  } else {
65092    putShortMSB(s, strm.adler >>> 16);
65093    putShortMSB(s, strm.adler & 0xffff);
65094  }
65095
65096  flush_pending(strm);
65097  /* If avail_out is zero, the application will call deflate again
65098   * to flush the rest.
65099   */
65100
65101  if (s.wrap > 0) {
65102    s.wrap = -s.wrap;
65103  }
65104  /* write the trailer only once! */
65105
65106
65107  return s.pending !== 0 ? Z_OK : Z_STREAM_END;
65108}
65109
65110function deflateEnd(strm) {
65111  var status;
65112
65113  if (!strm
65114  /*== Z_NULL*/
65115  || !strm.state
65116  /*== Z_NULL*/
65117  ) {
65118      return Z_STREAM_ERROR;
65119    }
65120
65121  status = strm.state.status;
65122
65123  if (status !== INIT_STATE && status !== EXTRA_STATE && status !== NAME_STATE && status !== COMMENT_STATE && status !== HCRC_STATE && status !== BUSY_STATE && status !== FINISH_STATE) {
65124    return err(strm, Z_STREAM_ERROR);
65125  }
65126
65127  strm.state = null;
65128  return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;
65129}
65130/* =========================================================================
65131 * Initializes the compression dictionary from the given byte
65132 * sequence without producing any compressed output.
65133 */
65134
65135
65136function deflateSetDictionary(strm, dictionary) {
65137  var dictLength = dictionary.length;
65138  var s;
65139  var str, n;
65140  var wrap;
65141  var avail;
65142  var next;
65143  var input;
65144  var tmpDict;
65145
65146  if (!strm
65147  /*== Z_NULL*/
65148  || !strm.state
65149  /*== Z_NULL*/
65150  ) {
65151      return Z_STREAM_ERROR;
65152    }
65153
65154  s = strm.state;
65155  wrap = s.wrap;
65156
65157  if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {
65158    return Z_STREAM_ERROR;
65159  }
65160  /* when using zlib wrappers, compute Adler-32 for provided dictionary */
65161
65162
65163  if (wrap === 1) {
65164    /* adler32(strm->adler, dictionary, dictLength); */
65165    strm.adler = adler32(strm.adler, dictionary, dictLength, 0);
65166  }
65167
65168  s.wrap = 0;
65169  /* avoid computing Adler-32 in read_buf */
65170
65171  /* if dictionary would fill window, just replace the history */
65172
65173  if (dictLength >= s.w_size) {
65174    if (wrap === 0) {
65175      /* already empty otherwise */
65176
65177      /*** CLEAR_HASH(s); ***/
65178      zero(s.head); // Fill with NIL (= 0);
65179
65180      s.strstart = 0;
65181      s.block_start = 0;
65182      s.insert = 0;
65183    }
65184    /* use the tail */
65185    // dictionary = dictionary.slice(dictLength - s.w_size);
65186
65187
65188    tmpDict = new utils.Buf8(s.w_size);
65189    utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);
65190    dictionary = tmpDict;
65191    dictLength = s.w_size;
65192  }
65193  /* insert dictionary into window and hash */
65194
65195
65196  avail = strm.avail_in;
65197  next = strm.next_in;
65198  input = strm.input;
65199  strm.avail_in = dictLength;
65200  strm.next_in = 0;
65201  strm.input = dictionary;
65202  fill_window(s);
65203
65204  while (s.lookahead >= MIN_MATCH) {
65205    str = s.strstart;
65206    n = s.lookahead - (MIN_MATCH - 1);
65207
65208    do {
65209      /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
65210      s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
65211      s.prev[str & s.w_mask] = s.head[s.ins_h];
65212      s.head[s.ins_h] = str;
65213      str++;
65214    } while (--n);
65215
65216    s.strstart = str;
65217    s.lookahead = MIN_MATCH - 1;
65218    fill_window(s);
65219  }
65220
65221  s.strstart += s.lookahead;
65222  s.block_start = s.strstart;
65223  s.insert = s.lookahead;
65224  s.lookahead = 0;
65225  s.match_length = s.prev_length = MIN_MATCH - 1;
65226  s.match_available = 0;
65227  strm.next_in = next;
65228  strm.input = input;
65229  strm.avail_in = avail;
65230  s.wrap = wrap;
65231  return Z_OK;
65232}
65233
65234exports.deflateInit = deflateInit;
65235exports.deflateInit2 = deflateInit2;
65236exports.deflateReset = deflateReset;
65237exports.deflateResetKeep = deflateResetKeep;
65238exports.deflateSetHeader = deflateSetHeader;
65239exports.deflate = deflate;
65240exports.deflateEnd = deflateEnd;
65241exports.deflateSetDictionary = deflateSetDictionary;
65242exports.deflateInfo = 'pako deflate (from Nodeca project)';
65243/* Not implemented
65244exports.deflateBound = deflateBound;
65245exports.deflateCopy = deflateCopy;
65246exports.deflateParams = deflateParams;
65247exports.deflatePending = deflatePending;
65248exports.deflatePrime = deflatePrime;
65249exports.deflateTune = deflateTune;
65250*/
65251
65252},{"../utils/common":442,"./adler32":444,"./crc32":446,"./messages":452,"./trees":453}],448:[function(require,module,exports){
65253'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
65254// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
65255//
65256// This software is provided 'as-is', without any express or implied
65257// warranty. In no event will the authors be held liable for any damages
65258// arising from the use of this software.
65259//
65260// Permission is granted to anyone to use this software for any purpose,
65261// including commercial applications, and to alter it and redistribute it
65262// freely, subject to the following restrictions:
65263//
65264// 1. The origin of this software must not be misrepresented; you must not
65265//   claim that you wrote the original software. If you use this software
65266//   in a product, an acknowledgment in the product documentation would be
65267//   appreciated but is not required.
65268// 2. Altered source versions must be plainly marked as such, and must not be
65269//   misrepresented as being the original software.
65270// 3. This notice may not be removed or altered from any source distribution.
65271
65272function GZheader() {
65273  /* true if compressed data believed to be text */
65274  this.text = 0;
65275  /* modification time */
65276
65277  this.time = 0;
65278  /* extra flags (not used when writing a gzip file) */
65279
65280  this.xflags = 0;
65281  /* operating system */
65282
65283  this.os = 0;
65284  /* pointer to extra field or Z_NULL if none */
65285
65286  this.extra = null;
65287  /* extra field length (valid if extra != Z_NULL) */
65288
65289  this.extra_len = 0; // Actually, we don't need it in JS,
65290  // but leave for few code modifications
65291  //
65292  // Setup limits is not necessary because in js we should not preallocate memory
65293  // for inflate use constant limit in 65536 bytes
65294  //
65295
65296  /* space at extra (only when reading header) */
65297  // this.extra_max  = 0;
65298
65299  /* pointer to zero-terminated file name or Z_NULL */
65300
65301  this.name = '';
65302  /* space at name (only when reading header) */
65303  // this.name_max   = 0;
65304
65305  /* pointer to zero-terminated comment or Z_NULL */
65306
65307  this.comment = '';
65308  /* space at comment (only when reading header) */
65309  // this.comm_max   = 0;
65310
65311  /* true if there was or will be a header crc */
65312
65313  this.hcrc = 0;
65314  /* true when done reading gzip header (not used when writing a gzip file) */
65315
65316  this.done = false;
65317}
65318
65319module.exports = GZheader;
65320
65321},{}],449:[function(require,module,exports){
65322'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
65323// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
65324//
65325// This software is provided 'as-is', without any express or implied
65326// warranty. In no event will the authors be held liable for any damages
65327// arising from the use of this software.
65328//
65329// Permission is granted to anyone to use this software for any purpose,
65330// including commercial applications, and to alter it and redistribute it
65331// freely, subject to the following restrictions:
65332//
65333// 1. The origin of this software must not be misrepresented; you must not
65334//   claim that you wrote the original software. If you use this software
65335//   in a product, an acknowledgment in the product documentation would be
65336//   appreciated but is not required.
65337// 2. Altered source versions must be plainly marked as such, and must not be
65338//   misrepresented as being the original software.
65339// 3. This notice may not be removed or altered from any source distribution.
65340// See state defs from inflate.js
65341
65342var BAD = 30;
65343/* got a data error -- remain here until reset */
65344
65345var TYPE = 12;
65346/* i: waiting for type bits, including last-flag bit */
65347
65348/*
65349   Decode literal, length, and distance codes and write out the resulting
65350   literal and match bytes until either not enough input or output is
65351   available, an end-of-block is encountered, or a data error is encountered.
65352   When large enough input and output buffers are supplied to inflate(), for
65353   example, a 16K input buffer and a 64K output buffer, more than 95% of the
65354   inflate execution time is spent in this routine.
65355
65356   Entry assumptions:
65357
65358        state.mode === LEN
65359        strm.avail_in >= 6
65360        strm.avail_out >= 258
65361        start >= strm.avail_out
65362        state.bits < 8
65363
65364   On return, state.mode is one of:
65365
65366        LEN -- ran out of enough output space or enough available input
65367        TYPE -- reached end of block code, inflate() to interpret next block
65368        BAD -- error in block data
65369
65370   Notes:
65371
65372    - The maximum input bits used by a length/distance pair is 15 bits for the
65373      length code, 5 bits for the length extra, 15 bits for the distance code,
65374      and 13 bits for the distance extra.  This totals 48 bits, or six bytes.
65375      Therefore if strm.avail_in >= 6, then there is enough input to avoid
65376      checking for available input while decoding.
65377
65378    - The maximum bytes that a single length/distance pair can output is 258
65379      bytes, which is the maximum length that can be coded.  inflate_fast()
65380      requires strm.avail_out >= 258 for each loop to avoid checking for
65381      output space.
65382 */
65383
65384module.exports = function inflate_fast(strm, start) {
65385  var state;
65386
65387  var _in;
65388  /* local strm.input */
65389
65390
65391  var last;
65392  /* have enough input while in < last */
65393
65394  var _out;
65395  /* local strm.output */
65396
65397
65398  var beg;
65399  /* inflate()'s initial strm.output */
65400
65401  var end;
65402  /* while out < end, enough space available */
65403  //#ifdef INFLATE_STRICT
65404
65405  var dmax;
65406  /* maximum distance from zlib header */
65407  //#endif
65408
65409  var wsize;
65410  /* window size or zero if not using window */
65411
65412  var whave;
65413  /* valid bytes in the window */
65414
65415  var wnext;
65416  /* window write index */
65417  // Use `s_window` instead `window`, avoid conflict with instrumentation tools
65418
65419  var s_window;
65420  /* allocated sliding window, if wsize != 0 */
65421
65422  var hold;
65423  /* local strm.hold */
65424
65425  var bits;
65426  /* local strm.bits */
65427
65428  var lcode;
65429  /* local strm.lencode */
65430
65431  var dcode;
65432  /* local strm.distcode */
65433
65434  var lmask;
65435  /* mask for first level of length codes */
65436
65437  var dmask;
65438  /* mask for first level of distance codes */
65439
65440  var here;
65441  /* retrieved table entry */
65442
65443  var op;
65444  /* code bits, operation, extra bits, or */
65445
65446  /*  window position, window bytes to copy */
65447
65448  var len;
65449  /* match length, unused bytes */
65450
65451  var dist;
65452  /* match distance */
65453
65454  var from;
65455  /* where to copy match from */
65456
65457  var from_source;
65458  var input, output; // JS specific, because we have no pointers
65459
65460  /* copy state to local variables */
65461
65462  state = strm.state; //here = state.here;
65463
65464  _in = strm.next_in;
65465  input = strm.input;
65466  last = _in + (strm.avail_in - 5);
65467  _out = strm.next_out;
65468  output = strm.output;
65469  beg = _out - (start - strm.avail_out);
65470  end = _out + (strm.avail_out - 257); //#ifdef INFLATE_STRICT
65471
65472  dmax = state.dmax; //#endif
65473
65474  wsize = state.wsize;
65475  whave = state.whave;
65476  wnext = state.wnext;
65477  s_window = state.window;
65478  hold = state.hold;
65479  bits = state.bits;
65480  lcode = state.lencode;
65481  dcode = state.distcode;
65482  lmask = (1 << state.lenbits) - 1;
65483  dmask = (1 << state.distbits) - 1;
65484  /* decode literals and length/distances until end-of-block or not enough
65485     input data or output space */
65486
65487  top: do {
65488    if (bits < 15) {
65489      hold += input[_in++] << bits;
65490      bits += 8;
65491      hold += input[_in++] << bits;
65492      bits += 8;
65493    }
65494
65495    here = lcode[hold & lmask];
65496
65497    dolen: for (;;) {
65498      // Goto emulation
65499      op = here >>> 24
65500      /*here.bits*/
65501      ;
65502      hold >>>= op;
65503      bits -= op;
65504      op = here >>> 16 & 0xff
65505      /*here.op*/
65506      ;
65507
65508      if (op === 0) {
65509        /* literal */
65510        //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
65511        //        "inflate:         literal '%c'\n" :
65512        //        "inflate:         literal 0x%02x\n", here.val));
65513        output[_out++] = here & 0xffff
65514        /*here.val*/
65515        ;
65516      } else if (op & 16) {
65517        /* length base */
65518        len = here & 0xffff
65519        /*here.val*/
65520        ;
65521        op &= 15;
65522        /* number of extra bits */
65523
65524        if (op) {
65525          if (bits < op) {
65526            hold += input[_in++] << bits;
65527            bits += 8;
65528          }
65529
65530          len += hold & (1 << op) - 1;
65531          hold >>>= op;
65532          bits -= op;
65533        } //Tracevv((stderr, "inflate:         length %u\n", len));
65534
65535
65536        if (bits < 15) {
65537          hold += input[_in++] << bits;
65538          bits += 8;
65539          hold += input[_in++] << bits;
65540          bits += 8;
65541        }
65542
65543        here = dcode[hold & dmask];
65544
65545        dodist: for (;;) {
65546          // goto emulation
65547          op = here >>> 24
65548          /*here.bits*/
65549          ;
65550          hold >>>= op;
65551          bits -= op;
65552          op = here >>> 16 & 0xff
65553          /*here.op*/
65554          ;
65555
65556          if (op & 16) {
65557            /* distance base */
65558            dist = here & 0xffff
65559            /*here.val*/
65560            ;
65561            op &= 15;
65562            /* number of extra bits */
65563
65564            if (bits < op) {
65565              hold += input[_in++] << bits;
65566              bits += 8;
65567
65568              if (bits < op) {
65569                hold += input[_in++] << bits;
65570                bits += 8;
65571              }
65572            }
65573
65574            dist += hold & (1 << op) - 1; //#ifdef INFLATE_STRICT
65575
65576            if (dist > dmax) {
65577              strm.msg = 'invalid distance too far back';
65578              state.mode = BAD;
65579              break top;
65580            } //#endif
65581
65582
65583            hold >>>= op;
65584            bits -= op; //Tracevv((stderr, "inflate:         distance %u\n", dist));
65585
65586            op = _out - beg;
65587            /* max distance in output */
65588
65589            if (dist > op) {
65590              /* see if copy from window */
65591              op = dist - op;
65592              /* distance back in window */
65593
65594              if (op > whave) {
65595                if (state.sane) {
65596                  strm.msg = 'invalid distance too far back';
65597                  state.mode = BAD;
65598                  break top;
65599                } // (!) This block is disabled in zlib defaults,
65600                // don't enable it for binary compatibility
65601                //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
65602                //                if (len <= op - whave) {
65603                //                  do {
65604                //                    output[_out++] = 0;
65605                //                  } while (--len);
65606                //                  continue top;
65607                //                }
65608                //                len -= op - whave;
65609                //                do {
65610                //                  output[_out++] = 0;
65611                //                } while (--op > whave);
65612                //                if (op === 0) {
65613                //                  from = _out - dist;
65614                //                  do {
65615                //                    output[_out++] = output[from++];
65616                //                  } while (--len);
65617                //                  continue top;
65618                //                }
65619                //#endif
65620
65621              }
65622
65623              from = 0; // window index
65624
65625              from_source = s_window;
65626
65627              if (wnext === 0) {
65628                /* very common case */
65629                from += wsize - op;
65630
65631                if (op < len) {
65632                  /* some from window */
65633                  len -= op;
65634
65635                  do {
65636                    output[_out++] = s_window[from++];
65637                  } while (--op);
65638
65639                  from = _out - dist;
65640                  /* rest from output */
65641
65642                  from_source = output;
65643                }
65644              } else if (wnext < op) {
65645                /* wrap around window */
65646                from += wsize + wnext - op;
65647                op -= wnext;
65648
65649                if (op < len) {
65650                  /* some from end of window */
65651                  len -= op;
65652
65653                  do {
65654                    output[_out++] = s_window[from++];
65655                  } while (--op);
65656
65657                  from = 0;
65658
65659                  if (wnext < len) {
65660                    /* some from start of window */
65661                    op = wnext;
65662                    len -= op;
65663
65664                    do {
65665                      output[_out++] = s_window[from++];
65666                    } while (--op);
65667
65668                    from = _out - dist;
65669                    /* rest from output */
65670
65671                    from_source = output;
65672                  }
65673                }
65674              } else {
65675                /* contiguous in window */
65676                from += wnext - op;
65677
65678                if (op < len) {
65679                  /* some from window */
65680                  len -= op;
65681
65682                  do {
65683                    output[_out++] = s_window[from++];
65684                  } while (--op);
65685
65686                  from = _out - dist;
65687                  /* rest from output */
65688
65689                  from_source = output;
65690                }
65691              }
65692
65693              while (len > 2) {
65694                output[_out++] = from_source[from++];
65695                output[_out++] = from_source[from++];
65696                output[_out++] = from_source[from++];
65697                len -= 3;
65698              }
65699
65700              if (len) {
65701                output[_out++] = from_source[from++];
65702
65703                if (len > 1) {
65704                  output[_out++] = from_source[from++];
65705                }
65706              }
65707            } else {
65708              from = _out - dist;
65709              /* copy direct from output */
65710
65711              do {
65712                /* minimum length is three */
65713                output[_out++] = output[from++];
65714                output[_out++] = output[from++];
65715                output[_out++] = output[from++];
65716                len -= 3;
65717              } while (len > 2);
65718
65719              if (len) {
65720                output[_out++] = output[from++];
65721
65722                if (len > 1) {
65723                  output[_out++] = output[from++];
65724                }
65725              }
65726            }
65727          } else if ((op & 64) === 0) {
65728            /* 2nd level distance code */
65729            here = dcode[(here & 0xffff) + (
65730            /*here.val*/
65731            hold & (1 << op) - 1)];
65732            continue dodist;
65733          } else {
65734            strm.msg = 'invalid distance code';
65735            state.mode = BAD;
65736            break top;
65737          }
65738
65739          break; // need to emulate goto via "continue"
65740        }
65741      } else if ((op & 64) === 0) {
65742        /* 2nd level length code */
65743        here = lcode[(here & 0xffff) + (
65744        /*here.val*/
65745        hold & (1 << op) - 1)];
65746        continue dolen;
65747      } else if (op & 32) {
65748        /* end-of-block */
65749        //Tracevv((stderr, "inflate:         end of block\n"));
65750        state.mode = TYPE;
65751        break top;
65752      } else {
65753        strm.msg = 'invalid literal/length code';
65754        state.mode = BAD;
65755        break top;
65756      }
65757
65758      break; // need to emulate goto via "continue"
65759    }
65760  } while (_in < last && _out < end);
65761  /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
65762
65763
65764  len = bits >> 3;
65765  _in -= len;
65766  bits -= len << 3;
65767  hold &= (1 << bits) - 1;
65768  /* update state and return */
65769
65770  strm.next_in = _in;
65771  strm.next_out = _out;
65772  strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
65773  strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
65774  state.hold = hold;
65775  state.bits = bits;
65776  return;
65777};
65778
65779},{}],450:[function(require,module,exports){
65780'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
65781// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
65782//
65783// This software is provided 'as-is', without any express or implied
65784// warranty. In no event will the authors be held liable for any damages
65785// arising from the use of this software.
65786//
65787// Permission is granted to anyone to use this software for any purpose,
65788// including commercial applications, and to alter it and redistribute it
65789// freely, subject to the following restrictions:
65790//
65791// 1. The origin of this software must not be misrepresented; you must not
65792//   claim that you wrote the original software. If you use this software
65793//   in a product, an acknowledgment in the product documentation would be
65794//   appreciated but is not required.
65795// 2. Altered source versions must be plainly marked as such, and must not be
65796//   misrepresented as being the original software.
65797// 3. This notice may not be removed or altered from any source distribution.
65798
65799var utils = require('../utils/common');
65800
65801var adler32 = require('./adler32');
65802
65803var crc32 = require('./crc32');
65804
65805var inflate_fast = require('./inffast');
65806
65807var inflate_table = require('./inftrees');
65808
65809var CODES = 0;
65810var LENS = 1;
65811var DISTS = 2;
65812/* Public constants ==========================================================*/
65813
65814/* ===========================================================================*/
65815
65816/* Allowed flush values; see deflate() and inflate() below for details */
65817//var Z_NO_FLUSH      = 0;
65818//var Z_PARTIAL_FLUSH = 1;
65819//var Z_SYNC_FLUSH    = 2;
65820//var Z_FULL_FLUSH    = 3;
65821
65822var Z_FINISH = 4;
65823var Z_BLOCK = 5;
65824var Z_TREES = 6;
65825/* Return codes for the compression/decompression functions. Negative values
65826 * are errors, positive values are used for special but normal events.
65827 */
65828
65829var Z_OK = 0;
65830var Z_STREAM_END = 1;
65831var Z_NEED_DICT = 2; //var Z_ERRNO         = -1;
65832
65833var Z_STREAM_ERROR = -2;
65834var Z_DATA_ERROR = -3;
65835var Z_MEM_ERROR = -4;
65836var Z_BUF_ERROR = -5; //var Z_VERSION_ERROR = -6;
65837
65838/* The deflate compression method */
65839
65840var Z_DEFLATED = 8;
65841/* STATES ====================================================================*/
65842
65843/* ===========================================================================*/
65844
65845var HEAD = 1;
65846/* i: waiting for magic header */
65847
65848var FLAGS = 2;
65849/* i: waiting for method and flags (gzip) */
65850
65851var TIME = 3;
65852/* i: waiting for modification time (gzip) */
65853
65854var OS = 4;
65855/* i: waiting for extra flags and operating system (gzip) */
65856
65857var EXLEN = 5;
65858/* i: waiting for extra length (gzip) */
65859
65860var EXTRA = 6;
65861/* i: waiting for extra bytes (gzip) */
65862
65863var NAME = 7;
65864/* i: waiting for end of file name (gzip) */
65865
65866var COMMENT = 8;
65867/* i: waiting for end of comment (gzip) */
65868
65869var HCRC = 9;
65870/* i: waiting for header crc (gzip) */
65871
65872var DICTID = 10;
65873/* i: waiting for dictionary check value */
65874
65875var DICT = 11;
65876/* waiting for inflateSetDictionary() call */
65877
65878var TYPE = 12;
65879/* i: waiting for type bits, including last-flag bit */
65880
65881var TYPEDO = 13;
65882/* i: same, but skip check to exit inflate on new block */
65883
65884var STORED = 14;
65885/* i: waiting for stored size (length and complement) */
65886
65887var COPY_ = 15;
65888/* i/o: same as COPY below, but only first time in */
65889
65890var COPY = 16;
65891/* i/o: waiting for input or output to copy stored block */
65892
65893var TABLE = 17;
65894/* i: waiting for dynamic block table lengths */
65895
65896var LENLENS = 18;
65897/* i: waiting for code length code lengths */
65898
65899var CODELENS = 19;
65900/* i: waiting for length/lit and distance code lengths */
65901
65902var LEN_ = 20;
65903/* i: same as LEN below, but only first time in */
65904
65905var LEN = 21;
65906/* i: waiting for length/lit/eob code */
65907
65908var LENEXT = 22;
65909/* i: waiting for length extra bits */
65910
65911var DIST = 23;
65912/* i: waiting for distance code */
65913
65914var DISTEXT = 24;
65915/* i: waiting for distance extra bits */
65916
65917var MATCH = 25;
65918/* o: waiting for output space to copy string */
65919
65920var LIT = 26;
65921/* o: waiting for output space to write literal */
65922
65923var CHECK = 27;
65924/* i: waiting for 32-bit check value */
65925
65926var LENGTH = 28;
65927/* i: waiting for 32-bit length (gzip) */
65928
65929var DONE = 29;
65930/* finished check, done -- remain here until reset */
65931
65932var BAD = 30;
65933/* got a data error -- remain here until reset */
65934
65935var MEM = 31;
65936/* got an inflate() memory error -- remain here until reset */
65937
65938var SYNC = 32;
65939/* looking for synchronization bytes to restart inflate() */
65940
65941/* ===========================================================================*/
65942
65943var ENOUGH_LENS = 852;
65944var ENOUGH_DISTS = 592; //var ENOUGH =  (ENOUGH_LENS+ENOUGH_DISTS);
65945
65946var MAX_WBITS = 15;
65947/* 32K LZ77 window */
65948
65949var DEF_WBITS = MAX_WBITS;
65950
65951function zswap32(q) {
65952  return (q >>> 24 & 0xff) + (q >>> 8 & 0xff00) + ((q & 0xff00) << 8) + ((q & 0xff) << 24);
65953}
65954
65955function InflateState() {
65956  this.mode = 0;
65957  /* current inflate mode */
65958
65959  this.last = false;
65960  /* true if processing last block */
65961
65962  this.wrap = 0;
65963  /* bit 0 true for zlib, bit 1 true for gzip */
65964
65965  this.havedict = false;
65966  /* true if dictionary provided */
65967
65968  this.flags = 0;
65969  /* gzip header method and flags (0 if zlib) */
65970
65971  this.dmax = 0;
65972  /* zlib header max distance (INFLATE_STRICT) */
65973
65974  this.check = 0;
65975  /* protected copy of check value */
65976
65977  this.total = 0;
65978  /* protected copy of output count */
65979  // TODO: may be {}
65980
65981  this.head = null;
65982  /* where to save gzip header information */
65983
65984  /* sliding window */
65985
65986  this.wbits = 0;
65987  /* log base 2 of requested window size */
65988
65989  this.wsize = 0;
65990  /* window size or zero if not using window */
65991
65992  this.whave = 0;
65993  /* valid bytes in the window */
65994
65995  this.wnext = 0;
65996  /* window write index */
65997
65998  this.window = null;
65999  /* allocated sliding window, if needed */
66000
66001  /* bit accumulator */
66002
66003  this.hold = 0;
66004  /* input bit accumulator */
66005
66006  this.bits = 0;
66007  /* number of bits in "in" */
66008
66009  /* for string and stored block copying */
66010
66011  this.length = 0;
66012  /* literal or length of data to copy */
66013
66014  this.offset = 0;
66015  /* distance back to copy string from */
66016
66017  /* for table and code decoding */
66018
66019  this.extra = 0;
66020  /* extra bits needed */
66021
66022  /* fixed and dynamic code tables */
66023
66024  this.lencode = null;
66025  /* starting table for length/literal codes */
66026
66027  this.distcode = null;
66028  /* starting table for distance codes */
66029
66030  this.lenbits = 0;
66031  /* index bits for lencode */
66032
66033  this.distbits = 0;
66034  /* index bits for distcode */
66035
66036  /* dynamic table building */
66037
66038  this.ncode = 0;
66039  /* number of code length code lengths */
66040
66041  this.nlen = 0;
66042  /* number of length code lengths */
66043
66044  this.ndist = 0;
66045  /* number of distance code lengths */
66046
66047  this.have = 0;
66048  /* number of code lengths in lens[] */
66049
66050  this.next = null;
66051  /* next available space in codes[] */
66052
66053  this.lens = new utils.Buf16(320);
66054  /* temporary storage for code lengths */
66055
66056  this.work = new utils.Buf16(288);
66057  /* work area for code table building */
66058
66059  /*
66060   because we don't have pointers in js, we use lencode and distcode directly
66061   as buffers so we don't need codes
66062  */
66063  //this.codes = new utils.Buf32(ENOUGH);       /* space for code tables */
66064
66065  this.lendyn = null;
66066  /* dynamic table for length/literal codes (JS specific) */
66067
66068  this.distdyn = null;
66069  /* dynamic table for distance codes (JS specific) */
66070
66071  this.sane = 0;
66072  /* if false, allow invalid distance too far */
66073
66074  this.back = 0;
66075  /* bits back of last unprocessed length/lit */
66076
66077  this.was = 0;
66078  /* initial length of match */
66079}
66080
66081function inflateResetKeep(strm) {
66082  var state;
66083
66084  if (!strm || !strm.state) {
66085    return Z_STREAM_ERROR;
66086  }
66087
66088  state = strm.state;
66089  strm.total_in = strm.total_out = state.total = 0;
66090  strm.msg = '';
66091  /*Z_NULL*/
66092
66093  if (state.wrap) {
66094    /* to support ill-conceived Java test suite */
66095    strm.adler = state.wrap & 1;
66096  }
66097
66098  state.mode = HEAD;
66099  state.last = 0;
66100  state.havedict = 0;
66101  state.dmax = 32768;
66102  state.head = null
66103  /*Z_NULL*/
66104  ;
66105  state.hold = 0;
66106  state.bits = 0; //state.lencode = state.distcode = state.next = state.codes;
66107
66108  state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
66109  state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
66110  state.sane = 1;
66111  state.back = -1; //Tracev((stderr, "inflate: reset\n"));
66112
66113  return Z_OK;
66114}
66115
66116function inflateReset(strm) {
66117  var state;
66118
66119  if (!strm || !strm.state) {
66120    return Z_STREAM_ERROR;
66121  }
66122
66123  state = strm.state;
66124  state.wsize = 0;
66125  state.whave = 0;
66126  state.wnext = 0;
66127  return inflateResetKeep(strm);
66128}
66129
66130function inflateReset2(strm, windowBits) {
66131  var wrap;
66132  var state;
66133  /* get the state */
66134
66135  if (!strm || !strm.state) {
66136    return Z_STREAM_ERROR;
66137  }
66138
66139  state = strm.state;
66140  /* extract wrap request from windowBits parameter */
66141
66142  if (windowBits < 0) {
66143    wrap = 0;
66144    windowBits = -windowBits;
66145  } else {
66146    wrap = (windowBits >> 4) + 1;
66147
66148    if (windowBits < 48) {
66149      windowBits &= 15;
66150    }
66151  }
66152  /* set number of window bits, free window if different */
66153
66154
66155  if (windowBits && (windowBits < 8 || windowBits > 15)) {
66156    return Z_STREAM_ERROR;
66157  }
66158
66159  if (state.window !== null && state.wbits !== windowBits) {
66160    state.window = null;
66161  }
66162  /* update state and reset the rest of it */
66163
66164
66165  state.wrap = wrap;
66166  state.wbits = windowBits;
66167  return inflateReset(strm);
66168}
66169
66170function inflateInit2(strm, windowBits) {
66171  var ret;
66172  var state;
66173
66174  if (!strm) {
66175    return Z_STREAM_ERROR;
66176  } //strm.msg = Z_NULL;                 /* in case we return an error */
66177
66178
66179  state = new InflateState(); //if (state === Z_NULL) return Z_MEM_ERROR;
66180  //Tracev((stderr, "inflate: allocated\n"));
66181
66182  strm.state = state;
66183  state.window = null
66184  /*Z_NULL*/
66185  ;
66186  ret = inflateReset2(strm, windowBits);
66187
66188  if (ret !== Z_OK) {
66189    strm.state = null
66190    /*Z_NULL*/
66191    ;
66192  }
66193
66194  return ret;
66195}
66196
66197function inflateInit(strm) {
66198  return inflateInit2(strm, DEF_WBITS);
66199}
66200/*
66201 Return state with length and distance decoding tables and index sizes set to
66202 fixed code decoding.  Normally this returns fixed tables from inffixed.h.
66203 If BUILDFIXED is defined, then instead this routine builds the tables the
66204 first time it's called, and returns those tables the first time and
66205 thereafter.  This reduces the size of the code by about 2K bytes, in
66206 exchange for a little execution time.  However, BUILDFIXED should not be
66207 used for threaded applications, since the rewriting of the tables and virgin
66208 may not be thread-safe.
66209 */
66210
66211
66212var virgin = true;
66213var lenfix, distfix; // We have no pointers in JS, so keep tables separate
66214
66215function fixedtables(state) {
66216  /* build fixed huffman tables if first call (may not be thread safe) */
66217  if (virgin) {
66218    var sym;
66219    lenfix = new utils.Buf32(512);
66220    distfix = new utils.Buf32(32);
66221    /* literal/length table */
66222
66223    sym = 0;
66224
66225    while (sym < 144) {
66226      state.lens[sym++] = 8;
66227    }
66228
66229    while (sym < 256) {
66230      state.lens[sym++] = 9;
66231    }
66232
66233    while (sym < 280) {
66234      state.lens[sym++] = 7;
66235    }
66236
66237    while (sym < 288) {
66238      state.lens[sym++] = 8;
66239    }
66240
66241    inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, {
66242      bits: 9
66243    });
66244    /* distance table */
66245
66246    sym = 0;
66247
66248    while (sym < 32) {
66249      state.lens[sym++] = 5;
66250    }
66251
66252    inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, {
66253      bits: 5
66254    });
66255    /* do this just once */
66256
66257    virgin = false;
66258  }
66259
66260  state.lencode = lenfix;
66261  state.lenbits = 9;
66262  state.distcode = distfix;
66263  state.distbits = 5;
66264}
66265/*
66266 Update the window with the last wsize (normally 32K) bytes written before
66267 returning.  If window does not exist yet, create it.  This is only called
66268 when a window is already in use, or when output has been written during this
66269 inflate call, but the end of the deflate stream has not been reached yet.
66270 It is also called to create a window for dictionary data when a dictionary
66271 is loaded.
66272
66273 Providing output buffers larger than 32K to inflate() should provide a speed
66274 advantage, since only the last 32K of output is copied to the sliding window
66275 upon return from inflate(), and since all distances after the first 32K of
66276 output will fall in the output data, making match copies simpler and faster.
66277 The advantage may be dependent on the size of the processor's data caches.
66278 */
66279
66280
66281function updatewindow(strm, src, end, copy) {
66282  var dist;
66283  var state = strm.state;
66284  /* if it hasn't been done already, allocate space for the window */
66285
66286  if (state.window === null) {
66287    state.wsize = 1 << state.wbits;
66288    state.wnext = 0;
66289    state.whave = 0;
66290    state.window = new utils.Buf8(state.wsize);
66291  }
66292  /* copy state->wsize or less output bytes into the circular window */
66293
66294
66295  if (copy >= state.wsize) {
66296    utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
66297    state.wnext = 0;
66298    state.whave = state.wsize;
66299  } else {
66300    dist = state.wsize - state.wnext;
66301
66302    if (dist > copy) {
66303      dist = copy;
66304    } //zmemcpy(state->window + state->wnext, end - copy, dist);
66305
66306
66307    utils.arraySet(state.window, src, end - copy, dist, state.wnext);
66308    copy -= dist;
66309
66310    if (copy) {
66311      //zmemcpy(state->window, end - copy, copy);
66312      utils.arraySet(state.window, src, end - copy, copy, 0);
66313      state.wnext = copy;
66314      state.whave = state.wsize;
66315    } else {
66316      state.wnext += dist;
66317
66318      if (state.wnext === state.wsize) {
66319        state.wnext = 0;
66320      }
66321
66322      if (state.whave < state.wsize) {
66323        state.whave += dist;
66324      }
66325    }
66326  }
66327
66328  return 0;
66329}
66330
66331function inflate(strm, flush) {
66332  var state;
66333  var input, output; // input/output buffers
66334
66335  var next;
66336  /* next input INDEX */
66337
66338  var put;
66339  /* next output INDEX */
66340
66341  var have, left;
66342  /* available input and output */
66343
66344  var hold;
66345  /* bit buffer */
66346
66347  var bits;
66348  /* bits in bit buffer */
66349
66350  var _in, _out;
66351  /* save starting available input and output */
66352
66353
66354  var copy;
66355  /* number of stored or match bytes to copy */
66356
66357  var from;
66358  /* where to copy match bytes from */
66359
66360  var from_source;
66361  var here = 0;
66362  /* current decoding table entry */
66363
66364  var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
66365  //var last;                   /* parent table entry */
66366
66367  var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
66368
66369  var len;
66370  /* length to copy for repeats, bits to drop */
66371
66372  var ret;
66373  /* return code */
66374
66375  var hbuf = new utils.Buf8(4);
66376  /* buffer for gzip header crc calculation */
66377
66378  var opts;
66379  var n; // temporary var for NEED_BITS
66380
66381  var order =
66382  /* permutation of code lengths */
66383  [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
66384
66385  if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
66386    return Z_STREAM_ERROR;
66387  }
66388
66389  state = strm.state;
66390
66391  if (state.mode === TYPE) {
66392    state.mode = TYPEDO;
66393  }
66394  /* skip check */
66395  //--- LOAD() ---
66396
66397
66398  put = strm.next_out;
66399  output = strm.output;
66400  left = strm.avail_out;
66401  next = strm.next_in;
66402  input = strm.input;
66403  have = strm.avail_in;
66404  hold = state.hold;
66405  bits = state.bits; //---
66406
66407  _in = have;
66408  _out = left;
66409  ret = Z_OK;
66410
66411  inf_leave: // goto emulation
66412  for (;;) {
66413    switch (state.mode) {
66414      case HEAD:
66415        if (state.wrap === 0) {
66416          state.mode = TYPEDO;
66417          break;
66418        } //=== NEEDBITS(16);
66419
66420
66421        while (bits < 16) {
66422          if (have === 0) {
66423            break inf_leave;
66424          }
66425
66426          have--;
66427          hold += input[next++] << bits;
66428          bits += 8;
66429        } //===//
66430
66431
66432        if (state.wrap & 2 && hold === 0x8b1f) {
66433          /* gzip header */
66434          state.check = 0
66435          /*crc32(0L, Z_NULL, 0)*/
66436          ; //=== CRC2(state.check, hold);
66437
66438          hbuf[0] = hold & 0xff;
66439          hbuf[1] = hold >>> 8 & 0xff;
66440          state.check = crc32(state.check, hbuf, 2, 0); //===//
66441          //=== INITBITS();
66442
66443          hold = 0;
66444          bits = 0; //===//
66445
66446          state.mode = FLAGS;
66447          break;
66448        }
66449
66450        state.flags = 0;
66451        /* expect zlib header */
66452
66453        if (state.head) {
66454          state.head.done = false;
66455        }
66456
66457        if (!(state.wrap & 1) ||
66458        /* check if zlib header allowed */
66459        (((hold & 0xff) <<
66460        /*BITS(8)*/
66461        8) + (hold >> 8)) % 31) {
66462          strm.msg = 'incorrect header check';
66463          state.mode = BAD;
66464          break;
66465        }
66466
66467        if ((hold & 0x0f) !==
66468        /*BITS(4)*/
66469        Z_DEFLATED) {
66470          strm.msg = 'unknown compression method';
66471          state.mode = BAD;
66472          break;
66473        } //--- DROPBITS(4) ---//
66474
66475
66476        hold >>>= 4;
66477        bits -= 4; //---//
66478
66479        len = (hold & 0x0f) +
66480        /*BITS(4)*/
66481        8;
66482
66483        if (state.wbits === 0) {
66484          state.wbits = len;
66485        } else if (len > state.wbits) {
66486          strm.msg = 'invalid window size';
66487          state.mode = BAD;
66488          break;
66489        }
66490
66491        state.dmax = 1 << len; //Tracev((stderr, "inflate:   zlib header ok\n"));
66492
66493        strm.adler = state.check = 1
66494        /*adler32(0L, Z_NULL, 0)*/
66495        ;
66496        state.mode = hold & 0x200 ? DICTID : TYPE; //=== INITBITS();
66497
66498        hold = 0;
66499        bits = 0; //===//
66500
66501        break;
66502
66503      case FLAGS:
66504        //=== NEEDBITS(16); */
66505        while (bits < 16) {
66506          if (have === 0) {
66507            break inf_leave;
66508          }
66509
66510          have--;
66511          hold += input[next++] << bits;
66512          bits += 8;
66513        } //===//
66514
66515
66516        state.flags = hold;
66517
66518        if ((state.flags & 0xff) !== Z_DEFLATED) {
66519          strm.msg = 'unknown compression method';
66520          state.mode = BAD;
66521          break;
66522        }
66523
66524        if (state.flags & 0xe000) {
66525          strm.msg = 'unknown header flags set';
66526          state.mode = BAD;
66527          break;
66528        }
66529
66530        if (state.head) {
66531          state.head.text = hold >> 8 & 1;
66532        }
66533
66534        if (state.flags & 0x0200) {
66535          //=== CRC2(state.check, hold);
66536          hbuf[0] = hold & 0xff;
66537          hbuf[1] = hold >>> 8 & 0xff;
66538          state.check = crc32(state.check, hbuf, 2, 0); //===//
66539        } //=== INITBITS();
66540
66541
66542        hold = 0;
66543        bits = 0; //===//
66544
66545        state.mode = TIME;
66546
66547      /* falls through */
66548
66549      case TIME:
66550        //=== NEEDBITS(32); */
66551        while (bits < 32) {
66552          if (have === 0) {
66553            break inf_leave;
66554          }
66555
66556          have--;
66557          hold += input[next++] << bits;
66558          bits += 8;
66559        } //===//
66560
66561
66562        if (state.head) {
66563          state.head.time = hold;
66564        }
66565
66566        if (state.flags & 0x0200) {
66567          //=== CRC4(state.check, hold)
66568          hbuf[0] = hold & 0xff;
66569          hbuf[1] = hold >>> 8 & 0xff;
66570          hbuf[2] = hold >>> 16 & 0xff;
66571          hbuf[3] = hold >>> 24 & 0xff;
66572          state.check = crc32(state.check, hbuf, 4, 0); //===
66573        } //=== INITBITS();
66574
66575
66576        hold = 0;
66577        bits = 0; //===//
66578
66579        state.mode = OS;
66580
66581      /* falls through */
66582
66583      case OS:
66584        //=== NEEDBITS(16); */
66585        while (bits < 16) {
66586          if (have === 0) {
66587            break inf_leave;
66588          }
66589
66590          have--;
66591          hold += input[next++] << bits;
66592          bits += 8;
66593        } //===//
66594
66595
66596        if (state.head) {
66597          state.head.xflags = hold & 0xff;
66598          state.head.os = hold >> 8;
66599        }
66600
66601        if (state.flags & 0x0200) {
66602          //=== CRC2(state.check, hold);
66603          hbuf[0] = hold & 0xff;
66604          hbuf[1] = hold >>> 8 & 0xff;
66605          state.check = crc32(state.check, hbuf, 2, 0); //===//
66606        } //=== INITBITS();
66607
66608
66609        hold = 0;
66610        bits = 0; //===//
66611
66612        state.mode = EXLEN;
66613
66614      /* falls through */
66615
66616      case EXLEN:
66617        if (state.flags & 0x0400) {
66618          //=== NEEDBITS(16); */
66619          while (bits < 16) {
66620            if (have === 0) {
66621              break inf_leave;
66622            }
66623
66624            have--;
66625            hold += input[next++] << bits;
66626            bits += 8;
66627          } //===//
66628
66629
66630          state.length = hold;
66631
66632          if (state.head) {
66633            state.head.extra_len = hold;
66634          }
66635
66636          if (state.flags & 0x0200) {
66637            //=== CRC2(state.check, hold);
66638            hbuf[0] = hold & 0xff;
66639            hbuf[1] = hold >>> 8 & 0xff;
66640            state.check = crc32(state.check, hbuf, 2, 0); //===//
66641          } //=== INITBITS();
66642
66643
66644          hold = 0;
66645          bits = 0; //===//
66646        } else if (state.head) {
66647          state.head.extra = null
66648          /*Z_NULL*/
66649          ;
66650        }
66651
66652        state.mode = EXTRA;
66653
66654      /* falls through */
66655
66656      case EXTRA:
66657        if (state.flags & 0x0400) {
66658          copy = state.length;
66659
66660          if (copy > have) {
66661            copy = have;
66662          }
66663
66664          if (copy) {
66665            if (state.head) {
66666              len = state.head.extra_len - state.length;
66667
66668              if (!state.head.extra) {
66669                // Use untyped array for more convenient processing later
66670                state.head.extra = new Array(state.head.extra_len);
66671              }
66672
66673              utils.arraySet(state.head.extra, input, next, // extra field is limited to 65536 bytes
66674              // - no need for additional size check
66675              copy,
66676              /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
66677              len); //zmemcpy(state.head.extra + len, next,
66678              //        len + copy > state.head.extra_max ?
66679              //        state.head.extra_max - len : copy);
66680            }
66681
66682            if (state.flags & 0x0200) {
66683              state.check = crc32(state.check, input, copy, next);
66684            }
66685
66686            have -= copy;
66687            next += copy;
66688            state.length -= copy;
66689          }
66690
66691          if (state.length) {
66692            break inf_leave;
66693          }
66694        }
66695
66696        state.length = 0;
66697        state.mode = NAME;
66698
66699      /* falls through */
66700
66701      case NAME:
66702        if (state.flags & 0x0800) {
66703          if (have === 0) {
66704            break inf_leave;
66705          }
66706
66707          copy = 0;
66708
66709          do {
66710            // TODO: 2 or 1 bytes?
66711            len = input[next + copy++];
66712            /* use constant limit because in js we should not preallocate memory */
66713
66714            if (state.head && len && state.length < 65536
66715            /*state.head.name_max*/
66716            ) {
66717              state.head.name += String.fromCharCode(len);
66718            }
66719          } while (len && copy < have);
66720
66721          if (state.flags & 0x0200) {
66722            state.check = crc32(state.check, input, copy, next);
66723          }
66724
66725          have -= copy;
66726          next += copy;
66727
66728          if (len) {
66729            break inf_leave;
66730          }
66731        } else if (state.head) {
66732          state.head.name = null;
66733        }
66734
66735        state.length = 0;
66736        state.mode = COMMENT;
66737
66738      /* falls through */
66739
66740      case COMMENT:
66741        if (state.flags & 0x1000) {
66742          if (have === 0) {
66743            break inf_leave;
66744          }
66745
66746          copy = 0;
66747
66748          do {
66749            len = input[next + copy++];
66750            /* use constant limit because in js we should not preallocate memory */
66751
66752            if (state.head && len && state.length < 65536
66753            /*state.head.comm_max*/
66754            ) {
66755              state.head.comment += String.fromCharCode(len);
66756            }
66757          } while (len && copy < have);
66758
66759          if (state.flags & 0x0200) {
66760            state.check = crc32(state.check, input, copy, next);
66761          }
66762
66763          have -= copy;
66764          next += copy;
66765
66766          if (len) {
66767            break inf_leave;
66768          }
66769        } else if (state.head) {
66770          state.head.comment = null;
66771        }
66772
66773        state.mode = HCRC;
66774
66775      /* falls through */
66776
66777      case HCRC:
66778        if (state.flags & 0x0200) {
66779          //=== NEEDBITS(16); */
66780          while (bits < 16) {
66781            if (have === 0) {
66782              break inf_leave;
66783            }
66784
66785            have--;
66786            hold += input[next++] << bits;
66787            bits += 8;
66788          } //===//
66789
66790
66791          if (hold !== (state.check & 0xffff)) {
66792            strm.msg = 'header crc mismatch';
66793            state.mode = BAD;
66794            break;
66795          } //=== INITBITS();
66796
66797
66798          hold = 0;
66799          bits = 0; //===//
66800        }
66801
66802        if (state.head) {
66803          state.head.hcrc = state.flags >> 9 & 1;
66804          state.head.done = true;
66805        }
66806
66807        strm.adler = state.check = 0;
66808        state.mode = TYPE;
66809        break;
66810
66811      case DICTID:
66812        //=== NEEDBITS(32); */
66813        while (bits < 32) {
66814          if (have === 0) {
66815            break inf_leave;
66816          }
66817
66818          have--;
66819          hold += input[next++] << bits;
66820          bits += 8;
66821        } //===//
66822
66823
66824        strm.adler = state.check = zswap32(hold); //=== INITBITS();
66825
66826        hold = 0;
66827        bits = 0; //===//
66828
66829        state.mode = DICT;
66830
66831      /* falls through */
66832
66833      case DICT:
66834        if (state.havedict === 0) {
66835          //--- RESTORE() ---
66836          strm.next_out = put;
66837          strm.avail_out = left;
66838          strm.next_in = next;
66839          strm.avail_in = have;
66840          state.hold = hold;
66841          state.bits = bits; //---
66842
66843          return Z_NEED_DICT;
66844        }
66845
66846        strm.adler = state.check = 1
66847        /*adler32(0L, Z_NULL, 0)*/
66848        ;
66849        state.mode = TYPE;
66850
66851      /* falls through */
66852
66853      case TYPE:
66854        if (flush === Z_BLOCK || flush === Z_TREES) {
66855          break inf_leave;
66856        }
66857
66858      /* falls through */
66859
66860      case TYPEDO:
66861        if (state.last) {
66862          //--- BYTEBITS() ---//
66863          hold >>>= bits & 7;
66864          bits -= bits & 7; //---//
66865
66866          state.mode = CHECK;
66867          break;
66868        } //=== NEEDBITS(3); */
66869
66870
66871        while (bits < 3) {
66872          if (have === 0) {
66873            break inf_leave;
66874          }
66875
66876          have--;
66877          hold += input[next++] << bits;
66878          bits += 8;
66879        } //===//
66880
66881
66882        state.last = hold & 0x01
66883        /*BITS(1)*/
66884        ; //--- DROPBITS(1) ---//
66885
66886        hold >>>= 1;
66887        bits -= 1; //---//
66888
66889        switch (hold & 0x03) {
66890          /*BITS(2)*/
66891          case 0:
66892            /* stored block */
66893            //Tracev((stderr, "inflate:     stored block%s\n",
66894            //        state.last ? " (last)" : ""));
66895            state.mode = STORED;
66896            break;
66897
66898          case 1:
66899            /* fixed block */
66900            fixedtables(state); //Tracev((stderr, "inflate:     fixed codes block%s\n",
66901            //        state.last ? " (last)" : ""));
66902
66903            state.mode = LEN_;
66904            /* decode codes */
66905
66906            if (flush === Z_TREES) {
66907              //--- DROPBITS(2) ---//
66908              hold >>>= 2;
66909              bits -= 2; //---//
66910
66911              break inf_leave;
66912            }
66913
66914            break;
66915
66916          case 2:
66917            /* dynamic block */
66918            //Tracev((stderr, "inflate:     dynamic codes block%s\n",
66919            //        state.last ? " (last)" : ""));
66920            state.mode = TABLE;
66921            break;
66922
66923          case 3:
66924            strm.msg = 'invalid block type';
66925            state.mode = BAD;
66926        } //--- DROPBITS(2) ---//
66927
66928
66929        hold >>>= 2;
66930        bits -= 2; //---//
66931
66932        break;
66933
66934      case STORED:
66935        //--- BYTEBITS() ---// /* go to byte boundary */
66936        hold >>>= bits & 7;
66937        bits -= bits & 7; //---//
66938        //=== NEEDBITS(32); */
66939
66940        while (bits < 32) {
66941          if (have === 0) {
66942            break inf_leave;
66943          }
66944
66945          have--;
66946          hold += input[next++] << bits;
66947          bits += 8;
66948        } //===//
66949
66950
66951        if ((hold & 0xffff) !== (hold >>> 16 ^ 0xffff)) {
66952          strm.msg = 'invalid stored block lengths';
66953          state.mode = BAD;
66954          break;
66955        }
66956
66957        state.length = hold & 0xffff; //Tracev((stderr, "inflate:       stored length %u\n",
66958        //        state.length));
66959        //=== INITBITS();
66960
66961        hold = 0;
66962        bits = 0; //===//
66963
66964        state.mode = COPY_;
66965
66966        if (flush === Z_TREES) {
66967          break inf_leave;
66968        }
66969
66970      /* falls through */
66971
66972      case COPY_:
66973        state.mode = COPY;
66974
66975      /* falls through */
66976
66977      case COPY:
66978        copy = state.length;
66979
66980        if (copy) {
66981          if (copy > have) {
66982            copy = have;
66983          }
66984
66985          if (copy > left) {
66986            copy = left;
66987          }
66988
66989          if (copy === 0) {
66990            break inf_leave;
66991          } //--- zmemcpy(put, next, copy); ---
66992
66993
66994          utils.arraySet(output, input, next, copy, put); //---//
66995
66996          have -= copy;
66997          next += copy;
66998          left -= copy;
66999          put += copy;
67000          state.length -= copy;
67001          break;
67002        } //Tracev((stderr, "inflate:       stored end\n"));
67003
67004
67005        state.mode = TYPE;
67006        break;
67007
67008      case TABLE:
67009        //=== NEEDBITS(14); */
67010        while (bits < 14) {
67011          if (have === 0) {
67012            break inf_leave;
67013          }
67014
67015          have--;
67016          hold += input[next++] << bits;
67017          bits += 8;
67018        } //===//
67019
67020
67021        state.nlen = (hold & 0x1f) +
67022        /*BITS(5)*/
67023        257; //--- DROPBITS(5) ---//
67024
67025        hold >>>= 5;
67026        bits -= 5; //---//
67027
67028        state.ndist = (hold & 0x1f) +
67029        /*BITS(5)*/
67030        1; //--- DROPBITS(5) ---//
67031
67032        hold >>>= 5;
67033        bits -= 5; //---//
67034
67035        state.ncode = (hold & 0x0f) +
67036        /*BITS(4)*/
67037        4; //--- DROPBITS(4) ---//
67038
67039        hold >>>= 4;
67040        bits -= 4; //---//
67041        //#ifndef PKZIP_BUG_WORKAROUND
67042
67043        if (state.nlen > 286 || state.ndist > 30) {
67044          strm.msg = 'too many length or distance symbols';
67045          state.mode = BAD;
67046          break;
67047        } //#endif
67048        //Tracev((stderr, "inflate:       table sizes ok\n"));
67049
67050
67051        state.have = 0;
67052        state.mode = LENLENS;
67053
67054      /* falls through */
67055
67056      case LENLENS:
67057        while (state.have < state.ncode) {
67058          //=== NEEDBITS(3);
67059          while (bits < 3) {
67060            if (have === 0) {
67061              break inf_leave;
67062            }
67063
67064            have--;
67065            hold += input[next++] << bits;
67066            bits += 8;
67067          } //===//
67068
67069
67070          state.lens[order[state.have++]] = hold & 0x07; //BITS(3);
67071          //--- DROPBITS(3) ---//
67072
67073          hold >>>= 3;
67074          bits -= 3; //---//
67075        }
67076
67077        while (state.have < 19) {
67078          state.lens[order[state.have++]] = 0;
67079        } // We have separate tables & no pointers. 2 commented lines below not needed.
67080        //state.next = state.codes;
67081        //state.lencode = state.next;
67082        // Switch to use dynamic table
67083
67084
67085        state.lencode = state.lendyn;
67086        state.lenbits = 7;
67087        opts = {
67088          bits: state.lenbits
67089        };
67090        ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
67091        state.lenbits = opts.bits;
67092
67093        if (ret) {
67094          strm.msg = 'invalid code lengths set';
67095          state.mode = BAD;
67096          break;
67097        } //Tracev((stderr, "inflate:       code lengths ok\n"));
67098
67099
67100        state.have = 0;
67101        state.mode = CODELENS;
67102
67103      /* falls through */
67104
67105      case CODELENS:
67106        while (state.have < state.nlen + state.ndist) {
67107          for (;;) {
67108            here = state.lencode[hold & (1 << state.lenbits) - 1];
67109            /*BITS(state.lenbits)*/
67110
67111            here_bits = here >>> 24;
67112            here_op = here >>> 16 & 0xff;
67113            here_val = here & 0xffff;
67114
67115            if (here_bits <= bits) {
67116              break;
67117            } //--- PULLBYTE() ---//
67118
67119
67120            if (have === 0) {
67121              break inf_leave;
67122            }
67123
67124            have--;
67125            hold += input[next++] << bits;
67126            bits += 8; //---//
67127          }
67128
67129          if (here_val < 16) {
67130            //--- DROPBITS(here.bits) ---//
67131            hold >>>= here_bits;
67132            bits -= here_bits; //---//
67133
67134            state.lens[state.have++] = here_val;
67135          } else {
67136            if (here_val === 16) {
67137              //=== NEEDBITS(here.bits + 2);
67138              n = here_bits + 2;
67139
67140              while (bits < n) {
67141                if (have === 0) {
67142                  break inf_leave;
67143                }
67144
67145                have--;
67146                hold += input[next++] << bits;
67147                bits += 8;
67148              } //===//
67149              //--- DROPBITS(here.bits) ---//
67150
67151
67152              hold >>>= here_bits;
67153              bits -= here_bits; //---//
67154
67155              if (state.have === 0) {
67156                strm.msg = 'invalid bit length repeat';
67157                state.mode = BAD;
67158                break;
67159              }
67160
67161              len = state.lens[state.have - 1];
67162              copy = 3 + (hold & 0x03); //BITS(2);
67163              //--- DROPBITS(2) ---//
67164
67165              hold >>>= 2;
67166              bits -= 2; //---//
67167            } else if (here_val === 17) {
67168              //=== NEEDBITS(here.bits + 3);
67169              n = here_bits + 3;
67170
67171              while (bits < n) {
67172                if (have === 0) {
67173                  break inf_leave;
67174                }
67175
67176                have--;
67177                hold += input[next++] << bits;
67178                bits += 8;
67179              } //===//
67180              //--- DROPBITS(here.bits) ---//
67181
67182
67183              hold >>>= here_bits;
67184              bits -= here_bits; //---//
67185
67186              len = 0;
67187              copy = 3 + (hold & 0x07); //BITS(3);
67188              //--- DROPBITS(3) ---//
67189
67190              hold >>>= 3;
67191              bits -= 3; //---//
67192            } else {
67193              //=== NEEDBITS(here.bits + 7);
67194              n = here_bits + 7;
67195
67196              while (bits < n) {
67197                if (have === 0) {
67198                  break inf_leave;
67199                }
67200
67201                have--;
67202                hold += input[next++] << bits;
67203                bits += 8;
67204              } //===//
67205              //--- DROPBITS(here.bits) ---//
67206
67207
67208              hold >>>= here_bits;
67209              bits -= here_bits; //---//
67210
67211              len = 0;
67212              copy = 11 + (hold & 0x7f); //BITS(7);
67213              //--- DROPBITS(7) ---//
67214
67215              hold >>>= 7;
67216              bits -= 7; //---//
67217            }
67218
67219            if (state.have + copy > state.nlen + state.ndist) {
67220              strm.msg = 'invalid bit length repeat';
67221              state.mode = BAD;
67222              break;
67223            }
67224
67225            while (copy--) {
67226              state.lens[state.have++] = len;
67227            }
67228          }
67229        }
67230        /* handle error breaks in while */
67231
67232
67233        if (state.mode === BAD) {
67234          break;
67235        }
67236        /* check for end-of-block code (better have one) */
67237
67238
67239        if (state.lens[256] === 0) {
67240          strm.msg = 'invalid code -- missing end-of-block';
67241          state.mode = BAD;
67242          break;
67243        }
67244        /* build code tables -- note: do not change the lenbits or distbits
67245           values here (9 and 6) without reading the comments in inftrees.h
67246           concerning the ENOUGH constants, which depend on those values */
67247
67248
67249        state.lenbits = 9;
67250        opts = {
67251          bits: state.lenbits
67252        };
67253        ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); // We have separate tables & no pointers. 2 commented lines below not needed.
67254        // state.next_index = opts.table_index;
67255
67256        state.lenbits = opts.bits; // state.lencode = state.next;
67257
67258        if (ret) {
67259          strm.msg = 'invalid literal/lengths set';
67260          state.mode = BAD;
67261          break;
67262        }
67263
67264        state.distbits = 6; //state.distcode.copy(state.codes);
67265        // Switch to use dynamic table
67266
67267        state.distcode = state.distdyn;
67268        opts = {
67269          bits: state.distbits
67270        };
67271        ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); // We have separate tables & no pointers. 2 commented lines below not needed.
67272        // state.next_index = opts.table_index;
67273
67274        state.distbits = opts.bits; // state.distcode = state.next;
67275
67276        if (ret) {
67277          strm.msg = 'invalid distances set';
67278          state.mode = BAD;
67279          break;
67280        } //Tracev((stderr, 'inflate:       codes ok\n'));
67281
67282
67283        state.mode = LEN_;
67284
67285        if (flush === Z_TREES) {
67286          break inf_leave;
67287        }
67288
67289      /* falls through */
67290
67291      case LEN_:
67292        state.mode = LEN;
67293
67294      /* falls through */
67295
67296      case LEN:
67297        if (have >= 6 && left >= 258) {
67298          //--- RESTORE() ---
67299          strm.next_out = put;
67300          strm.avail_out = left;
67301          strm.next_in = next;
67302          strm.avail_in = have;
67303          state.hold = hold;
67304          state.bits = bits; //---
67305
67306          inflate_fast(strm, _out); //--- LOAD() ---
67307
67308          put = strm.next_out;
67309          output = strm.output;
67310          left = strm.avail_out;
67311          next = strm.next_in;
67312          input = strm.input;
67313          have = strm.avail_in;
67314          hold = state.hold;
67315          bits = state.bits; //---
67316
67317          if (state.mode === TYPE) {
67318            state.back = -1;
67319          }
67320
67321          break;
67322        }
67323
67324        state.back = 0;
67325
67326        for (;;) {
67327          here = state.lencode[hold & (1 << state.lenbits) - 1];
67328          /*BITS(state.lenbits)*/
67329
67330          here_bits = here >>> 24;
67331          here_op = here >>> 16 & 0xff;
67332          here_val = here & 0xffff;
67333
67334          if (here_bits <= bits) {
67335            break;
67336          } //--- PULLBYTE() ---//
67337
67338
67339          if (have === 0) {
67340            break inf_leave;
67341          }
67342
67343          have--;
67344          hold += input[next++] << bits;
67345          bits += 8; //---//
67346        }
67347
67348        if (here_op && (here_op & 0xf0) === 0) {
67349          last_bits = here_bits;
67350          last_op = here_op;
67351          last_val = here_val;
67352
67353          for (;;) {
67354            here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >>
67355            /*BITS(last.bits + last.op)*/
67356            last_bits)];
67357            here_bits = here >>> 24;
67358            here_op = here >>> 16 & 0xff;
67359            here_val = here & 0xffff;
67360
67361            if (last_bits + here_bits <= bits) {
67362              break;
67363            } //--- PULLBYTE() ---//
67364
67365
67366            if (have === 0) {
67367              break inf_leave;
67368            }
67369
67370            have--;
67371            hold += input[next++] << bits;
67372            bits += 8; //---//
67373          } //--- DROPBITS(last.bits) ---//
67374
67375
67376          hold >>>= last_bits;
67377          bits -= last_bits; //---//
67378
67379          state.back += last_bits;
67380        } //--- DROPBITS(here.bits) ---//
67381
67382
67383        hold >>>= here_bits;
67384        bits -= here_bits; //---//
67385
67386        state.back += here_bits;
67387        state.length = here_val;
67388
67389        if (here_op === 0) {
67390          //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
67391          //        "inflate:         literal '%c'\n" :
67392          //        "inflate:         literal 0x%02x\n", here.val));
67393          state.mode = LIT;
67394          break;
67395        }
67396
67397        if (here_op & 32) {
67398          //Tracevv((stderr, "inflate:         end of block\n"));
67399          state.back = -1;
67400          state.mode = TYPE;
67401          break;
67402        }
67403
67404        if (here_op & 64) {
67405          strm.msg = 'invalid literal/length code';
67406          state.mode = BAD;
67407          break;
67408        }
67409
67410        state.extra = here_op & 15;
67411        state.mode = LENEXT;
67412
67413      /* falls through */
67414
67415      case LENEXT:
67416        if (state.extra) {
67417          //=== NEEDBITS(state.extra);
67418          n = state.extra;
67419
67420          while (bits < n) {
67421            if (have === 0) {
67422              break inf_leave;
67423            }
67424
67425            have--;
67426            hold += input[next++] << bits;
67427            bits += 8;
67428          } //===//
67429
67430
67431          state.length += hold & (1 << state.extra) - 1
67432          /*BITS(state.extra)*/
67433          ; //--- DROPBITS(state.extra) ---//
67434
67435          hold >>>= state.extra;
67436          bits -= state.extra; //---//
67437
67438          state.back += state.extra;
67439        } //Tracevv((stderr, "inflate:         length %u\n", state.length));
67440
67441
67442        state.was = state.length;
67443        state.mode = DIST;
67444
67445      /* falls through */
67446
67447      case DIST:
67448        for (;;) {
67449          here = state.distcode[hold & (1 << state.distbits) - 1];
67450          /*BITS(state.distbits)*/
67451
67452          here_bits = here >>> 24;
67453          here_op = here >>> 16 & 0xff;
67454          here_val = here & 0xffff;
67455
67456          if (here_bits <= bits) {
67457            break;
67458          } //--- PULLBYTE() ---//
67459
67460
67461          if (have === 0) {
67462            break inf_leave;
67463          }
67464
67465          have--;
67466          hold += input[next++] << bits;
67467          bits += 8; //---//
67468        }
67469
67470        if ((here_op & 0xf0) === 0) {
67471          last_bits = here_bits;
67472          last_op = here_op;
67473          last_val = here_val;
67474
67475          for (;;) {
67476            here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >>
67477            /*BITS(last.bits + last.op)*/
67478            last_bits)];
67479            here_bits = here >>> 24;
67480            here_op = here >>> 16 & 0xff;
67481            here_val = here & 0xffff;
67482
67483            if (last_bits + here_bits <= bits) {
67484              break;
67485            } //--- PULLBYTE() ---//
67486
67487
67488            if (have === 0) {
67489              break inf_leave;
67490            }
67491
67492            have--;
67493            hold += input[next++] << bits;
67494            bits += 8; //---//
67495          } //--- DROPBITS(last.bits) ---//
67496
67497
67498          hold >>>= last_bits;
67499          bits -= last_bits; //---//
67500
67501          state.back += last_bits;
67502        } //--- DROPBITS(here.bits) ---//
67503
67504
67505        hold >>>= here_bits;
67506        bits -= here_bits; //---//
67507
67508        state.back += here_bits;
67509
67510        if (here_op & 64) {
67511          strm.msg = 'invalid distance code';
67512          state.mode = BAD;
67513          break;
67514        }
67515
67516        state.offset = here_val;
67517        state.extra = here_op & 15;
67518        state.mode = DISTEXT;
67519
67520      /* falls through */
67521
67522      case DISTEXT:
67523        if (state.extra) {
67524          //=== NEEDBITS(state.extra);
67525          n = state.extra;
67526
67527          while (bits < n) {
67528            if (have === 0) {
67529              break inf_leave;
67530            }
67531
67532            have--;
67533            hold += input[next++] << bits;
67534            bits += 8;
67535          } //===//
67536
67537
67538          state.offset += hold & (1 << state.extra) - 1
67539          /*BITS(state.extra)*/
67540          ; //--- DROPBITS(state.extra) ---//
67541
67542          hold >>>= state.extra;
67543          bits -= state.extra; //---//
67544
67545          state.back += state.extra;
67546        } //#ifdef INFLATE_STRICT
67547
67548
67549        if (state.offset > state.dmax) {
67550          strm.msg = 'invalid distance too far back';
67551          state.mode = BAD;
67552          break;
67553        } //#endif
67554        //Tracevv((stderr, "inflate:         distance %u\n", state.offset));
67555
67556
67557        state.mode = MATCH;
67558
67559      /* falls through */
67560
67561      case MATCH:
67562        if (left === 0) {
67563          break inf_leave;
67564        }
67565
67566        copy = _out - left;
67567
67568        if (state.offset > copy) {
67569          /* copy from window */
67570          copy = state.offset - copy;
67571
67572          if (copy > state.whave) {
67573            if (state.sane) {
67574              strm.msg = 'invalid distance too far back';
67575              state.mode = BAD;
67576              break;
67577            } // (!) This block is disabled in zlib defaults,
67578            // don't enable it for binary compatibility
67579            //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
67580            //          Trace((stderr, "inflate.c too far\n"));
67581            //          copy -= state.whave;
67582            //          if (copy > state.length) { copy = state.length; }
67583            //          if (copy > left) { copy = left; }
67584            //          left -= copy;
67585            //          state.length -= copy;
67586            //          do {
67587            //            output[put++] = 0;
67588            //          } while (--copy);
67589            //          if (state.length === 0) { state.mode = LEN; }
67590            //          break;
67591            //#endif
67592
67593          }
67594
67595          if (copy > state.wnext) {
67596            copy -= state.wnext;
67597            from = state.wsize - copy;
67598          } else {
67599            from = state.wnext - copy;
67600          }
67601
67602          if (copy > state.length) {
67603            copy = state.length;
67604          }
67605
67606          from_source = state.window;
67607        } else {
67608          /* copy from output */
67609          from_source = output;
67610          from = put - state.offset;
67611          copy = state.length;
67612        }
67613
67614        if (copy > left) {
67615          copy = left;
67616        }
67617
67618        left -= copy;
67619        state.length -= copy;
67620
67621        do {
67622          output[put++] = from_source[from++];
67623        } while (--copy);
67624
67625        if (state.length === 0) {
67626          state.mode = LEN;
67627        }
67628
67629        break;
67630
67631      case LIT:
67632        if (left === 0) {
67633          break inf_leave;
67634        }
67635
67636        output[put++] = state.length;
67637        left--;
67638        state.mode = LEN;
67639        break;
67640
67641      case CHECK:
67642        if (state.wrap) {
67643          //=== NEEDBITS(32);
67644          while (bits < 32) {
67645            if (have === 0) {
67646              break inf_leave;
67647            }
67648
67649            have--; // Use '|' instead of '+' to make sure that result is signed
67650
67651            hold |= input[next++] << bits;
67652            bits += 8;
67653          } //===//
67654
67655
67656          _out -= left;
67657          strm.total_out += _out;
67658          state.total += _out;
67659
67660          if (_out) {
67661            strm.adler = state.check =
67662            /*UPDATE(state.check, put - _out, _out);*/
67663            state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out);
67664          }
67665
67666          _out = left; // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
67667
67668          if ((state.flags ? hold : zswap32(hold)) !== state.check) {
67669            strm.msg = 'incorrect data check';
67670            state.mode = BAD;
67671            break;
67672          } //=== INITBITS();
67673
67674
67675          hold = 0;
67676          bits = 0; //===//
67677          //Tracev((stderr, "inflate:   check matches trailer\n"));
67678        }
67679
67680        state.mode = LENGTH;
67681
67682      /* falls through */
67683
67684      case LENGTH:
67685        if (state.wrap && state.flags) {
67686          //=== NEEDBITS(32);
67687          while (bits < 32) {
67688            if (have === 0) {
67689              break inf_leave;
67690            }
67691
67692            have--;
67693            hold += input[next++] << bits;
67694            bits += 8;
67695          } //===//
67696
67697
67698          if (hold !== (state.total & 0xffffffff)) {
67699            strm.msg = 'incorrect length check';
67700            state.mode = BAD;
67701            break;
67702          } //=== INITBITS();
67703
67704
67705          hold = 0;
67706          bits = 0; //===//
67707          //Tracev((stderr, "inflate:   length matches trailer\n"));
67708        }
67709
67710        state.mode = DONE;
67711
67712      /* falls through */
67713
67714      case DONE:
67715        ret = Z_STREAM_END;
67716        break inf_leave;
67717
67718      case BAD:
67719        ret = Z_DATA_ERROR;
67720        break inf_leave;
67721
67722      case MEM:
67723        return Z_MEM_ERROR;
67724
67725      case SYNC:
67726      /* falls through */
67727
67728      default:
67729        return Z_STREAM_ERROR;
67730    }
67731  } // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
67732
67733  /*
67734     Return from inflate(), updating the total counts and the check value.
67735     If there was no progress during the inflate() call, return a buffer
67736     error.  Call updatewindow() to create and/or update the window state.
67737     Note: a memory error from inflate() is non-recoverable.
67738   */
67739  //--- RESTORE() ---
67740
67741
67742  strm.next_out = put;
67743  strm.avail_out = left;
67744  strm.next_in = next;
67745  strm.avail_in = have;
67746  state.hold = hold;
67747  state.bits = bits; //---
67748
67749  if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) {
67750    if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
67751      state.mode = MEM;
67752      return Z_MEM_ERROR;
67753    }
67754  }
67755
67756  _in -= strm.avail_in;
67757  _out -= strm.avail_out;
67758  strm.total_in += _in;
67759  strm.total_out += _out;
67760  state.total += _out;
67761
67762  if (state.wrap && _out) {
67763    strm.adler = state.check =
67764    /*UPDATE(state.check, strm.next_out - _out, _out);*/
67765    state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out);
67766  }
67767
67768  strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
67769
67770  if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
67771    ret = Z_BUF_ERROR;
67772  }
67773
67774  return ret;
67775}
67776
67777function inflateEnd(strm) {
67778  if (!strm || !strm.state
67779  /*|| strm->zfree == (free_func)0*/
67780  ) {
67781      return Z_STREAM_ERROR;
67782    }
67783
67784  var state = strm.state;
67785
67786  if (state.window) {
67787    state.window = null;
67788  }
67789
67790  strm.state = null;
67791  return Z_OK;
67792}
67793
67794function inflateGetHeader(strm, head) {
67795  var state;
67796  /* check state */
67797
67798  if (!strm || !strm.state) {
67799    return Z_STREAM_ERROR;
67800  }
67801
67802  state = strm.state;
67803
67804  if ((state.wrap & 2) === 0) {
67805    return Z_STREAM_ERROR;
67806  }
67807  /* save header structure */
67808
67809
67810  state.head = head;
67811  head.done = false;
67812  return Z_OK;
67813}
67814
67815function inflateSetDictionary(strm, dictionary) {
67816  var dictLength = dictionary.length;
67817  var state;
67818  var dictid;
67819  var ret;
67820  /* check state */
67821
67822  if (!strm
67823  /* == Z_NULL */
67824  || !strm.state
67825  /* == Z_NULL */
67826  ) {
67827      return Z_STREAM_ERROR;
67828    }
67829
67830  state = strm.state;
67831
67832  if (state.wrap !== 0 && state.mode !== DICT) {
67833    return Z_STREAM_ERROR;
67834  }
67835  /* check for correct dictionary identifier */
67836
67837
67838  if (state.mode === DICT) {
67839    dictid = 1;
67840    /* adler32(0, null, 0)*/
67841
67842    /* dictid = adler32(dictid, dictionary, dictLength); */
67843
67844    dictid = adler32(dictid, dictionary, dictLength, 0);
67845
67846    if (dictid !== state.check) {
67847      return Z_DATA_ERROR;
67848    }
67849  }
67850  /* copy dictionary to window using updatewindow(), which will amend the
67851   existing dictionary if appropriate */
67852
67853
67854  ret = updatewindow(strm, dictionary, dictLength, dictLength);
67855
67856  if (ret) {
67857    state.mode = MEM;
67858    return Z_MEM_ERROR;
67859  }
67860
67861  state.havedict = 1; // Tracev((stderr, "inflate:   dictionary set\n"));
67862
67863  return Z_OK;
67864}
67865
67866exports.inflateReset = inflateReset;
67867exports.inflateReset2 = inflateReset2;
67868exports.inflateResetKeep = inflateResetKeep;
67869exports.inflateInit = inflateInit;
67870exports.inflateInit2 = inflateInit2;
67871exports.inflate = inflate;
67872exports.inflateEnd = inflateEnd;
67873exports.inflateGetHeader = inflateGetHeader;
67874exports.inflateSetDictionary = inflateSetDictionary;
67875exports.inflateInfo = 'pako inflate (from Nodeca project)';
67876/* Not implemented
67877exports.inflateCopy = inflateCopy;
67878exports.inflateGetDictionary = inflateGetDictionary;
67879exports.inflateMark = inflateMark;
67880exports.inflatePrime = inflatePrime;
67881exports.inflateSync = inflateSync;
67882exports.inflateSyncPoint = inflateSyncPoint;
67883exports.inflateUndermine = inflateUndermine;
67884*/
67885
67886},{"../utils/common":442,"./adler32":444,"./crc32":446,"./inffast":449,"./inftrees":451}],451:[function(require,module,exports){
67887'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
67888// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
67889//
67890// This software is provided 'as-is', without any express or implied
67891// warranty. In no event will the authors be held liable for any damages
67892// arising from the use of this software.
67893//
67894// Permission is granted to anyone to use this software for any purpose,
67895// including commercial applications, and to alter it and redistribute it
67896// freely, subject to the following restrictions:
67897//
67898// 1. The origin of this software must not be misrepresented; you must not
67899//   claim that you wrote the original software. If you use this software
67900//   in a product, an acknowledgment in the product documentation would be
67901//   appreciated but is not required.
67902// 2. Altered source versions must be plainly marked as such, and must not be
67903//   misrepresented as being the original software.
67904// 3. This notice may not be removed or altered from any source distribution.
67905
67906var utils = require('../utils/common');
67907
67908var MAXBITS = 15;
67909var ENOUGH_LENS = 852;
67910var ENOUGH_DISTS = 592; //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
67911
67912var CODES = 0;
67913var LENS = 1;
67914var DISTS = 2;
67915var lbase = [
67916/* Length codes 257..285 base */
679173, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0];
67918var lext = [
67919/* Length codes 257..285 extra */
6792016, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78];
67921var dbase = [
67922/* Distance codes 0..29 base */
679231, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0];
67924var dext = [
67925/* Distance codes 0..29 extra */
6792616, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64];
67927
67928module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
67929  var bits = opts.bits; //here = opts.here; /* table entry for duplication */
67930
67931  var len = 0;
67932  /* a code's length in bits */
67933
67934  var sym = 0;
67935  /* index of code symbols */
67936
67937  var min = 0,
67938      max = 0;
67939  /* minimum and maximum code lengths */
67940
67941  var root = 0;
67942  /* number of index bits for root table */
67943
67944  var curr = 0;
67945  /* number of index bits for current table */
67946
67947  var drop = 0;
67948  /* code bits to drop for sub-table */
67949
67950  var left = 0;
67951  /* number of prefix codes available */
67952
67953  var used = 0;
67954  /* code entries in table used */
67955
67956  var huff = 0;
67957  /* Huffman code */
67958
67959  var incr;
67960  /* for incrementing code, index */
67961
67962  var fill;
67963  /* index for replicating entries */
67964
67965  var low;
67966  /* low bits for current root entry */
67967
67968  var mask;
67969  /* mask for low root bits */
67970
67971  var next;
67972  /* next available space in table */
67973
67974  var base = null;
67975  /* base value table to use */
67976
67977  var base_index = 0; //  var shoextra;    /* extra bits table to use */
67978
67979  var end;
67980  /* use base and extra for symbol > end */
67981
67982  var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1];    /* number of codes of each length */
67983
67984  var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1];     /* offsets in table for each length */
67985
67986  var extra = null;
67987  var extra_index = 0;
67988  var here_bits, here_op, here_val;
67989  /*
67990   Process a set of code lengths to create a canonical Huffman code.  The
67991   code lengths are lens[0..codes-1].  Each length corresponds to the
67992   symbols 0..codes-1.  The Huffman code is generated by first sorting the
67993   symbols by length from short to long, and retaining the symbol order
67994   for codes with equal lengths.  Then the code starts with all zero bits
67995   for the first code of the shortest length, and the codes are integer
67996   increments for the same length, and zeros are appended as the length
67997   increases.  For the deflate format, these bits are stored backwards
67998   from their more natural integer increment ordering, and so when the
67999   decoding tables are built in the large loop below, the integer codes
68000   are incremented backwards.
68001    This routine assumes, but does not check, that all of the entries in
68002   lens[] are in the range 0..MAXBITS.  The caller must assure this.
68003   1..MAXBITS is interpreted as that code length.  zero means that that
68004   symbol does not occur in this code.
68005    The codes are sorted by computing a count of codes for each length,
68006   creating from that a table of starting indices for each length in the
68007   sorted table, and then entering the symbols in order in the sorted
68008   table.  The sorted table is work[], with that space being provided by
68009   the caller.
68010    The length counts are used for other purposes as well, i.e. finding
68011   the minimum and maximum length codes, determining if there are any
68012   codes at all, checking for a valid set of lengths, and looking ahead
68013   at length counts to determine sub-table sizes when building the
68014   decoding tables.
68015   */
68016
68017  /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
68018
68019  for (len = 0; len <= MAXBITS; len++) {
68020    count[len] = 0;
68021  }
68022
68023  for (sym = 0; sym < codes; sym++) {
68024    count[lens[lens_index + sym]]++;
68025  }
68026  /* bound code lengths, force root to be within code lengths */
68027
68028
68029  root = bits;
68030
68031  for (max = MAXBITS; max >= 1; max--) {
68032    if (count[max] !== 0) {
68033      break;
68034    }
68035  }
68036
68037  if (root > max) {
68038    root = max;
68039  }
68040
68041  if (max === 0) {
68042    /* no symbols to code at all */
68043    //table.op[opts.table_index] = 64;  //here.op = (var char)64;    /* invalid code marker */
68044    //table.bits[opts.table_index] = 1;   //here.bits = (var char)1;
68045    //table.val[opts.table_index++] = 0;   //here.val = (var short)0;
68046    table[table_index++] = 1 << 24 | 64 << 16 | 0; //table.op[opts.table_index] = 64;
68047    //table.bits[opts.table_index] = 1;
68048    //table.val[opts.table_index++] = 0;
68049
68050    table[table_index++] = 1 << 24 | 64 << 16 | 0;
68051    opts.bits = 1;
68052    return 0;
68053    /* no symbols, but wait for decoding to report error */
68054  }
68055
68056  for (min = 1; min < max; min++) {
68057    if (count[min] !== 0) {
68058      break;
68059    }
68060  }
68061
68062  if (root < min) {
68063    root = min;
68064  }
68065  /* check for an over-subscribed or incomplete set of lengths */
68066
68067
68068  left = 1;
68069
68070  for (len = 1; len <= MAXBITS; len++) {
68071    left <<= 1;
68072    left -= count[len];
68073
68074    if (left < 0) {
68075      return -1;
68076    }
68077    /* over-subscribed */
68078
68079  }
68080
68081  if (left > 0 && (type === CODES || max !== 1)) {
68082    return -1;
68083    /* incomplete set */
68084  }
68085  /* generate offsets into symbol table for each length for sorting */
68086
68087
68088  offs[1] = 0;
68089
68090  for (len = 1; len < MAXBITS; len++) {
68091    offs[len + 1] = offs[len] + count[len];
68092  }
68093  /* sort symbols by length, by symbol order within each length */
68094
68095
68096  for (sym = 0; sym < codes; sym++) {
68097    if (lens[lens_index + sym] !== 0) {
68098      work[offs[lens[lens_index + sym]]++] = sym;
68099    }
68100  }
68101  /*
68102   Create and fill in decoding tables.  In this loop, the table being
68103   filled is at next and has curr index bits.  The code being used is huff
68104   with length len.  That code is converted to an index by dropping drop
68105   bits off of the bottom.  For codes where len is less than drop + curr,
68106   those top drop + curr - len bits are incremented through all values to
68107   fill the table with replicated entries.
68108    root is the number of index bits for the root table.  When len exceeds
68109   root, sub-tables are created pointed to by the root entry with an index
68110   of the low root bits of huff.  This is saved in low to check for when a
68111   new sub-table should be started.  drop is zero when the root table is
68112   being filled, and drop is root when sub-tables are being filled.
68113    When a new sub-table is needed, it is necessary to look ahead in the
68114   code lengths to determine what size sub-table is needed.  The length
68115   counts are used for this, and so count[] is decremented as codes are
68116   entered in the tables.
68117    used keeps track of how many table entries have been allocated from the
68118   provided *table space.  It is checked for LENS and DIST tables against
68119   the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
68120   the initial root table size constants.  See the comments in inftrees.h
68121   for more information.
68122    sym increments through all symbols, and the loop terminates when
68123   all codes of length max, i.e. all codes, have been processed.  This
68124   routine permits incomplete codes, so another loop after this one fills
68125   in the rest of the decoding tables with invalid code markers.
68126   */
68127
68128  /* set up for code type */
68129  // poor man optimization - use if-else instead of switch,
68130  // to avoid deopts in old v8
68131
68132
68133  if (type === CODES) {
68134    base = extra = work;
68135    /* dummy value--not used */
68136
68137    end = 19;
68138  } else if (type === LENS) {
68139    base = lbase;
68140    base_index -= 257;
68141    extra = lext;
68142    extra_index -= 257;
68143    end = 256;
68144  } else {
68145    /* DISTS */
68146    base = dbase;
68147    extra = dext;
68148    end = -1;
68149  }
68150  /* initialize opts for loop */
68151
68152
68153  huff = 0;
68154  /* starting code */
68155
68156  sym = 0;
68157  /* starting code symbol */
68158
68159  len = min;
68160  /* starting code length */
68161
68162  next = table_index;
68163  /* current table to fill in */
68164
68165  curr = root;
68166  /* current table index bits */
68167
68168  drop = 0;
68169  /* current bits to drop from code for index */
68170
68171  low = -1;
68172  /* trigger new sub-table when len > root */
68173
68174  used = 1 << root;
68175  /* use root table entries */
68176
68177  mask = used - 1;
68178  /* mask for comparing low */
68179
68180  /* check available table space */
68181
68182  if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
68183    return 1;
68184  }
68185  /* process all codes and make table entries */
68186
68187
68188  for (;;) {
68189    /* create table entry */
68190    here_bits = len - drop;
68191
68192    if (work[sym] < end) {
68193      here_op = 0;
68194      here_val = work[sym];
68195    } else if (work[sym] > end) {
68196      here_op = extra[extra_index + work[sym]];
68197      here_val = base[base_index + work[sym]];
68198    } else {
68199      here_op = 32 + 64;
68200      /* end of block */
68201
68202      here_val = 0;
68203    }
68204    /* replicate for those indices with low len bits equal to huff */
68205
68206
68207    incr = 1 << len - drop;
68208    fill = 1 << curr;
68209    min = fill;
68210    /* save offset to next table */
68211
68212    do {
68213      fill -= incr;
68214      table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
68215    } while (fill !== 0);
68216    /* backwards increment the len-bit code huff */
68217
68218
68219    incr = 1 << len - 1;
68220
68221    while (huff & incr) {
68222      incr >>= 1;
68223    }
68224
68225    if (incr !== 0) {
68226      huff &= incr - 1;
68227      huff += incr;
68228    } else {
68229      huff = 0;
68230    }
68231    /* go to next symbol, update count, len */
68232
68233
68234    sym++;
68235
68236    if (--count[len] === 0) {
68237      if (len === max) {
68238        break;
68239      }
68240
68241      len = lens[lens_index + work[sym]];
68242    }
68243    /* create new sub-table if needed */
68244
68245
68246    if (len > root && (huff & mask) !== low) {
68247      /* if first time, transition to sub-tables */
68248      if (drop === 0) {
68249        drop = root;
68250      }
68251      /* increment past last table */
68252
68253
68254      next += min;
68255      /* here min is 1 << curr */
68256
68257      /* determine length of next table */
68258
68259      curr = len - drop;
68260      left = 1 << curr;
68261
68262      while (curr + drop < max) {
68263        left -= count[curr + drop];
68264
68265        if (left <= 0) {
68266          break;
68267        }
68268
68269        curr++;
68270        left <<= 1;
68271      }
68272      /* check for enough space */
68273
68274
68275      used += 1 << curr;
68276
68277      if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
68278        return 1;
68279      }
68280      /* point entry in root table to sub-table */
68281
68282
68283      low = huff & mask;
68284      /*table.op[low] = curr;
68285      table.bits[low] = root;
68286      table.val[low] = next - opts.table_index;*/
68287
68288      table[low] = root << 24 | curr << 16 | next - table_index | 0;
68289    }
68290  }
68291  /* fill in remaining table entry if code is incomplete (guaranteed to have
68292   at most one remaining entry, since if the code is incomplete, the
68293   maximum code length that was allowed to get this far is one bit) */
68294
68295
68296  if (huff !== 0) {
68297    //table.op[next + huff] = 64;            /* invalid code marker */
68298    //table.bits[next + huff] = len - drop;
68299    //table.val[next + huff] = 0;
68300    table[next + huff] = len - drop << 24 | 64 << 16 | 0;
68301  }
68302  /* set return parameters */
68303  //opts.table_index += used;
68304
68305
68306  opts.bits = root;
68307  return 0;
68308};
68309
68310},{"../utils/common":442}],452:[function(require,module,exports){
68311'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
68312// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
68313//
68314// This software is provided 'as-is', without any express or implied
68315// warranty. In no event will the authors be held liable for any damages
68316// arising from the use of this software.
68317//
68318// Permission is granted to anyone to use this software for any purpose,
68319// including commercial applications, and to alter it and redistribute it
68320// freely, subject to the following restrictions:
68321//
68322// 1. The origin of this software must not be misrepresented; you must not
68323//   claim that you wrote the original software. If you use this software
68324//   in a product, an acknowledgment in the product documentation would be
68325//   appreciated but is not required.
68326// 2. Altered source versions must be plainly marked as such, and must not be
68327//   misrepresented as being the original software.
68328// 3. This notice may not be removed or altered from any source distribution.
68329
68330module.exports = {
68331  2: 'need dictionary',
68332
68333  /* Z_NEED_DICT       2  */
68334  1: 'stream end',
68335
68336  /* Z_STREAM_END      1  */
68337  0: '',
68338
68339  /* Z_OK              0  */
68340  '-1': 'file error',
68341
68342  /* Z_ERRNO         (-1) */
68343  '-2': 'stream error',
68344
68345  /* Z_STREAM_ERROR  (-2) */
68346  '-3': 'data error',
68347
68348  /* Z_DATA_ERROR    (-3) */
68349  '-4': 'insufficient memory',
68350
68351  /* Z_MEM_ERROR     (-4) */
68352  '-5': 'buffer error',
68353
68354  /* Z_BUF_ERROR     (-5) */
68355  '-6': 'incompatible version'
68356  /* Z_VERSION_ERROR (-6) */
68357
68358};
68359
68360},{}],453:[function(require,module,exports){
68361'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
68362// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
68363//
68364// This software is provided 'as-is', without any express or implied
68365// warranty. In no event will the authors be held liable for any damages
68366// arising from the use of this software.
68367//
68368// Permission is granted to anyone to use this software for any purpose,
68369// including commercial applications, and to alter it and redistribute it
68370// freely, subject to the following restrictions:
68371//
68372// 1. The origin of this software must not be misrepresented; you must not
68373//   claim that you wrote the original software. If you use this software
68374//   in a product, an acknowledgment in the product documentation would be
68375//   appreciated but is not required.
68376// 2. Altered source versions must be plainly marked as such, and must not be
68377//   misrepresented as being the original software.
68378// 3. This notice may not be removed or altered from any source distribution.
68379
68380/* eslint-disable space-unary-ops */
68381
68382var utils = require('../utils/common');
68383/* Public constants ==========================================================*/
68384
68385/* ===========================================================================*/
68386//var Z_FILTERED          = 1;
68387//var Z_HUFFMAN_ONLY      = 2;
68388//var Z_RLE               = 3;
68389
68390
68391var Z_FIXED = 4; //var Z_DEFAULT_STRATEGY  = 0;
68392
68393/* Possible values of the data_type field (though see inflate()) */
68394
68395var Z_BINARY = 0;
68396var Z_TEXT = 1; //var Z_ASCII             = 1; // = Z_TEXT
68397
68398var Z_UNKNOWN = 2;
68399/*============================================================================*/
68400
68401function zero(buf) {
68402  var len = buf.length;
68403
68404  while (--len >= 0) {
68405    buf[len] = 0;
68406  }
68407} // From zutil.h
68408
68409
68410var STORED_BLOCK = 0;
68411var STATIC_TREES = 1;
68412var DYN_TREES = 2;
68413/* The three kinds of block type */
68414
68415var MIN_MATCH = 3;
68416var MAX_MATCH = 258;
68417/* The minimum and maximum match lengths */
68418// From deflate.h
68419
68420/* ===========================================================================
68421 * Internal compression state.
68422 */
68423
68424var LENGTH_CODES = 29;
68425/* number of length codes, not counting the special END_BLOCK code */
68426
68427var LITERALS = 256;
68428/* number of literal bytes 0..255 */
68429
68430var L_CODES = LITERALS + 1 + LENGTH_CODES;
68431/* number of Literal or Length codes, including the END_BLOCK code */
68432
68433var D_CODES = 30;
68434/* number of distance codes */
68435
68436var BL_CODES = 19;
68437/* number of codes used to transfer the bit lengths */
68438
68439var HEAP_SIZE = 2 * L_CODES + 1;
68440/* maximum heap size */
68441
68442var MAX_BITS = 15;
68443/* All codes must not exceed MAX_BITS bits */
68444
68445var Buf_size = 16;
68446/* size of bit buffer in bi_buf */
68447
68448/* ===========================================================================
68449 * Constants
68450 */
68451
68452var MAX_BL_BITS = 7;
68453/* Bit length codes must not exceed MAX_BL_BITS bits */
68454
68455var END_BLOCK = 256;
68456/* end of block literal code */
68457
68458var REP_3_6 = 16;
68459/* repeat previous bit length 3-6 times (2 bits of repeat count) */
68460
68461var REPZ_3_10 = 17;
68462/* repeat a zero length 3-10 times  (3 bits of repeat count) */
68463
68464var REPZ_11_138 = 18;
68465/* repeat a zero length 11-138 times  (7 bits of repeat count) */
68466
68467/* eslint-disable comma-spacing,array-bracket-spacing */
68468
68469var extra_lbits =
68470/* extra bits for each length code */
68471[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0];
68472var extra_dbits =
68473/* extra bits for each distance code */
68474[0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
68475var extra_blbits =
68476/* extra bits for each bit length code */
68477[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7];
68478var bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
68479/* eslint-enable comma-spacing,array-bracket-spacing */
68480
68481/* The lengths of the bit length codes are sent in order of decreasing
68482 * probability, to avoid transmitting the lengths for unused bit length codes.
68483 */
68484
68485/* ===========================================================================
68486 * Local data. These are initialized only once.
68487 */
68488// We pre-fill arrays with 0 to avoid uninitialized gaps
68489
68490var DIST_CODE_LEN = 512;
68491/* see definition of array dist_code below */
68492// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1
68493
68494var static_ltree = new Array((L_CODES + 2) * 2);
68495zero(static_ltree);
68496/* The static literal tree. Since the bit lengths are imposed, there is no
68497 * need for the L_CODES extra codes used during heap construction. However
68498 * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
68499 * below).
68500 */
68501
68502var static_dtree = new Array(D_CODES * 2);
68503zero(static_dtree);
68504/* The static distance tree. (Actually a trivial tree since all codes use
68505 * 5 bits.)
68506 */
68507
68508var _dist_code = new Array(DIST_CODE_LEN);
68509
68510zero(_dist_code);
68511/* Distance codes. The first 256 values correspond to the distances
68512 * 3 .. 258, the last 256 values correspond to the top 8 bits of
68513 * the 15 bit distances.
68514 */
68515
68516var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);
68517
68518zero(_length_code);
68519/* length code for each normalized match length (0 == MIN_MATCH) */
68520
68521var base_length = new Array(LENGTH_CODES);
68522zero(base_length);
68523/* First normalized length for each code (0 = MIN_MATCH) */
68524
68525var base_dist = new Array(D_CODES);
68526zero(base_dist);
68527/* First normalized distance for each code (0 = distance of 1) */
68528
68529function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {
68530  this.static_tree = static_tree;
68531  /* static tree or NULL */
68532
68533  this.extra_bits = extra_bits;
68534  /* extra bits for each code or NULL */
68535
68536  this.extra_base = extra_base;
68537  /* base index for extra_bits */
68538
68539  this.elems = elems;
68540  /* max number of elements in the tree */
68541
68542  this.max_length = max_length;
68543  /* max bit length for the codes */
68544  // show if `static_tree` has data or dummy - needed for monomorphic objects
68545
68546  this.has_stree = static_tree && static_tree.length;
68547}
68548
68549var static_l_desc;
68550var static_d_desc;
68551var static_bl_desc;
68552
68553function TreeDesc(dyn_tree, stat_desc) {
68554  this.dyn_tree = dyn_tree;
68555  /* the dynamic tree */
68556
68557  this.max_code = 0;
68558  /* largest code with non zero frequency */
68559
68560  this.stat_desc = stat_desc;
68561  /* the corresponding static tree */
68562}
68563
68564function d_code(dist) {
68565  return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
68566}
68567/* ===========================================================================
68568 * Output a short LSB first on the stream.
68569 * IN assertion: there is enough room in pendingBuf.
68570 */
68571
68572
68573function put_short(s, w) {
68574  //    put_byte(s, (uch)((w) & 0xff));
68575  //    put_byte(s, (uch)((ush)(w) >> 8));
68576  s.pending_buf[s.pending++] = w & 0xff;
68577  s.pending_buf[s.pending++] = w >>> 8 & 0xff;
68578}
68579/* ===========================================================================
68580 * Send a value on a given number of bits.
68581 * IN assertion: length <= 16 and value fits in length bits.
68582 */
68583
68584
68585function send_bits(s, value, length) {
68586  if (s.bi_valid > Buf_size - length) {
68587    s.bi_buf |= value << s.bi_valid & 0xffff;
68588    put_short(s, s.bi_buf);
68589    s.bi_buf = value >> Buf_size - s.bi_valid;
68590    s.bi_valid += length - Buf_size;
68591  } else {
68592    s.bi_buf |= value << s.bi_valid & 0xffff;
68593    s.bi_valid += length;
68594  }
68595}
68596
68597function send_code(s, c, tree) {
68598  send_bits(s, tree[c * 2]
68599  /*.Code*/
68600  , tree[c * 2 + 1]
68601  /*.Len*/
68602  );
68603}
68604/* ===========================================================================
68605 * Reverse the first len bits of a code, using straightforward code (a faster
68606 * method would use a table)
68607 * IN assertion: 1 <= len <= 15
68608 */
68609
68610
68611function bi_reverse(code, len) {
68612  var res = 0;
68613
68614  do {
68615    res |= code & 1;
68616    code >>>= 1;
68617    res <<= 1;
68618  } while (--len > 0);
68619
68620  return res >>> 1;
68621}
68622/* ===========================================================================
68623 * Flush the bit buffer, keeping at most 7 bits in it.
68624 */
68625
68626
68627function bi_flush(s) {
68628  if (s.bi_valid === 16) {
68629    put_short(s, s.bi_buf);
68630    s.bi_buf = 0;
68631    s.bi_valid = 0;
68632  } else if (s.bi_valid >= 8) {
68633    s.pending_buf[s.pending++] = s.bi_buf & 0xff;
68634    s.bi_buf >>= 8;
68635    s.bi_valid -= 8;
68636  }
68637}
68638/* ===========================================================================
68639 * Compute the optimal bit lengths for a tree and update the total bit length
68640 * for the current block.
68641 * IN assertion: the fields freq and dad are set, heap[heap_max] and
68642 *    above are the tree nodes sorted by increasing frequency.
68643 * OUT assertions: the field len is set to the optimal bit length, the
68644 *     array bl_count contains the frequencies for each bit length.
68645 *     The length opt_len is updated; static_len is also updated if stree is
68646 *     not null.
68647 */
68648
68649
68650function gen_bitlen(s, desc) //    deflate_state *s;
68651//    tree_desc *desc;    /* the tree descriptor */
68652{
68653  var tree = desc.dyn_tree;
68654  var max_code = desc.max_code;
68655  var stree = desc.stat_desc.static_tree;
68656  var has_stree = desc.stat_desc.has_stree;
68657  var extra = desc.stat_desc.extra_bits;
68658  var base = desc.stat_desc.extra_base;
68659  var max_length = desc.stat_desc.max_length;
68660  var h;
68661  /* heap index */
68662
68663  var n, m;
68664  /* iterate over the tree elements */
68665
68666  var bits;
68667  /* bit length */
68668
68669  var xbits;
68670  /* extra bits */
68671
68672  var f;
68673  /* frequency */
68674
68675  var overflow = 0;
68676  /* number of elements with bit length too large */
68677
68678  for (bits = 0; bits <= MAX_BITS; bits++) {
68679    s.bl_count[bits] = 0;
68680  }
68681  /* In a first pass, compute the optimal bit lengths (which may
68682   * overflow in the case of the bit length tree).
68683   */
68684
68685
68686  tree[s.heap[s.heap_max] * 2 + 1]
68687  /*.Len*/
68688  = 0;
68689  /* root of the heap */
68690
68691  for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {
68692    n = s.heap[h];
68693    bits = tree[tree[n * 2 + 1]
68694    /*.Dad*/
68695    * 2 + 1]
68696    /*.Len*/
68697    + 1;
68698
68699    if (bits > max_length) {
68700      bits = max_length;
68701      overflow++;
68702    }
68703
68704    tree[n * 2 + 1]
68705    /*.Len*/
68706    = bits;
68707    /* We overwrite tree[n].Dad which is no longer needed */
68708
68709    if (n > max_code) {
68710      continue;
68711    }
68712    /* not a leaf node */
68713
68714
68715    s.bl_count[bits]++;
68716    xbits = 0;
68717
68718    if (n >= base) {
68719      xbits = extra[n - base];
68720    }
68721
68722    f = tree[n * 2]
68723    /*.Freq*/
68724    ;
68725    s.opt_len += f * (bits + xbits);
68726
68727    if (has_stree) {
68728      s.static_len += f * (stree[n * 2 + 1]
68729      /*.Len*/
68730      + xbits);
68731    }
68732  }
68733
68734  if (overflow === 0) {
68735    return;
68736  } // Trace((stderr,"\nbit length overflow\n"));
68737
68738  /* This happens for example on obj2 and pic of the Calgary corpus */
68739
68740  /* Find the first bit length which could increase: */
68741
68742
68743  do {
68744    bits = max_length - 1;
68745
68746    while (s.bl_count[bits] === 0) {
68747      bits--;
68748    }
68749
68750    s.bl_count[bits]--;
68751    /* move one leaf down the tree */
68752
68753    s.bl_count[bits + 1] += 2;
68754    /* move one overflow item as its brother */
68755
68756    s.bl_count[max_length]--;
68757    /* The brother of the overflow item also moves one step up,
68758     * but this does not affect bl_count[max_length]
68759     */
68760
68761    overflow -= 2;
68762  } while (overflow > 0);
68763  /* Now recompute all bit lengths, scanning in increasing frequency.
68764   * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
68765   * lengths instead of fixing only the wrong ones. This idea is taken
68766   * from 'ar' written by Haruhiko Okumura.)
68767   */
68768
68769
68770  for (bits = max_length; bits !== 0; bits--) {
68771    n = s.bl_count[bits];
68772
68773    while (n !== 0) {
68774      m = s.heap[--h];
68775
68776      if (m > max_code) {
68777        continue;
68778      }
68779
68780      if (tree[m * 2 + 1]
68781      /*.Len*/
68782      !== bits) {
68783        // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
68784        s.opt_len += (bits - tree[m * 2 + 1]
68785        /*.Len*/
68786        ) * tree[m * 2]
68787        /*.Freq*/
68788        ;
68789        tree[m * 2 + 1]
68790        /*.Len*/
68791        = bits;
68792      }
68793
68794      n--;
68795    }
68796  }
68797}
68798/* ===========================================================================
68799 * Generate the codes for a given tree and bit counts (which need not be
68800 * optimal).
68801 * IN assertion: the array bl_count contains the bit length statistics for
68802 * the given tree and the field len is set for all tree elements.
68803 * OUT assertion: the field code is set for all tree elements of non
68804 *     zero code length.
68805 */
68806
68807
68808function gen_codes(tree, max_code, bl_count) //    ct_data *tree;             /* the tree to decorate */
68809//    int max_code;              /* largest code with non zero frequency */
68810//    ushf *bl_count;            /* number of codes at each bit length */
68811{
68812  var next_code = new Array(MAX_BITS + 1);
68813  /* next code value for each bit length */
68814
68815  var code = 0;
68816  /* running code value */
68817
68818  var bits;
68819  /* bit index */
68820
68821  var n;
68822  /* code index */
68823
68824  /* The distribution counts are first used to generate the code values
68825   * without bit reversal.
68826   */
68827
68828  for (bits = 1; bits <= MAX_BITS; bits++) {
68829    next_code[bits] = code = code + bl_count[bits - 1] << 1;
68830  }
68831  /* Check that the bit counts in bl_count are consistent. The last code
68832   * must be all ones.
68833   */
68834  //Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
68835  //        "inconsistent bit counts");
68836  //Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
68837
68838
68839  for (n = 0; n <= max_code; n++) {
68840    var len = tree[n * 2 + 1]
68841    /*.Len*/
68842    ;
68843
68844    if (len === 0) {
68845      continue;
68846    }
68847    /* Now reverse the bits */
68848
68849
68850    tree[n * 2]
68851    /*.Code*/
68852    = bi_reverse(next_code[len]++, len); //Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
68853    //     n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
68854  }
68855}
68856/* ===========================================================================
68857 * Initialize the various 'constant' tables.
68858 */
68859
68860
68861function tr_static_init() {
68862  var n;
68863  /* iterates over tree elements */
68864
68865  var bits;
68866  /* bit counter */
68867
68868  var length;
68869  /* length value */
68870
68871  var code;
68872  /* code value */
68873
68874  var dist;
68875  /* distance index */
68876
68877  var bl_count = new Array(MAX_BITS + 1);
68878  /* number of codes at each bit length for an optimal tree */
68879  // do check in _tr_init()
68880  //if (static_init_done) return;
68881
68882  /* For some embedded targets, global variables are not initialized: */
68883
68884  /*#ifdef NO_INIT_GLOBAL_POINTERS
68885    static_l_desc.static_tree = static_ltree;
68886    static_l_desc.extra_bits = extra_lbits;
68887    static_d_desc.static_tree = static_dtree;
68888    static_d_desc.extra_bits = extra_dbits;
68889    static_bl_desc.extra_bits = extra_blbits;
68890  #endif*/
68891
68892  /* Initialize the mapping length (0..255) -> length code (0..28) */
68893
68894  length = 0;
68895
68896  for (code = 0; code < LENGTH_CODES - 1; code++) {
68897    base_length[code] = length;
68898
68899    for (n = 0; n < 1 << extra_lbits[code]; n++) {
68900      _length_code[length++] = code;
68901    }
68902  } //Assert (length == 256, "tr_static_init: length != 256");
68903
68904  /* Note that the length 255 (match length 258) can be represented
68905   * in two different ways: code 284 + 5 bits or code 285, so we
68906   * overwrite length_code[255] to use the best encoding:
68907   */
68908
68909
68910  _length_code[length - 1] = code;
68911  /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
68912
68913  dist = 0;
68914
68915  for (code = 0; code < 16; code++) {
68916    base_dist[code] = dist;
68917
68918    for (n = 0; n < 1 << extra_dbits[code]; n++) {
68919      _dist_code[dist++] = code;
68920    }
68921  } //Assert (dist == 256, "tr_static_init: dist != 256");
68922
68923
68924  dist >>= 7;
68925  /* from now on, all distances are divided by 128 */
68926
68927  for (; code < D_CODES; code++) {
68928    base_dist[code] = dist << 7;
68929
68930    for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {
68931      _dist_code[256 + dist++] = code;
68932    }
68933  } //Assert (dist == 256, "tr_static_init: 256+dist != 512");
68934
68935  /* Construct the codes of the static literal tree */
68936
68937
68938  for (bits = 0; bits <= MAX_BITS; bits++) {
68939    bl_count[bits] = 0;
68940  }
68941
68942  n = 0;
68943
68944  while (n <= 143) {
68945    static_ltree[n * 2 + 1]
68946    /*.Len*/
68947    = 8;
68948    n++;
68949    bl_count[8]++;
68950  }
68951
68952  while (n <= 255) {
68953    static_ltree[n * 2 + 1]
68954    /*.Len*/
68955    = 9;
68956    n++;
68957    bl_count[9]++;
68958  }
68959
68960  while (n <= 279) {
68961    static_ltree[n * 2 + 1]
68962    /*.Len*/
68963    = 7;
68964    n++;
68965    bl_count[7]++;
68966  }
68967
68968  while (n <= 287) {
68969    static_ltree[n * 2 + 1]
68970    /*.Len*/
68971    = 8;
68972    n++;
68973    bl_count[8]++;
68974  }
68975  /* Codes 286 and 287 do not exist, but we must include them in the
68976   * tree construction to get a canonical Huffman tree (longest code
68977   * all ones)
68978   */
68979
68980
68981  gen_codes(static_ltree, L_CODES + 1, bl_count);
68982  /* The static distance tree is trivial: */
68983
68984  for (n = 0; n < D_CODES; n++) {
68985    static_dtree[n * 2 + 1]
68986    /*.Len*/
68987    = 5;
68988    static_dtree[n * 2]
68989    /*.Code*/
68990    = bi_reverse(n, 5);
68991  } // Now data ready and we can init static trees
68992
68993
68994  static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);
68995  static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);
68996  static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); //static_init_done = true;
68997}
68998/* ===========================================================================
68999 * Initialize a new block.
69000 */
69001
69002
69003function init_block(s) {
69004  var n;
69005  /* iterates over tree elements */
69006
69007  /* Initialize the trees. */
69008
69009  for (n = 0; n < L_CODES; n++) {
69010    s.dyn_ltree[n * 2]
69011    /*.Freq*/
69012    = 0;
69013  }
69014
69015  for (n = 0; n < D_CODES; n++) {
69016    s.dyn_dtree[n * 2]
69017    /*.Freq*/
69018    = 0;
69019  }
69020
69021  for (n = 0; n < BL_CODES; n++) {
69022    s.bl_tree[n * 2]
69023    /*.Freq*/
69024    = 0;
69025  }
69026
69027  s.dyn_ltree[END_BLOCK * 2]
69028  /*.Freq*/
69029  = 1;
69030  s.opt_len = s.static_len = 0;
69031  s.last_lit = s.matches = 0;
69032}
69033/* ===========================================================================
69034 * Flush the bit buffer and align the output on a byte boundary
69035 */
69036
69037
69038function bi_windup(s) {
69039  if (s.bi_valid > 8) {
69040    put_short(s, s.bi_buf);
69041  } else if (s.bi_valid > 0) {
69042    //put_byte(s, (Byte)s->bi_buf);
69043    s.pending_buf[s.pending++] = s.bi_buf;
69044  }
69045
69046  s.bi_buf = 0;
69047  s.bi_valid = 0;
69048}
69049/* ===========================================================================
69050 * Copy a stored block, storing first the length and its
69051 * one's complement if requested.
69052 */
69053
69054
69055function copy_block(s, buf, len, header) //DeflateState *s;
69056//charf    *buf;    /* the input data */
69057//unsigned len;     /* its length */
69058//int      header;  /* true if block header must be written */
69059{
69060  bi_windup(s);
69061  /* align on byte boundary */
69062
69063  if (header) {
69064    put_short(s, len);
69065    put_short(s, ~len);
69066  } //  while (len--) {
69067  //    put_byte(s, *buf++);
69068  //  }
69069
69070
69071  utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);
69072  s.pending += len;
69073}
69074/* ===========================================================================
69075 * Compares to subtrees, using the tree depth as tie breaker when
69076 * the subtrees have equal frequency. This minimizes the worst case length.
69077 */
69078
69079
69080function smaller(tree, n, m, depth) {
69081  var _n2 = n * 2;
69082
69083  var _m2 = m * 2;
69084
69085  return tree[_n2]
69086  /*.Freq*/
69087  < tree[_m2]
69088  /*.Freq*/
69089  || tree[_n2]
69090  /*.Freq*/
69091  === tree[_m2]
69092  /*.Freq*/
69093  && depth[n] <= depth[m];
69094}
69095/* ===========================================================================
69096 * Restore the heap property by moving down the tree starting at node k,
69097 * exchanging a node with the smallest of its two sons if necessary, stopping
69098 * when the heap property is re-established (each father smaller than its
69099 * two sons).
69100 */
69101
69102
69103function pqdownheap(s, tree, k) //    deflate_state *s;
69104//    ct_data *tree;  /* the tree to restore */
69105//    int k;               /* node to move down */
69106{
69107  var v = s.heap[k];
69108  var j = k << 1;
69109  /* left son of k */
69110
69111  while (j <= s.heap_len) {
69112    /* Set j to the smallest of the two sons: */
69113    if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
69114      j++;
69115    }
69116    /* Exit if v is smaller than both sons */
69117
69118
69119    if (smaller(tree, v, s.heap[j], s.depth)) {
69120      break;
69121    }
69122    /* Exchange v with the smallest son */
69123
69124
69125    s.heap[k] = s.heap[j];
69126    k = j;
69127    /* And continue down the tree, setting j to the left son of k */
69128
69129    j <<= 1;
69130  }
69131
69132  s.heap[k] = v;
69133} // inlined manually
69134// var SMALLEST = 1;
69135
69136/* ===========================================================================
69137 * Send the block data compressed using the given Huffman trees
69138 */
69139
69140
69141function compress_block(s, ltree, dtree) //    deflate_state *s;
69142//    const ct_data *ltree; /* literal tree */
69143//    const ct_data *dtree; /* distance tree */
69144{
69145  var dist;
69146  /* distance of matched string */
69147
69148  var lc;
69149  /* match length or unmatched char (if dist == 0) */
69150
69151  var lx = 0;
69152  /* running index in l_buf */
69153
69154  var code;
69155  /* the code to send */
69156
69157  var extra;
69158  /* number of extra bits to send */
69159
69160  if (s.last_lit !== 0) {
69161    do {
69162      dist = s.pending_buf[s.d_buf + lx * 2] << 8 | s.pending_buf[s.d_buf + lx * 2 + 1];
69163      lc = s.pending_buf[s.l_buf + lx];
69164      lx++;
69165
69166      if (dist === 0) {
69167        send_code(s, lc, ltree);
69168        /* send a literal byte */
69169        //Tracecv(isgraph(lc), (stderr," '%c' ", lc));
69170      } else {
69171        /* Here, lc is the match length - MIN_MATCH */
69172        code = _length_code[lc];
69173        send_code(s, code + LITERALS + 1, ltree);
69174        /* send the length code */
69175
69176        extra = extra_lbits[code];
69177
69178        if (extra !== 0) {
69179          lc -= base_length[code];
69180          send_bits(s, lc, extra);
69181          /* send the extra length bits */
69182        }
69183
69184        dist--;
69185        /* dist is now the match distance - 1 */
69186
69187        code = d_code(dist); //Assert (code < D_CODES, "bad d_code");
69188
69189        send_code(s, code, dtree);
69190        /* send the distance code */
69191
69192        extra = extra_dbits[code];
69193
69194        if (extra !== 0) {
69195          dist -= base_dist[code];
69196          send_bits(s, dist, extra);
69197          /* send the extra distance bits */
69198        }
69199      }
69200      /* literal or match pair ? */
69201
69202      /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
69203      //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
69204      //       "pendingBuf overflow");
69205
69206    } while (lx < s.last_lit);
69207  }
69208
69209  send_code(s, END_BLOCK, ltree);
69210}
69211/* ===========================================================================
69212 * Construct one Huffman tree and assigns the code bit strings and lengths.
69213 * Update the total bit length for the current block.
69214 * IN assertion: the field freq is set for all tree elements.
69215 * OUT assertions: the fields len and code are set to the optimal bit length
69216 *     and corresponding code. The length opt_len is updated; static_len is
69217 *     also updated if stree is not null. The field max_code is set.
69218 */
69219
69220
69221function build_tree(s, desc) //    deflate_state *s;
69222//    tree_desc *desc; /* the tree descriptor */
69223{
69224  var tree = desc.dyn_tree;
69225  var stree = desc.stat_desc.static_tree;
69226  var has_stree = desc.stat_desc.has_stree;
69227  var elems = desc.stat_desc.elems;
69228  var n, m;
69229  /* iterate over heap elements */
69230
69231  var max_code = -1;
69232  /* largest code with non zero frequency */
69233
69234  var node;
69235  /* new node being created */
69236
69237  /* Construct the initial heap, with least frequent element in
69238   * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
69239   * heap[0] is not used.
69240   */
69241
69242  s.heap_len = 0;
69243  s.heap_max = HEAP_SIZE;
69244
69245  for (n = 0; n < elems; n++) {
69246    if (tree[n * 2]
69247    /*.Freq*/
69248    !== 0) {
69249      s.heap[++s.heap_len] = max_code = n;
69250      s.depth[n] = 0;
69251    } else {
69252      tree[n * 2 + 1]
69253      /*.Len*/
69254      = 0;
69255    }
69256  }
69257  /* The pkzip format requires that at least one distance code exists,
69258   * and that at least one bit should be sent even if there is only one
69259   * possible code. So to avoid special checks later on we force at least
69260   * two codes of non zero frequency.
69261   */
69262
69263
69264  while (s.heap_len < 2) {
69265    node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;
69266    tree[node * 2]
69267    /*.Freq*/
69268    = 1;
69269    s.depth[node] = 0;
69270    s.opt_len--;
69271
69272    if (has_stree) {
69273      s.static_len -= stree[node * 2 + 1]
69274      /*.Len*/
69275      ;
69276    }
69277    /* node is 0 or 1 so it does not have extra bits */
69278
69279  }
69280
69281  desc.max_code = max_code;
69282  /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
69283   * establish sub-heaps of increasing lengths:
69284   */
69285
69286  for (n = s.heap_len >> 1
69287  /*int /2*/
69288  ; n >= 1; n--) {
69289    pqdownheap(s, tree, n);
69290  }
69291  /* Construct the Huffman tree by repeatedly combining the least two
69292   * frequent nodes.
69293   */
69294
69295
69296  node = elems;
69297  /* next internal node of the tree */
69298
69299  do {
69300    //pqremove(s, tree, n);  /* n = node of least frequency */
69301
69302    /*** pqremove ***/
69303    n = s.heap[1
69304    /*SMALLEST*/
69305    ];
69306    s.heap[1
69307    /*SMALLEST*/
69308    ] = s.heap[s.heap_len--];
69309    pqdownheap(s, tree, 1
69310    /*SMALLEST*/
69311    );
69312    /***/
69313
69314    m = s.heap[1
69315    /*SMALLEST*/
69316    ];
69317    /* m = node of next least frequency */
69318
69319    s.heap[--s.heap_max] = n;
69320    /* keep the nodes sorted by frequency */
69321
69322    s.heap[--s.heap_max] = m;
69323    /* Create a new node father of n and m */
69324
69325    tree[node * 2]
69326    /*.Freq*/
69327    = tree[n * 2]
69328    /*.Freq*/
69329    + tree[m * 2]
69330    /*.Freq*/
69331    ;
69332    s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
69333    tree[n * 2 + 1]
69334    /*.Dad*/
69335    = tree[m * 2 + 1]
69336    /*.Dad*/
69337    = node;
69338    /* and insert the new node in the heap */
69339
69340    s.heap[1
69341    /*SMALLEST*/
69342    ] = node++;
69343    pqdownheap(s, tree, 1
69344    /*SMALLEST*/
69345    );
69346  } while (s.heap_len >= 2);
69347
69348  s.heap[--s.heap_max] = s.heap[1
69349  /*SMALLEST*/
69350  ];
69351  /* At this point, the fields freq and dad are set. We can now
69352   * generate the bit lengths.
69353   */
69354
69355  gen_bitlen(s, desc);
69356  /* The field len is now set, we can generate the bit codes */
69357
69358  gen_codes(tree, max_code, s.bl_count);
69359}
69360/* ===========================================================================
69361 * Scan a literal or distance tree to determine the frequencies of the codes
69362 * in the bit length tree.
69363 */
69364
69365
69366function scan_tree(s, tree, max_code) //    deflate_state *s;
69367//    ct_data *tree;   /* the tree to be scanned */
69368//    int max_code;    /* and its largest code of non zero frequency */
69369{
69370  var n;
69371  /* iterates over all tree elements */
69372
69373  var prevlen = -1;
69374  /* last emitted length */
69375
69376  var curlen;
69377  /* length of current code */
69378
69379  var nextlen = tree[0 * 2 + 1]
69380  /*.Len*/
69381  ;
69382  /* length of next code */
69383
69384  var count = 0;
69385  /* repeat count of the current code */
69386
69387  var max_count = 7;
69388  /* max repeat count */
69389
69390  var min_count = 4;
69391  /* min repeat count */
69392
69393  if (nextlen === 0) {
69394    max_count = 138;
69395    min_count = 3;
69396  }
69397
69398  tree[(max_code + 1) * 2 + 1]
69399  /*.Len*/
69400  = 0xffff;
69401  /* guard */
69402
69403  for (n = 0; n <= max_code; n++) {
69404    curlen = nextlen;
69405    nextlen = tree[(n + 1) * 2 + 1]
69406    /*.Len*/
69407    ;
69408
69409    if (++count < max_count && curlen === nextlen) {
69410      continue;
69411    } else if (count < min_count) {
69412      s.bl_tree[curlen * 2]
69413      /*.Freq*/
69414      += count;
69415    } else if (curlen !== 0) {
69416      if (curlen !== prevlen) {
69417        s.bl_tree[curlen * 2] /*.Freq*/++;
69418      }
69419
69420      s.bl_tree[REP_3_6 * 2] /*.Freq*/++;
69421    } else if (count <= 10) {
69422      s.bl_tree[REPZ_3_10 * 2] /*.Freq*/++;
69423    } else {
69424      s.bl_tree[REPZ_11_138 * 2] /*.Freq*/++;
69425    }
69426
69427    count = 0;
69428    prevlen = curlen;
69429
69430    if (nextlen === 0) {
69431      max_count = 138;
69432      min_count = 3;
69433    } else if (curlen === nextlen) {
69434      max_count = 6;
69435      min_count = 3;
69436    } else {
69437      max_count = 7;
69438      min_count = 4;
69439    }
69440  }
69441}
69442/* ===========================================================================
69443 * Send a literal or distance tree in compressed form, using the codes in
69444 * bl_tree.
69445 */
69446
69447
69448function send_tree(s, tree, max_code) //    deflate_state *s;
69449//    ct_data *tree; /* the tree to be scanned */
69450//    int max_code;       /* and its largest code of non zero frequency */
69451{
69452  var n;
69453  /* iterates over all tree elements */
69454
69455  var prevlen = -1;
69456  /* last emitted length */
69457
69458  var curlen;
69459  /* length of current code */
69460
69461  var nextlen = tree[0 * 2 + 1]
69462  /*.Len*/
69463  ;
69464  /* length of next code */
69465
69466  var count = 0;
69467  /* repeat count of the current code */
69468
69469  var max_count = 7;
69470  /* max repeat count */
69471
69472  var min_count = 4;
69473  /* min repeat count */
69474
69475  /* tree[max_code+1].Len = -1; */
69476
69477  /* guard already set */
69478
69479  if (nextlen === 0) {
69480    max_count = 138;
69481    min_count = 3;
69482  }
69483
69484  for (n = 0; n <= max_code; n++) {
69485    curlen = nextlen;
69486    nextlen = tree[(n + 1) * 2 + 1]
69487    /*.Len*/
69488    ;
69489
69490    if (++count < max_count && curlen === nextlen) {
69491      continue;
69492    } else if (count < min_count) {
69493      do {
69494        send_code(s, curlen, s.bl_tree);
69495      } while (--count !== 0);
69496    } else if (curlen !== 0) {
69497      if (curlen !== prevlen) {
69498        send_code(s, curlen, s.bl_tree);
69499        count--;
69500      } //Assert(count >= 3 && count <= 6, " 3_6?");
69501
69502
69503      send_code(s, REP_3_6, s.bl_tree);
69504      send_bits(s, count - 3, 2);
69505    } else if (count <= 10) {
69506      send_code(s, REPZ_3_10, s.bl_tree);
69507      send_bits(s, count - 3, 3);
69508    } else {
69509      send_code(s, REPZ_11_138, s.bl_tree);
69510      send_bits(s, count - 11, 7);
69511    }
69512
69513    count = 0;
69514    prevlen = curlen;
69515
69516    if (nextlen === 0) {
69517      max_count = 138;
69518      min_count = 3;
69519    } else if (curlen === nextlen) {
69520      max_count = 6;
69521      min_count = 3;
69522    } else {
69523      max_count = 7;
69524      min_count = 4;
69525    }
69526  }
69527}
69528/* ===========================================================================
69529 * Construct the Huffman tree for the bit lengths and return the index in
69530 * bl_order of the last bit length code to send.
69531 */
69532
69533
69534function build_bl_tree(s) {
69535  var max_blindex;
69536  /* index of last bit length code of non zero freq */
69537
69538  /* Determine the bit length frequencies for literal and distance trees */
69539
69540  scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
69541  scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
69542  /* Build the bit length tree: */
69543
69544  build_tree(s, s.bl_desc);
69545  /* opt_len now includes the length of the tree representations, except
69546   * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
69547   */
69548
69549  /* Determine the number of bit length codes to send. The pkzip format
69550   * requires that at least 4 bit length codes be sent. (appnote.txt says
69551   * 3 but the actual value used is 4.)
69552   */
69553
69554  for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {
69555    if (s.bl_tree[bl_order[max_blindex] * 2 + 1]
69556    /*.Len*/
69557    !== 0) {
69558      break;
69559    }
69560  }
69561  /* Update opt_len to include the bit length tree and counts */
69562
69563
69564  s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
69565  //        s->opt_len, s->static_len));
69566
69567  return max_blindex;
69568}
69569/* ===========================================================================
69570 * Send the header for a block using dynamic Huffman trees: the counts, the
69571 * lengths of the bit length codes, the literal tree and the distance tree.
69572 * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
69573 */
69574
69575
69576function send_all_trees(s, lcodes, dcodes, blcodes) //    deflate_state *s;
69577//    int lcodes, dcodes, blcodes; /* number of codes for each tree */
69578{
69579  var rank;
69580  /* index in bl_order */
69581  //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
69582  //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
69583  //        "too many codes");
69584  //Tracev((stderr, "\nbl counts: "));
69585
69586  send_bits(s, lcodes - 257, 5);
69587  /* not +255 as stated in appnote.txt */
69588
69589  send_bits(s, dcodes - 1, 5);
69590  send_bits(s, blcodes - 4, 4);
69591  /* not -3 as stated in appnote.txt */
69592
69593  for (rank = 0; rank < blcodes; rank++) {
69594    //Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
69595    send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]
69596    /*.Len*/
69597    , 3);
69598  } //Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
69599
69600
69601  send_tree(s, s.dyn_ltree, lcodes - 1);
69602  /* literal tree */
69603  //Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
69604
69605  send_tree(s, s.dyn_dtree, dcodes - 1);
69606  /* distance tree */
69607  //Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
69608}
69609/* ===========================================================================
69610 * Check if the data type is TEXT or BINARY, using the following algorithm:
69611 * - TEXT if the two conditions below are satisfied:
69612 *    a) There are no non-portable control characters belonging to the
69613 *       "black list" (0..6, 14..25, 28..31).
69614 *    b) There is at least one printable character belonging to the
69615 *       "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
69616 * - BINARY otherwise.
69617 * - The following partially-portable control characters form a
69618 *   "gray list" that is ignored in this detection algorithm:
69619 *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
69620 * IN assertion: the fields Freq of dyn_ltree are set.
69621 */
69622
69623
69624function detect_data_type(s) {
69625  /* black_mask is the bit mask of black-listed bytes
69626   * set bits 0..6, 14..25, and 28..31
69627   * 0xf3ffc07f = binary 11110011111111111100000001111111
69628   */
69629  var black_mask = 0xf3ffc07f;
69630  var n;
69631  /* Check for non-textual ("black-listed") bytes. */
69632
69633  for (n = 0; n <= 31; n++, black_mask >>>= 1) {
69634    if (black_mask & 1 && s.dyn_ltree[n * 2]
69635    /*.Freq*/
69636    !== 0) {
69637      return Z_BINARY;
69638    }
69639  }
69640  /* Check for textual ("white-listed") bytes. */
69641
69642
69643  if (s.dyn_ltree[9 * 2]
69644  /*.Freq*/
69645  !== 0 || s.dyn_ltree[10 * 2]
69646  /*.Freq*/
69647  !== 0 || s.dyn_ltree[13 * 2]
69648  /*.Freq*/
69649  !== 0) {
69650    return Z_TEXT;
69651  }
69652
69653  for (n = 32; n < LITERALS; n++) {
69654    if (s.dyn_ltree[n * 2]
69655    /*.Freq*/
69656    !== 0) {
69657      return Z_TEXT;
69658    }
69659  }
69660  /* There are no "black-listed" or "white-listed" bytes:
69661   * this stream either is empty or has tolerated ("gray-listed") bytes only.
69662   */
69663
69664
69665  return Z_BINARY;
69666}
69667
69668var static_init_done = false;
69669/* ===========================================================================
69670 * Initialize the tree data structures for a new zlib stream.
69671 */
69672
69673function _tr_init(s) {
69674  if (!static_init_done) {
69675    tr_static_init();
69676    static_init_done = true;
69677  }
69678
69679  s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);
69680  s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);
69681  s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);
69682  s.bi_buf = 0;
69683  s.bi_valid = 0;
69684  /* Initialize the first block of the first file: */
69685
69686  init_block(s);
69687}
69688/* ===========================================================================
69689 * Send a stored block
69690 */
69691
69692
69693function _tr_stored_block(s, buf, stored_len, last) //DeflateState *s;
69694//charf *buf;       /* input block */
69695//ulg stored_len;   /* length of input block */
69696//int last;         /* one if this is the last block for a file */
69697{
69698  send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);
69699  /* send block type */
69700
69701  copy_block(s, buf, stored_len, true);
69702  /* with header */
69703}
69704/* ===========================================================================
69705 * Send one empty static block to give enough lookahead for inflate.
69706 * This takes 10 bits, of which 7 may remain in the bit buffer.
69707 */
69708
69709
69710function _tr_align(s) {
69711  send_bits(s, STATIC_TREES << 1, 3);
69712  send_code(s, END_BLOCK, static_ltree);
69713  bi_flush(s);
69714}
69715/* ===========================================================================
69716 * Determine the best encoding for the current block: dynamic trees, static
69717 * trees or store, and output the encoded block to the zip file.
69718 */
69719
69720
69721function _tr_flush_block(s, buf, stored_len, last) //DeflateState *s;
69722//charf *buf;       /* input block, or NULL if too old */
69723//ulg stored_len;   /* length of input block */
69724//int last;         /* one if this is the last block for a file */
69725{
69726  var opt_lenb, static_lenb;
69727  /* opt_len and static_len in bytes */
69728
69729  var max_blindex = 0;
69730  /* index of last bit length code of non zero freq */
69731
69732  /* Build the Huffman trees unless a stored block is forced */
69733
69734  if (s.level > 0) {
69735    /* Check if the file is binary or text */
69736    if (s.strm.data_type === Z_UNKNOWN) {
69737      s.strm.data_type = detect_data_type(s);
69738    }
69739    /* Construct the literal and distance trees */
69740
69741
69742    build_tree(s, s.l_desc); // Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
69743    //        s->static_len));
69744
69745    build_tree(s, s.d_desc); // Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
69746    //        s->static_len));
69747
69748    /* At this point, opt_len and static_len are the total bit lengths of
69749     * the compressed block data, excluding the tree representations.
69750     */
69751
69752    /* Build the bit length tree for the above two trees, and get the index
69753     * in bl_order of the last bit length code to send.
69754     */
69755
69756    max_blindex = build_bl_tree(s);
69757    /* Determine the best encoding. Compute the block lengths in bytes. */
69758
69759    opt_lenb = s.opt_len + 3 + 7 >>> 3;
69760    static_lenb = s.static_len + 3 + 7 >>> 3; // Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
69761    //        opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
69762    //        s->last_lit));
69763
69764    if (static_lenb <= opt_lenb) {
69765      opt_lenb = static_lenb;
69766    }
69767  } else {
69768    // Assert(buf != (char*)0, "lost buf");
69769    opt_lenb = static_lenb = stored_len + 5;
69770    /* force a stored block */
69771  }
69772
69773  if (stored_len + 4 <= opt_lenb && buf !== -1) {
69774    /* 4: two words for the lengths */
69775
69776    /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
69777     * Otherwise we can't have processed more than WSIZE input bytes since
69778     * the last block flush, because compression would have been
69779     * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
69780     * transform a block into a stored block.
69781     */
69782    _tr_stored_block(s, buf, stored_len, last);
69783  } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {
69784    send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);
69785    compress_block(s, static_ltree, static_dtree);
69786  } else {
69787    send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);
69788    send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);
69789    compress_block(s, s.dyn_ltree, s.dyn_dtree);
69790  } // Assert (s->compressed_len == s->bits_sent, "bad compressed size");
69791
69792  /* The above check is made mod 2^32, for files larger than 512 MB
69793   * and uLong implemented on 32 bits.
69794   */
69795
69796
69797  init_block(s);
69798
69799  if (last) {
69800    bi_windup(s);
69801  } // Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
69802  //       s->compressed_len-7*last));
69803
69804}
69805/* ===========================================================================
69806 * Save the match info and tally the frequency counts. Return true if
69807 * the current block must be flushed.
69808 */
69809
69810
69811function _tr_tally(s, dist, lc) //    deflate_state *s;
69812//    unsigned dist;  /* distance of matched string */
69813//    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */
69814{
69815  //var out_length, in_length, dcode;
69816  s.pending_buf[s.d_buf + s.last_lit * 2] = dist >>> 8 & 0xff;
69817  s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;
69818  s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
69819  s.last_lit++;
69820
69821  if (dist === 0) {
69822    /* lc is the unmatched char */
69823    s.dyn_ltree[lc * 2] /*.Freq*/++;
69824  } else {
69825    s.matches++;
69826    /* Here, lc is the match length - MIN_MATCH */
69827
69828    dist--;
69829    /* dist = match distance - 1 */
69830    //Assert((ush)dist < (ush)MAX_DIST(s) &&
69831    //       (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
69832    //       (ush)d_code(dist) < (ush)D_CODES,  "_tr_tally: bad match");
69833
69834    s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2] /*.Freq*/++;
69835    s.dyn_dtree[d_code(dist) * 2] /*.Freq*/++;
69836  } // (!) This block is disabled in zlib defaults,
69837  // don't enable it for binary compatibility
69838  //#ifdef TRUNCATE_BLOCK
69839  //  /* Try to guess if it is profitable to stop the current block here */
69840  //  if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {
69841  //    /* Compute an upper bound for the compressed length */
69842  //    out_length = s.last_lit*8;
69843  //    in_length = s.strstart - s.block_start;
69844  //
69845  //    for (dcode = 0; dcode < D_CODES; dcode++) {
69846  //      out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);
69847  //    }
69848  //    out_length >>>= 3;
69849  //    //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
69850  //    //       s->last_lit, in_length, out_length,
69851  //    //       100L - out_length*100L/in_length));
69852  //    if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {
69853  //      return true;
69854  //    }
69855  //  }
69856  //#endif
69857
69858
69859  return s.last_lit === s.lit_bufsize - 1;
69860  /* We avoid equality with lit_bufsize because of wraparound at 64K
69861   * on 16 bit machines and because stored blocks are restricted to
69862   * 64K-1 bytes.
69863   */
69864}
69865
69866exports._tr_init = _tr_init;
69867exports._tr_stored_block = _tr_stored_block;
69868exports._tr_flush_block = _tr_flush_block;
69869exports._tr_tally = _tr_tally;
69870exports._tr_align = _tr_align;
69871
69872},{"../utils/common":442}],454:[function(require,module,exports){
69873'use strict'; // (C) 1995-2013 Jean-loup Gailly and Mark Adler
69874// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
69875//
69876// This software is provided 'as-is', without any express or implied
69877// warranty. In no event will the authors be held liable for any damages
69878// arising from the use of this software.
69879//
69880// Permission is granted to anyone to use this software for any purpose,
69881// including commercial applications, and to alter it and redistribute it
69882// freely, subject to the following restrictions:
69883//
69884// 1. The origin of this software must not be misrepresented; you must not
69885//   claim that you wrote the original software. If you use this software
69886//   in a product, an acknowledgment in the product documentation would be
69887//   appreciated but is not required.
69888// 2. Altered source versions must be plainly marked as such, and must not be
69889//   misrepresented as being the original software.
69890// 3. This notice may not be removed or altered from any source distribution.
69891
69892function ZStream() {
69893  /* next input byte */
69894  this.input = null; // JS specific, because we have no pointers
69895
69896  this.next_in = 0;
69897  /* number of bytes available at input */
69898
69899  this.avail_in = 0;
69900  /* total number of input bytes read so far */
69901
69902  this.total_in = 0;
69903  /* next output byte should be put there */
69904
69905  this.output = null; // JS specific, because we have no pointers
69906
69907  this.next_out = 0;
69908  /* remaining free space at output */
69909
69910  this.avail_out = 0;
69911  /* total number of bytes output so far */
69912
69913  this.total_out = 0;
69914  /* last error message, NULL if no error */
69915
69916  this.msg = ''
69917  /*Z_NULL*/
69918  ;
69919  /* not visible by applications */
69920
69921  this.state = null;
69922  /* best guess about the data type: binary or text */
69923
69924  this.data_type = 2
69925  /*Z_UNKNOWN*/
69926  ;
69927  /* adler32 value of the uncompressed data */
69928
69929  this.adler = 0;
69930}
69931
69932module.exports = ZStream;
69933
69934},{}],455:[function(require,module,exports){
69935module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb",
69936"2.16.840.1.101.3.4.1.2": "aes-128-cbc",
69937"2.16.840.1.101.3.4.1.3": "aes-128-ofb",
69938"2.16.840.1.101.3.4.1.4": "aes-128-cfb",
69939"2.16.840.1.101.3.4.1.21": "aes-192-ecb",
69940"2.16.840.1.101.3.4.1.22": "aes-192-cbc",
69941"2.16.840.1.101.3.4.1.23": "aes-192-ofb",
69942"2.16.840.1.101.3.4.1.24": "aes-192-cfb",
69943"2.16.840.1.101.3.4.1.41": "aes-256-ecb",
69944"2.16.840.1.101.3.4.1.42": "aes-256-cbc",
69945"2.16.840.1.101.3.4.1.43": "aes-256-ofb",
69946"2.16.840.1.101.3.4.1.44": "aes-256-cfb"
69947}
69948},{}],456:[function(require,module,exports){
69949// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
69950// Fedor, you are amazing.
69951'use strict';
69952
69953var asn1 = require('asn1.js');
69954
69955exports.certificate = require('./certificate');
69956var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
69957  this.seq().obj(this.key('version').int(), this.key('modulus').int(), this.key('publicExponent').int(), this.key('privateExponent').int(), this.key('prime1').int(), this.key('prime2').int(), this.key('exponent1').int(), this.key('exponent2').int(), this.key('coefficient').int());
69958});
69959exports.RSAPrivateKey = RSAPrivateKey;
69960var RSAPublicKey = asn1.define('RSAPublicKey', function () {
69961  this.seq().obj(this.key('modulus').int(), this.key('publicExponent').int());
69962});
69963exports.RSAPublicKey = RSAPublicKey;
69964var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
69965  this.seq().obj(this.key('algorithm').use(AlgorithmIdentifier), this.key('subjectPublicKey').bitstr());
69966});
69967exports.PublicKey = PublicKey;
69968var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
69969  this.seq().obj(this.key('algorithm').objid(), this.key('none').null_().optional(), this.key('curve').objid().optional(), this.key('params').seq().obj(this.key('p').int(), this.key('q').int(), this.key('g').int()).optional());
69970});
69971var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
69972  this.seq().obj(this.key('version').int(), this.key('algorithm').use(AlgorithmIdentifier), this.key('subjectPrivateKey').octstr());
69973});
69974exports.PrivateKey = PrivateKeyInfo;
69975var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
69976  this.seq().obj(this.key('algorithm').seq().obj(this.key('id').objid(), this.key('decrypt').seq().obj(this.key('kde').seq().obj(this.key('id').objid(), this.key('kdeparams').seq().obj(this.key('salt').octstr(), this.key('iters').int())), this.key('cipher').seq().obj(this.key('algo').objid(), this.key('iv').octstr()))), this.key('subjectPrivateKey').octstr());
69977});
69978exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo;
69979var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
69980  this.seq().obj(this.key('version').int(), this.key('p').int(), this.key('q').int(), this.key('g').int(), this.key('pub_key').int(), this.key('priv_key').int());
69981});
69982exports.DSAPrivateKey = DSAPrivateKey;
69983exports.DSAparam = asn1.define('DSAparam', function () {
69984  this.int();
69985});
69986var ECPrivateKey = asn1.define('ECPrivateKey', function () {
69987  this.seq().obj(this.key('version').int(), this.key('privateKey').octstr(), this.key('parameters').optional().explicit(0).use(ECParameters), this.key('publicKey').optional().explicit(1).bitstr());
69988});
69989exports.ECPrivateKey = ECPrivateKey;
69990var ECParameters = asn1.define('ECParameters', function () {
69991  this.choice({
69992    namedCurve: this.objid()
69993  });
69994});
69995exports.signature = asn1.define('signature', function () {
69996  this.seq().obj(this.key('r').int(), this.key('s').int());
69997});
69998
69999},{"./certificate":457,"asn1.js":167}],457:[function(require,module,exports){
70000// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
70001// thanks to @Rantanen
70002'use strict';
70003
70004var asn = require('asn1.js');
70005
70006var Time = asn.define('Time', function () {
70007  this.choice({
70008    utcTime: this.utctime(),
70009    generalTime: this.gentime()
70010  });
70011});
70012var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
70013  this.seq().obj(this.key('type').objid(), this.key('value').any());
70014});
70015var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
70016  this.seq().obj(this.key('algorithm').objid(), this.key('parameters').optional(), this.key('curve').objid().optional());
70017});
70018var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
70019  this.seq().obj(this.key('algorithm').use(AlgorithmIdentifier), this.key('subjectPublicKey').bitstr());
70020});
70021var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
70022  this.setof(AttributeTypeValue);
70023});
70024var RDNSequence = asn.define('RDNSequence', function () {
70025  this.seqof(RelativeDistinguishedName);
70026});
70027var Name = asn.define('Name', function () {
70028  this.choice({
70029    rdnSequence: this.use(RDNSequence)
70030  });
70031});
70032var Validity = asn.define('Validity', function () {
70033  this.seq().obj(this.key('notBefore').use(Time), this.key('notAfter').use(Time));
70034});
70035var Extension = asn.define('Extension', function () {
70036  this.seq().obj(this.key('extnID').objid(), this.key('critical').bool().def(false), this.key('extnValue').octstr());
70037});
70038var TBSCertificate = asn.define('TBSCertificate', function () {
70039  this.seq().obj(this.key('version').explicit(0).int().optional(), this.key('serialNumber').int(), this.key('signature').use(AlgorithmIdentifier), this.key('issuer').use(Name), this.key('validity').use(Validity), this.key('subject').use(Name), this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), this.key('issuerUniqueID').implicit(1).bitstr().optional(), this.key('subjectUniqueID').implicit(2).bitstr().optional(), this.key('extensions').explicit(3).seqof(Extension).optional());
70040});
70041var X509Certificate = asn.define('X509Certificate', function () {
70042  this.seq().obj(this.key('tbsCertificate').use(TBSCertificate), this.key('signatureAlgorithm').use(AlgorithmIdentifier), this.key('signatureValue').bitstr());
70043});
70044module.exports = X509Certificate;
70045
70046},{"asn1.js":167}],458:[function(require,module,exports){
70047"use strict";
70048
70049// adapted from https://github.com/apatil/pemstrip
70050var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m;
70051var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m;
70052var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m;
70053
70054var evp = require('evp_bytestokey');
70055
70056var ciphers = require('browserify-aes');
70057
70058var Buffer = require('safe-buffer').Buffer;
70059
70060module.exports = function (okey, password) {
70061  var key = okey.toString();
70062  var match = key.match(findProc);
70063  var decrypted;
70064
70065  if (!match) {
70066    var match2 = key.match(fullRegex);
70067    decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64');
70068  } else {
70069    var suite = 'aes' + match[1];
70070    var iv = Buffer.from(match[2], 'hex');
70071    var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64');
70072    var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key;
70073    var out = [];
70074    var cipher = ciphers.createDecipheriv(suite, cipherKey, iv);
70075    out.push(cipher.update(cipherText));
70076    out.push(cipher.final());
70077    decrypted = Buffer.concat(out);
70078  }
70079
70080  var tag = key.match(startRegex)[1];
70081  return {
70082    tag: tag,
70083    data: decrypted
70084  };
70085};
70086
70087},{"browserify-aes":188,"evp_bytestokey":368,"safe-buffer":494}],459:[function(require,module,exports){
70088"use strict";
70089
70090function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
70091
70092var asn1 = require('./asn1');
70093
70094var aesid = require('./aesid.json');
70095
70096var fixProc = require('./fixProc');
70097
70098var ciphers = require('browserify-aes');
70099
70100var compat = require('pbkdf2');
70101
70102var Buffer = require('safe-buffer').Buffer;
70103
70104module.exports = parseKeys;
70105
70106function parseKeys(buffer) {
70107  var password;
70108
70109  if (_typeof(buffer) === 'object' && !Buffer.isBuffer(buffer)) {
70110    password = buffer.passphrase;
70111    buffer = buffer.key;
70112  }
70113
70114  if (typeof buffer === 'string') {
70115    buffer = Buffer.from(buffer);
70116  }
70117
70118  var stripped = fixProc(buffer, password);
70119  var type = stripped.tag;
70120  var data = stripped.data;
70121  var subtype, ndata;
70122
70123  switch (type) {
70124    case 'CERTIFICATE':
70125      ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo;
70126    // falls through
70127
70128    case 'PUBLIC KEY':
70129      if (!ndata) {
70130        ndata = asn1.PublicKey.decode(data, 'der');
70131      }
70132
70133      subtype = ndata.algorithm.algorithm.join('.');
70134
70135      switch (subtype) {
70136        case '1.2.840.113549.1.1.1':
70137          return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der');
70138
70139        case '1.2.840.10045.2.1':
70140          ndata.subjectPrivateKey = ndata.subjectPublicKey;
70141          return {
70142            type: 'ec',
70143            data: ndata
70144          };
70145
70146        case '1.2.840.10040.4.1':
70147          ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der');
70148          return {
70149            type: 'dsa',
70150            data: ndata.algorithm.params
70151          };
70152
70153        default:
70154          throw new Error('unknown key id ' + subtype);
70155      }
70156
70157    // throw new Error('unknown key type ' + type)
70158
70159    case 'ENCRYPTED PRIVATE KEY':
70160      data = asn1.EncryptedPrivateKey.decode(data, 'der');
70161      data = decrypt(data, password);
70162    // falls through
70163
70164    case 'PRIVATE KEY':
70165      ndata = asn1.PrivateKey.decode(data, 'der');
70166      subtype = ndata.algorithm.algorithm.join('.');
70167
70168      switch (subtype) {
70169        case '1.2.840.113549.1.1.1':
70170          return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der');
70171
70172        case '1.2.840.10045.2.1':
70173          return {
70174            curve: ndata.algorithm.curve,
70175            privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
70176          };
70177
70178        case '1.2.840.10040.4.1':
70179          ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der');
70180          return {
70181            type: 'dsa',
70182            params: ndata.algorithm.params
70183          };
70184
70185        default:
70186          throw new Error('unknown key id ' + subtype);
70187      }
70188
70189    // throw new Error('unknown key type ' + type)
70190
70191    case 'RSA PUBLIC KEY':
70192      return asn1.RSAPublicKey.decode(data, 'der');
70193
70194    case 'RSA PRIVATE KEY':
70195      return asn1.RSAPrivateKey.decode(data, 'der');
70196
70197    case 'DSA PRIVATE KEY':
70198      return {
70199        type: 'dsa',
70200        params: asn1.DSAPrivateKey.decode(data, 'der')
70201      };
70202
70203    case 'EC PRIVATE KEY':
70204      data = asn1.ECPrivateKey.decode(data, 'der');
70205      return {
70206        curve: data.parameters.value,
70207        privateKey: data.privateKey
70208      };
70209
70210    default:
70211      throw new Error('unknown key type ' + type);
70212  }
70213}
70214
70215parseKeys.signature = asn1.signature;
70216
70217function decrypt(data, password) {
70218  var salt = data.algorithm.decrypt.kde.kdeparams.salt;
70219  var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10);
70220  var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')];
70221  var iv = data.algorithm.decrypt.cipher.iv;
70222  var cipherText = data.subjectPrivateKey;
70223  var keylen = parseInt(algo.split('-')[1], 10) / 8;
70224  var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1');
70225  var cipher = ciphers.createDecipheriv(algo, key, iv);
70226  var out = [];
70227  out.push(cipher.update(cipherText));
70228  out.push(cipher.final());
70229  return Buffer.concat(out);
70230}
70231
70232},{"./aesid.json":455,"./asn1":456,"./fixProc":458,"browserify-aes":188,"pbkdf2":460,"safe-buffer":494}],460:[function(require,module,exports){
70233"use strict";
70234
70235exports.pbkdf2 = require('./lib/async');
70236exports.pbkdf2Sync = require('./lib/sync');
70237
70238},{"./lib/async":461,"./lib/sync":464}],461:[function(require,module,exports){
70239(function (process,global){
70240"use strict";
70241
70242var Buffer = require('safe-buffer').Buffer;
70243
70244var checkParameters = require('./precondition');
70245
70246var defaultEncoding = require('./default-encoding');
70247
70248var sync = require('./sync');
70249
70250var toBuffer = require('./to-buffer');
70251
70252var ZERO_BUF;
70253var subtle = global.crypto && global.crypto.subtle;
70254var toBrowser = {
70255  sha: 'SHA-1',
70256  'sha-1': 'SHA-1',
70257  sha1: 'SHA-1',
70258  sha256: 'SHA-256',
70259  'sha-256': 'SHA-256',
70260  sha384: 'SHA-384',
70261  'sha-384': 'SHA-384',
70262  'sha-512': 'SHA-512',
70263  sha512: 'SHA-512'
70264};
70265var checks = [];
70266
70267function checkNative(algo) {
70268  if (global.process && !global.process.browser) {
70269    return Promise.resolve(false);
70270  }
70271
70272  if (!subtle || !subtle.importKey || !subtle.deriveBits) {
70273    return Promise.resolve(false);
70274  }
70275
70276  if (checks[algo] !== undefined) {
70277    return checks[algo];
70278  }
70279
70280  ZERO_BUF = ZERO_BUF || Buffer.alloc(8);
70281  var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo).then(function () {
70282    return true;
70283  }).catch(function () {
70284    return false;
70285  });
70286  checks[algo] = prom;
70287  return prom;
70288}
70289
70290function browserPbkdf2(password, salt, iterations, length, algo) {
70291  return subtle.importKey('raw', password, {
70292    name: 'PBKDF2'
70293  }, false, ['deriveBits']).then(function (key) {
70294    return subtle.deriveBits({
70295      name: 'PBKDF2',
70296      salt: salt,
70297      iterations: iterations,
70298      hash: {
70299        name: algo
70300      }
70301    }, key, length << 3);
70302  }).then(function (res) {
70303    return Buffer.from(res);
70304  });
70305}
70306
70307function resolvePromise(promise, callback) {
70308  promise.then(function (out) {
70309    process.nextTick(function () {
70310      callback(null, out);
70311    });
70312  }, function (e) {
70313    process.nextTick(function () {
70314      callback(e);
70315    });
70316  });
70317}
70318
70319module.exports = function (password, salt, iterations, keylen, digest, callback) {
70320  if (typeof digest === 'function') {
70321    callback = digest;
70322    digest = undefined;
70323  }
70324
70325  digest = digest || 'sha1';
70326  var algo = toBrowser[digest.toLowerCase()];
70327
70328  if (!algo || typeof global.Promise !== 'function') {
70329    return process.nextTick(function () {
70330      var out;
70331
70332      try {
70333        out = sync(password, salt, iterations, keylen, digest);
70334      } catch (e) {
70335        return callback(e);
70336      }
70337
70338      callback(null, out);
70339    });
70340  }
70341
70342  checkParameters(iterations, keylen);
70343  password = toBuffer(password, defaultEncoding, 'Password');
70344  salt = toBuffer(salt, defaultEncoding, 'Salt');
70345  if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2');
70346  resolvePromise(checkNative(algo).then(function (resp) {
70347    if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo);
70348    return sync(password, salt, iterations, keylen, digest);
70349  }), callback);
70350};
70351
70352}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
70353
70354},{"./default-encoding":462,"./precondition":463,"./sync":464,"./to-buffer":465,"_process":467,"safe-buffer":494}],462:[function(require,module,exports){
70355(function (process){
70356"use strict";
70357
70358var defaultEncoding;
70359/* istanbul ignore next */
70360
70361if (process.browser) {
70362  defaultEncoding = 'utf-8';
70363} else if (process.version) {
70364  var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10);
70365  defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary';
70366} else {
70367  defaultEncoding = 'utf-8';
70368}
70369
70370module.exports = defaultEncoding;
70371
70372}).call(this,require('_process'))
70373
70374},{"_process":467}],463:[function(require,module,exports){
70375"use strict";
70376
70377var MAX_ALLOC = Math.pow(2, 30) - 1; // default in iojs
70378
70379module.exports = function (iterations, keylen) {
70380  if (typeof iterations !== 'number') {
70381    throw new TypeError('Iterations not a number');
70382  }
70383
70384  if (iterations < 0) {
70385    throw new TypeError('Bad iterations');
70386  }
70387
70388  if (typeof keylen !== 'number') {
70389    throw new TypeError('Key length not a number');
70390  }
70391
70392  if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) {
70393    /* eslint no-self-compare: 0 */
70394    throw new TypeError('Bad key length');
70395  }
70396};
70397
70398},{}],464:[function(require,module,exports){
70399"use strict";
70400
70401var md5 = require('create-hash/md5');
70402
70403var RIPEMD160 = require('ripemd160');
70404
70405var sha = require('sha.js');
70406
70407var Buffer = require('safe-buffer').Buffer;
70408
70409var checkParameters = require('./precondition');
70410
70411var defaultEncoding = require('./default-encoding');
70412
70413var toBuffer = require('./to-buffer');
70414
70415var ZEROS = Buffer.alloc(128);
70416var sizes = {
70417  md5: 16,
70418  sha1: 20,
70419  sha224: 28,
70420  sha256: 32,
70421  sha384: 48,
70422  sha512: 64,
70423  rmd160: 20,
70424  ripemd160: 20
70425};
70426
70427function Hmac(alg, key, saltLen) {
70428  var hash = getDigest(alg);
70429  var blocksize = alg === 'sha512' || alg === 'sha384' ? 128 : 64;
70430
70431  if (key.length > blocksize) {
70432    key = hash(key);
70433  } else if (key.length < blocksize) {
70434    key = Buffer.concat([key, ZEROS], blocksize);
70435  }
70436
70437  var ipad = Buffer.allocUnsafe(blocksize + sizes[alg]);
70438  var opad = Buffer.allocUnsafe(blocksize + sizes[alg]);
70439
70440  for (var i = 0; i < blocksize; i++) {
70441    ipad[i] = key[i] ^ 0x36;
70442    opad[i] = key[i] ^ 0x5C;
70443  }
70444
70445  var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4);
70446  ipad.copy(ipad1, 0, 0, blocksize);
70447  this.ipad1 = ipad1;
70448  this.ipad2 = ipad;
70449  this.opad = opad;
70450  this.alg = alg;
70451  this.blocksize = blocksize;
70452  this.hash = hash;
70453  this.size = sizes[alg];
70454}
70455
70456Hmac.prototype.run = function (data, ipad) {
70457  data.copy(ipad, this.blocksize);
70458  var h = this.hash(ipad);
70459  h.copy(this.opad, this.blocksize);
70460  return this.hash(this.opad);
70461};
70462
70463function getDigest(alg) {
70464  function shaFunc(data) {
70465    return sha(alg).update(data).digest();
70466  }
70467
70468  function rmd160Func(data) {
70469    return new RIPEMD160().update(data).digest();
70470  }
70471
70472  if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func;
70473  if (alg === 'md5') return md5;
70474  return shaFunc;
70475}
70476
70477function pbkdf2(password, salt, iterations, keylen, digest) {
70478  checkParameters(iterations, keylen);
70479  password = toBuffer(password, defaultEncoding, 'Password');
70480  salt = toBuffer(salt, defaultEncoding, 'Salt');
70481  digest = digest || 'sha1';
70482  var hmac = new Hmac(digest, password, salt.length);
70483  var DK = Buffer.allocUnsafe(keylen);
70484  var block1 = Buffer.allocUnsafe(salt.length + 4);
70485  salt.copy(block1, 0, 0, salt.length);
70486  var destPos = 0;
70487  var hLen = sizes[digest];
70488  var l = Math.ceil(keylen / hLen);
70489
70490  for (var i = 1; i <= l; i++) {
70491    block1.writeUInt32BE(i, salt.length);
70492    var T = hmac.run(block1, hmac.ipad1);
70493    var U = T;
70494
70495    for (var j = 1; j < iterations; j++) {
70496      U = hmac.run(U, hmac.ipad2);
70497
70498      for (var k = 0; k < hLen; k++) {
70499        T[k] ^= U[k];
70500      }
70501    }
70502
70503    T.copy(DK, destPos);
70504    destPos += hLen;
70505  }
70506
70507  return DK;
70508}
70509
70510module.exports = pbkdf2;
70511
70512},{"./default-encoding":462,"./precondition":463,"./to-buffer":465,"create-hash/md5":332,"ripemd160":493,"safe-buffer":494,"sha.js":499}],465:[function(require,module,exports){
70513"use strict";
70514
70515var Buffer = require('safe-buffer').Buffer;
70516
70517module.exports = function (thing, encoding, name) {
70518  if (Buffer.isBuffer(thing)) {
70519    return thing;
70520  } else if (typeof thing === 'string') {
70521    return Buffer.from(thing, encoding);
70522  } else if (ArrayBuffer.isView(thing)) {
70523    return Buffer.from(thing.buffer);
70524  } else {
70525    throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView');
70526  }
70527};
70528
70529},{"safe-buffer":494}],466:[function(require,module,exports){
70530(function (process){
70531'use strict';
70532
70533if (typeof process === 'undefined' || !process.version || process.version.indexOf('v0.') === 0 || process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
70534  module.exports = {
70535    nextTick: nextTick
70536  };
70537} else {
70538  module.exports = process;
70539}
70540
70541function nextTick(fn, arg1, arg2, arg3) {
70542  if (typeof fn !== 'function') {
70543    throw new TypeError('"callback" argument must be a function');
70544  }
70545
70546  var len = arguments.length;
70547  var args, i;
70548
70549  switch (len) {
70550    case 0:
70551    case 1:
70552      return process.nextTick(fn);
70553
70554    case 2:
70555      return process.nextTick(function afterTickOne() {
70556        fn.call(null, arg1);
70557      });
70558
70559    case 3:
70560      return process.nextTick(function afterTickTwo() {
70561        fn.call(null, arg1, arg2);
70562      });
70563
70564    case 4:
70565      return process.nextTick(function afterTickThree() {
70566        fn.call(null, arg1, arg2, arg3);
70567      });
70568
70569    default:
70570      args = new Array(len - 1);
70571      i = 0;
70572
70573      while (i < args.length) {
70574        args[i++] = arguments[i];
70575      }
70576
70577      return process.nextTick(function afterTick() {
70578        fn.apply(null, args);
70579      });
70580  }
70581}
70582
70583}).call(this,require('_process'))
70584
70585},{"_process":467}],467:[function(require,module,exports){
70586"use strict";
70587
70588// shim for using process in browser
70589var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it
70590// don't break things.  But we need to wrap it in a try catch in case it is
70591// wrapped in strict mode code which doesn't define any globals.  It's inside a
70592// function because try/catches deoptimize in certain engines.
70593
70594var cachedSetTimeout;
70595var cachedClearTimeout;
70596
70597function defaultSetTimout() {
70598  throw new Error('setTimeout has not been defined');
70599}
70600
70601function defaultClearTimeout() {
70602  throw new Error('clearTimeout has not been defined');
70603}
70604
70605(function () {
70606  try {
70607    if (typeof setTimeout === 'function') {
70608      cachedSetTimeout = setTimeout;
70609    } else {
70610      cachedSetTimeout = defaultSetTimout;
70611    }
70612  } catch (e) {
70613    cachedSetTimeout = defaultSetTimout;
70614  }
70615
70616  try {
70617    if (typeof clearTimeout === 'function') {
70618      cachedClearTimeout = clearTimeout;
70619    } else {
70620      cachedClearTimeout = defaultClearTimeout;
70621    }
70622  } catch (e) {
70623    cachedClearTimeout = defaultClearTimeout;
70624  }
70625})();
70626
70627function runTimeout(fun) {
70628  if (cachedSetTimeout === setTimeout) {
70629    //normal enviroments in sane situations
70630    return setTimeout(fun, 0);
70631  } // if setTimeout wasn't available but was latter defined
70632
70633
70634  if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
70635    cachedSetTimeout = setTimeout;
70636    return setTimeout(fun, 0);
70637  }
70638
70639  try {
70640    // when when somebody has screwed with setTimeout but no I.E. maddness
70641    return cachedSetTimeout(fun, 0);
70642  } catch (e) {
70643    try {
70644      // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
70645      return cachedSetTimeout.call(null, fun, 0);
70646    } catch (e) {
70647      // 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
70648      return cachedSetTimeout.call(this, fun, 0);
70649    }
70650  }
70651}
70652
70653function runClearTimeout(marker) {
70654  if (cachedClearTimeout === clearTimeout) {
70655    //normal enviroments in sane situations
70656    return clearTimeout(marker);
70657  } // if clearTimeout wasn't available but was latter defined
70658
70659
70660  if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
70661    cachedClearTimeout = clearTimeout;
70662    return clearTimeout(marker);
70663  }
70664
70665  try {
70666    // when when somebody has screwed with setTimeout but no I.E. maddness
70667    return cachedClearTimeout(marker);
70668  } catch (e) {
70669    try {
70670      // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
70671      return cachedClearTimeout.call(null, marker);
70672    } catch (e) {
70673      // 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.
70674      // Some versions of I.E. have different rules for clearTimeout vs setTimeout
70675      return cachedClearTimeout.call(this, marker);
70676    }
70677  }
70678}
70679
70680var queue = [];
70681var draining = false;
70682var currentQueue;
70683var queueIndex = -1;
70684
70685function cleanUpNextTick() {
70686  if (!draining || !currentQueue) {
70687    return;
70688  }
70689
70690  draining = false;
70691
70692  if (currentQueue.length) {
70693    queue = currentQueue.concat(queue);
70694  } else {
70695    queueIndex = -1;
70696  }
70697
70698  if (queue.length) {
70699    drainQueue();
70700  }
70701}
70702
70703function drainQueue() {
70704  if (draining) {
70705    return;
70706  }
70707
70708  var timeout = runTimeout(cleanUpNextTick);
70709  draining = true;
70710  var len = queue.length;
70711
70712  while (len) {
70713    currentQueue = queue;
70714    queue = [];
70715
70716    while (++queueIndex < len) {
70717      if (currentQueue) {
70718        currentQueue[queueIndex].run();
70719      }
70720    }
70721
70722    queueIndex = -1;
70723    len = queue.length;
70724  }
70725
70726  currentQueue = null;
70727  draining = false;
70728  runClearTimeout(timeout);
70729}
70730
70731process.nextTick = function (fun) {
70732  var args = new Array(arguments.length - 1);
70733
70734  if (arguments.length > 1) {
70735    for (var i = 1; i < arguments.length; i++) {
70736      args[i - 1] = arguments[i];
70737    }
70738  }
70739
70740  queue.push(new Item(fun, args));
70741
70742  if (queue.length === 1 && !draining) {
70743    runTimeout(drainQueue);
70744  }
70745}; // v8 likes predictible objects
70746
70747
70748function Item(fun, array) {
70749  this.fun = fun;
70750  this.array = array;
70751}
70752
70753Item.prototype.run = function () {
70754  this.fun.apply(null, this.array);
70755};
70756
70757process.title = 'browser';
70758process.browser = true;
70759process.env = {};
70760process.argv = [];
70761process.version = ''; // empty string to avoid regexp issues
70762
70763process.versions = {};
70764
70765function noop() {}
70766
70767process.on = noop;
70768process.addListener = noop;
70769process.once = noop;
70770process.off = noop;
70771process.removeListener = noop;
70772process.removeAllListeners = noop;
70773process.emit = noop;
70774process.prependListener = noop;
70775process.prependOnceListener = noop;
70776
70777process.listeners = function (name) {
70778  return [];
70779};
70780
70781process.binding = function (name) {
70782  throw new Error('process.binding is not supported');
70783};
70784
70785process.cwd = function () {
70786  return '/';
70787};
70788
70789process.chdir = function (dir) {
70790  throw new Error('process.chdir is not supported');
70791};
70792
70793process.umask = function () {
70794  return 0;
70795};
70796
70797},{}],468:[function(require,module,exports){
70798"use strict";
70799
70800exports.publicEncrypt = require('./publicEncrypt');
70801exports.privateDecrypt = require('./privateDecrypt');
70802
70803exports.privateEncrypt = function privateEncrypt(key, buf) {
70804  return exports.publicEncrypt(key, buf, true);
70805};
70806
70807exports.publicDecrypt = function publicDecrypt(key, buf) {
70808  return exports.privateDecrypt(key, buf, true);
70809};
70810
70811},{"./privateDecrypt":471,"./publicEncrypt":472}],469:[function(require,module,exports){
70812"use strict";
70813
70814var createHash = require('create-hash');
70815
70816var Buffer = require('safe-buffer').Buffer;
70817
70818module.exports = function (seed, len) {
70819  var t = Buffer.alloc(0);
70820  var i = 0;
70821  var c;
70822
70823  while (t.length < len) {
70824    c = i2ops(i++);
70825    t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]);
70826  }
70827
70828  return t.slice(0, len);
70829};
70830
70831function i2ops(c) {
70832  var out = Buffer.allocUnsafe(4);
70833  out.writeUInt32BE(c, 0);
70834  return out;
70835}
70836
70837},{"create-hash":331,"safe-buffer":494}],470:[function(require,module,exports){
70838arguments[4][181][0].apply(exports,arguments)
70839},{"buffer":185,"dup":181}],471:[function(require,module,exports){
70840"use strict";
70841
70842var parseKeys = require('parse-asn1');
70843
70844var mgf = require('./mgf');
70845
70846var xor = require('./xor');
70847
70848var BN = require('bn.js');
70849
70850var crt = require('browserify-rsa');
70851
70852var createHash = require('create-hash');
70853
70854var withPublic = require('./withPublic');
70855
70856var Buffer = require('safe-buffer').Buffer;
70857
70858module.exports = function privateDecrypt(privateKey, enc, reverse) {
70859  var padding;
70860
70861  if (privateKey.padding) {
70862    padding = privateKey.padding;
70863  } else if (reverse) {
70864    padding = 1;
70865  } else {
70866    padding = 4;
70867  }
70868
70869  var key = parseKeys(privateKey);
70870  var k = key.modulus.byteLength();
70871
70872  if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) {
70873    throw new Error('decryption error');
70874  }
70875
70876  var msg;
70877
70878  if (reverse) {
70879    msg = withPublic(new BN(enc), key);
70880  } else {
70881    msg = crt(enc, key);
70882  }
70883
70884  var zBuffer = Buffer.alloc(k - msg.length);
70885  msg = Buffer.concat([zBuffer, msg], k);
70886
70887  if (padding === 4) {
70888    return oaep(key, msg);
70889  } else if (padding === 1) {
70890    return pkcs1(key, msg, reverse);
70891  } else if (padding === 3) {
70892    return msg;
70893  } else {
70894    throw new Error('unknown padding');
70895  }
70896};
70897
70898function oaep(key, msg) {
70899  var k = key.modulus.byteLength();
70900  var iHash = createHash('sha1').update(Buffer.alloc(0)).digest();
70901  var hLen = iHash.length;
70902
70903  if (msg[0] !== 0) {
70904    throw new Error('decryption error');
70905  }
70906
70907  var maskedSeed = msg.slice(1, hLen + 1);
70908  var maskedDb = msg.slice(hLen + 1);
70909  var seed = xor(maskedSeed, mgf(maskedDb, hLen));
70910  var db = xor(maskedDb, mgf(seed, k - hLen - 1));
70911
70912  if (compare(iHash, db.slice(0, hLen))) {
70913    throw new Error('decryption error');
70914  }
70915
70916  var i = hLen;
70917
70918  while (db[i] === 0) {
70919    i++;
70920  }
70921
70922  if (db[i++] !== 1) {
70923    throw new Error('decryption error');
70924  }
70925
70926  return db.slice(i);
70927}
70928
70929function pkcs1(key, msg, reverse) {
70930  var p1 = msg.slice(0, 2);
70931  var i = 2;
70932  var status = 0;
70933
70934  while (msg[i++] !== 0) {
70935    if (i >= msg.length) {
70936      status++;
70937      break;
70938    }
70939  }
70940
70941  var ps = msg.slice(2, i - 1);
70942
70943  if (p1.toString('hex') !== '0002' && !reverse || p1.toString('hex') !== '0001' && reverse) {
70944    status++;
70945  }
70946
70947  if (ps.length < 8) {
70948    status++;
70949  }
70950
70951  if (status) {
70952    throw new Error('decryption error');
70953  }
70954
70955  return msg.slice(i);
70956}
70957
70958function compare(a, b) {
70959  a = Buffer.from(a);
70960  b = Buffer.from(b);
70961  var dif = 0;
70962  var len = a.length;
70963
70964  if (a.length !== b.length) {
70965    dif++;
70966    len = Math.min(a.length, b.length);
70967  }
70968
70969  var i = -1;
70970
70971  while (++i < len) {
70972    dif += a[i] ^ b[i];
70973  }
70974
70975  return dif;
70976}
70977
70978},{"./mgf":469,"./withPublic":473,"./xor":474,"bn.js":470,"browserify-rsa":206,"create-hash":331,"parse-asn1":459,"safe-buffer":494}],472:[function(require,module,exports){
70979"use strict";
70980
70981var parseKeys = require('parse-asn1');
70982
70983var randomBytes = require('randombytes');
70984
70985var createHash = require('create-hash');
70986
70987var mgf = require('./mgf');
70988
70989var xor = require('./xor');
70990
70991var BN = require('bn.js');
70992
70993var withPublic = require('./withPublic');
70994
70995var crt = require('browserify-rsa');
70996
70997var Buffer = require('safe-buffer').Buffer;
70998
70999module.exports = function publicEncrypt(publicKey, msg, reverse) {
71000  var padding;
71001
71002  if (publicKey.padding) {
71003    padding = publicKey.padding;
71004  } else if (reverse) {
71005    padding = 1;
71006  } else {
71007    padding = 4;
71008  }
71009
71010  var key = parseKeys(publicKey);
71011  var paddedMsg;
71012
71013  if (padding === 4) {
71014    paddedMsg = oaep(key, msg);
71015  } else if (padding === 1) {
71016    paddedMsg = pkcs1(key, msg, reverse);
71017  } else if (padding === 3) {
71018    paddedMsg = new BN(msg);
71019
71020    if (paddedMsg.cmp(key.modulus) >= 0) {
71021      throw new Error('data too long for modulus');
71022    }
71023  } else {
71024    throw new Error('unknown padding');
71025  }
71026
71027  if (reverse) {
71028    return crt(paddedMsg, key);
71029  } else {
71030    return withPublic(paddedMsg, key);
71031  }
71032};
71033
71034function oaep(key, msg) {
71035  var k = key.modulus.byteLength();
71036  var mLen = msg.length;
71037  var iHash = createHash('sha1').update(Buffer.alloc(0)).digest();
71038  var hLen = iHash.length;
71039  var hLen2 = 2 * hLen;
71040
71041  if (mLen > k - hLen2 - 2) {
71042    throw new Error('message too long');
71043  }
71044
71045  var ps = Buffer.alloc(k - mLen - hLen2 - 2);
71046  var dblen = k - hLen - 1;
71047  var seed = randomBytes(hLen);
71048  var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen));
71049  var maskedSeed = xor(seed, mgf(maskedDb, hLen));
71050  return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k));
71051}
71052
71053function pkcs1(key, msg, reverse) {
71054  var mLen = msg.length;
71055  var k = key.modulus.byteLength();
71056
71057  if (mLen > k - 11) {
71058    throw new Error('message too long');
71059  }
71060
71061  var ps;
71062
71063  if (reverse) {
71064    ps = Buffer.alloc(k - mLen - 3, 0xff);
71065  } else {
71066    ps = nonZero(k - mLen - 3);
71067  }
71068
71069  return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k));
71070}
71071
71072function nonZero(len) {
71073  var out = Buffer.allocUnsafe(len);
71074  var i = 0;
71075  var cache = randomBytes(len * 2);
71076  var cur = 0;
71077  var num;
71078
71079  while (i < len) {
71080    if (cur === cache.length) {
71081      cache = randomBytes(len * 2);
71082      cur = 0;
71083    }
71084
71085    num = cache[cur++];
71086
71087    if (num) {
71088      out[i++] = num;
71089    }
71090  }
71091
71092  return out;
71093}
71094
71095},{"./mgf":469,"./withPublic":473,"./xor":474,"bn.js":470,"browserify-rsa":206,"create-hash":331,"parse-asn1":459,"randombytes":475,"safe-buffer":494}],473:[function(require,module,exports){
71096"use strict";
71097
71098var BN = require('bn.js');
71099
71100var Buffer = require('safe-buffer').Buffer;
71101
71102function withPublic(paddedMsg, key) {
71103  return Buffer.from(paddedMsg.toRed(BN.mont(key.modulus)).redPow(new BN(key.publicExponent)).fromRed().toArray());
71104}
71105
71106module.exports = withPublic;
71107
71108},{"bn.js":470,"safe-buffer":494}],474:[function(require,module,exports){
71109"use strict";
71110
71111module.exports = function xor(a, b) {
71112  var len = a.length;
71113  var i = -1;
71114
71115  while (++i < len) {
71116    a[i] ^= b[i];
71117  }
71118
71119  return a;
71120};
71121
71122},{}],475:[function(require,module,exports){
71123(function (process,global){
71124'use strict'; // limit of Crypto.getRandomValues()
71125// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
71126
71127var MAX_BYTES = 65536; // Node supports requesting up to this number of bytes
71128// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
71129
71130var MAX_UINT32 = 4294967295;
71131
71132function oldBrowser() {
71133  throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
71134}
71135
71136var Buffer = require('safe-buffer').Buffer;
71137
71138var crypto = global.crypto || global.msCrypto;
71139
71140if (crypto && crypto.getRandomValues) {
71141  module.exports = randomBytes;
71142} else {
71143  module.exports = oldBrowser;
71144}
71145
71146function randomBytes(size, cb) {
71147  // phantomjs needs to throw
71148  if (size > MAX_UINT32) throw new RangeError('requested too many random bytes');
71149  var bytes = Buffer.allocUnsafe(size);
71150
71151  if (size > 0) {
71152    // getRandomValues fails on IE if size == 0
71153    if (size > MAX_BYTES) {
71154      // this is the max bytes crypto.getRandomValues
71155      // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
71156      for (var generated = 0; generated < size; generated += MAX_BYTES) {
71157        // buffer.slice automatically checks if the end is past the end of
71158        // the buffer so we don't have to here
71159        crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
71160      }
71161    } else {
71162      crypto.getRandomValues(bytes);
71163    }
71164  }
71165
71166  if (typeof cb === 'function') {
71167    return process.nextTick(function () {
71168      cb(null, bytes);
71169    });
71170  }
71171
71172  return bytes;
71173}
71174
71175}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
71176
71177},{"_process":467,"safe-buffer":494}],476:[function(require,module,exports){
71178(function (process,global){
71179'use strict';
71180
71181function oldBrowser() {
71182  throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11');
71183}
71184
71185var safeBuffer = require('safe-buffer');
71186
71187var randombytes = require('randombytes');
71188
71189var Buffer = safeBuffer.Buffer;
71190var kBufferMaxLength = safeBuffer.kMaxLength;
71191var crypto = global.crypto || global.msCrypto;
71192var kMaxUint32 = Math.pow(2, 32) - 1;
71193
71194function assertOffset(offset, length) {
71195  if (typeof offset !== 'number' || offset !== offset) {
71196    // eslint-disable-line no-self-compare
71197    throw new TypeError('offset must be a number');
71198  }
71199
71200  if (offset > kMaxUint32 || offset < 0) {
71201    throw new TypeError('offset must be a uint32');
71202  }
71203
71204  if (offset > kBufferMaxLength || offset > length) {
71205    throw new RangeError('offset out of range');
71206  }
71207}
71208
71209function assertSize(size, offset, length) {
71210  if (typeof size !== 'number' || size !== size) {
71211    // eslint-disable-line no-self-compare
71212    throw new TypeError('size must be a number');
71213  }
71214
71215  if (size > kMaxUint32 || size < 0) {
71216    throw new TypeError('size must be a uint32');
71217  }
71218
71219  if (size + offset > length || size > kBufferMaxLength) {
71220    throw new RangeError('buffer too small');
71221  }
71222}
71223
71224if (crypto && crypto.getRandomValues || !process.browser) {
71225  exports.randomFill = randomFill;
71226  exports.randomFillSync = randomFillSync;
71227} else {
71228  exports.randomFill = oldBrowser;
71229  exports.randomFillSync = oldBrowser;
71230}
71231
71232function randomFill(buf, offset, size, cb) {
71233  if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
71234    throw new TypeError('"buf" argument must be a Buffer or Uint8Array');
71235  }
71236
71237  if (typeof offset === 'function') {
71238    cb = offset;
71239    offset = 0;
71240    size = buf.length;
71241  } else if (typeof size === 'function') {
71242    cb = size;
71243    size = buf.length - offset;
71244  } else if (typeof cb !== 'function') {
71245    throw new TypeError('"cb" argument must be a function');
71246  }
71247
71248  assertOffset(offset, buf.length);
71249  assertSize(size, offset, buf.length);
71250  return actualFill(buf, offset, size, cb);
71251}
71252
71253function actualFill(buf, offset, size, cb) {
71254  if (process.browser) {
71255    var ourBuf = buf.buffer;
71256    var uint = new Uint8Array(ourBuf, offset, size);
71257    crypto.getRandomValues(uint);
71258
71259    if (cb) {
71260      process.nextTick(function () {
71261        cb(null, buf);
71262      });
71263      return;
71264    }
71265
71266    return buf;
71267  }
71268
71269  if (cb) {
71270    randombytes(size, function (err, bytes) {
71271      if (err) {
71272        return cb(err);
71273      }
71274
71275      bytes.copy(buf, offset);
71276      cb(null, buf);
71277    });
71278    return;
71279  }
71280
71281  var bytes = randombytes(size);
71282  bytes.copy(buf, offset);
71283  return buf;
71284}
71285
71286function randomFillSync(buf, offset, size) {
71287  if (typeof offset === 'undefined') {
71288    offset = 0;
71289  }
71290
71291  if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
71292    throw new TypeError('"buf" argument must be a Buffer or Uint8Array');
71293  }
71294
71295  assertOffset(offset, buf.length);
71296  if (size === undefined) size = buf.length - offset;
71297  assertSize(size, offset, buf.length);
71298  return actualFill(buf, offset, size);
71299}
71300
71301}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
71302
71303},{"_process":467,"randombytes":475,"safe-buffer":494}],477:[function(require,module,exports){
71304'use strict';
71305
71306function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
71307
71308function _inheritsLoose(subClass, superClass) {
71309  subClass.prototype = Object.create(superClass.prototype);
71310  subClass.prototype.constructor = subClass;
71311  subClass.__proto__ = superClass;
71312}
71313
71314var codes = {};
71315
71316function createErrorType(code, message, Base) {
71317  if (!Base) {
71318    Base = Error;
71319  }
71320
71321  function getMessage(arg1, arg2, arg3) {
71322    if (typeof message === 'string') {
71323      return message;
71324    } else {
71325      return message(arg1, arg2, arg3);
71326    }
71327  }
71328
71329  var NodeError = /*#__PURE__*/function (_Base) {
71330    _inheritsLoose(NodeError, _Base);
71331
71332    function NodeError(arg1, arg2, arg3) {
71333      return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
71334    }
71335
71336    return NodeError;
71337  }(Base);
71338
71339  NodeError.prototype.name = Base.name;
71340  NodeError.prototype.code = code;
71341  codes[code] = NodeError;
71342} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
71343
71344
71345function oneOf(expected, thing) {
71346  if (Array.isArray(expected)) {
71347    var len = expected.length;
71348    expected = expected.map(function (i) {
71349      return String(i);
71350    });
71351
71352    if (len > 2) {
71353      return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
71354    } else if (len === 2) {
71355      return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
71356    } else {
71357      return "of ".concat(thing, " ").concat(expected[0]);
71358    }
71359  } else {
71360    return "of ".concat(thing, " ").concat(String(expected));
71361  }
71362} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
71363
71364
71365function startsWith(str, search, pos) {
71366  return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
71367} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
71368
71369
71370function endsWith(str, search, this_len) {
71371  if (this_len === undefined || this_len > str.length) {
71372    this_len = str.length;
71373  }
71374
71375  return str.substring(this_len - search.length, this_len) === search;
71376} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
71377
71378
71379function includes(str, search, start) {
71380  if (typeof start !== 'number') {
71381    start = 0;
71382  }
71383
71384  if (start + search.length > str.length) {
71385    return false;
71386  } else {
71387    return str.indexOf(search, start) !== -1;
71388  }
71389}
71390
71391createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
71392  return 'The value "' + value + '" is invalid for option "' + name + '"';
71393}, TypeError);
71394createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
71395  // determiner: 'must be' or 'must not be'
71396  var determiner;
71397
71398  if (typeof expected === 'string' && startsWith(expected, 'not ')) {
71399    determiner = 'must not be';
71400    expected = expected.replace(/^not /, '');
71401  } else {
71402    determiner = 'must be';
71403  }
71404
71405  var msg;
71406
71407  if (endsWith(name, ' argument')) {
71408    // For cases like 'first argument'
71409    msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
71410  } else {
71411    var type = includes(name, '.') ? 'property' : 'argument';
71412    msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
71413  }
71414
71415  msg += ". Received type ".concat(_typeof(actual));
71416  return msg;
71417}, TypeError);
71418createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
71419createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
71420  return 'The ' + name + ' method is not implemented';
71421});
71422createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
71423createErrorType('ERR_STREAM_DESTROYED', function (name) {
71424  return 'Cannot call ' + name + ' after a stream was destroyed';
71425});
71426createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
71427createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
71428createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
71429createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
71430createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
71431  return 'Unknown encoding: ' + arg;
71432}, TypeError);
71433createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
71434module.exports.codes = codes;
71435
71436},{}],478:[function(require,module,exports){
71437(function (process){
71438// Copyright Joyent, Inc. and other Node contributors.
71439//
71440// Permission is hereby granted, free of charge, to any person obtaining a
71441// copy of this software and associated documentation files (the
71442// "Software"), to deal in the Software without restriction, including
71443// without limitation the rights to use, copy, modify, merge, publish,
71444// distribute, sublicense, and/or sell copies of the Software, and to permit
71445// persons to whom the Software is furnished to do so, subject to the
71446// following conditions:
71447//
71448// The above copyright notice and this permission notice shall be included
71449// in all copies or substantial portions of the Software.
71450//
71451// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
71452// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71453// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
71454// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
71455// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
71456// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
71457// USE OR OTHER DEALINGS IN THE SOFTWARE.
71458// a duplex stream is just a stream that is both readable and writable.
71459// Since JS doesn't have multiple prototypal inheritance, this class
71460// prototypally inherits from Readable, and then parasitically from
71461// Writable.
71462'use strict';
71463/*<replacement>*/
71464
71465var objectKeys = Object.keys || function (obj) {
71466  var keys = [];
71467
71468  for (var key in obj) {
71469    keys.push(key);
71470  }
71471
71472  return keys;
71473};
71474/*</replacement>*/
71475
71476
71477module.exports = Duplex;
71478
71479var Readable = require('./_stream_readable');
71480
71481var Writable = require('./_stream_writable');
71482
71483require('inherits')(Duplex, Readable);
71484
71485{
71486  // Allow the keys array to be GC'ed.
71487  var keys = objectKeys(Writable.prototype);
71488
71489  for (var v = 0; v < keys.length; v++) {
71490    var method = keys[v];
71491    if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
71492  }
71493}
71494
71495function Duplex(options) {
71496  if (!(this instanceof Duplex)) return new Duplex(options);
71497  Readable.call(this, options);
71498  Writable.call(this, options);
71499  this.allowHalfOpen = true;
71500
71501  if (options) {
71502    if (options.readable === false) this.readable = false;
71503    if (options.writable === false) this.writable = false;
71504
71505    if (options.allowHalfOpen === false) {
71506      this.allowHalfOpen = false;
71507      this.once('end', onend);
71508    }
71509  }
71510}
71511
71512Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
71513  // making it explicit this property is not enumerable
71514  // because otherwise some prototype manipulation in
71515  // userland will fail
71516  enumerable: false,
71517  get: function get() {
71518    return this._writableState.highWaterMark;
71519  }
71520});
71521Object.defineProperty(Duplex.prototype, 'writableBuffer', {
71522  // making it explicit this property is not enumerable
71523  // because otherwise some prototype manipulation in
71524  // userland will fail
71525  enumerable: false,
71526  get: function get() {
71527    return this._writableState && this._writableState.getBuffer();
71528  }
71529});
71530Object.defineProperty(Duplex.prototype, 'writableLength', {
71531  // making it explicit this property is not enumerable
71532  // because otherwise some prototype manipulation in
71533  // userland will fail
71534  enumerable: false,
71535  get: function get() {
71536    return this._writableState.length;
71537  }
71538}); // the no-half-open enforcer
71539
71540function onend() {
71541  // If the writable side ended, then we're ok.
71542  if (this._writableState.ended) return; // no more data can be written.
71543  // But allow more writes to happen in this tick.
71544
71545  process.nextTick(onEndNT, this);
71546}
71547
71548function onEndNT(self) {
71549  self.end();
71550}
71551
71552Object.defineProperty(Duplex.prototype, 'destroyed', {
71553  // making it explicit this property is not enumerable
71554  // because otherwise some prototype manipulation in
71555  // userland will fail
71556  enumerable: false,
71557  get: function get() {
71558    if (this._readableState === undefined || this._writableState === undefined) {
71559      return false;
71560    }
71561
71562    return this._readableState.destroyed && this._writableState.destroyed;
71563  },
71564  set: function set(value) {
71565    // we ignore the value if the stream
71566    // has not been initialized yet
71567    if (this._readableState === undefined || this._writableState === undefined) {
71568      return;
71569    } // backward compatibility, the user is explicitly
71570    // managing destroyed
71571
71572
71573    this._readableState.destroyed = value;
71574    this._writableState.destroyed = value;
71575  }
71576});
71577
71578}).call(this,require('_process'))
71579
71580},{"./_stream_readable":480,"./_stream_writable":482,"_process":467,"inherits":387}],479:[function(require,module,exports){
71581// Copyright Joyent, Inc. and other Node contributors.
71582//
71583// Permission is hereby granted, free of charge, to any person obtaining a
71584// copy of this software and associated documentation files (the
71585// "Software"), to deal in the Software without restriction, including
71586// without limitation the rights to use, copy, modify, merge, publish,
71587// distribute, sublicense, and/or sell copies of the Software, and to permit
71588// persons to whom the Software is furnished to do so, subject to the
71589// following conditions:
71590//
71591// The above copyright notice and this permission notice shall be included
71592// in all copies or substantial portions of the Software.
71593//
71594// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
71595// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71596// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
71597// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
71598// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
71599// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
71600// USE OR OTHER DEALINGS IN THE SOFTWARE.
71601// a passthrough stream.
71602// basically just the most minimal sort of Transform stream.
71603// Every written chunk gets output as-is.
71604'use strict';
71605
71606module.exports = PassThrough;
71607
71608var Transform = require('./_stream_transform');
71609
71610require('inherits')(PassThrough, Transform);
71611
71612function PassThrough(options) {
71613  if (!(this instanceof PassThrough)) return new PassThrough(options);
71614  Transform.call(this, options);
71615}
71616
71617PassThrough.prototype._transform = function (chunk, encoding, cb) {
71618  cb(null, chunk);
71619};
71620
71621},{"./_stream_transform":481,"inherits":387}],480:[function(require,module,exports){
71622(function (process,global){
71623// Copyright Joyent, Inc. and other Node contributors.
71624//
71625// Permission is hereby granted, free of charge, to any person obtaining a
71626// copy of this software and associated documentation files (the
71627// "Software"), to deal in the Software without restriction, including
71628// without limitation the rights to use, copy, modify, merge, publish,
71629// distribute, sublicense, and/or sell copies of the Software, and to permit
71630// persons to whom the Software is furnished to do so, subject to the
71631// following conditions:
71632//
71633// The above copyright notice and this permission notice shall be included
71634// in all copies or substantial portions of the Software.
71635//
71636// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
71637// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71638// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
71639// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
71640// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
71641// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
71642// USE OR OTHER DEALINGS IN THE SOFTWARE.
71643'use strict';
71644
71645module.exports = Readable;
71646/*<replacement>*/
71647
71648var Duplex;
71649/*</replacement>*/
71650
71651Readable.ReadableState = ReadableState;
71652/*<replacement>*/
71653
71654var EE = require('events').EventEmitter;
71655
71656var EElistenerCount = function EElistenerCount(emitter, type) {
71657  return emitter.listeners(type).length;
71658};
71659/*</replacement>*/
71660
71661/*<replacement>*/
71662
71663
71664var Stream = require('./internal/streams/stream');
71665/*</replacement>*/
71666
71667
71668var Buffer = require('buffer').Buffer;
71669
71670var OurUint8Array = global.Uint8Array || function () {};
71671
71672function _uint8ArrayToBuffer(chunk) {
71673  return Buffer.from(chunk);
71674}
71675
71676function _isUint8Array(obj) {
71677  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
71678}
71679/*<replacement>*/
71680
71681
71682var debugUtil = require('util');
71683
71684var debug;
71685
71686if (debugUtil && debugUtil.debuglog) {
71687  debug = debugUtil.debuglog('stream');
71688} else {
71689  debug = function debug() {};
71690}
71691/*</replacement>*/
71692
71693
71694var BufferList = require('./internal/streams/buffer_list');
71695
71696var destroyImpl = require('./internal/streams/destroy');
71697
71698var _require = require('./internal/streams/state'),
71699    getHighWaterMark = _require.getHighWaterMark;
71700
71701var _require$codes = require('../errors').codes,
71702    ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
71703    ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
71704    ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
71705    ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.
71706
71707
71708var StringDecoder;
71709var createReadableStreamAsyncIterator;
71710var from;
71711
71712require('inherits')(Readable, Stream);
71713
71714var errorOrDestroy = destroyImpl.errorOrDestroy;
71715var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
71716
71717function prependListener(emitter, event, fn) {
71718  // Sadly this is not cacheable as some libraries bundle their own
71719  // event emitter implementation with them.
71720  if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
71721  // userland ones.  NEVER DO THIS. This is here only because this code needs
71722  // to continue to work with older versions of Node.js that do not include
71723  // the prependListener() method. The goal is to eventually remove this hack.
71724
71725  if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
71726}
71727
71728function ReadableState(options, stream, isDuplex) {
71729  Duplex = Duplex || require('./_stream_duplex');
71730  options = options || {}; // Duplex streams are both readable and writable, but share
71731  // the same options object.
71732  // However, some cases require setting options to different
71733  // values for the readable and the writable sides of the duplex stream.
71734  // These options can be provided separately as readableXXX and writableXXX.
71735
71736  if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
71737  // make all the buffer merging and length checks go away
71738
71739  this.objectMode = !!options.objectMode;
71740  if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
71741  // Note: 0 is a valid value, means "don't call _read preemptively ever"
71742
71743  this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the
71744  // linked list can remove elements from the beginning faster than
71745  // array.shift()
71746
71747  this.buffer = new BufferList();
71748  this.length = 0;
71749  this.pipes = null;
71750  this.pipesCount = 0;
71751  this.flowing = null;
71752  this.ended = false;
71753  this.endEmitted = false;
71754  this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
71755  // immediately, or on a later tick.  We set this to true at first, because
71756  // any actions that shouldn't happen until "later" should generally also
71757  // not happen before the first read call.
71758
71759  this.sync = true; // whenever we return null, then we set a flag to say
71760  // that we're awaiting a 'readable' event emission.
71761
71762  this.needReadable = false;
71763  this.emittedReadable = false;
71764  this.readableListening = false;
71765  this.resumeScheduled = false;
71766  this.paused = true; // Should close be emitted on destroy. Defaults to true.
71767
71768  this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')
71769
71770  this.autoDestroy = !!options.autoDestroy; // has it been destroyed
71771
71772  this.destroyed = false; // Crypto is kind of old and crusty.  Historically, its default string
71773  // encoding is 'binary' so we have to make this configurable.
71774  // Everything else in the universe uses 'utf8', though.
71775
71776  this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s
71777
71778  this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
71779
71780  this.readingMore = false;
71781  this.decoder = null;
71782  this.encoding = null;
71783
71784  if (options.encoding) {
71785    if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
71786    this.decoder = new StringDecoder(options.encoding);
71787    this.encoding = options.encoding;
71788  }
71789}
71790
71791function Readable(options) {
71792  Duplex = Duplex || require('./_stream_duplex');
71793  if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside
71794  // the ReadableState constructor, at least with V8 6.5
71795
71796  var isDuplex = this instanceof Duplex;
71797  this._readableState = new ReadableState(options, this, isDuplex); // legacy
71798
71799  this.readable = true;
71800
71801  if (options) {
71802    if (typeof options.read === 'function') this._read = options.read;
71803    if (typeof options.destroy === 'function') this._destroy = options.destroy;
71804  }
71805
71806  Stream.call(this);
71807}
71808
71809Object.defineProperty(Readable.prototype, 'destroyed', {
71810  // making it explicit this property is not enumerable
71811  // because otherwise some prototype manipulation in
71812  // userland will fail
71813  enumerable: false,
71814  get: function get() {
71815    if (this._readableState === undefined) {
71816      return false;
71817    }
71818
71819    return this._readableState.destroyed;
71820  },
71821  set: function set(value) {
71822    // we ignore the value if the stream
71823    // has not been initialized yet
71824    if (!this._readableState) {
71825      return;
71826    } // backward compatibility, the user is explicitly
71827    // managing destroyed
71828
71829
71830    this._readableState.destroyed = value;
71831  }
71832});
71833Readable.prototype.destroy = destroyImpl.destroy;
71834Readable.prototype._undestroy = destroyImpl.undestroy;
71835
71836Readable.prototype._destroy = function (err, cb) {
71837  cb(err);
71838}; // Manually shove something into the read() buffer.
71839// This returns true if the highWaterMark has not been hit yet,
71840// similar to how Writable.write() returns true if you should
71841// write() some more.
71842
71843
71844Readable.prototype.push = function (chunk, encoding) {
71845  var state = this._readableState;
71846  var skipChunkCheck;
71847
71848  if (!state.objectMode) {
71849    if (typeof chunk === 'string') {
71850      encoding = encoding || state.defaultEncoding;
71851
71852      if (encoding !== state.encoding) {
71853        chunk = Buffer.from(chunk, encoding);
71854        encoding = '';
71855      }
71856
71857      skipChunkCheck = true;
71858    }
71859  } else {
71860    skipChunkCheck = true;
71861  }
71862
71863  return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
71864}; // Unshift should *always* be something directly out of read()
71865
71866
71867Readable.prototype.unshift = function (chunk) {
71868  return readableAddChunk(this, chunk, null, true, false);
71869};
71870
71871function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
71872  debug('readableAddChunk', chunk);
71873  var state = stream._readableState;
71874
71875  if (chunk === null) {
71876    state.reading = false;
71877    onEofChunk(stream, state);
71878  } else {
71879    var er;
71880    if (!skipChunkCheck) er = chunkInvalid(state, chunk);
71881
71882    if (er) {
71883      errorOrDestroy(stream, er);
71884    } else if (state.objectMode || chunk && chunk.length > 0) {
71885      if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
71886        chunk = _uint8ArrayToBuffer(chunk);
71887      }
71888
71889      if (addToFront) {
71890        if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
71891      } else if (state.ended) {
71892        errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
71893      } else if (state.destroyed) {
71894        return false;
71895      } else {
71896        state.reading = false;
71897
71898        if (state.decoder && !encoding) {
71899          chunk = state.decoder.write(chunk);
71900          if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
71901        } else {
71902          addChunk(stream, state, chunk, false);
71903        }
71904      }
71905    } else if (!addToFront) {
71906      state.reading = false;
71907      maybeReadMore(stream, state);
71908    }
71909  } // We can push more data if we are below the highWaterMark.
71910  // Also, if we have no data yet, we can stand some more bytes.
71911  // This is to work around cases where hwm=0, such as the repl.
71912
71913
71914  return !state.ended && (state.length < state.highWaterMark || state.length === 0);
71915}
71916
71917function addChunk(stream, state, chunk, addToFront) {
71918  if (state.flowing && state.length === 0 && !state.sync) {
71919    state.awaitDrain = 0;
71920    stream.emit('data', chunk);
71921  } else {
71922    // update the buffer info.
71923    state.length += state.objectMode ? 1 : chunk.length;
71924    if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
71925    if (state.needReadable) emitReadable(stream);
71926  }
71927
71928  maybeReadMore(stream, state);
71929}
71930
71931function chunkInvalid(state, chunk) {
71932  var er;
71933
71934  if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
71935    er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
71936  }
71937
71938  return er;
71939}
71940
71941Readable.prototype.isPaused = function () {
71942  return this._readableState.flowing === false;
71943}; // backwards compatibility.
71944
71945
71946Readable.prototype.setEncoding = function (enc) {
71947  if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
71948  var decoder = new StringDecoder(enc);
71949  this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8
71950
71951  this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:
71952
71953  var p = this._readableState.buffer.head;
71954  var content = '';
71955
71956  while (p !== null) {
71957    content += decoder.write(p.data);
71958    p = p.next;
71959  }
71960
71961  this._readableState.buffer.clear();
71962
71963  if (content !== '') this._readableState.buffer.push(content);
71964  this._readableState.length = content.length;
71965  return this;
71966}; // Don't raise the hwm > 1GB
71967
71968
71969var MAX_HWM = 0x40000000;
71970
71971function computeNewHighWaterMark(n) {
71972  if (n >= MAX_HWM) {
71973    // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
71974    n = MAX_HWM;
71975  } else {
71976    // Get the next highest power of 2 to prevent increasing hwm excessively in
71977    // tiny amounts
71978    n--;
71979    n |= n >>> 1;
71980    n |= n >>> 2;
71981    n |= n >>> 4;
71982    n |= n >>> 8;
71983    n |= n >>> 16;
71984    n++;
71985  }
71986
71987  return n;
71988} // This function is designed to be inlinable, so please take care when making
71989// changes to the function body.
71990
71991
71992function howMuchToRead(n, state) {
71993  if (n <= 0 || state.length === 0 && state.ended) return 0;
71994  if (state.objectMode) return 1;
71995
71996  if (n !== n) {
71997    // Only flow one buffer at a time
71998    if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
71999  } // If we're asking for more than the current hwm, then raise the hwm.
72000
72001
72002  if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
72003  if (n <= state.length) return n; // Don't have enough
72004
72005  if (!state.ended) {
72006    state.needReadable = true;
72007    return 0;
72008  }
72009
72010  return state.length;
72011} // you can override either this method, or the async _read(n) below.
72012
72013
72014Readable.prototype.read = function (n) {
72015  debug('read', n);
72016  n = parseInt(n, 10);
72017  var state = this._readableState;
72018  var nOrig = n;
72019  if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
72020  // already have a bunch of data in the buffer, then just trigger
72021  // the 'readable' event and move on.
72022
72023  if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
72024    debug('read: emitReadable', state.length, state.ended);
72025    if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
72026    return null;
72027  }
72028
72029  n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
72030
72031  if (n === 0 && state.ended) {
72032    if (state.length === 0) endReadable(this);
72033    return null;
72034  } // All the actual chunk generation logic needs to be
72035  // *below* the call to _read.  The reason is that in certain
72036  // synthetic stream cases, such as passthrough streams, _read
72037  // may be a completely synchronous operation which may change
72038  // the state of the read buffer, providing enough data when
72039  // before there was *not* enough.
72040  //
72041  // So, the steps are:
72042  // 1. Figure out what the state of things will be after we do
72043  // a read from the buffer.
72044  //
72045  // 2. If that resulting state will trigger a _read, then call _read.
72046  // Note that this may be asynchronous, or synchronous.  Yes, it is
72047  // deeply ugly to write APIs this way, but that still doesn't mean
72048  // that the Readable class should behave improperly, as streams are
72049  // designed to be sync/async agnostic.
72050  // Take note if the _read call is sync or async (ie, if the read call
72051  // has returned yet), so that we know whether or not it's safe to emit
72052  // 'readable' etc.
72053  //
72054  // 3. Actually pull the requested chunks out of the buffer and return.
72055  // if we need a readable event, then we need to do some reading.
72056
72057
72058  var doRead = state.needReadable;
72059  debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some
72060
72061  if (state.length === 0 || state.length - n < state.highWaterMark) {
72062    doRead = true;
72063    debug('length less than watermark', doRead);
72064  } // however, if we've ended, then there's no point, and if we're already
72065  // reading, then it's unnecessary.
72066
72067
72068  if (state.ended || state.reading) {
72069    doRead = false;
72070    debug('reading or ended', doRead);
72071  } else if (doRead) {
72072    debug('do read');
72073    state.reading = true;
72074    state.sync = true; // if the length is currently zero, then we *need* a readable event.
72075
72076    if (state.length === 0) state.needReadable = true; // call internal read method
72077
72078    this._read(state.highWaterMark);
72079
72080    state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
72081    // and we need to re-evaluate how much data we can return to the user.
72082
72083    if (!state.reading) n = howMuchToRead(nOrig, state);
72084  }
72085
72086  var ret;
72087  if (n > 0) ret = fromList(n, state);else ret = null;
72088
72089  if (ret === null) {
72090    state.needReadable = state.length <= state.highWaterMark;
72091    n = 0;
72092  } else {
72093    state.length -= n;
72094    state.awaitDrain = 0;
72095  }
72096
72097  if (state.length === 0) {
72098    // If we have nothing in the buffer, then we want to know
72099    // as soon as we *do* get something into the buffer.
72100    if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
72101
72102    if (nOrig !== n && state.ended) endReadable(this);
72103  }
72104
72105  if (ret !== null) this.emit('data', ret);
72106  return ret;
72107};
72108
72109function onEofChunk(stream, state) {
72110  debug('onEofChunk');
72111  if (state.ended) return;
72112
72113  if (state.decoder) {
72114    var chunk = state.decoder.end();
72115
72116    if (chunk && chunk.length) {
72117      state.buffer.push(chunk);
72118      state.length += state.objectMode ? 1 : chunk.length;
72119    }
72120  }
72121
72122  state.ended = true;
72123
72124  if (state.sync) {
72125    // if we are sync, wait until next tick to emit the data.
72126    // Otherwise we risk emitting data in the flow()
72127    // the readable code triggers during a read() call
72128    emitReadable(stream);
72129  } else {
72130    // emit 'readable' now to make sure it gets picked up.
72131    state.needReadable = false;
72132
72133    if (!state.emittedReadable) {
72134      state.emittedReadable = true;
72135      emitReadable_(stream);
72136    }
72137  }
72138} // Don't emit readable right away in sync mode, because this can trigger
72139// another read() call => stack overflow.  This way, it might trigger
72140// a nextTick recursion warning, but that's not so bad.
72141
72142
72143function emitReadable(stream) {
72144  var state = stream._readableState;
72145  debug('emitReadable', state.needReadable, state.emittedReadable);
72146  state.needReadable = false;
72147
72148  if (!state.emittedReadable) {
72149    debug('emitReadable', state.flowing);
72150    state.emittedReadable = true;
72151    process.nextTick(emitReadable_, stream);
72152  }
72153}
72154
72155function emitReadable_(stream) {
72156  var state = stream._readableState;
72157  debug('emitReadable_', state.destroyed, state.length, state.ended);
72158
72159  if (!state.destroyed && (state.length || state.ended)) {
72160    stream.emit('readable');
72161    state.emittedReadable = false;
72162  } // The stream needs another readable event if
72163  // 1. It is not flowing, as the flow mechanism will take
72164  //    care of it.
72165  // 2. It is not ended.
72166  // 3. It is below the highWaterMark, so we can schedule
72167  //    another readable later.
72168
72169
72170  state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
72171  flow(stream);
72172} // at this point, the user has presumably seen the 'readable' event,
72173// and called read() to consume some data.  that may have triggered
72174// in turn another _read(n) call, in which case reading = true if
72175// it's in progress.
72176// However, if we're not ended, or reading, and the length < hwm,
72177// then go ahead and try to read some more preemptively.
72178
72179
72180function maybeReadMore(stream, state) {
72181  if (!state.readingMore) {
72182    state.readingMore = true;
72183    process.nextTick(maybeReadMore_, stream, state);
72184  }
72185}
72186
72187function maybeReadMore_(stream, state) {
72188  // Attempt to read more data if we should.
72189  //
72190  // The conditions for reading more data are (one of):
72191  // - Not enough data buffered (state.length < state.highWaterMark). The loop
72192  //   is responsible for filling the buffer with enough data if such data
72193  //   is available. If highWaterMark is 0 and we are not in the flowing mode
72194  //   we should _not_ attempt to buffer any extra data. We'll get more data
72195  //   when the stream consumer calls read() instead.
72196  // - No data in the buffer, and the stream is in flowing mode. In this mode
72197  //   the loop below is responsible for ensuring read() is called. Failing to
72198  //   call read here would abort the flow and there's no other mechanism for
72199  //   continuing the flow if the stream consumer has just subscribed to the
72200  //   'data' event.
72201  //
72202  // In addition to the above conditions to keep reading data, the following
72203  // conditions prevent the data from being read:
72204  // - The stream has ended (state.ended).
72205  // - There is already a pending 'read' operation (state.reading). This is a
72206  //   case where the the stream has called the implementation defined _read()
72207  //   method, but they are processing the call asynchronously and have _not_
72208  //   called push() with new data. In this case we skip performing more
72209  //   read()s. The execution ends in this method again after the _read() ends
72210  //   up calling push() with more data.
72211  while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
72212    var len = state.length;
72213    debug('maybeReadMore read 0');
72214    stream.read(0);
72215    if (len === state.length) // didn't get any data, stop spinning.
72216      break;
72217  }
72218
72219  state.readingMore = false;
72220} // abstract method.  to be overridden in specific implementation classes.
72221// call cb(er, data) where data is <= n in length.
72222// for virtual (non-string, non-buffer) streams, "length" is somewhat
72223// arbitrary, and perhaps not very meaningful.
72224
72225
72226Readable.prototype._read = function (n) {
72227  errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
72228};
72229
72230Readable.prototype.pipe = function (dest, pipeOpts) {
72231  var src = this;
72232  var state = this._readableState;
72233
72234  switch (state.pipesCount) {
72235    case 0:
72236      state.pipes = dest;
72237      break;
72238
72239    case 1:
72240      state.pipes = [state.pipes, dest];
72241      break;
72242
72243    default:
72244      state.pipes.push(dest);
72245      break;
72246  }
72247
72248  state.pipesCount += 1;
72249  debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
72250  var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
72251  var endFn = doEnd ? onend : unpipe;
72252  if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
72253  dest.on('unpipe', onunpipe);
72254
72255  function onunpipe(readable, unpipeInfo) {
72256    debug('onunpipe');
72257
72258    if (readable === src) {
72259      if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
72260        unpipeInfo.hasUnpiped = true;
72261        cleanup();
72262      }
72263    }
72264  }
72265
72266  function onend() {
72267    debug('onend');
72268    dest.end();
72269  } // when the dest drains, it reduces the awaitDrain counter
72270  // on the source.  This would be more elegant with a .once()
72271  // handler in flow(), but adding and removing repeatedly is
72272  // too slow.
72273
72274
72275  var ondrain = pipeOnDrain(src);
72276  dest.on('drain', ondrain);
72277  var cleanedUp = false;
72278
72279  function cleanup() {
72280    debug('cleanup'); // cleanup event handlers once the pipe is broken
72281
72282    dest.removeListener('close', onclose);
72283    dest.removeListener('finish', onfinish);
72284    dest.removeListener('drain', ondrain);
72285    dest.removeListener('error', onerror);
72286    dest.removeListener('unpipe', onunpipe);
72287    src.removeListener('end', onend);
72288    src.removeListener('end', unpipe);
72289    src.removeListener('data', ondata);
72290    cleanedUp = true; // if the reader is waiting for a drain event from this
72291    // specific writer, then it would cause it to never start
72292    // flowing again.
72293    // So, if this is awaiting a drain, then we just call it now.
72294    // If we don't know, then assume that we are waiting for one.
72295
72296    if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
72297  }
72298
72299  src.on('data', ondata);
72300
72301  function ondata(chunk) {
72302    debug('ondata');
72303    var ret = dest.write(chunk);
72304    debug('dest.write', ret);
72305
72306    if (ret === false) {
72307      // If the user unpiped during `dest.write()`, it is possible
72308      // to get stuck in a permanently paused state if that write
72309      // also returned false.
72310      // => Check whether `dest` is still a piping destination.
72311      if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
72312        debug('false write response, pause', state.awaitDrain);
72313        state.awaitDrain++;
72314      }
72315
72316      src.pause();
72317    }
72318  } // if the dest has an error, then stop piping into it.
72319  // however, don't suppress the throwing behavior for this.
72320
72321
72322  function onerror(er) {
72323    debug('onerror', er);
72324    unpipe();
72325    dest.removeListener('error', onerror);
72326    if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
72327  } // Make sure our error handler is attached before userland ones.
72328
72329
72330  prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.
72331
72332  function onclose() {
72333    dest.removeListener('finish', onfinish);
72334    unpipe();
72335  }
72336
72337  dest.once('close', onclose);
72338
72339  function onfinish() {
72340    debug('onfinish');
72341    dest.removeListener('close', onclose);
72342    unpipe();
72343  }
72344
72345  dest.once('finish', onfinish);
72346
72347  function unpipe() {
72348    debug('unpipe');
72349    src.unpipe(dest);
72350  } // tell the dest that it's being piped to
72351
72352
72353  dest.emit('pipe', src); // start the flow if it hasn't been started already.
72354
72355  if (!state.flowing) {
72356    debug('pipe resume');
72357    src.resume();
72358  }
72359
72360  return dest;
72361};
72362
72363function pipeOnDrain(src) {
72364  return function pipeOnDrainFunctionResult() {
72365    var state = src._readableState;
72366    debug('pipeOnDrain', state.awaitDrain);
72367    if (state.awaitDrain) state.awaitDrain--;
72368
72369    if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
72370      state.flowing = true;
72371      flow(src);
72372    }
72373  };
72374}
72375
72376Readable.prototype.unpipe = function (dest) {
72377  var state = this._readableState;
72378  var unpipeInfo = {
72379    hasUnpiped: false
72380  }; // if we're not piping anywhere, then do nothing.
72381
72382  if (state.pipesCount === 0) return this; // just one destination.  most common case.
72383
72384  if (state.pipesCount === 1) {
72385    // passed in one, but it's not the right one.
72386    if (dest && dest !== state.pipes) return this;
72387    if (!dest) dest = state.pipes; // got a match.
72388
72389    state.pipes = null;
72390    state.pipesCount = 0;
72391    state.flowing = false;
72392    if (dest) dest.emit('unpipe', this, unpipeInfo);
72393    return this;
72394  } // slow case. multiple pipe destinations.
72395
72396
72397  if (!dest) {
72398    // remove all.
72399    var dests = state.pipes;
72400    var len = state.pipesCount;
72401    state.pipes = null;
72402    state.pipesCount = 0;
72403    state.flowing = false;
72404
72405    for (var i = 0; i < len; i++) {
72406      dests[i].emit('unpipe', this, {
72407        hasUnpiped: false
72408      });
72409    }
72410
72411    return this;
72412  } // try to find the right one.
72413
72414
72415  var index = indexOf(state.pipes, dest);
72416  if (index === -1) return this;
72417  state.pipes.splice(index, 1);
72418  state.pipesCount -= 1;
72419  if (state.pipesCount === 1) state.pipes = state.pipes[0];
72420  dest.emit('unpipe', this, unpipeInfo);
72421  return this;
72422}; // set up data events if they are asked for
72423// Ensure readable listeners eventually get something
72424
72425
72426Readable.prototype.on = function (ev, fn) {
72427  var res = Stream.prototype.on.call(this, ev, fn);
72428  var state = this._readableState;
72429
72430  if (ev === 'data') {
72431    // update readableListening so that resume() may be a no-op
72432    // a few lines down. This is needed to support once('readable').
72433    state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused
72434
72435    if (state.flowing !== false) this.resume();
72436  } else if (ev === 'readable') {
72437    if (!state.endEmitted && !state.readableListening) {
72438      state.readableListening = state.needReadable = true;
72439      state.flowing = false;
72440      state.emittedReadable = false;
72441      debug('on readable', state.length, state.reading);
72442
72443      if (state.length) {
72444        emitReadable(this);
72445      } else if (!state.reading) {
72446        process.nextTick(nReadingNextTick, this);
72447      }
72448    }
72449  }
72450
72451  return res;
72452};
72453
72454Readable.prototype.addListener = Readable.prototype.on;
72455
72456Readable.prototype.removeListener = function (ev, fn) {
72457  var res = Stream.prototype.removeListener.call(this, ev, fn);
72458
72459  if (ev === 'readable') {
72460    // We need to check if there is someone still listening to
72461    // readable and reset the state. However this needs to happen
72462    // after readable has been emitted but before I/O (nextTick) to
72463    // support once('readable', fn) cycles. This means that calling
72464    // resume within the same tick will have no
72465    // effect.
72466    process.nextTick(updateReadableListening, this);
72467  }
72468
72469  return res;
72470};
72471
72472Readable.prototype.removeAllListeners = function (ev) {
72473  var res = Stream.prototype.removeAllListeners.apply(this, arguments);
72474
72475  if (ev === 'readable' || ev === undefined) {
72476    // We need to check if there is someone still listening to
72477    // readable and reset the state. However this needs to happen
72478    // after readable has been emitted but before I/O (nextTick) to
72479    // support once('readable', fn) cycles. This means that calling
72480    // resume within the same tick will have no
72481    // effect.
72482    process.nextTick(updateReadableListening, this);
72483  }
72484
72485  return res;
72486};
72487
72488function updateReadableListening(self) {
72489  var state = self._readableState;
72490  state.readableListening = self.listenerCount('readable') > 0;
72491
72492  if (state.resumeScheduled && !state.paused) {
72493    // flowing needs to be set to true now, otherwise
72494    // the upcoming resume will not flow.
72495    state.flowing = true; // crude way to check if we should resume
72496  } else if (self.listenerCount('data') > 0) {
72497    self.resume();
72498  }
72499}
72500
72501function nReadingNextTick(self) {
72502  debug('readable nexttick read 0');
72503  self.read(0);
72504} // pause() and resume() are remnants of the legacy readable stream API
72505// If the user uses them, then switch into old mode.
72506
72507
72508Readable.prototype.resume = function () {
72509  var state = this._readableState;
72510
72511  if (!state.flowing) {
72512    debug('resume'); // we flow only if there is no one listening
72513    // for readable, but we still have to call
72514    // resume()
72515
72516    state.flowing = !state.readableListening;
72517    resume(this, state);
72518  }
72519
72520  state.paused = false;
72521  return this;
72522};
72523
72524function resume(stream, state) {
72525  if (!state.resumeScheduled) {
72526    state.resumeScheduled = true;
72527    process.nextTick(resume_, stream, state);
72528  }
72529}
72530
72531function resume_(stream, state) {
72532  debug('resume', state.reading);
72533
72534  if (!state.reading) {
72535    stream.read(0);
72536  }
72537
72538  state.resumeScheduled = false;
72539  stream.emit('resume');
72540  flow(stream);
72541  if (state.flowing && !state.reading) stream.read(0);
72542}
72543
72544Readable.prototype.pause = function () {
72545  debug('call pause flowing=%j', this._readableState.flowing);
72546
72547  if (this._readableState.flowing !== false) {
72548    debug('pause');
72549    this._readableState.flowing = false;
72550    this.emit('pause');
72551  }
72552
72553  this._readableState.paused = true;
72554  return this;
72555};
72556
72557function flow(stream) {
72558  var state = stream._readableState;
72559  debug('flow', state.flowing);
72560
72561  while (state.flowing && stream.read() !== null) {
72562    ;
72563  }
72564} // wrap an old-style stream as the async data source.
72565// This is *not* part of the readable stream interface.
72566// It is an ugly unfortunate mess of history.
72567
72568
72569Readable.prototype.wrap = function (stream) {
72570  var _this = this;
72571
72572  var state = this._readableState;
72573  var paused = false;
72574  stream.on('end', function () {
72575    debug('wrapped end');
72576
72577    if (state.decoder && !state.ended) {
72578      var chunk = state.decoder.end();
72579      if (chunk && chunk.length) _this.push(chunk);
72580    }
72581
72582    _this.push(null);
72583  });
72584  stream.on('data', function (chunk) {
72585    debug('wrapped data');
72586    if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
72587
72588    if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
72589
72590    var ret = _this.push(chunk);
72591
72592    if (!ret) {
72593      paused = true;
72594      stream.pause();
72595    }
72596  }); // proxy all the other methods.
72597  // important when wrapping filters and duplexes.
72598
72599  for (var i in stream) {
72600    if (this[i] === undefined && typeof stream[i] === 'function') {
72601      this[i] = function methodWrap(method) {
72602        return function methodWrapReturnFunction() {
72603          return stream[method].apply(stream, arguments);
72604        };
72605      }(i);
72606    }
72607  } // proxy certain important events.
72608
72609
72610  for (var n = 0; n < kProxyEvents.length; n++) {
72611    stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
72612  } // when we try to consume some more bytes, simply unpause the
72613  // underlying stream.
72614
72615
72616  this._read = function (n) {
72617    debug('wrapped _read', n);
72618
72619    if (paused) {
72620      paused = false;
72621      stream.resume();
72622    }
72623  };
72624
72625  return this;
72626};
72627
72628if (typeof Symbol === 'function') {
72629  Readable.prototype[Symbol.asyncIterator] = function () {
72630    if (createReadableStreamAsyncIterator === undefined) {
72631      createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');
72632    }
72633
72634    return createReadableStreamAsyncIterator(this);
72635  };
72636}
72637
72638Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
72639  // making it explicit this property is not enumerable
72640  // because otherwise some prototype manipulation in
72641  // userland will fail
72642  enumerable: false,
72643  get: function get() {
72644    return this._readableState.highWaterMark;
72645  }
72646});
72647Object.defineProperty(Readable.prototype, 'readableBuffer', {
72648  // making it explicit this property is not enumerable
72649  // because otherwise some prototype manipulation in
72650  // userland will fail
72651  enumerable: false,
72652  get: function get() {
72653    return this._readableState && this._readableState.buffer;
72654  }
72655});
72656Object.defineProperty(Readable.prototype, 'readableFlowing', {
72657  // making it explicit this property is not enumerable
72658  // because otherwise some prototype manipulation in
72659  // userland will fail
72660  enumerable: false,
72661  get: function get() {
72662    return this._readableState.flowing;
72663  },
72664  set: function set(state) {
72665    if (this._readableState) {
72666      this._readableState.flowing = state;
72667    }
72668  }
72669}); // exposed for testing purposes only.
72670
72671Readable._fromList = fromList;
72672Object.defineProperty(Readable.prototype, 'readableLength', {
72673  // making it explicit this property is not enumerable
72674  // because otherwise some prototype manipulation in
72675  // userland will fail
72676  enumerable: false,
72677  get: function get() {
72678    return this._readableState.length;
72679  }
72680}); // Pluck off n bytes from an array of buffers.
72681// Length is the combined lengths of all the buffers in the list.
72682// This function is designed to be inlinable, so please take care when making
72683// changes to the function body.
72684
72685function fromList(n, state) {
72686  // nothing buffered
72687  if (state.length === 0) return null;
72688  var ret;
72689  if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
72690    // read it all, truncate the list
72691    if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);
72692    state.buffer.clear();
72693  } else {
72694    // read part of list
72695    ret = state.buffer.consume(n, state.decoder);
72696  }
72697  return ret;
72698}
72699
72700function endReadable(stream) {
72701  var state = stream._readableState;
72702  debug('endReadable', state.endEmitted);
72703
72704  if (!state.endEmitted) {
72705    state.ended = true;
72706    process.nextTick(endReadableNT, state, stream);
72707  }
72708}
72709
72710function endReadableNT(state, stream) {
72711  debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.
72712
72713  if (!state.endEmitted && state.length === 0) {
72714    state.endEmitted = true;
72715    stream.readable = false;
72716    stream.emit('end');
72717
72718    if (state.autoDestroy) {
72719      // In case of duplex streams we need a way to detect
72720      // if the writable side is ready for autoDestroy as well
72721      var wState = stream._writableState;
72722
72723      if (!wState || wState.autoDestroy && wState.finished) {
72724        stream.destroy();
72725      }
72726    }
72727  }
72728}
72729
72730if (typeof Symbol === 'function') {
72731  Readable.from = function (iterable, opts) {
72732    if (from === undefined) {
72733      from = require('./internal/streams/from');
72734    }
72735
72736    return from(Readable, iterable, opts);
72737  };
72738}
72739
72740function indexOf(xs, x) {
72741  for (var i = 0, l = xs.length; i < l; i++) {
72742    if (xs[i] === x) return i;
72743  }
72744
72745  return -1;
72746}
72747
72748}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
72749
72750},{"../errors":477,"./_stream_duplex":478,"./internal/streams/async_iterator":483,"./internal/streams/buffer_list":484,"./internal/streams/destroy":485,"./internal/streams/from":487,"./internal/streams/state":489,"./internal/streams/stream":490,"_process":467,"buffer":216,"events":367,"inherits":387,"string_decoder/":520,"util":185}],481:[function(require,module,exports){
72751// Copyright Joyent, Inc. and other Node contributors.
72752//
72753// Permission is hereby granted, free of charge, to any person obtaining a
72754// copy of this software and associated documentation files (the
72755// "Software"), to deal in the Software without restriction, including
72756// without limitation the rights to use, copy, modify, merge, publish,
72757// distribute, sublicense, and/or sell copies of the Software, and to permit
72758// persons to whom the Software is furnished to do so, subject to the
72759// following conditions:
72760//
72761// The above copyright notice and this permission notice shall be included
72762// in all copies or substantial portions of the Software.
72763//
72764// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
72765// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
72766// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
72767// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
72768// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
72769// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
72770// USE OR OTHER DEALINGS IN THE SOFTWARE.
72771// a transform stream is a readable/writable stream where you do
72772// something with the data.  Sometimes it's called a "filter",
72773// but that's not a great name for it, since that implies a thing where
72774// some bits pass through, and others are simply ignored.  (That would
72775// be a valid example of a transform, of course.)
72776//
72777// While the output is causally related to the input, it's not a
72778// necessarily symmetric or synchronous transformation.  For example,
72779// a zlib stream might take multiple plain-text writes(), and then
72780// emit a single compressed chunk some time in the future.
72781//
72782// Here's how this works:
72783//
72784// The Transform stream has all the aspects of the readable and writable
72785// stream classes.  When you write(chunk), that calls _write(chunk,cb)
72786// internally, and returns false if there's a lot of pending writes
72787// buffered up.  When you call read(), that calls _read(n) until
72788// there's enough pending readable data buffered up.
72789//
72790// In a transform stream, the written data is placed in a buffer.  When
72791// _read(n) is called, it transforms the queued up data, calling the
72792// buffered _write cb's as it consumes chunks.  If consuming a single
72793// written chunk would result in multiple output chunks, then the first
72794// outputted bit calls the readcb, and subsequent chunks just go into
72795// the read buffer, and will cause it to emit 'readable' if necessary.
72796//
72797// This way, back-pressure is actually determined by the reading side,
72798// since _read has to be called to start processing a new chunk.  However,
72799// a pathological inflate type of transform can cause excessive buffering
72800// here.  For example, imagine a stream where every byte of input is
72801// interpreted as an integer from 0-255, and then results in that many
72802// bytes of output.  Writing the 4 bytes {ff,ff,ff,ff} would result in
72803// 1kb of data being output.  In this case, you could write a very small
72804// amount of input, and end up with a very large amount of output.  In
72805// such a pathological inflating mechanism, there'd be no way to tell
72806// the system to stop doing the transform.  A single 4MB write could
72807// cause the system to run out of memory.
72808//
72809// However, even in such a pathological case, only a single written chunk
72810// would be consumed, and then the rest would wait (un-transformed) until
72811// the results of the previous transformed chunk were consumed.
72812'use strict';
72813
72814module.exports = Transform;
72815
72816var _require$codes = require('../errors').codes,
72817    ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
72818    ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
72819    ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
72820    ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
72821
72822var Duplex = require('./_stream_duplex');
72823
72824require('inherits')(Transform, Duplex);
72825
72826function afterTransform(er, data) {
72827  var ts = this._transformState;
72828  ts.transforming = false;
72829  var cb = ts.writecb;
72830
72831  if (cb === null) {
72832    return this.emit('error', new ERR_MULTIPLE_CALLBACK());
72833  }
72834
72835  ts.writechunk = null;
72836  ts.writecb = null;
72837  if (data != null) // single equals check for both `null` and `undefined`
72838    this.push(data);
72839  cb(er);
72840  var rs = this._readableState;
72841  rs.reading = false;
72842
72843  if (rs.needReadable || rs.length < rs.highWaterMark) {
72844    this._read(rs.highWaterMark);
72845  }
72846}
72847
72848function Transform(options) {
72849  if (!(this instanceof Transform)) return new Transform(options);
72850  Duplex.call(this, options);
72851  this._transformState = {
72852    afterTransform: afterTransform.bind(this),
72853    needTransform: false,
72854    transforming: false,
72855    writecb: null,
72856    writechunk: null,
72857    writeencoding: null
72858  }; // start out asking for a readable event once data is transformed.
72859
72860  this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
72861  // that Readable wants before the first _read call, so unset the
72862  // sync guard flag.
72863
72864  this._readableState.sync = false;
72865
72866  if (options) {
72867    if (typeof options.transform === 'function') this._transform = options.transform;
72868    if (typeof options.flush === 'function') this._flush = options.flush;
72869  } // When the writable side finishes, then flush out anything remaining.
72870
72871
72872  this.on('prefinish', prefinish);
72873}
72874
72875function prefinish() {
72876  var _this = this;
72877
72878  if (typeof this._flush === 'function' && !this._readableState.destroyed) {
72879    this._flush(function (er, data) {
72880      done(_this, er, data);
72881    });
72882  } else {
72883    done(this, null, null);
72884  }
72885}
72886
72887Transform.prototype.push = function (chunk, encoding) {
72888  this._transformState.needTransform = false;
72889  return Duplex.prototype.push.call(this, chunk, encoding);
72890}; // This is the part where you do stuff!
72891// override this function in implementation classes.
72892// 'chunk' is an input chunk.
72893//
72894// Call `push(newChunk)` to pass along transformed output
72895// to the readable side.  You may call 'push' zero or more times.
72896//
72897// Call `cb(err)` when you are done with this chunk.  If you pass
72898// an error, then that'll put the hurt on the whole operation.  If you
72899// never call cb(), then you'll never get another chunk.
72900
72901
72902Transform.prototype._transform = function (chunk, encoding, cb) {
72903  cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
72904};
72905
72906Transform.prototype._write = function (chunk, encoding, cb) {
72907  var ts = this._transformState;
72908  ts.writecb = cb;
72909  ts.writechunk = chunk;
72910  ts.writeencoding = encoding;
72911
72912  if (!ts.transforming) {
72913    var rs = this._readableState;
72914    if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
72915  }
72916}; // Doesn't matter what the args are here.
72917// _transform does all the work.
72918// That we got here means that the readable side wants more data.
72919
72920
72921Transform.prototype._read = function (n) {
72922  var ts = this._transformState;
72923
72924  if (ts.writechunk !== null && !ts.transforming) {
72925    ts.transforming = true;
72926
72927    this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
72928  } else {
72929    // mark that we need a transform, so that any data that comes in
72930    // will get processed, now that we've asked for it.
72931    ts.needTransform = true;
72932  }
72933};
72934
72935Transform.prototype._destroy = function (err, cb) {
72936  Duplex.prototype._destroy.call(this, err, function (err2) {
72937    cb(err2);
72938  });
72939};
72940
72941function done(stream, er, data) {
72942  if (er) return stream.emit('error', er);
72943  if (data != null) // single equals check for both `null` and `undefined`
72944    stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
72945  // if there's nothing in the write buffer, then that means
72946  // that nothing more will ever be provided
72947
72948  if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
72949  if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
72950  return stream.push(null);
72951}
72952
72953},{"../errors":477,"./_stream_duplex":478,"inherits":387}],482:[function(require,module,exports){
72954(function (process,global){
72955// Copyright Joyent, Inc. and other Node contributors.
72956//
72957// Permission is hereby granted, free of charge, to any person obtaining a
72958// copy of this software and associated documentation files (the
72959// "Software"), to deal in the Software without restriction, including
72960// without limitation the rights to use, copy, modify, merge, publish,
72961// distribute, sublicense, and/or sell copies of the Software, and to permit
72962// persons to whom the Software is furnished to do so, subject to the
72963// following conditions:
72964//
72965// The above copyright notice and this permission notice shall be included
72966// in all copies or substantial portions of the Software.
72967//
72968// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
72969// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
72970// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
72971// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
72972// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
72973// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
72974// USE OR OTHER DEALINGS IN THE SOFTWARE.
72975// A bit simpler than readable streams.
72976// Implement an async ._write(chunk, encoding, cb), and it'll handle all
72977// the drain event emission and buffering.
72978'use strict';
72979
72980module.exports = Writable;
72981/* <replacement> */
72982
72983function WriteReq(chunk, encoding, cb) {
72984  this.chunk = chunk;
72985  this.encoding = encoding;
72986  this.callback = cb;
72987  this.next = null;
72988} // It seems a linked list but it is not
72989// there will be only 2 of these for each stream
72990
72991
72992function CorkedRequest(state) {
72993  var _this = this;
72994
72995  this.next = null;
72996  this.entry = null;
72997
72998  this.finish = function () {
72999    onCorkedFinish(_this, state);
73000  };
73001}
73002/* </replacement> */
73003
73004/*<replacement>*/
73005
73006
73007var Duplex;
73008/*</replacement>*/
73009
73010Writable.WritableState = WritableState;
73011/*<replacement>*/
73012
73013var internalUtil = {
73014  deprecate: require('util-deprecate')
73015};
73016/*</replacement>*/
73017
73018/*<replacement>*/
73019
73020var Stream = require('./internal/streams/stream');
73021/*</replacement>*/
73022
73023
73024var Buffer = require('buffer').Buffer;
73025
73026var OurUint8Array = global.Uint8Array || function () {};
73027
73028function _uint8ArrayToBuffer(chunk) {
73029  return Buffer.from(chunk);
73030}
73031
73032function _isUint8Array(obj) {
73033  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
73034}
73035
73036var destroyImpl = require('./internal/streams/destroy');
73037
73038var _require = require('./internal/streams/state'),
73039    getHighWaterMark = _require.getHighWaterMark;
73040
73041var _require$codes = require('../errors').codes,
73042    ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
73043    ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
73044    ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
73045    ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
73046    ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
73047    ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
73048    ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
73049    ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
73050
73051var errorOrDestroy = destroyImpl.errorOrDestroy;
73052
73053require('inherits')(Writable, Stream);
73054
73055function nop() {}
73056
73057function WritableState(options, stream, isDuplex) {
73058  Duplex = Duplex || require('./_stream_duplex');
73059  options = options || {}; // Duplex streams are both readable and writable, but share
73060  // the same options object.
73061  // However, some cases require setting options to different
73062  // values for the readable and the writable sides of the duplex stream,
73063  // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
73064
73065  if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
73066  // contains buffers or objects.
73067
73068  this.objectMode = !!options.objectMode;
73069  if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
73070  // Note: 0 is a valid value, means that we always return false if
73071  // the entire buffer is not flushed immediately on write()
73072
73073  this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called
73074
73075  this.finalCalled = false; // drain event flag.
73076
73077  this.needDrain = false; // at the start of calling end()
73078
73079  this.ending = false; // when end() has been called, and returned
73080
73081  this.ended = false; // when 'finish' is emitted
73082
73083  this.finished = false; // has it been destroyed
73084
73085  this.destroyed = false; // should we decode strings into buffers before passing to _write?
73086  // this is here so that some node-core streams can optimize string
73087  // handling at a lower level.
73088
73089  var noDecode = options.decodeStrings === false;
73090  this.decodeStrings = !noDecode; // Crypto is kind of old and crusty.  Historically, its default string
73091  // encoding is 'binary' so we have to make this configurable.
73092  // Everything else in the universe uses 'utf8', though.
73093
73094  this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
73095  // of how much we're waiting to get pushed to some underlying
73096  // socket or file.
73097
73098  this.length = 0; // a flag to see when we're in the middle of a write.
73099
73100  this.writing = false; // when true all writes will be buffered until .uncork() call
73101
73102  this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
73103  // or on a later tick.  We set this to true at first, because any
73104  // actions that shouldn't happen until "later" should generally also
73105  // not happen before the first write call.
73106
73107  this.sync = true; // a flag to know if we're processing previously buffered items, which
73108  // may call the _write() callback in the same tick, so that we don't
73109  // end up in an overlapped onwrite situation.
73110
73111  this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
73112
73113  this.onwrite = function (er) {
73114    onwrite(stream, er);
73115  }; // the callback that the user supplies to write(chunk,encoding,cb)
73116
73117
73118  this.writecb = null; // the amount that is being written when _write is called.
73119
73120  this.writelen = 0;
73121  this.bufferedRequest = null;
73122  this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
73123  // this must be 0 before 'finish' can be emitted
73124
73125  this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
73126  // This is relevant for synchronous Transform streams
73127
73128  this.prefinished = false; // True if the error was already emitted and should not be thrown again
73129
73130  this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.
73131
73132  this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
73133
73134  this.autoDestroy = !!options.autoDestroy; // count buffered requests
73135
73136  this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
73137  // one allocated and free to use, and we maintain at most two
73138
73139  this.corkedRequestsFree = new CorkedRequest(this);
73140}
73141
73142WritableState.prototype.getBuffer = function getBuffer() {
73143  var current = this.bufferedRequest;
73144  var out = [];
73145
73146  while (current) {
73147    out.push(current);
73148    current = current.next;
73149  }
73150
73151  return out;
73152};
73153
73154(function () {
73155  try {
73156    Object.defineProperty(WritableState.prototype, 'buffer', {
73157      get: internalUtil.deprecate(function writableStateBufferGetter() {
73158        return this.getBuffer();
73159      }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
73160    });
73161  } catch (_) {}
73162})(); // Test _writableState for inheritance to account for Duplex streams,
73163// whose prototype chain only points to Readable.
73164
73165
73166var realHasInstance;
73167
73168if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
73169  realHasInstance = Function.prototype[Symbol.hasInstance];
73170  Object.defineProperty(Writable, Symbol.hasInstance, {
73171    value: function value(object) {
73172      if (realHasInstance.call(this, object)) return true;
73173      if (this !== Writable) return false;
73174      return object && object._writableState instanceof WritableState;
73175    }
73176  });
73177} else {
73178  realHasInstance = function realHasInstance(object) {
73179    return object instanceof this;
73180  };
73181}
73182
73183function Writable(options) {
73184  Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.
73185  // `realHasInstance` is necessary because using plain `instanceof`
73186  // would return false, as no `_writableState` property is attached.
73187  // Trying to use the custom `instanceof` for Writable here will also break the
73188  // Node.js LazyTransform implementation, which has a non-trivial getter for
73189  // `_writableState` that would lead to infinite recursion.
73190  // Checking for a Stream.Duplex instance is faster here instead of inside
73191  // the WritableState constructor, at least with V8 6.5
73192
73193  var isDuplex = this instanceof Duplex;
73194  if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
73195  this._writableState = new WritableState(options, this, isDuplex); // legacy.
73196
73197  this.writable = true;
73198
73199  if (options) {
73200    if (typeof options.write === 'function') this._write = options.write;
73201    if (typeof options.writev === 'function') this._writev = options.writev;
73202    if (typeof options.destroy === 'function') this._destroy = options.destroy;
73203    if (typeof options.final === 'function') this._final = options.final;
73204  }
73205
73206  Stream.call(this);
73207} // Otherwise people can pipe Writable streams, which is just wrong.
73208
73209
73210Writable.prototype.pipe = function () {
73211  errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
73212};
73213
73214function writeAfterEnd(stream, cb) {
73215  var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb
73216
73217  errorOrDestroy(stream, er);
73218  process.nextTick(cb, er);
73219} // Checks that a user-supplied chunk is valid, especially for the particular
73220// mode the stream is in. Currently this means that `null` is never accepted
73221// and undefined/non-string values are only allowed in object mode.
73222
73223
73224function validChunk(stream, state, chunk, cb) {
73225  var er;
73226
73227  if (chunk === null) {
73228    er = new ERR_STREAM_NULL_VALUES();
73229  } else if (typeof chunk !== 'string' && !state.objectMode) {
73230    er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
73231  }
73232
73233  if (er) {
73234    errorOrDestroy(stream, er);
73235    process.nextTick(cb, er);
73236    return false;
73237  }
73238
73239  return true;
73240}
73241
73242Writable.prototype.write = function (chunk, encoding, cb) {
73243  var state = this._writableState;
73244  var ret = false;
73245
73246  var isBuf = !state.objectMode && _isUint8Array(chunk);
73247
73248  if (isBuf && !Buffer.isBuffer(chunk)) {
73249    chunk = _uint8ArrayToBuffer(chunk);
73250  }
73251
73252  if (typeof encoding === 'function') {
73253    cb = encoding;
73254    encoding = null;
73255  }
73256
73257  if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
73258  if (typeof cb !== 'function') cb = nop;
73259  if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
73260    state.pendingcb++;
73261    ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
73262  }
73263  return ret;
73264};
73265
73266Writable.prototype.cork = function () {
73267  this._writableState.corked++;
73268};
73269
73270Writable.prototype.uncork = function () {
73271  var state = this._writableState;
73272
73273  if (state.corked) {
73274    state.corked--;
73275    if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
73276  }
73277};
73278
73279Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
73280  // node::ParseEncoding() requires lower case.
73281  if (typeof encoding === 'string') encoding = encoding.toLowerCase();
73282  if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
73283  this._writableState.defaultEncoding = encoding;
73284  return this;
73285};
73286
73287Object.defineProperty(Writable.prototype, 'writableBuffer', {
73288  // making it explicit this property is not enumerable
73289  // because otherwise some prototype manipulation in
73290  // userland will fail
73291  enumerable: false,
73292  get: function get() {
73293    return this._writableState && this._writableState.getBuffer();
73294  }
73295});
73296
73297function decodeChunk(state, chunk, encoding) {
73298  if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
73299    chunk = Buffer.from(chunk, encoding);
73300  }
73301
73302  return chunk;
73303}
73304
73305Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
73306  // making it explicit this property is not enumerable
73307  // because otherwise some prototype manipulation in
73308  // userland will fail
73309  enumerable: false,
73310  get: function get() {
73311    return this._writableState.highWaterMark;
73312  }
73313}); // if we're already writing something, then just put this
73314// in the queue, and wait our turn.  Otherwise, call _write
73315// If we return false, then we need a drain event, so set that flag.
73316
73317function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
73318  if (!isBuf) {
73319    var newChunk = decodeChunk(state, chunk, encoding);
73320
73321    if (chunk !== newChunk) {
73322      isBuf = true;
73323      encoding = 'buffer';
73324      chunk = newChunk;
73325    }
73326  }
73327
73328  var len = state.objectMode ? 1 : chunk.length;
73329  state.length += len;
73330  var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
73331
73332  if (!ret) state.needDrain = true;
73333
73334  if (state.writing || state.corked) {
73335    var last = state.lastBufferedRequest;
73336    state.lastBufferedRequest = {
73337      chunk: chunk,
73338      encoding: encoding,
73339      isBuf: isBuf,
73340      callback: cb,
73341      next: null
73342    };
73343
73344    if (last) {
73345      last.next = state.lastBufferedRequest;
73346    } else {
73347      state.bufferedRequest = state.lastBufferedRequest;
73348    }
73349
73350    state.bufferedRequestCount += 1;
73351  } else {
73352    doWrite(stream, state, false, len, chunk, encoding, cb);
73353  }
73354
73355  return ret;
73356}
73357
73358function doWrite(stream, state, writev, len, chunk, encoding, cb) {
73359  state.writelen = len;
73360  state.writecb = cb;
73361  state.writing = true;
73362  state.sync = true;
73363  if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
73364  state.sync = false;
73365}
73366
73367function onwriteError(stream, state, sync, er, cb) {
73368  --state.pendingcb;
73369
73370  if (sync) {
73371    // defer the callback if we are being called synchronously
73372    // to avoid piling up things on the stack
73373    process.nextTick(cb, er); // this can emit finish, and it will always happen
73374    // after error
73375
73376    process.nextTick(finishMaybe, stream, state);
73377    stream._writableState.errorEmitted = true;
73378    errorOrDestroy(stream, er);
73379  } else {
73380    // the caller expect this to happen before if
73381    // it is async
73382    cb(er);
73383    stream._writableState.errorEmitted = true;
73384    errorOrDestroy(stream, er); // this can emit finish, but finish must
73385    // always follow error
73386
73387    finishMaybe(stream, state);
73388  }
73389}
73390
73391function onwriteStateUpdate(state) {
73392  state.writing = false;
73393  state.writecb = null;
73394  state.length -= state.writelen;
73395  state.writelen = 0;
73396}
73397
73398function onwrite(stream, er) {
73399  var state = stream._writableState;
73400  var sync = state.sync;
73401  var cb = state.writecb;
73402  if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
73403  onwriteStateUpdate(state);
73404  if (er) onwriteError(stream, state, sync, er, cb);else {
73405    // Check if we're actually ready to finish, but don't emit yet
73406    var finished = needFinish(state) || stream.destroyed;
73407
73408    if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
73409      clearBuffer(stream, state);
73410    }
73411
73412    if (sync) {
73413      process.nextTick(afterWrite, stream, state, finished, cb);
73414    } else {
73415      afterWrite(stream, state, finished, cb);
73416    }
73417  }
73418}
73419
73420function afterWrite(stream, state, finished, cb) {
73421  if (!finished) onwriteDrain(stream, state);
73422  state.pendingcb--;
73423  cb();
73424  finishMaybe(stream, state);
73425} // Must force callback to be called on nextTick, so that we don't
73426// emit 'drain' before the write() consumer gets the 'false' return
73427// value, and has a chance to attach a 'drain' listener.
73428
73429
73430function onwriteDrain(stream, state) {
73431  if (state.length === 0 && state.needDrain) {
73432    state.needDrain = false;
73433    stream.emit('drain');
73434  }
73435} // if there's something in the buffer waiting, then process it
73436
73437
73438function clearBuffer(stream, state) {
73439  state.bufferProcessing = true;
73440  var entry = state.bufferedRequest;
73441
73442  if (stream._writev && entry && entry.next) {
73443    // Fast case, write everything using _writev()
73444    var l = state.bufferedRequestCount;
73445    var buffer = new Array(l);
73446    var holder = state.corkedRequestsFree;
73447    holder.entry = entry;
73448    var count = 0;
73449    var allBuffers = true;
73450
73451    while (entry) {
73452      buffer[count] = entry;
73453      if (!entry.isBuf) allBuffers = false;
73454      entry = entry.next;
73455      count += 1;
73456    }
73457
73458    buffer.allBuffers = allBuffers;
73459    doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
73460    // as the hot path ends with doWrite
73461
73462    state.pendingcb++;
73463    state.lastBufferedRequest = null;
73464
73465    if (holder.next) {
73466      state.corkedRequestsFree = holder.next;
73467      holder.next = null;
73468    } else {
73469      state.corkedRequestsFree = new CorkedRequest(state);
73470    }
73471
73472    state.bufferedRequestCount = 0;
73473  } else {
73474    // Slow case, write chunks one-by-one
73475    while (entry) {
73476      var chunk = entry.chunk;
73477      var encoding = entry.encoding;
73478      var cb = entry.callback;
73479      var len = state.objectMode ? 1 : chunk.length;
73480      doWrite(stream, state, false, len, chunk, encoding, cb);
73481      entry = entry.next;
73482      state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
73483      // it means that we need to wait until it does.
73484      // also, that means that the chunk and cb are currently
73485      // being processed, so move the buffer counter past them.
73486
73487      if (state.writing) {
73488        break;
73489      }
73490    }
73491
73492    if (entry === null) state.lastBufferedRequest = null;
73493  }
73494
73495  state.bufferedRequest = entry;
73496  state.bufferProcessing = false;
73497}
73498
73499Writable.prototype._write = function (chunk, encoding, cb) {
73500  cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
73501};
73502
73503Writable.prototype._writev = null;
73504
73505Writable.prototype.end = function (chunk, encoding, cb) {
73506  var state = this._writableState;
73507
73508  if (typeof chunk === 'function') {
73509    cb = chunk;
73510    chunk = null;
73511    encoding = null;
73512  } else if (typeof encoding === 'function') {
73513    cb = encoding;
73514    encoding = null;
73515  }
73516
73517  if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
73518
73519  if (state.corked) {
73520    state.corked = 1;
73521    this.uncork();
73522  } // ignore unnecessary end() calls.
73523
73524
73525  if (!state.ending) endWritable(this, state, cb);
73526  return this;
73527};
73528
73529Object.defineProperty(Writable.prototype, 'writableLength', {
73530  // making it explicit this property is not enumerable
73531  // because otherwise some prototype manipulation in
73532  // userland will fail
73533  enumerable: false,
73534  get: function get() {
73535    return this._writableState.length;
73536  }
73537});
73538
73539function needFinish(state) {
73540  return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
73541}
73542
73543function callFinal(stream, state) {
73544  stream._final(function (err) {
73545    state.pendingcb--;
73546
73547    if (err) {
73548      errorOrDestroy(stream, err);
73549    }
73550
73551    state.prefinished = true;
73552    stream.emit('prefinish');
73553    finishMaybe(stream, state);
73554  });
73555}
73556
73557function prefinish(stream, state) {
73558  if (!state.prefinished && !state.finalCalled) {
73559    if (typeof stream._final === 'function' && !state.destroyed) {
73560      state.pendingcb++;
73561      state.finalCalled = true;
73562      process.nextTick(callFinal, stream, state);
73563    } else {
73564      state.prefinished = true;
73565      stream.emit('prefinish');
73566    }
73567  }
73568}
73569
73570function finishMaybe(stream, state) {
73571  var need = needFinish(state);
73572
73573  if (need) {
73574    prefinish(stream, state);
73575
73576    if (state.pendingcb === 0) {
73577      state.finished = true;
73578      stream.emit('finish');
73579
73580      if (state.autoDestroy) {
73581        // In case of duplex streams we need a way to detect
73582        // if the readable side is ready for autoDestroy as well
73583        var rState = stream._readableState;
73584
73585        if (!rState || rState.autoDestroy && rState.endEmitted) {
73586          stream.destroy();
73587        }
73588      }
73589    }
73590  }
73591
73592  return need;
73593}
73594
73595function endWritable(stream, state, cb) {
73596  state.ending = true;
73597  finishMaybe(stream, state);
73598
73599  if (cb) {
73600    if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
73601  }
73602
73603  state.ended = true;
73604  stream.writable = false;
73605}
73606
73607function onCorkedFinish(corkReq, state, err) {
73608  var entry = corkReq.entry;
73609  corkReq.entry = null;
73610
73611  while (entry) {
73612    var cb = entry.callback;
73613    state.pendingcb--;
73614    cb(err);
73615    entry = entry.next;
73616  } // reuse the free corkReq.
73617
73618
73619  state.corkedRequestsFree.next = corkReq;
73620}
73621
73622Object.defineProperty(Writable.prototype, 'destroyed', {
73623  // making it explicit this property is not enumerable
73624  // because otherwise some prototype manipulation in
73625  // userland will fail
73626  enumerable: false,
73627  get: function get() {
73628    if (this._writableState === undefined) {
73629      return false;
73630    }
73631
73632    return this._writableState.destroyed;
73633  },
73634  set: function set(value) {
73635    // we ignore the value if the stream
73636    // has not been initialized yet
73637    if (!this._writableState) {
73638      return;
73639    } // backward compatibility, the user is explicitly
73640    // managing destroyed
73641
73642
73643    this._writableState.destroyed = value;
73644  }
73645});
73646Writable.prototype.destroy = destroyImpl.destroy;
73647Writable.prototype._undestroy = destroyImpl.undestroy;
73648
73649Writable.prototype._destroy = function (err, cb) {
73650  cb(err);
73651};
73652
73653}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
73654
73655},{"../errors":477,"./_stream_duplex":478,"./internal/streams/destroy":485,"./internal/streams/state":489,"./internal/streams/stream":490,"_process":467,"buffer":216,"inherits":387,"util-deprecate":522}],483:[function(require,module,exports){
73656(function (process){
73657'use strict';
73658
73659var _Object$setPrototypeO;
73660
73661function _defineProperty(obj, key, value) {
73662  if (key in obj) {
73663    Object.defineProperty(obj, key, {
73664      value: value,
73665      enumerable: true,
73666      configurable: true,
73667      writable: true
73668    });
73669  } else {
73670    obj[key] = value;
73671  }
73672
73673  return obj;
73674}
73675
73676var finished = require('./end-of-stream');
73677
73678var kLastResolve = Symbol('lastResolve');
73679var kLastReject = Symbol('lastReject');
73680var kError = Symbol('error');
73681var kEnded = Symbol('ended');
73682var kLastPromise = Symbol('lastPromise');
73683var kHandlePromise = Symbol('handlePromise');
73684var kStream = Symbol('stream');
73685
73686function createIterResult(value, done) {
73687  return {
73688    value: value,
73689    done: done
73690  };
73691}
73692
73693function readAndResolve(iter) {
73694  var resolve = iter[kLastResolve];
73695
73696  if (resolve !== null) {
73697    var data = iter[kStream].read(); // we defer if data is null
73698    // we can be expecting either 'end' or
73699    // 'error'
73700
73701    if (data !== null) {
73702      iter[kLastPromise] = null;
73703      iter[kLastResolve] = null;
73704      iter[kLastReject] = null;
73705      resolve(createIterResult(data, false));
73706    }
73707  }
73708}
73709
73710function onReadable(iter) {
73711  // we wait for the next tick, because it might
73712  // emit an error with process.nextTick
73713  process.nextTick(readAndResolve, iter);
73714}
73715
73716function wrapForNext(lastPromise, iter) {
73717  return function (resolve, reject) {
73718    lastPromise.then(function () {
73719      if (iter[kEnded]) {
73720        resolve(createIterResult(undefined, true));
73721        return;
73722      }
73723
73724      iter[kHandlePromise](resolve, reject);
73725    }, reject);
73726  };
73727}
73728
73729var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
73730var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
73731  get stream() {
73732    return this[kStream];
73733  },
73734
73735  next: function next() {
73736    var _this = this; // if we have detected an error in the meanwhile
73737    // reject straight away
73738
73739
73740    var error = this[kError];
73741
73742    if (error !== null) {
73743      return Promise.reject(error);
73744    }
73745
73746    if (this[kEnded]) {
73747      return Promise.resolve(createIterResult(undefined, true));
73748    }
73749
73750    if (this[kStream].destroyed) {
73751      // We need to defer via nextTick because if .destroy(err) is
73752      // called, the error will be emitted via nextTick, and
73753      // we cannot guarantee that there is no error lingering around
73754      // waiting to be emitted.
73755      return new Promise(function (resolve, reject) {
73756        process.nextTick(function () {
73757          if (_this[kError]) {
73758            reject(_this[kError]);
73759          } else {
73760            resolve(createIterResult(undefined, true));
73761          }
73762        });
73763      });
73764    } // if we have multiple next() calls
73765    // we will wait for the previous Promise to finish
73766    // this logic is optimized to support for await loops,
73767    // where next() is only called once at a time
73768
73769
73770    var lastPromise = this[kLastPromise];
73771    var promise;
73772
73773    if (lastPromise) {
73774      promise = new Promise(wrapForNext(lastPromise, this));
73775    } else {
73776      // fast path needed to support multiple this.push()
73777      // without triggering the next() queue
73778      var data = this[kStream].read();
73779
73780      if (data !== null) {
73781        return Promise.resolve(createIterResult(data, false));
73782      }
73783
73784      promise = new Promise(this[kHandlePromise]);
73785    }
73786
73787    this[kLastPromise] = promise;
73788    return promise;
73789  }
73790}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
73791  return this;
73792}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
73793  var _this2 = this; // destroy(err, cb) is a private API
73794  // we can guarantee we have that here, because we control the
73795  // Readable class this is attached to
73796
73797
73798  return new Promise(function (resolve, reject) {
73799    _this2[kStream].destroy(null, function (err) {
73800      if (err) {
73801        reject(err);
73802        return;
73803      }
73804
73805      resolve(createIterResult(undefined, true));
73806    });
73807  });
73808}), _Object$setPrototypeO), AsyncIteratorPrototype);
73809
73810var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
73811  var _Object$create;
73812
73813  var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
73814    value: stream,
73815    writable: true
73816  }), _defineProperty(_Object$create, kLastResolve, {
73817    value: null,
73818    writable: true
73819  }), _defineProperty(_Object$create, kLastReject, {
73820    value: null,
73821    writable: true
73822  }), _defineProperty(_Object$create, kError, {
73823    value: null,
73824    writable: true
73825  }), _defineProperty(_Object$create, kEnded, {
73826    value: stream._readableState.endEmitted,
73827    writable: true
73828  }), _defineProperty(_Object$create, kHandlePromise, {
73829    value: function value(resolve, reject) {
73830      var data = iterator[kStream].read();
73831
73832      if (data) {
73833        iterator[kLastPromise] = null;
73834        iterator[kLastResolve] = null;
73835        iterator[kLastReject] = null;
73836        resolve(createIterResult(data, false));
73837      } else {
73838        iterator[kLastResolve] = resolve;
73839        iterator[kLastReject] = reject;
73840      }
73841    },
73842    writable: true
73843  }), _Object$create));
73844  iterator[kLastPromise] = null;
73845  finished(stream, function (err) {
73846    if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
73847      var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise
73848      // returned by next() and store the error
73849
73850      if (reject !== null) {
73851        iterator[kLastPromise] = null;
73852        iterator[kLastResolve] = null;
73853        iterator[kLastReject] = null;
73854        reject(err);
73855      }
73856
73857      iterator[kError] = err;
73858      return;
73859    }
73860
73861    var resolve = iterator[kLastResolve];
73862
73863    if (resolve !== null) {
73864      iterator[kLastPromise] = null;
73865      iterator[kLastResolve] = null;
73866      iterator[kLastReject] = null;
73867      resolve(createIterResult(undefined, true));
73868    }
73869
73870    iterator[kEnded] = true;
73871  });
73872  stream.on('readable', onReadable.bind(null, iterator));
73873  return iterator;
73874};
73875
73876module.exports = createReadableStreamAsyncIterator;
73877
73878}).call(this,require('_process'))
73879
73880},{"./end-of-stream":486,"_process":467}],484:[function(require,module,exports){
73881'use strict';
73882
73883function ownKeys(object, enumerableOnly) {
73884  var keys = Object.keys(object);
73885
73886  if (Object.getOwnPropertySymbols) {
73887    var symbols = Object.getOwnPropertySymbols(object);
73888    if (enumerableOnly) symbols = symbols.filter(function (sym) {
73889      return Object.getOwnPropertyDescriptor(object, sym).enumerable;
73890    });
73891    keys.push.apply(keys, symbols);
73892  }
73893
73894  return keys;
73895}
73896
73897function _objectSpread(target) {
73898  for (var i = 1; i < arguments.length; i++) {
73899    var source = arguments[i] != null ? arguments[i] : {};
73900
73901    if (i % 2) {
73902      ownKeys(Object(source), true).forEach(function (key) {
73903        _defineProperty(target, key, source[key]);
73904      });
73905    } else if (Object.getOwnPropertyDescriptors) {
73906      Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
73907    } else {
73908      ownKeys(Object(source)).forEach(function (key) {
73909        Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
73910      });
73911    }
73912  }
73913
73914  return target;
73915}
73916
73917function _defineProperty(obj, key, value) {
73918  if (key in obj) {
73919    Object.defineProperty(obj, key, {
73920      value: value,
73921      enumerable: true,
73922      configurable: true,
73923      writable: true
73924    });
73925  } else {
73926    obj[key] = value;
73927  }
73928
73929  return obj;
73930}
73931
73932function _classCallCheck(instance, Constructor) {
73933  if (!(instance instanceof Constructor)) {
73934    throw new TypeError("Cannot call a class as a function");
73935  }
73936}
73937
73938function _defineProperties(target, props) {
73939  for (var i = 0; i < props.length; i++) {
73940    var descriptor = props[i];
73941    descriptor.enumerable = descriptor.enumerable || false;
73942    descriptor.configurable = true;
73943    if ("value" in descriptor) descriptor.writable = true;
73944    Object.defineProperty(target, descriptor.key, descriptor);
73945  }
73946}
73947
73948function _createClass(Constructor, protoProps, staticProps) {
73949  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
73950  if (staticProps) _defineProperties(Constructor, staticProps);
73951  return Constructor;
73952}
73953
73954var _require = require('buffer'),
73955    Buffer = _require.Buffer;
73956
73957var _require2 = require('util'),
73958    inspect = _require2.inspect;
73959
73960var custom = inspect && inspect.custom || 'inspect';
73961
73962function copyBuffer(src, target, offset) {
73963  Buffer.prototype.copy.call(src, target, offset);
73964}
73965
73966module.exports = /*#__PURE__*/function () {
73967  function BufferList() {
73968    _classCallCheck(this, BufferList);
73969
73970    this.head = null;
73971    this.tail = null;
73972    this.length = 0;
73973  }
73974
73975  _createClass(BufferList, [{
73976    key: "push",
73977    value: function push(v) {
73978      var entry = {
73979        data: v,
73980        next: null
73981      };
73982      if (this.length > 0) this.tail.next = entry;else this.head = entry;
73983      this.tail = entry;
73984      ++this.length;
73985    }
73986  }, {
73987    key: "unshift",
73988    value: function unshift(v) {
73989      var entry = {
73990        data: v,
73991        next: this.head
73992      };
73993      if (this.length === 0) this.tail = entry;
73994      this.head = entry;
73995      ++this.length;
73996    }
73997  }, {
73998    key: "shift",
73999    value: function shift() {
74000      if (this.length === 0) return;
74001      var ret = this.head.data;
74002      if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
74003      --this.length;
74004      return ret;
74005    }
74006  }, {
74007    key: "clear",
74008    value: function clear() {
74009      this.head = this.tail = null;
74010      this.length = 0;
74011    }
74012  }, {
74013    key: "join",
74014    value: function join(s) {
74015      if (this.length === 0) return '';
74016      var p = this.head;
74017      var ret = '' + p.data;
74018
74019      while (p = p.next) {
74020        ret += s + p.data;
74021      }
74022
74023      return ret;
74024    }
74025  }, {
74026    key: "concat",
74027    value: function concat(n) {
74028      if (this.length === 0) return Buffer.alloc(0);
74029      var ret = Buffer.allocUnsafe(n >>> 0);
74030      var p = this.head;
74031      var i = 0;
74032
74033      while (p) {
74034        copyBuffer(p.data, ret, i);
74035        i += p.data.length;
74036        p = p.next;
74037      }
74038
74039      return ret;
74040    } // Consumes a specified amount of bytes or characters from the buffered data.
74041
74042  }, {
74043    key: "consume",
74044    value: function consume(n, hasStrings) {
74045      var ret;
74046
74047      if (n < this.head.data.length) {
74048        // `slice` is the same for buffers and strings.
74049        ret = this.head.data.slice(0, n);
74050        this.head.data = this.head.data.slice(n);
74051      } else if (n === this.head.data.length) {
74052        // First chunk is a perfect match.
74053        ret = this.shift();
74054      } else {
74055        // Result spans more than one buffer.
74056        ret = hasStrings ? this._getString(n) : this._getBuffer(n);
74057      }
74058
74059      return ret;
74060    }
74061  }, {
74062    key: "first",
74063    value: function first() {
74064      return this.head.data;
74065    } // Consumes a specified amount of characters from the buffered data.
74066
74067  }, {
74068    key: "_getString",
74069    value: function _getString(n) {
74070      var p = this.head;
74071      var c = 1;
74072      var ret = p.data;
74073      n -= ret.length;
74074
74075      while (p = p.next) {
74076        var str = p.data;
74077        var nb = n > str.length ? str.length : n;
74078        if (nb === str.length) ret += str;else ret += str.slice(0, n);
74079        n -= nb;
74080
74081        if (n === 0) {
74082          if (nb === str.length) {
74083            ++c;
74084            if (p.next) this.head = p.next;else this.head = this.tail = null;
74085          } else {
74086            this.head = p;
74087            p.data = str.slice(nb);
74088          }
74089
74090          break;
74091        }
74092
74093        ++c;
74094      }
74095
74096      this.length -= c;
74097      return ret;
74098    } // Consumes a specified amount of bytes from the buffered data.
74099
74100  }, {
74101    key: "_getBuffer",
74102    value: function _getBuffer(n) {
74103      var ret = Buffer.allocUnsafe(n);
74104      var p = this.head;
74105      var c = 1;
74106      p.data.copy(ret);
74107      n -= p.data.length;
74108
74109      while (p = p.next) {
74110        var buf = p.data;
74111        var nb = n > buf.length ? buf.length : n;
74112        buf.copy(ret, ret.length - n, 0, nb);
74113        n -= nb;
74114
74115        if (n === 0) {
74116          if (nb === buf.length) {
74117            ++c;
74118            if (p.next) this.head = p.next;else this.head = this.tail = null;
74119          } else {
74120            this.head = p;
74121            p.data = buf.slice(nb);
74122          }
74123
74124          break;
74125        }
74126
74127        ++c;
74128      }
74129
74130      this.length -= c;
74131      return ret;
74132    } // Make sure the linked list only shows the minimal necessary information.
74133
74134  }, {
74135    key: custom,
74136    value: function value(_, options) {
74137      return inspect(this, _objectSpread({}, options, {
74138        // Only inspect one level.
74139        depth: 0,
74140        // It should not recurse.
74141        customInspect: false
74142      }));
74143    }
74144  }]);
74145
74146  return BufferList;
74147}();
74148
74149},{"buffer":216,"util":185}],485:[function(require,module,exports){
74150(function (process){
74151'use strict'; // undocumented cb() API, needed for core, not for public API
74152
74153function destroy(err, cb) {
74154  var _this = this;
74155
74156  var readableDestroyed = this._readableState && this._readableState.destroyed;
74157  var writableDestroyed = this._writableState && this._writableState.destroyed;
74158
74159  if (readableDestroyed || writableDestroyed) {
74160    if (cb) {
74161      cb(err);
74162    } else if (err) {
74163      if (!this._writableState) {
74164        process.nextTick(emitErrorNT, this, err);
74165      } else if (!this._writableState.errorEmitted) {
74166        this._writableState.errorEmitted = true;
74167        process.nextTick(emitErrorNT, this, err);
74168      }
74169    }
74170
74171    return this;
74172  } // we set destroyed to true before firing error callbacks in order
74173  // to make it re-entrance safe in case destroy() is called within callbacks
74174
74175
74176  if (this._readableState) {
74177    this._readableState.destroyed = true;
74178  } // if this is a duplex stream mark the writable part as destroyed as well
74179
74180
74181  if (this._writableState) {
74182    this._writableState.destroyed = true;
74183  }
74184
74185  this._destroy(err || null, function (err) {
74186    if (!cb && err) {
74187      if (!_this._writableState) {
74188        process.nextTick(emitErrorAndCloseNT, _this, err);
74189      } else if (!_this._writableState.errorEmitted) {
74190        _this._writableState.errorEmitted = true;
74191        process.nextTick(emitErrorAndCloseNT, _this, err);
74192      } else {
74193        process.nextTick(emitCloseNT, _this);
74194      }
74195    } else if (cb) {
74196      process.nextTick(emitCloseNT, _this);
74197      cb(err);
74198    } else {
74199      process.nextTick(emitCloseNT, _this);
74200    }
74201  });
74202
74203  return this;
74204}
74205
74206function emitErrorAndCloseNT(self, err) {
74207  emitErrorNT(self, err);
74208  emitCloseNT(self);
74209}
74210
74211function emitCloseNT(self) {
74212  if (self._writableState && !self._writableState.emitClose) return;
74213  if (self._readableState && !self._readableState.emitClose) return;
74214  self.emit('close');
74215}
74216
74217function undestroy() {
74218  if (this._readableState) {
74219    this._readableState.destroyed = false;
74220    this._readableState.reading = false;
74221    this._readableState.ended = false;
74222    this._readableState.endEmitted = false;
74223  }
74224
74225  if (this._writableState) {
74226    this._writableState.destroyed = false;
74227    this._writableState.ended = false;
74228    this._writableState.ending = false;
74229    this._writableState.finalCalled = false;
74230    this._writableState.prefinished = false;
74231    this._writableState.finished = false;
74232    this._writableState.errorEmitted = false;
74233  }
74234}
74235
74236function emitErrorNT(self, err) {
74237  self.emit('error', err);
74238}
74239
74240function errorOrDestroy(stream, err) {
74241  // We have tests that rely on errors being emitted
74242  // in the same tick, so changing this is semver major.
74243  // For now when you opt-in to autoDestroy we allow
74244  // the error to be emitted nextTick. In a future
74245  // semver major update we should change the default to this.
74246  var rState = stream._readableState;
74247  var wState = stream._writableState;
74248  if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
74249}
74250
74251module.exports = {
74252  destroy: destroy,
74253  undestroy: undestroy,
74254  errorOrDestroy: errorOrDestroy
74255};
74256
74257}).call(this,require('_process'))
74258
74259},{"_process":467}],486:[function(require,module,exports){
74260// Ported from https://github.com/mafintosh/end-of-stream with
74261// permission from the author, Mathias Buus (@mafintosh).
74262'use strict';
74263
74264var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;
74265
74266function once(callback) {
74267  var called = false;
74268  return function () {
74269    if (called) return;
74270    called = true;
74271
74272    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
74273      args[_key] = arguments[_key];
74274    }
74275
74276    callback.apply(this, args);
74277  };
74278}
74279
74280function noop() {}
74281
74282function isRequest(stream) {
74283  return stream.setHeader && typeof stream.abort === 'function';
74284}
74285
74286function eos(stream, opts, callback) {
74287  if (typeof opts === 'function') return eos(stream, null, opts);
74288  if (!opts) opts = {};
74289  callback = once(callback || noop);
74290  var readable = opts.readable || opts.readable !== false && stream.readable;
74291  var writable = opts.writable || opts.writable !== false && stream.writable;
74292
74293  var onlegacyfinish = function onlegacyfinish() {
74294    if (!stream.writable) onfinish();
74295  };
74296
74297  var writableEnded = stream._writableState && stream._writableState.finished;
74298
74299  var onfinish = function onfinish() {
74300    writable = false;
74301    writableEnded = true;
74302    if (!readable) callback.call(stream);
74303  };
74304
74305  var readableEnded = stream._readableState && stream._readableState.endEmitted;
74306
74307  var onend = function onend() {
74308    readable = false;
74309    readableEnded = true;
74310    if (!writable) callback.call(stream);
74311  };
74312
74313  var onerror = function onerror(err) {
74314    callback.call(stream, err);
74315  };
74316
74317  var onclose = function onclose() {
74318    var err;
74319
74320    if (readable && !readableEnded) {
74321      if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
74322      return callback.call(stream, err);
74323    }
74324
74325    if (writable && !writableEnded) {
74326      if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
74327      return callback.call(stream, err);
74328    }
74329  };
74330
74331  var onrequest = function onrequest() {
74332    stream.req.on('finish', onfinish);
74333  };
74334
74335  if (isRequest(stream)) {
74336    stream.on('complete', onfinish);
74337    stream.on('abort', onclose);
74338    if (stream.req) onrequest();else stream.on('request', onrequest);
74339  } else if (writable && !stream._writableState) {
74340    // legacy streams
74341    stream.on('end', onlegacyfinish);
74342    stream.on('close', onlegacyfinish);
74343  }
74344
74345  stream.on('end', onend);
74346  stream.on('finish', onfinish);
74347  if (opts.error !== false) stream.on('error', onerror);
74348  stream.on('close', onclose);
74349  return function () {
74350    stream.removeListener('complete', onfinish);
74351    stream.removeListener('abort', onclose);
74352    stream.removeListener('request', onrequest);
74353    if (stream.req) stream.req.removeListener('finish', onfinish);
74354    stream.removeListener('end', onlegacyfinish);
74355    stream.removeListener('close', onlegacyfinish);
74356    stream.removeListener('finish', onfinish);
74357    stream.removeListener('end', onend);
74358    stream.removeListener('error', onerror);
74359    stream.removeListener('close', onclose);
74360  };
74361}
74362
74363module.exports = eos;
74364
74365},{"../../../errors":477}],487:[function(require,module,exports){
74366"use strict";
74367
74368module.exports = function () {
74369  throw new Error('Readable.from is not available in the browser');
74370};
74371
74372},{}],488:[function(require,module,exports){
74373// Ported from https://github.com/mafintosh/pump with
74374// permission from the author, Mathias Buus (@mafintosh).
74375'use strict';
74376
74377var eos;
74378
74379function once(callback) {
74380  var called = false;
74381  return function () {
74382    if (called) return;
74383    called = true;
74384    callback.apply(void 0, arguments);
74385  };
74386}
74387
74388var _require$codes = require('../../../errors').codes,
74389    ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
74390    ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
74391
74392function noop(err) {
74393  // Rethrow the error if it exists to avoid swallowing it
74394  if (err) throw err;
74395}
74396
74397function isRequest(stream) {
74398  return stream.setHeader && typeof stream.abort === 'function';
74399}
74400
74401function destroyer(stream, reading, writing, callback) {
74402  callback = once(callback);
74403  var closed = false;
74404  stream.on('close', function () {
74405    closed = true;
74406  });
74407  if (eos === undefined) eos = require('./end-of-stream');
74408  eos(stream, {
74409    readable: reading,
74410    writable: writing
74411  }, function (err) {
74412    if (err) return callback(err);
74413    closed = true;
74414    callback();
74415  });
74416  var destroyed = false;
74417  return function (err) {
74418    if (closed) return;
74419    if (destroyed) return;
74420    destroyed = true; // request.destroy just do .end - .abort is what we want
74421
74422    if (isRequest(stream)) return stream.abort();
74423    if (typeof stream.destroy === 'function') return stream.destroy();
74424    callback(err || new ERR_STREAM_DESTROYED('pipe'));
74425  };
74426}
74427
74428function call(fn) {
74429  fn();
74430}
74431
74432function pipe(from, to) {
74433  return from.pipe(to);
74434}
74435
74436function popCallback(streams) {
74437  if (!streams.length) return noop;
74438  if (typeof streams[streams.length - 1] !== 'function') return noop;
74439  return streams.pop();
74440}
74441
74442function pipeline() {
74443  for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
74444    streams[_key] = arguments[_key];
74445  }
74446
74447  var callback = popCallback(streams);
74448  if (Array.isArray(streams[0])) streams = streams[0];
74449
74450  if (streams.length < 2) {
74451    throw new ERR_MISSING_ARGS('streams');
74452  }
74453
74454  var error;
74455  var destroys = streams.map(function (stream, i) {
74456    var reading = i < streams.length - 1;
74457    var writing = i > 0;
74458    return destroyer(stream, reading, writing, function (err) {
74459      if (!error) error = err;
74460      if (err) destroys.forEach(call);
74461      if (reading) return;
74462      destroys.forEach(call);
74463      callback(error);
74464    });
74465  });
74466  return streams.reduce(pipe);
74467}
74468
74469module.exports = pipeline;
74470
74471},{"../../../errors":477,"./end-of-stream":486}],489:[function(require,module,exports){
74472'use strict';
74473
74474var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
74475
74476function highWaterMarkFrom(options, isDuplex, duplexKey) {
74477  return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
74478}
74479
74480function getHighWaterMark(state, options, duplexKey, isDuplex) {
74481  var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
74482
74483  if (hwm != null) {
74484    if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
74485      var name = isDuplex ? duplexKey : 'highWaterMark';
74486      throw new ERR_INVALID_OPT_VALUE(name, hwm);
74487    }
74488
74489    return Math.floor(hwm);
74490  } // Default value
74491
74492
74493  return state.objectMode ? 16 : 16 * 1024;
74494}
74495
74496module.exports = {
74497  getHighWaterMark: getHighWaterMark
74498};
74499
74500},{"../../../errors":477}],490:[function(require,module,exports){
74501"use strict";
74502
74503module.exports = require('events').EventEmitter;
74504
74505},{"events":367}],491:[function(require,module,exports){
74506"use strict";
74507
74508exports = module.exports = require('./lib/_stream_readable.js');
74509exports.Stream = exports;
74510exports.Readable = exports;
74511exports.Writable = require('./lib/_stream_writable.js');
74512exports.Duplex = require('./lib/_stream_duplex.js');
74513exports.Transform = require('./lib/_stream_transform.js');
74514exports.PassThrough = require('./lib/_stream_passthrough.js');
74515exports.finished = require('./lib/internal/streams/end-of-stream.js');
74516exports.pipeline = require('./lib/internal/streams/pipeline.js');
74517
74518},{"./lib/_stream_duplex.js":478,"./lib/_stream_passthrough.js":479,"./lib/_stream_readable.js":480,"./lib/_stream_transform.js":481,"./lib/_stream_writable.js":482,"./lib/internal/streams/end-of-stream.js":486,"./lib/internal/streams/pipeline.js":488}],492:[function(require,module,exports){
74519"use strict";
74520
74521function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
74522
74523/**
74524 * Copyright (c) 2014-present, Facebook, Inc.
74525 *
74526 * This source code is licensed under the MIT license found in the
74527 * LICENSE file in the root directory of this source tree.
74528 */
74529var runtime = function (exports) {
74530  "use strict";
74531
74532  var Op = Object.prototype;
74533  var hasOwn = Op.hasOwnProperty;
74534  var undefined; // More compressible than void 0.
74535
74536  var $Symbol = typeof Symbol === "function" ? Symbol : {};
74537  var iteratorSymbol = $Symbol.iterator || "@@iterator";
74538  var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
74539  var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
74540
74541  function define(obj, key, value) {
74542    Object.defineProperty(obj, key, {
74543      value: value,
74544      enumerable: true,
74545      configurable: true,
74546      writable: true
74547    });
74548    return obj[key];
74549  }
74550
74551  try {
74552    // IE 8 has a broken Object.defineProperty that only works on DOM objects.
74553    define({}, "");
74554  } catch (err) {
74555    define = function define(obj, key, value) {
74556      return obj[key] = value;
74557    };
74558  }
74559
74560  function wrap(innerFn, outerFn, self, tryLocsList) {
74561    // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
74562    var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
74563    var generator = Object.create(protoGenerator.prototype);
74564    var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
74565    // .throw, and .return methods.
74566
74567    generator._invoke = makeInvokeMethod(innerFn, self, context);
74568    return generator;
74569  }
74570
74571  exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
74572  // record like context.tryEntries[i].completion. This interface could
74573  // have been (and was previously) designed to take a closure to be
74574  // invoked without arguments, but in all the cases we care about we
74575  // already have an existing method we want to call, so there's no need
74576  // to create a new function object. We can even get away with assuming
74577  // the method takes exactly one argument, since that happens to be true
74578  // in every case, so we don't have to touch the arguments object. The
74579  // only additional allocation required is the completion record, which
74580  // has a stable shape and so hopefully should be cheap to allocate.
74581
74582  function tryCatch(fn, obj, arg) {
74583    try {
74584      return {
74585        type: "normal",
74586        arg: fn.call(obj, arg)
74587      };
74588    } catch (err) {
74589      return {
74590        type: "throw",
74591        arg: err
74592      };
74593    }
74594  }
74595
74596  var GenStateSuspendedStart = "suspendedStart";
74597  var GenStateSuspendedYield = "suspendedYield";
74598  var GenStateExecuting = "executing";
74599  var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
74600  // breaking out of the dispatch switch statement.
74601
74602  var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
74603  // .constructor.prototype properties for functions that return Generator
74604  // objects. For full spec compliance, you may wish to configure your
74605  // minifier not to mangle the names of these two functions.
74606
74607  function Generator() {}
74608
74609  function GeneratorFunction() {}
74610
74611  function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
74612  // don't natively support it.
74613
74614
74615  var IteratorPrototype = {};
74616
74617  IteratorPrototype[iteratorSymbol] = function () {
74618    return this;
74619  };
74620
74621  var getProto = Object.getPrototypeOf;
74622  var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
74623
74624  if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
74625    // This environment has a native %IteratorPrototype%; use it instead
74626    // of the polyfill.
74627    IteratorPrototype = NativeIteratorPrototype;
74628  }
74629
74630  var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
74631  GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
74632  GeneratorFunctionPrototype.constructor = GeneratorFunction;
74633  GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
74634  // Iterator interface in terms of a single ._invoke method.
74635
74636  function defineIteratorMethods(prototype) {
74637    ["next", "throw", "return"].forEach(function (method) {
74638      define(prototype, method, function (arg) {
74639        return this._invoke(method, arg);
74640      });
74641    });
74642  }
74643
74644  exports.isGeneratorFunction = function (genFun) {
74645    var ctor = typeof genFun === "function" && genFun.constructor;
74646    return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
74647    // do is to check its .name property.
74648    (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
74649  };
74650
74651  exports.mark = function (genFun) {
74652    if (Object.setPrototypeOf) {
74653      Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
74654    } else {
74655      genFun.__proto__ = GeneratorFunctionPrototype;
74656      define(genFun, toStringTagSymbol, "GeneratorFunction");
74657    }
74658
74659    genFun.prototype = Object.create(Gp);
74660    return genFun;
74661  }; // Within the body of any async function, `await x` is transformed to
74662  // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
74663  // `hasOwn.call(value, "__await")` to determine if the yielded value is
74664  // meant to be awaited.
74665
74666
74667  exports.awrap = function (arg) {
74668    return {
74669      __await: arg
74670    };
74671  };
74672
74673  function AsyncIterator(generator, PromiseImpl) {
74674    function invoke(method, arg, resolve, reject) {
74675      var record = tryCatch(generator[method], generator, arg);
74676
74677      if (record.type === "throw") {
74678        reject(record.arg);
74679      } else {
74680        var result = record.arg;
74681        var value = result.value;
74682
74683        if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
74684          return PromiseImpl.resolve(value.__await).then(function (value) {
74685            invoke("next", value, resolve, reject);
74686          }, function (err) {
74687            invoke("throw", err, resolve, reject);
74688          });
74689        }
74690
74691        return PromiseImpl.resolve(value).then(function (unwrapped) {
74692          // When a yielded Promise is resolved, its final value becomes
74693          // the .value of the Promise<{value,done}> result for the
74694          // current iteration.
74695          result.value = unwrapped;
74696          resolve(result);
74697        }, function (error) {
74698          // If a rejected Promise was yielded, throw the rejection back
74699          // into the async generator function so it can be handled there.
74700          return invoke("throw", error, resolve, reject);
74701        });
74702      }
74703    }
74704
74705    var previousPromise;
74706
74707    function enqueue(method, arg) {
74708      function callInvokeWithMethodAndArg() {
74709        return new PromiseImpl(function (resolve, reject) {
74710          invoke(method, arg, resolve, reject);
74711        });
74712      }
74713
74714      return previousPromise = // If enqueue has been called before, then we want to wait until
74715      // all previous Promises have been resolved before calling invoke,
74716      // so that results are always delivered in the correct order. If
74717      // enqueue has not been called before, then it is important to
74718      // call invoke immediately, without waiting on a callback to fire,
74719      // so that the async generator function has the opportunity to do
74720      // any necessary setup in a predictable way. This predictability
74721      // is why the Promise constructor synchronously invokes its
74722      // executor callback, and why async functions synchronously
74723      // execute code before the first await. Since we implement simple
74724      // async functions in terms of async generators, it is especially
74725      // important to get this right, even though it requires care.
74726      previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
74727      // invocations of the iterator.
74728      callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
74729    } // Define the unified helper method that is used to implement .next,
74730    // .throw, and .return (see defineIteratorMethods).
74731
74732
74733    this._invoke = enqueue;
74734  }
74735
74736  defineIteratorMethods(AsyncIterator.prototype);
74737
74738  AsyncIterator.prototype[asyncIteratorSymbol] = function () {
74739    return this;
74740  };
74741
74742  exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
74743  // AsyncIterator objects; they just return a Promise for the value of
74744  // the final result produced by the iterator.
74745
74746  exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
74747    if (PromiseImpl === void 0) PromiseImpl = Promise;
74748    var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
74749    return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
74750    : iter.next().then(function (result) {
74751      return result.done ? result.value : iter.next();
74752    });
74753  };
74754
74755  function makeInvokeMethod(innerFn, self, context) {
74756    var state = GenStateSuspendedStart;
74757    return function invoke(method, arg) {
74758      if (state === GenStateExecuting) {
74759        throw new Error("Generator is already running");
74760      }
74761
74762      if (state === GenStateCompleted) {
74763        if (method === "throw") {
74764          throw arg;
74765        } // Be forgiving, per 25.3.3.3.3 of the spec:
74766        // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
74767
74768
74769        return doneResult();
74770      }
74771
74772      context.method = method;
74773      context.arg = arg;
74774
74775      while (true) {
74776        var delegate = context.delegate;
74777
74778        if (delegate) {
74779          var delegateResult = maybeInvokeDelegate(delegate, context);
74780
74781          if (delegateResult) {
74782            if (delegateResult === ContinueSentinel) continue;
74783            return delegateResult;
74784          }
74785        }
74786
74787        if (context.method === "next") {
74788          // Setting context._sent for legacy support of Babel's
74789          // function.sent implementation.
74790          context.sent = context._sent = context.arg;
74791        } else if (context.method === "throw") {
74792          if (state === GenStateSuspendedStart) {
74793            state = GenStateCompleted;
74794            throw context.arg;
74795          }
74796
74797          context.dispatchException(context.arg);
74798        } else if (context.method === "return") {
74799          context.abrupt("return", context.arg);
74800        }
74801
74802        state = GenStateExecuting;
74803        var record = tryCatch(innerFn, self, context);
74804
74805        if (record.type === "normal") {
74806          // If an exception is thrown from innerFn, we leave state ===
74807          // GenStateExecuting and loop back for another invocation.
74808          state = context.done ? GenStateCompleted : GenStateSuspendedYield;
74809
74810          if (record.arg === ContinueSentinel) {
74811            continue;
74812          }
74813
74814          return {
74815            value: record.arg,
74816            done: context.done
74817          };
74818        } else if (record.type === "throw") {
74819          state = GenStateCompleted; // Dispatch the exception by looping back around to the
74820          // context.dispatchException(context.arg) call above.
74821
74822          context.method = "throw";
74823          context.arg = record.arg;
74824        }
74825      }
74826    };
74827  } // Call delegate.iterator[context.method](context.arg) and handle the
74828  // result, either by returning a { value, done } result from the
74829  // delegate iterator, or by modifying context.method and context.arg,
74830  // setting context.delegate to null, and returning the ContinueSentinel.
74831
74832
74833  function maybeInvokeDelegate(delegate, context) {
74834    var method = delegate.iterator[context.method];
74835
74836    if (method === undefined) {
74837      // A .throw or .return when the delegate iterator has no .throw
74838      // method always terminates the yield* loop.
74839      context.delegate = null;
74840
74841      if (context.method === "throw") {
74842        // Note: ["return"] must be used for ES3 parsing compatibility.
74843        if (delegate.iterator["return"]) {
74844          // If the delegate iterator has a return method, give it a
74845          // chance to clean up.
74846          context.method = "return";
74847          context.arg = undefined;
74848          maybeInvokeDelegate(delegate, context);
74849
74850          if (context.method === "throw") {
74851            // If maybeInvokeDelegate(context) changed context.method from
74852            // "return" to "throw", let that override the TypeError below.
74853            return ContinueSentinel;
74854          }
74855        }
74856
74857        context.method = "throw";
74858        context.arg = new TypeError("The iterator does not provide a 'throw' method");
74859      }
74860
74861      return ContinueSentinel;
74862    }
74863
74864    var record = tryCatch(method, delegate.iterator, context.arg);
74865
74866    if (record.type === "throw") {
74867      context.method = "throw";
74868      context.arg = record.arg;
74869      context.delegate = null;
74870      return ContinueSentinel;
74871    }
74872
74873    var info = record.arg;
74874
74875    if (!info) {
74876      context.method = "throw";
74877      context.arg = new TypeError("iterator result is not an object");
74878      context.delegate = null;
74879      return ContinueSentinel;
74880    }
74881
74882    if (info.done) {
74883      // Assign the result of the finished delegate to the temporary
74884      // variable specified by delegate.resultName (see delegateYield).
74885      context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
74886
74887      context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
74888      // exception, let the outer generator proceed normally. If
74889      // context.method was "next", forget context.arg since it has been
74890      // "consumed" by the delegate iterator. If context.method was
74891      // "return", allow the original .return call to continue in the
74892      // outer generator.
74893
74894      if (context.method !== "return") {
74895        context.method = "next";
74896        context.arg = undefined;
74897      }
74898    } else {
74899      // Re-yield the result returned by the delegate method.
74900      return info;
74901    } // The delegate iterator is finished, so forget it and continue with
74902    // the outer generator.
74903
74904
74905    context.delegate = null;
74906    return ContinueSentinel;
74907  } // Define Generator.prototype.{next,throw,return} in terms of the
74908  // unified ._invoke helper method.
74909
74910
74911  defineIteratorMethods(Gp);
74912  define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
74913  // @@iterator function is called on it. Some browsers' implementations of the
74914  // iterator prototype chain incorrectly implement this, causing the Generator
74915  // object to not be returned from this call. This ensures that doesn't happen.
74916  // See https://github.com/facebook/regenerator/issues/274 for more details.
74917
74918  Gp[iteratorSymbol] = function () {
74919    return this;
74920  };
74921
74922  Gp.toString = function () {
74923    return "[object Generator]";
74924  };
74925
74926  function pushTryEntry(locs) {
74927    var entry = {
74928      tryLoc: locs[0]
74929    };
74930
74931    if (1 in locs) {
74932      entry.catchLoc = locs[1];
74933    }
74934
74935    if (2 in locs) {
74936      entry.finallyLoc = locs[2];
74937      entry.afterLoc = locs[3];
74938    }
74939
74940    this.tryEntries.push(entry);
74941  }
74942
74943  function resetTryEntry(entry) {
74944    var record = entry.completion || {};
74945    record.type = "normal";
74946    delete record.arg;
74947    entry.completion = record;
74948  }
74949
74950  function Context(tryLocsList) {
74951    // The root entry object (effectively a try statement without a catch
74952    // or a finally block) gives us a place to store values thrown from
74953    // locations where there is no enclosing try statement.
74954    this.tryEntries = [{
74955      tryLoc: "root"
74956    }];
74957    tryLocsList.forEach(pushTryEntry, this);
74958    this.reset(true);
74959  }
74960
74961  exports.keys = function (object) {
74962    var keys = [];
74963
74964    for (var key in object) {
74965      keys.push(key);
74966    }
74967
74968    keys.reverse(); // Rather than returning an object with a next method, we keep
74969    // things simple and return the next function itself.
74970
74971    return function next() {
74972      while (keys.length) {
74973        var key = keys.pop();
74974
74975        if (key in object) {
74976          next.value = key;
74977          next.done = false;
74978          return next;
74979        }
74980      } // To avoid creating an additional object, we just hang the .value
74981      // and .done properties off the next function object itself. This
74982      // also ensures that the minifier will not anonymize the function.
74983
74984
74985      next.done = true;
74986      return next;
74987    };
74988  };
74989
74990  function values(iterable) {
74991    if (iterable) {
74992      var iteratorMethod = iterable[iteratorSymbol];
74993
74994      if (iteratorMethod) {
74995        return iteratorMethod.call(iterable);
74996      }
74997
74998      if (typeof iterable.next === "function") {
74999        return iterable;
75000      }
75001
75002      if (!isNaN(iterable.length)) {
75003        var i = -1,
75004            next = function next() {
75005          while (++i < iterable.length) {
75006            if (hasOwn.call(iterable, i)) {
75007              next.value = iterable[i];
75008              next.done = false;
75009              return next;
75010            }
75011          }
75012
75013          next.value = undefined;
75014          next.done = true;
75015          return next;
75016        };
75017
75018        return next.next = next;
75019      }
75020    } // Return an iterator with no values.
75021
75022
75023    return {
75024      next: doneResult
75025    };
75026  }
75027
75028  exports.values = values;
75029
75030  function doneResult() {
75031    return {
75032      value: undefined,
75033      done: true
75034    };
75035  }
75036
75037  Context.prototype = {
75038    constructor: Context,
75039    reset: function reset(skipTempReset) {
75040      this.prev = 0;
75041      this.next = 0; // Resetting context._sent for legacy support of Babel's
75042      // function.sent implementation.
75043
75044      this.sent = this._sent = undefined;
75045      this.done = false;
75046      this.delegate = null;
75047      this.method = "next";
75048      this.arg = undefined;
75049      this.tryEntries.forEach(resetTryEntry);
75050
75051      if (!skipTempReset) {
75052        for (var name in this) {
75053          // Not sure about the optimal order of these conditions:
75054          if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
75055            this[name] = undefined;
75056          }
75057        }
75058      }
75059    },
75060    stop: function stop() {
75061      this.done = true;
75062      var rootEntry = this.tryEntries[0];
75063      var rootRecord = rootEntry.completion;
75064
75065      if (rootRecord.type === "throw") {
75066        throw rootRecord.arg;
75067      }
75068
75069      return this.rval;
75070    },
75071    dispatchException: function dispatchException(exception) {
75072      if (this.done) {
75073        throw exception;
75074      }
75075
75076      var context = this;
75077
75078      function handle(loc, caught) {
75079        record.type = "throw";
75080        record.arg = exception;
75081        context.next = loc;
75082
75083        if (caught) {
75084          // If the dispatched exception was caught by a catch block,
75085          // then let that catch block handle the exception normally.
75086          context.method = "next";
75087          context.arg = undefined;
75088        }
75089
75090        return !!caught;
75091      }
75092
75093      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
75094        var entry = this.tryEntries[i];
75095        var record = entry.completion;
75096
75097        if (entry.tryLoc === "root") {
75098          // Exception thrown outside of any try block that could handle
75099          // it, so set the completion value of the entire function to
75100          // throw the exception.
75101          return handle("end");
75102        }
75103
75104        if (entry.tryLoc <= this.prev) {
75105          var hasCatch = hasOwn.call(entry, "catchLoc");
75106          var hasFinally = hasOwn.call(entry, "finallyLoc");
75107
75108          if (hasCatch && hasFinally) {
75109            if (this.prev < entry.catchLoc) {
75110              return handle(entry.catchLoc, true);
75111            } else if (this.prev < entry.finallyLoc) {
75112              return handle(entry.finallyLoc);
75113            }
75114          } else if (hasCatch) {
75115            if (this.prev < entry.catchLoc) {
75116              return handle(entry.catchLoc, true);
75117            }
75118          } else if (hasFinally) {
75119            if (this.prev < entry.finallyLoc) {
75120              return handle(entry.finallyLoc);
75121            }
75122          } else {
75123            throw new Error("try statement without catch or finally");
75124          }
75125        }
75126      }
75127    },
75128    abrupt: function abrupt(type, arg) {
75129      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
75130        var entry = this.tryEntries[i];
75131
75132        if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
75133          var finallyEntry = entry;
75134          break;
75135        }
75136      }
75137
75138      if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
75139        // Ignore the finally entry if control is not jumping to a
75140        // location outside the try/catch block.
75141        finallyEntry = null;
75142      }
75143
75144      var record = finallyEntry ? finallyEntry.completion : {};
75145      record.type = type;
75146      record.arg = arg;
75147
75148      if (finallyEntry) {
75149        this.method = "next";
75150        this.next = finallyEntry.finallyLoc;
75151        return ContinueSentinel;
75152      }
75153
75154      return this.complete(record);
75155    },
75156    complete: function complete(record, afterLoc) {
75157      if (record.type === "throw") {
75158        throw record.arg;
75159      }
75160
75161      if (record.type === "break" || record.type === "continue") {
75162        this.next = record.arg;
75163      } else if (record.type === "return") {
75164        this.rval = this.arg = record.arg;
75165        this.method = "return";
75166        this.next = "end";
75167      } else if (record.type === "normal" && afterLoc) {
75168        this.next = afterLoc;
75169      }
75170
75171      return ContinueSentinel;
75172    },
75173    finish: function finish(finallyLoc) {
75174      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
75175        var entry = this.tryEntries[i];
75176
75177        if (entry.finallyLoc === finallyLoc) {
75178          this.complete(entry.completion, entry.afterLoc);
75179          resetTryEntry(entry);
75180          return ContinueSentinel;
75181        }
75182      }
75183    },
75184    "catch": function _catch(tryLoc) {
75185      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
75186        var entry = this.tryEntries[i];
75187
75188        if (entry.tryLoc === tryLoc) {
75189          var record = entry.completion;
75190
75191          if (record.type === "throw") {
75192            var thrown = record.arg;
75193            resetTryEntry(entry);
75194          }
75195
75196          return thrown;
75197        }
75198      } // The context.catch method must only be called with a location
75199      // argument that corresponds to a known catch block.
75200
75201
75202      throw new Error("illegal catch attempt");
75203    },
75204    delegateYield: function delegateYield(iterable, resultName, nextLoc) {
75205      this.delegate = {
75206        iterator: values(iterable),
75207        resultName: resultName,
75208        nextLoc: nextLoc
75209      };
75210
75211      if (this.method === "next") {
75212        // Deliberately forget the last sent value so that we don't
75213        // accidentally pass it on to the delegate.
75214        this.arg = undefined;
75215      }
75216
75217      return ContinueSentinel;
75218    }
75219  }; // Regardless of whether this script is executing as a CommonJS module
75220  // or not, return the runtime object so that we can declare the variable
75221  // regeneratorRuntime in the outer scope, which allows this module to be
75222  // injected easily by `bin/regenerator --include-runtime script.js`.
75223
75224  return exports;
75225}( // If this script is executing as a CommonJS module, use module.exports
75226// as the regeneratorRuntime namespace. Otherwise create a new empty
75227// object. Either way, the resulting object will be used to initialize
75228// the regeneratorRuntime variable at the top of this file.
75229(typeof module === "undefined" ? "undefined" : _typeof(module)) === "object" ? module.exports : {});
75230
75231try {
75232  regeneratorRuntime = runtime;
75233} catch (accidentalStrictMode) {
75234  // This module should not be running in strict mode, so the above
75235  // assignment should always work unless something is misconfigured. Just
75236  // in case runtime.js accidentally runs in strict mode, we can escape
75237  // strict mode using a global Function call. This could conceivably fail
75238  // if a Content Security Policy forbids using Function, but in that case
75239  // the proper solution is to fix the accidental strict mode problem. If
75240  // you've misconfigured your bundler to force strict mode and applied a
75241  // CSP to forbid Function, and you're not willing to fix either of those
75242  // problems, please detail your unique predicament in a GitHub issue.
75243  Function("r", "regeneratorRuntime = r")(runtime);
75244}
75245
75246},{}],493:[function(require,module,exports){
75247'use strict';
75248
75249var Buffer = require('buffer').Buffer;
75250
75251var inherits = require('inherits');
75252
75253var HashBase = require('hash-base');
75254
75255var ARRAY16 = new Array(16);
75256var zl = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
75257var zr = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
75258var sl = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6];
75259var sr = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11];
75260var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e];
75261var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000];
75262
75263function RIPEMD160() {
75264  HashBase.call(this, 64); // state
75265
75266  this._a = 0x67452301;
75267  this._b = 0xefcdab89;
75268  this._c = 0x98badcfe;
75269  this._d = 0x10325476;
75270  this._e = 0xc3d2e1f0;
75271}
75272
75273inherits(RIPEMD160, HashBase);
75274
75275RIPEMD160.prototype._update = function () {
75276  var words = ARRAY16;
75277
75278  for (var j = 0; j < 16; ++j) {
75279    words[j] = this._block.readInt32LE(j * 4);
75280  }
75281
75282  var al = this._a | 0;
75283  var bl = this._b | 0;
75284  var cl = this._c | 0;
75285  var dl = this._d | 0;
75286  var el = this._e | 0;
75287  var ar = this._a | 0;
75288  var br = this._b | 0;
75289  var cr = this._c | 0;
75290  var dr = this._d | 0;
75291  var er = this._e | 0; // computation
75292
75293  for (var i = 0; i < 80; i += 1) {
75294    var tl;
75295    var tr;
75296
75297    if (i < 16) {
75298      tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]);
75299      tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]);
75300    } else if (i < 32) {
75301      tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]);
75302      tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]);
75303    } else if (i < 48) {
75304      tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]);
75305      tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]);
75306    } else if (i < 64) {
75307      tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]);
75308      tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]);
75309    } else {
75310      // if (i<80) {
75311      tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]);
75312      tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]);
75313    }
75314
75315    al = el;
75316    el = dl;
75317    dl = rotl(cl, 10);
75318    cl = bl;
75319    bl = tl;
75320    ar = er;
75321    er = dr;
75322    dr = rotl(cr, 10);
75323    cr = br;
75324    br = tr;
75325  } // update state
75326
75327
75328  var t = this._b + cl + dr | 0;
75329  this._b = this._c + dl + er | 0;
75330  this._c = this._d + el + ar | 0;
75331  this._d = this._e + al + br | 0;
75332  this._e = this._a + bl + cr | 0;
75333  this._a = t;
75334};
75335
75336RIPEMD160.prototype._digest = function () {
75337  // create padding and handle blocks
75338  this._block[this._blockOffset++] = 0x80;
75339
75340  if (this._blockOffset > 56) {
75341    this._block.fill(0, this._blockOffset, 64);
75342
75343    this._update();
75344
75345    this._blockOffset = 0;
75346  }
75347
75348  this._block.fill(0, this._blockOffset, 56);
75349
75350  this._block.writeUInt32LE(this._length[0], 56);
75351
75352  this._block.writeUInt32LE(this._length[1], 60);
75353
75354  this._update(); // produce result
75355
75356
75357  var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20);
75358  buffer.writeInt32LE(this._a, 0);
75359  buffer.writeInt32LE(this._b, 4);
75360  buffer.writeInt32LE(this._c, 8);
75361  buffer.writeInt32LE(this._d, 12);
75362  buffer.writeInt32LE(this._e, 16);
75363  return buffer;
75364};
75365
75366function rotl(x, n) {
75367  return x << n | x >>> 32 - n;
75368}
75369
75370function fn1(a, b, c, d, e, m, k, s) {
75371  return rotl(a + (b ^ c ^ d) + m + k | 0, s) + e | 0;
75372}
75373
75374function fn2(a, b, c, d, e, m, k, s) {
75375  return rotl(a + (b & c | ~b & d) + m + k | 0, s) + e | 0;
75376}
75377
75378function fn3(a, b, c, d, e, m, k, s) {
75379  return rotl(a + ((b | ~c) ^ d) + m + k | 0, s) + e | 0;
75380}
75381
75382function fn4(a, b, c, d, e, m, k, s) {
75383  return rotl(a + (b & d | c & ~d) + m + k | 0, s) + e | 0;
75384}
75385
75386function fn5(a, b, c, d, e, m, k, s) {
75387  return rotl(a + (b ^ (c | ~d)) + m + k | 0, s) + e | 0;
75388}
75389
75390module.exports = RIPEMD160;
75391
75392},{"buffer":216,"hash-base":370,"inherits":387}],494:[function(require,module,exports){
75393"use strict";
75394
75395/* eslint-disable node/no-deprecated-api */
75396var buffer = require('buffer');
75397
75398var Buffer = buffer.Buffer; // alternative to using Object.keys for old browsers
75399
75400function copyProps(src, dst) {
75401  for (var key in src) {
75402    dst[key] = src[key];
75403  }
75404}
75405
75406if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
75407  module.exports = buffer;
75408} else {
75409  // Copy properties from require('buffer')
75410  copyProps(buffer, exports);
75411  exports.Buffer = SafeBuffer;
75412}
75413
75414function SafeBuffer(arg, encodingOrOffset, length) {
75415  return Buffer(arg, encodingOrOffset, length);
75416} // Copy static methods from Buffer
75417
75418
75419copyProps(Buffer, SafeBuffer);
75420
75421SafeBuffer.from = function (arg, encodingOrOffset, length) {
75422  if (typeof arg === 'number') {
75423    throw new TypeError('Argument must not be a number');
75424  }
75425
75426  return Buffer(arg, encodingOrOffset, length);
75427};
75428
75429SafeBuffer.alloc = function (size, fill, encoding) {
75430  if (typeof size !== 'number') {
75431    throw new TypeError('Argument must be a number');
75432  }
75433
75434  var buf = Buffer(size);
75435
75436  if (fill !== undefined) {
75437    if (typeof encoding === 'string') {
75438      buf.fill(fill, encoding);
75439    } else {
75440      buf.fill(fill);
75441    }
75442  } else {
75443    buf.fill(0);
75444  }
75445
75446  return buf;
75447};
75448
75449SafeBuffer.allocUnsafe = function (size) {
75450  if (typeof size !== 'number') {
75451    throw new TypeError('Argument must be a number');
75452  }
75453
75454  return Buffer(size);
75455};
75456
75457SafeBuffer.allocUnsafeSlow = function (size) {
75458  if (typeof size !== 'number') {
75459    throw new TypeError('Argument must be a number');
75460  }
75461
75462  return buffer.SlowBuffer(size);
75463};
75464
75465},{"buffer":216}],495:[function(require,module,exports){
75466(function (process){
75467/* eslint-disable node/no-deprecated-api */
75468'use strict';
75469
75470function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
75471
75472var buffer = require('buffer');
75473
75474var Buffer = buffer.Buffer;
75475var safer = {};
75476var key;
75477
75478for (key in buffer) {
75479  if (!buffer.hasOwnProperty(key)) continue;
75480  if (key === 'SlowBuffer' || key === 'Buffer') continue;
75481  safer[key] = buffer[key];
75482}
75483
75484var Safer = safer.Buffer = {};
75485
75486for (key in Buffer) {
75487  if (!Buffer.hasOwnProperty(key)) continue;
75488  if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue;
75489  Safer[key] = Buffer[key];
75490}
75491
75492safer.Buffer.prototype = Buffer.prototype;
75493
75494if (!Safer.from || Safer.from === Uint8Array.from) {
75495  Safer.from = function (value, encodingOrOffset, length) {
75496    if (typeof value === 'number') {
75497      throw new TypeError('The "value" argument must not be of type number. Received type ' + _typeof(value));
75498    }
75499
75500    if (value && typeof value.length === 'undefined') {
75501      throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + _typeof(value));
75502    }
75503
75504    return Buffer(value, encodingOrOffset, length);
75505  };
75506}
75507
75508if (!Safer.alloc) {
75509  Safer.alloc = function (size, fill, encoding) {
75510    if (typeof size !== 'number') {
75511      throw new TypeError('The "size" argument must be of type number. Received type ' + _typeof(size));
75512    }
75513
75514    if (size < 0 || size >= 2 * (1 << 30)) {
75515      throw new RangeError('The value "' + size + '" is invalid for option "size"');
75516    }
75517
75518    var buf = Buffer(size);
75519
75520    if (!fill || fill.length === 0) {
75521      buf.fill(0);
75522    } else if (typeof encoding === 'string') {
75523      buf.fill(fill, encoding);
75524    } else {
75525      buf.fill(fill);
75526    }
75527
75528    return buf;
75529  };
75530}
75531
75532if (!safer.kStringMaxLength) {
75533  try {
75534    safer.kStringMaxLength = process.binding('buffer').kStringMaxLength;
75535  } catch (e) {// we can't determine kStringMaxLength in environments where process.binding
75536    // is unsupported, so let's not set it
75537  }
75538}
75539
75540if (!safer.constants) {
75541  safer.constants = {
75542    MAX_LENGTH: safer.kMaxLength
75543  };
75544
75545  if (safer.kStringMaxLength) {
75546    safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength;
75547  }
75548}
75549
75550module.exports = safer;
75551
75552}).call(this,require('_process'))
75553
75554},{"_process":467,"buffer":216}],496:[function(require,module,exports){
75555"use strict";
75556
75557function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
75558
75559function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
75560
75561function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
75562
75563function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
75564
75565function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
75566
75567function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
75568
75569function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
75570
75571function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
75572
75573function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
75574
75575function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
75576
75577function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
75578
75579Object.defineProperty(exports, "__esModule", {
75580  value: true
75581});
75582
75583var ed5 = require("xmlchars/xml/1.0/ed5");
75584
75585var ed2 = require("xmlchars/xml/1.1/ed2");
75586
75587var NSed3 = require("xmlchars/xmlns/1.0/ed3");
75588
75589var isS = ed5.isS;
75590var isChar10 = ed5.isChar;
75591var isNameStartChar = ed5.isNameStartChar;
75592var isNameChar = ed5.isNameChar;
75593var S_LIST = ed5.S_LIST;
75594var NAME_RE = ed5.NAME_RE;
75595var isChar11 = ed2.isChar;
75596var isNCNameStartChar = NSed3.isNCNameStartChar;
75597var isNCNameChar = NSed3.isNCNameChar;
75598var NC_NAME_RE = NSed3.NC_NAME_RE;
75599var XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
75600var XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
75601var rootNS = {
75602  // eslint-disable-next-line @typescript-eslint/no-explicit-any
75603  __proto__: null,
75604  xml: XML_NAMESPACE,
75605  xmlns: XMLNS_NAMESPACE
75606};
75607var XML_ENTITIES = {
75608  // eslint-disable-next-line @typescript-eslint/no-explicit-any
75609  __proto__: null,
75610  amp: "&",
75611  gt: ">",
75612  lt: "<",
75613  quot: "\"",
75614  apos: "'"
75615}; // EOC: end-of-chunk
75616
75617var EOC = -1;
75618var NL_LIKE = -2;
75619var S_BEGIN = 0; // Initial state.
75620
75621var S_BEGIN_WHITESPACE = 1; // leading whitespace
75622
75623var S_DOCTYPE = 2; // <!DOCTYPE
75624
75625var S_DOCTYPE_QUOTE = 3; // <!DOCTYPE "//blah
75626
75627var S_DTD = 4; // <!DOCTYPE "//blah" [ ...
75628
75629var S_DTD_QUOTED = 5; // <!DOCTYPE "//blah" [ "foo
75630
75631var S_DTD_OPEN_WAKA = 6;
75632var S_DTD_OPEN_WAKA_BANG = 7;
75633var S_DTD_COMMENT = 8; // <!--
75634
75635var S_DTD_COMMENT_ENDING = 9; // <!-- blah -
75636
75637var S_DTD_COMMENT_ENDED = 10; // <!-- blah --
75638
75639var S_DTD_PI = 11; // <?
75640
75641var S_DTD_PI_ENDING = 12; // <?hi "there" ?
75642
75643var S_TEXT = 13; // general stuff
75644
75645var S_ENTITY = 14; // &amp and such
75646
75647var S_OPEN_WAKA = 15; // <
75648
75649var S_OPEN_WAKA_BANG = 16; // <!...
75650
75651var S_COMMENT = 17; // <!--
75652
75653var S_COMMENT_ENDING = 18; // <!-- blah -
75654
75655var S_COMMENT_ENDED = 19; // <!-- blah --
75656
75657var S_CDATA = 20; // <![CDATA[ something
75658
75659var S_CDATA_ENDING = 21; // ]
75660
75661var S_CDATA_ENDING_2 = 22; // ]]
75662
75663var S_PI_FIRST_CHAR = 23; // <?hi, first char
75664
75665var S_PI_REST = 24; // <?hi, rest of the name
75666
75667var S_PI_BODY = 25; // <?hi there
75668
75669var S_PI_ENDING = 26; // <?hi "there" ?
75670
75671var S_XML_DECL_NAME_START = 27; // <?xml
75672
75673var S_XML_DECL_NAME = 28; // <?xml foo
75674
75675var S_XML_DECL_EQ = 29; // <?xml foo=
75676
75677var S_XML_DECL_VALUE_START = 30; // <?xml foo=
75678
75679var S_XML_DECL_VALUE = 31; // <?xml foo="bar"
75680
75681var S_XML_DECL_SEPARATOR = 32; // <?xml foo="bar"
75682
75683var S_XML_DECL_ENDING = 33; // <?xml ... ?
75684
75685var S_OPEN_TAG = 34; // <strong
75686
75687var S_OPEN_TAG_SLASH = 35; // <strong /
75688
75689var S_ATTRIB = 36; // <a
75690
75691var S_ATTRIB_NAME = 37; // <a foo
75692
75693var S_ATTRIB_NAME_SAW_WHITE = 38; // <a foo _
75694
75695var S_ATTRIB_VALUE = 39; // <a foo=
75696
75697var S_ATTRIB_VALUE_QUOTED = 40; // <a foo="bar
75698
75699var S_ATTRIB_VALUE_CLOSED = 41; // <a foo="bar"
75700
75701var S_ATTRIB_VALUE_UNQUOTED = 42; // <a foo=bar
75702
75703var S_CLOSE_TAG = 43; // </a
75704
75705var S_CLOSE_TAG_SAW_WHITE = 44; // </a   >
75706
75707var TAB = 9;
75708var NL = 0xA;
75709var CR = 0xD;
75710var SPACE = 0x20;
75711var BANG = 0x21;
75712var DQUOTE = 0x22;
75713var AMP = 0x26;
75714var SQUOTE = 0x27;
75715var MINUS = 0x2D;
75716var FORWARD_SLASH = 0x2F;
75717var SEMICOLON = 0x3B;
75718var LESS = 0x3C;
75719var EQUAL = 0x3D;
75720var GREATER = 0x3E;
75721var QUESTION = 0x3F;
75722var OPEN_BRACKET = 0x5B;
75723var CLOSE_BRACKET = 0x5D;
75724var NEL = 0x85;
75725var LS = 0x2028; // Line Separator
75726
75727var isQuote = function isQuote(c) {
75728  return c === DQUOTE || c === SQUOTE;
75729};
75730
75731var QUOTES = [DQUOTE, SQUOTE];
75732var DOCTYPE_TERMINATOR = [].concat(QUOTES, [OPEN_BRACKET, GREATER]);
75733var DTD_TERMINATOR = [].concat(QUOTES, [LESS, CLOSE_BRACKET]);
75734var XML_DECL_NAME_TERMINATOR = [EQUAL, QUESTION].concat(_toConsumableArray(S_LIST));
75735var ATTRIB_VALUE_UNQUOTED_TERMINATOR = [].concat(_toConsumableArray(S_LIST), [GREATER, AMP, LESS]);
75736
75737function nsPairCheck(parser, prefix, uri) {
75738  switch (prefix) {
75739    case "xml":
75740      if (uri !== XML_NAMESPACE) {
75741        parser.fail("xml prefix must be bound to ".concat(XML_NAMESPACE, "."));
75742      }
75743
75744      break;
75745
75746    case "xmlns":
75747      if (uri !== XMLNS_NAMESPACE) {
75748        parser.fail("xmlns prefix must be bound to ".concat(XMLNS_NAMESPACE, "."));
75749      }
75750
75751      break;
75752
75753    default:
75754  }
75755
75756  switch (uri) {
75757    case XMLNS_NAMESPACE:
75758      parser.fail(prefix === "" ? "the default namespace may not be set to ".concat(uri, ".") : "may not assign a prefix (even \"xmlns\") to the URI ".concat(XMLNS_NAMESPACE, "."));
75759      break;
75760
75761    case XML_NAMESPACE:
75762      switch (prefix) {
75763        case "xml":
75764          // Assinging the XML namespace to "xml" is fine.
75765          break;
75766
75767        case "":
75768          parser.fail("the default namespace may not be set to ".concat(uri, "."));
75769          break;
75770
75771        default:
75772          parser.fail("may not assign the xml namespace to another prefix.");
75773      }
75774
75775      break;
75776
75777    default:
75778  }
75779}
75780
75781function nsMappingCheck(parser, mapping) {
75782  for (var _i = 0, _Object$keys = Object.keys(mapping); _i < _Object$keys.length; _i++) {
75783    var local = _Object$keys[_i];
75784    nsPairCheck(parser, local, mapping[local]);
75785  }
75786}
75787
75788var isNCName = function isNCName(name) {
75789  return NC_NAME_RE.test(name);
75790};
75791
75792var isName = function isName(name) {
75793  return NAME_RE.test(name);
75794};
75795
75796var FORBIDDEN_START = 0;
75797var FORBIDDEN_BRACKET = 1;
75798var FORBIDDEN_BRACKET_BRACKET = 2;
75799/**
75800 * The list of supported events.
75801 */
75802
75803exports.EVENTS = ["xmldecl", "text", "processinginstruction", "doctype", "comment", "opentagstart", "attribute", "opentag", "closetag", "cdata", "error", "end", "ready"];
75804var EVENT_NAME_TO_HANDLER_NAME = {
75805  xmldecl: "xmldeclHandler",
75806  text: "textHandler",
75807  processinginstruction: "piHandler",
75808  doctype: "doctypeHandler",
75809  comment: "commentHandler",
75810  opentagstart: "openTagStartHandler",
75811  attribute: "attributeHandler",
75812  opentag: "openTagHandler",
75813  closetag: "closeTagHandler",
75814  cdata: "cdataHandler",
75815  error: "errorHandler",
75816  end: "endHandler",
75817  ready: "readyHandler"
75818};
75819
75820var SaxesParser = /*#__PURE__*/function () {
75821  /**
75822   * @param opt The parser options.
75823   */
75824  function SaxesParser(opt) {
75825    _classCallCheck(this, SaxesParser);
75826
75827    this.opt = opt !== null && opt !== void 0 ? opt : {};
75828    this.fragmentOpt = !!this.opt.fragment;
75829    var xmlnsOpt = this.xmlnsOpt = !!this.opt.xmlns;
75830    this.trackPosition = this.opt.position !== false;
75831    this.fileName = this.opt.fileName;
75832
75833    if (xmlnsOpt) {
75834      // This is the function we use to perform name checks on PIs and entities.
75835      // When namespaces are used, colons are not allowed in PI target names or
75836      // entity names. So the check depends on whether namespaces are used. See:
75837      //
75838      // https://www.w3.org/XML/xml-names-19990114-errata.html
75839      // NE08
75840      //
75841      this.nameStartCheck = isNCNameStartChar;
75842      this.nameCheck = isNCNameChar;
75843      this.isName = isNCName; // eslint-disable-next-line @typescript-eslint/unbound-method
75844
75845      this.processAttribs = this.processAttribsNS; // eslint-disable-next-line @typescript-eslint/unbound-method
75846
75847      this.pushAttrib = this.pushAttribNS; // eslint-disable-next-line @typescript-eslint/no-explicit-any
75848
75849      this.ns = Object.assign({
75850        __proto__: null
75851      }, rootNS);
75852      var additional = this.opt.additionalNamespaces;
75853
75854      if (additional != null) {
75855        nsMappingCheck(this, additional);
75856        Object.assign(this.ns, additional);
75857      }
75858    } else {
75859      this.nameStartCheck = isNameStartChar;
75860      this.nameCheck = isNameChar;
75861      this.isName = isName; // eslint-disable-next-line @typescript-eslint/unbound-method
75862
75863      this.processAttribs = this.processAttribsPlain; // eslint-disable-next-line @typescript-eslint/unbound-method
75864
75865      this.pushAttrib = this.pushAttribPlain;
75866    } //
75867    // The order of the members in this table needs to correspond to the state
75868    // numbers given to the states that correspond to the methods being recorded
75869    // here.
75870    //
75871
75872
75873    this.stateTable = [
75874    /* eslint-disable @typescript-eslint/unbound-method */
75875    this.sBegin, this.sBeginWhitespace, this.sDoctype, this.sDoctypeQuote, this.sDTD, this.sDTDQuoted, this.sDTDOpenWaka, this.sDTDOpenWakaBang, this.sDTDComment, this.sDTDCommentEnding, this.sDTDCommentEnded, this.sDTDPI, this.sDTDPIEnding, this.sText, this.sEntity, this.sOpenWaka, this.sOpenWakaBang, this.sComment, this.sCommentEnding, this.sCommentEnded, this.sCData, this.sCDataEnding, this.sCDataEnding2, this.sPIFirstChar, this.sPIRest, this.sPIBody, this.sPIEnding, this.sXMLDeclNameStart, this.sXMLDeclName, this.sXMLDeclEq, this.sXMLDeclValueStart, this.sXMLDeclValue, this.sXMLDeclSeparator, this.sXMLDeclEnding, this.sOpenTag, this.sOpenTagSlash, this.sAttrib, this.sAttribName, this.sAttribNameSawWhite, this.sAttribValue, this.sAttribValueQuoted, this.sAttribValueClosed, this.sAttribValueUnquoted, this.sCloseTag, this.sCloseTagSawWhite];
75876
75877    this._init();
75878  }
75879  /**
75880   * Indicates whether or not the parser is closed. If ``true``, wait for
75881   * the ``ready`` event to write again.
75882   */
75883
75884
75885  _createClass(SaxesParser, [{
75886    key: "_init",
75887    value: function _init() {
75888      var _a;
75889
75890      this.openWakaBang = "";
75891      this.text = "";
75892      this.name = "";
75893      this.piTarget = "";
75894      this.entity = "";
75895      this.q = null;
75896      this.tags = [];
75897      this.tag = null;
75898      this.topNS = null;
75899      this.chunk = "";
75900      this.chunkPosition = 0;
75901      this.i = 0;
75902      this.prevI = 0;
75903      this.carriedFromPrevious = undefined;
75904      this.forbiddenState = FORBIDDEN_START;
75905      this.attribList = []; // The logic is organized so as to minimize the need to check
75906      // this.opt.fragment while parsing.
75907
75908      var fragmentOpt = this.fragmentOpt;
75909      this.state = fragmentOpt ? S_TEXT : S_BEGIN; // We want these to be all true if we are dealing with a fragment.
75910
75911      this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = fragmentOpt; // An XML declaration is intially possible only when parsing whole
75912      // documents.
75913
75914      this.xmlDeclPossible = !fragmentOpt;
75915      this.xmlDeclExpects = ["version"];
75916      this.entityReturnState = undefined;
75917      var defaultXMLVersion = this.opt.defaultXMLVersion;
75918
75919      if (defaultXMLVersion === undefined) {
75920        if (this.opt.forceXMLVersion === true) {
75921          throw new Error("forceXMLVersion set but defaultXMLVersion is not set");
75922        }
75923
75924        defaultXMLVersion = "1.0";
75925      }
75926
75927      this.setXMLVersion(defaultXMLVersion);
75928      this.positionAtNewLine = 0;
75929      this.doctype = false;
75930      this._closed = false;
75931      this.xmlDecl = {
75932        version: undefined,
75933        encoding: undefined,
75934        standalone: undefined
75935      };
75936      this.line = 1;
75937      this.column = 0;
75938      this.ENTITIES = Object.create(XML_ENTITIES); // eslint-disable-next-line no-unused-expressions
75939
75940      (_a = this.readyHandler) === null || _a === void 0 ? void 0 : _a.call(this);
75941    }
75942    /**
75943     * The stream position the parser is currently looking at. This field is
75944     * zero-based.
75945     *
75946     * This field is not based on counting Unicode characters but is to be
75947     * interpreted as a plain index into a JavaScript string.
75948     */
75949
75950  }, {
75951    key: "on",
75952
75953    /**
75954     * Set an event listener on an event. The parser supports one handler per
75955     * event type. If you try to set an event handler over an existing handler,
75956     * the old handler is silently overwritten.
75957     *
75958     * @param name The event to listen to.
75959     *
75960     * @param handler The handler to set.
75961     */
75962    value: function on(name, handler) {
75963      // eslint-disable-next-line @typescript-eslint/no-explicit-any
75964      this[EVENT_NAME_TO_HANDLER_NAME[name]] = handler;
75965    }
75966    /**
75967     * Unset an event handler.
75968     *
75969     * @parma name The event to stop listening to.
75970     */
75971
75972  }, {
75973    key: "off",
75974    value: function off(name) {
75975      // eslint-disable-next-line @typescript-eslint/no-explicit-any
75976      this[EVENT_NAME_TO_HANDLER_NAME[name]] = undefined;
75977    }
75978    /**
75979     * Make an error object. The error object will have a message that contains
75980     * the ``fileName`` option passed at the creation of the parser. If position
75981     * tracking was turned on, it will also have line and column number
75982     * information.
75983     *
75984     * @param message The message describing the error to report.
75985     *
75986     * @returns An error object with a properly formatted message.
75987     */
75988
75989  }, {
75990    key: "makeError",
75991    value: function makeError(message) {
75992      var _a;
75993
75994      var msg = (_a = this.fileName) !== null && _a !== void 0 ? _a : "";
75995
75996      if (this.trackPosition) {
75997        if (msg.length > 0) {
75998          msg += ":";
75999        }
76000
76001        msg += "".concat(this.line, ":").concat(this.column);
76002      }
76003
76004      if (msg.length > 0) {
76005        msg += ": ";
76006      }
76007
76008      return new Error(msg + message);
76009    }
76010    /**
76011     * Report a parsing error. This method is made public so that client code may
76012     * check for issues that are outside the scope of this project and can report
76013     * errors.
76014     *
76015     * @param message The error to report.
76016     *
76017     * @returns this
76018     */
76019
76020  }, {
76021    key: "fail",
76022    value: function fail(message) {
76023      var err = this.makeError(message);
76024      var handler = this.errorHandler;
76025
76026      if (handler === undefined) {
76027        throw err;
76028      } else {
76029        handler(err);
76030      }
76031
76032      return this;
76033    }
76034    /**
76035     * Write a XML data to the parser.
76036     *
76037     * @param chunk The XML data to write.
76038     *
76039     * @returns this
76040     */
76041
76042  }, {
76043    key: "write",
76044    value: function write(chunk) {
76045      if (this.closed) {
76046        return this.fail("cannot write after close; assign an onready handler.");
76047      }
76048
76049      var end = false;
76050
76051      if (chunk === null) {
76052        // We cannot return immediately because carriedFromPrevious may need
76053        // processing.
76054        end = true;
76055        chunk = "";
76056      } else if (_typeof(chunk) === "object") {
76057        chunk = chunk.toString();
76058      } // We checked if performing a pre-decomposition of the string into an array
76059      // of single complete characters (``Array.from(chunk)``) would be faster
76060      // than the current repeated calls to ``charCodeAt``. As of August 2018, it
76061      // isn't. (There may be Node-specific code that would perform faster than
76062      // ``Array.from`` but don't want to be dependent on Node.)
76063
76064
76065      if (this.carriedFromPrevious !== undefined) {
76066        // The previous chunk had char we must carry over.
76067        chunk = "".concat(this.carriedFromPrevious).concat(chunk);
76068        this.carriedFromPrevious = undefined;
76069      }
76070
76071      var limit = chunk.length;
76072      var lastCode = chunk.charCodeAt(limit - 1);
76073
76074      if (!end && ( // A trailing CR or surrogate must be carried over to the next
76075      // chunk.
76076      lastCode === CR || lastCode >= 0xD800 && lastCode <= 0xDBFF)) {
76077        // The chunk ends with a character that must be carried over. We cannot
76078        // know how to handle it until we get the next chunk or the end of the
76079        // stream. So save it for later.
76080        this.carriedFromPrevious = chunk[limit - 1];
76081        limit--;
76082        chunk = chunk.slice(0, limit);
76083      }
76084
76085      var stateTable = this.stateTable;
76086      this.chunk = chunk;
76087      this.i = 0;
76088
76089      while (this.i < limit) {
76090        // eslint-disable-next-line @typescript-eslint/no-explicit-any
76091        stateTable[this.state].call(this);
76092      }
76093
76094      this.chunkPosition += limit;
76095      return end ? this.end() : this;
76096    }
76097    /**
76098     * Close the current stream. Perform final well-formedness checks and reset
76099     * the parser tstate.
76100     *
76101     * @returns this
76102     */
76103
76104  }, {
76105    key: "close",
76106    value: function close() {
76107      return this.write(null);
76108    }
76109    /**
76110     * Get a single code point out of the current chunk. This updates the current
76111     * position if we do position tracking.
76112     *
76113     * This is the algorithm to use for XML 1.0.
76114     *
76115     * @returns The character read.
76116     */
76117
76118  }, {
76119    key: "getCode10",
76120    value: function getCode10() {
76121      var chunk = this.chunk,
76122          i = this.i;
76123      this.prevI = i; // Yes, we do this instead of doing this.i++. Doing it this way, we do not
76124      // read this.i again, which is a bit faster.
76125
76126      this.i = i + 1;
76127
76128      if (i >= chunk.length) {
76129        return EOC;
76130      } // Using charCodeAt and handling the surrogates ourselves is faster
76131      // than using codePointAt.
76132
76133
76134      var code = chunk.charCodeAt(i);
76135      this.column++;
76136
76137      if (code < 0xD800) {
76138        if (code >= SPACE || code === TAB) {
76139          return code;
76140        }
76141
76142        switch (code) {
76143          case NL:
76144            this.line++;
76145            this.column = 0;
76146            this.positionAtNewLine = this.position;
76147            return NL;
76148
76149          case CR:
76150            // We may get NaN if we read past the end of the chunk, which is fine.
76151            if (chunk.charCodeAt(i + 1) === NL) {
76152              // A \r\n sequence is converted to \n so we have to skip over the
76153              // next character. We already know it has a size of 1 so ++ is fine
76154              // here.
76155              this.i = i + 2;
76156            } // Otherwise, a \r is just converted to \n, so we don't have to skip
76157            // ahead.
76158            // In either case, \r becomes \n.
76159
76160
76161            this.line++;
76162            this.column = 0;
76163            this.positionAtNewLine = this.position;
76164            return NL_LIKE;
76165
76166          default:
76167            // If we get here, then code < SPACE and it is not NL CR or TAB.
76168            this.fail("disallowed character.");
76169            return code;
76170        }
76171      }
76172
76173      if (code > 0xDBFF) {
76174        // This is a specialized version of isChar10 that takes into account
76175        // that in this context code > 0xDBFF and code <= 0xFFFF. So it does not
76176        // test cases that don't need testing.
76177        if (!(code >= 0xE000 && code <= 0xFFFD)) {
76178          this.fail("disallowed character.");
76179        }
76180
76181        return code;
76182      }
76183
76184      var final = 0x10000 + (code - 0xD800) * 0x400 + (chunk.charCodeAt(i + 1) - 0xDC00);
76185      this.i = i + 2; // This is a specialized version of isChar10 that takes into account that in
76186      // this context necessarily final >= 0x10000.
76187
76188      if (final > 0x10FFFF) {
76189        this.fail("disallowed character.");
76190      }
76191
76192      return final;
76193    }
76194    /**
76195     * Get a single code point out of the current chunk. This updates the current
76196     * position if we do position tracking.
76197     *
76198     * This is the algorithm to use for XML 1.1.
76199     *
76200     * @returns {number} The character read.
76201     */
76202
76203  }, {
76204    key: "getCode11",
76205    value: function getCode11() {
76206      var chunk = this.chunk,
76207          i = this.i;
76208      this.prevI = i; // Yes, we do this instead of doing this.i++. Doing it this way, we do not
76209      // read this.i again, which is a bit faster.
76210
76211      this.i = i + 1;
76212
76213      if (i >= chunk.length) {
76214        return EOC;
76215      } // Using charCodeAt and handling the surrogates ourselves is faster
76216      // than using codePointAt.
76217
76218
76219      var code = chunk.charCodeAt(i);
76220      this.column++;
76221
76222      if (code < 0xD800) {
76223        if (code > 0x1F && code < 0x7F || code > 0x9F && code !== LS || code === TAB) {
76224          return code;
76225        }
76226
76227        switch (code) {
76228          case NL:
76229            // 0xA
76230            this.line++;
76231            this.column = 0;
76232            this.positionAtNewLine = this.position;
76233            return NL;
76234
76235          case CR:
76236            {
76237              // 0xD
76238              // We may get NaN if we read past the end of the chunk, which is
76239              // fine.
76240              var next = chunk.charCodeAt(i + 1);
76241
76242              if (next === NL || next === NEL) {
76243                // A CR NL or CR NEL sequence is converted to NL so we have to skip
76244                // over the next character. We already know it has a size of 1.
76245                this.i = i + 2;
76246              } // Otherwise, a CR is just converted to NL, no skip.
76247
76248            }
76249
76250          /* yes, fall through */
76251
76252          case NEL: // 0x85
76253
76254          case LS:
76255            // Ox2028
76256            this.line++;
76257            this.column = 0;
76258            this.positionAtNewLine = this.position;
76259            return NL_LIKE;
76260
76261          default:
76262            this.fail("disallowed character.");
76263            return code;
76264        }
76265      }
76266
76267      if (code > 0xDBFF) {
76268        // This is a specialized version of isCharAndNotRestricted that takes into
76269        // account that in this context code > 0xDBFF and code <= 0xFFFF. So it
76270        // does not test cases that don't need testing.
76271        if (!(code >= 0xE000 && code <= 0xFFFD)) {
76272          this.fail("disallowed character.");
76273        }
76274
76275        return code;
76276      }
76277
76278      var final = 0x10000 + (code - 0xD800) * 0x400 + (chunk.charCodeAt(i + 1) - 0xDC00);
76279      this.i = i + 2; // This is a specialized version of isCharAndNotRestricted that takes into
76280      // account that in this context necessarily final >= 0x10000.
76281
76282      if (final > 0x10FFFF) {
76283        this.fail("disallowed character.");
76284      }
76285
76286      return final;
76287    }
76288    /**
76289     * Like ``getCode`` but with the return value normalized so that ``NL`` is
76290     * returned for ``NL_LIKE``.
76291     */
76292
76293  }, {
76294    key: "getCodeNorm",
76295    value: function getCodeNorm() {
76296      var c = this.getCode();
76297      return c === NL_LIKE ? NL : c;
76298    }
76299  }, {
76300    key: "unget",
76301    value: function unget() {
76302      this.i = this.prevI;
76303      this.column--;
76304    }
76305    /**
76306     * Capture characters into a buffer until encountering one of a set of
76307     * characters.
76308     *
76309     * @param chars An array of codepoints. Encountering a character in the array
76310     * ends the capture. (``chars`` may safely contain ``NL``.)
76311     *
76312     * @return The character code that made the capture end, or ``EOC`` if we hit
76313     * the end of the chunk. The return value cannot be NL_LIKE: NL is returned
76314     * instead.
76315     */
76316
76317  }, {
76318    key: "captureTo",
76319    value: function captureTo(chars) {
76320      var start = this.i;
76321      var chunk = this.chunk; // eslint-disable-next-line no-constant-condition
76322
76323      while (true) {
76324        var c = this.getCode();
76325        var isNLLike = c === NL_LIKE;
76326        var final = isNLLike ? NL : c;
76327
76328        if (final === EOC || chars.includes(final)) {
76329          this.text += chunk.slice(start, this.prevI);
76330          return final;
76331        }
76332
76333        if (isNLLike) {
76334          this.text += "".concat(chunk.slice(start, this.prevI), "\n");
76335          start = this.i;
76336        }
76337      }
76338    }
76339    /**
76340     * Capture characters into a buffer until encountering a character.
76341     *
76342     * @param char The codepoint that ends the capture. **NOTE ``char`` MAY NOT
76343     * CONTAIN ``NL``.** Passing ``NL`` will result in buggy behavior.
76344     *
76345     * @return ``true`` if we ran into the character. Otherwise, we ran into the
76346     * end of the current chunk.
76347     */
76348
76349  }, {
76350    key: "captureToChar",
76351    value: function captureToChar(char) {
76352      var start = this.i;
76353      var chunk = this.chunk; // eslint-disable-next-line no-constant-condition
76354
76355      while (true) {
76356        var c = this.getCode();
76357
76358        switch (c) {
76359          case NL_LIKE:
76360            this.text += "".concat(chunk.slice(start, this.prevI), "\n");
76361            start = this.i;
76362            c = NL;
76363            break;
76364
76365          case EOC:
76366            this.text += chunk.slice(start);
76367            return false;
76368
76369          default:
76370        }
76371
76372        if (c === char) {
76373          this.text += chunk.slice(start, this.prevI);
76374          return true;
76375        }
76376      }
76377    }
76378    /**
76379     * Capture characters that satisfy ``isNameChar`` into the ``name`` field of
76380     * this parser.
76381     *
76382     * @return The character code that made the test fail, or ``EOC`` if we hit
76383     * the end of the chunk. The return value cannot be NL_LIKE: NL is returned
76384     * instead.
76385     */
76386
76387  }, {
76388    key: "captureNameChars",
76389    value: function captureNameChars() {
76390      var chunk = this.chunk,
76391          start = this.i; // eslint-disable-next-line no-constant-condition
76392
76393      while (true) {
76394        var c = this.getCode();
76395
76396        if (c === EOC) {
76397          this.name += chunk.slice(start);
76398          return EOC;
76399        } // NL is not a name char so we don't have to test specifically for it.
76400
76401
76402        if (!isNameChar(c)) {
76403          this.name += chunk.slice(start, this.prevI);
76404          return c === NL_LIKE ? NL : c;
76405        }
76406      }
76407    }
76408    /**
76409     * Skip white spaces.
76410     *
76411     * @return The character that ended the skip, or ``EOC`` if we hit
76412     * the end of the chunk. The return value cannot be NL_LIKE: NL is returned
76413     * instead.
76414     */
76415
76416  }, {
76417    key: "skipSpaces",
76418    value: function skipSpaces() {
76419      // eslint-disable-next-line no-constant-condition
76420      while (true) {
76421        var c = this.getCodeNorm();
76422
76423        if (c === EOC || !isS(c)) {
76424          return c;
76425        }
76426      }
76427    }
76428  }, {
76429    key: "setXMLVersion",
76430    value: function setXMLVersion(version) {
76431      this.currentXMLVersion = version;
76432      /*  eslint-disable @typescript-eslint/unbound-method */
76433
76434      if (version === "1.0") {
76435        this.isChar = isChar10;
76436        this.getCode = this.getCode10;
76437      } else {
76438        this.isChar = isChar11;
76439        this.getCode = this.getCode11;
76440      }
76441      /* eslint-enable @typescript-eslint/unbound-method */
76442
76443    } // STATE ENGINE METHODS
76444    // This needs to be a state separate from S_BEGIN_WHITESPACE because we want
76445    // to be sure never to come back to this state later.
76446
76447  }, {
76448    key: "sBegin",
76449    value: function sBegin() {
76450      // We are essentially peeking at the first character of the chunk. Since
76451      // S_BEGIN can be in effect only when we start working on the first chunk,
76452      // the index at which we must look is necessarily 0. Note also that the
76453      // following test does not depend on decoding surrogates.
76454      // If the initial character is 0xFEFF, ignore it.
76455      if (this.chunk.charCodeAt(0) === 0xFEFF) {
76456        this.i++;
76457        this.column++;
76458      }
76459
76460      this.state = S_BEGIN_WHITESPACE;
76461    }
76462  }, {
76463    key: "sBeginWhitespace",
76464    value: function sBeginWhitespace() {
76465      // We need to know whether we've encountered spaces or not because as soon
76466      // as we run into a space, an XML declaration is no longer possible. Rather
76467      // than slow down skipSpaces even in places where we don't care whether it
76468      // skipped anything or not, we check whether prevI is equal to the value of
76469      // i from before we skip spaces.
76470      var iBefore = this.i;
76471      var c = this.skipSpaces();
76472
76473      if (this.prevI !== iBefore) {
76474        this.xmlDeclPossible = false;
76475      }
76476
76477      switch (c) {
76478        case LESS:
76479          this.state = S_OPEN_WAKA; // We could naively call closeText but in this state, it is not normal
76480          // to have text be filled with any data.
76481
76482          if (this.text.length !== 0) {
76483            throw new Error("no-empty text at start");
76484          }
76485
76486          break;
76487
76488        case EOC:
76489          break;
76490
76491        default:
76492          this.unget();
76493          this.state = S_TEXT;
76494          this.xmlDeclPossible = false;
76495      }
76496    }
76497  }, {
76498    key: "sDoctype",
76499    value: function sDoctype() {
76500      var _a;
76501
76502      var c = this.captureTo(DOCTYPE_TERMINATOR);
76503
76504      switch (c) {
76505        case GREATER:
76506          {
76507            // eslint-disable-next-line no-unused-expressions
76508            (_a = this.doctypeHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.text);
76509            this.text = "";
76510            this.state = S_TEXT;
76511            this.doctype = true; // just remember that we saw it.
76512
76513            break;
76514          }
76515
76516        case EOC:
76517          break;
76518
76519        default:
76520          this.text += String.fromCodePoint(c);
76521
76522          if (c === OPEN_BRACKET) {
76523            this.state = S_DTD;
76524          } else if (isQuote(c)) {
76525            this.state = S_DOCTYPE_QUOTE;
76526            this.q = c;
76527          }
76528
76529      }
76530    }
76531  }, {
76532    key: "sDoctypeQuote",
76533    value: function sDoctypeQuote() {
76534      var q = this.q;
76535
76536      if (this.captureToChar(q)) {
76537        this.text += String.fromCodePoint(q);
76538        this.q = null;
76539        this.state = S_DOCTYPE;
76540      }
76541    }
76542  }, {
76543    key: "sDTD",
76544    value: function sDTD() {
76545      var c = this.captureTo(DTD_TERMINATOR);
76546
76547      if (c === EOC) {
76548        return;
76549      }
76550
76551      this.text += String.fromCodePoint(c);
76552
76553      if (c === CLOSE_BRACKET) {
76554        this.state = S_DOCTYPE;
76555      } else if (c === LESS) {
76556        this.state = S_DTD_OPEN_WAKA;
76557      } else if (isQuote(c)) {
76558        this.state = S_DTD_QUOTED;
76559        this.q = c;
76560      }
76561    }
76562  }, {
76563    key: "sDTDQuoted",
76564    value: function sDTDQuoted() {
76565      var q = this.q;
76566
76567      if (this.captureToChar(q)) {
76568        this.text += String.fromCodePoint(q);
76569        this.state = S_DTD;
76570        this.q = null;
76571      }
76572    }
76573  }, {
76574    key: "sDTDOpenWaka",
76575    value: function sDTDOpenWaka() {
76576      var c = this.getCodeNorm();
76577      this.text += String.fromCodePoint(c);
76578
76579      switch (c) {
76580        case BANG:
76581          this.state = S_DTD_OPEN_WAKA_BANG;
76582          this.openWakaBang = "";
76583          break;
76584
76585        case QUESTION:
76586          this.state = S_DTD_PI;
76587          break;
76588
76589        default:
76590          this.state = S_DTD;
76591      }
76592    }
76593  }, {
76594    key: "sDTDOpenWakaBang",
76595    value: function sDTDOpenWakaBang() {
76596      var char = String.fromCodePoint(this.getCodeNorm());
76597      var owb = this.openWakaBang += char;
76598      this.text += char;
76599
76600      if (owb !== "-") {
76601        this.state = owb === "--" ? S_DTD_COMMENT : S_DTD;
76602        this.openWakaBang = "";
76603      }
76604    }
76605  }, {
76606    key: "sDTDComment",
76607    value: function sDTDComment() {
76608      if (this.captureToChar(MINUS)) {
76609        this.text += "-";
76610        this.state = S_DTD_COMMENT_ENDING;
76611      }
76612    }
76613  }, {
76614    key: "sDTDCommentEnding",
76615    value: function sDTDCommentEnding() {
76616      var c = this.getCodeNorm();
76617      this.text += String.fromCodePoint(c);
76618      this.state = c === MINUS ? S_DTD_COMMENT_ENDED : S_DTD_COMMENT;
76619    }
76620  }, {
76621    key: "sDTDCommentEnded",
76622    value: function sDTDCommentEnded() {
76623      var c = this.getCodeNorm();
76624      this.text += String.fromCodePoint(c);
76625
76626      if (c === GREATER) {
76627        this.state = S_DTD;
76628      } else {
76629        this.fail("malformed comment."); // <!-- blah -- bloo --> will be recorded as
76630        // a comment of " blah -- bloo "
76631
76632        this.state = S_DTD_COMMENT;
76633      }
76634    }
76635  }, {
76636    key: "sDTDPI",
76637    value: function sDTDPI() {
76638      if (this.captureToChar(QUESTION)) {
76639        this.text += "?";
76640        this.state = S_DTD_PI_ENDING;
76641      }
76642    }
76643  }, {
76644    key: "sDTDPIEnding",
76645    value: function sDTDPIEnding() {
76646      var c = this.getCodeNorm();
76647      this.text += String.fromCodePoint(c);
76648
76649      if (c === GREATER) {
76650        this.state = S_DTD;
76651      }
76652    }
76653  }, {
76654    key: "sText",
76655    value: function sText() {
76656      //
76657      // We did try a version of saxes where the S_TEXT state was split in two
76658      // states: one for text inside the root element, and one for text
76659      // outside. This was avoiding having to test this.tags.length to decide
76660      // what implementation to actually use.
76661      //
76662      // Peformance testing on gigabyte-size files did not show any advantage to
76663      // using the two states solution instead of the current one. Conversely, it
76664      // made the code a bit more complicated elsewhere. For instance, a comment
76665      // can appear before the root element so when a comment ended it was
76666      // necessary to determine whether to return to the S_TEXT state or to the
76667      // new text-outside-root state.
76668      //
76669      if (this.tags.length !== 0) {
76670        this.handleTextInRoot();
76671      } else {
76672        this.handleTextOutsideRoot();
76673      }
76674    }
76675  }, {
76676    key: "sEntity",
76677    value: function sEntity() {
76678      // This is essentially a specialized version of captureToChar(SEMICOLON...)
76679      var start = this.i;
76680      var chunk = this.chunk; // eslint-disable-next-line no-labels, no-restricted-syntax
76681
76682      loop: // eslint-disable-next-line no-constant-condition
76683      while (true) {
76684        switch (this.getCode()) {
76685          case NL_LIKE:
76686            this.entity += "".concat(chunk.slice(start, this.prevI), "\n");
76687            start = this.i;
76688            break;
76689
76690          case SEMICOLON:
76691            {
76692              var entityReturnState = this.entityReturnState;
76693              var entity = this.entity + chunk.slice(start, this.prevI);
76694              this.state = entityReturnState;
76695              var parsed = void 0;
76696
76697              if (entity === "") {
76698                this.fail("empty entity name.");
76699                parsed = "&;";
76700              } else {
76701                parsed = this.parseEntity(entity);
76702                this.entity = "";
76703              }
76704
76705              if (entityReturnState !== S_TEXT || this.textHandler !== undefined) {
76706                this.text += parsed;
76707              } // eslint-disable-next-line no-labels
76708
76709
76710              break loop;
76711            }
76712
76713          case EOC:
76714            this.entity += chunk.slice(start); // eslint-disable-next-line no-labels
76715
76716            break loop;
76717
76718          default:
76719        }
76720      }
76721    }
76722  }, {
76723    key: "sOpenWaka",
76724    value: function sOpenWaka() {
76725      // Reminder: a state handler is called with at least one character
76726      // available in the current chunk. So the first call to get code inside of
76727      // a state handler cannot return ``EOC``. That's why we don't test
76728      // for it.
76729      var c = this.getCode(); // either a /, ?, !, or text is coming next.
76730
76731      if (isNameStartChar(c)) {
76732        this.state = S_OPEN_TAG;
76733        this.unget();
76734        this.xmlDeclPossible = false;
76735      } else {
76736        switch (c) {
76737          case FORWARD_SLASH:
76738            this.state = S_CLOSE_TAG;
76739            this.xmlDeclPossible = false;
76740            break;
76741
76742          case BANG:
76743            this.state = S_OPEN_WAKA_BANG;
76744            this.openWakaBang = "";
76745            this.xmlDeclPossible = false;
76746            break;
76747
76748          case QUESTION:
76749            this.state = S_PI_FIRST_CHAR;
76750            break;
76751
76752          default:
76753            this.fail("disallowed character in tag name");
76754            this.state = S_TEXT;
76755            this.xmlDeclPossible = false;
76756        }
76757      }
76758    }
76759  }, {
76760    key: "sOpenWakaBang",
76761    value: function sOpenWakaBang() {
76762      this.openWakaBang += String.fromCodePoint(this.getCodeNorm());
76763
76764      switch (this.openWakaBang) {
76765        case "[CDATA[":
76766          if (!this.sawRoot && !this.reportedTextBeforeRoot) {
76767            this.fail("text data outside of root node.");
76768            this.reportedTextBeforeRoot = true;
76769          }
76770
76771          if (this.closedRoot && !this.reportedTextAfterRoot) {
76772            this.fail("text data outside of root node.");
76773            this.reportedTextAfterRoot = true;
76774          }
76775
76776          this.state = S_CDATA;
76777          this.openWakaBang = "";
76778          break;
76779
76780        case "--":
76781          this.state = S_COMMENT;
76782          this.openWakaBang = "";
76783          break;
76784
76785        case "DOCTYPE":
76786          this.state = S_DOCTYPE;
76787
76788          if (this.doctype || this.sawRoot) {
76789            this.fail("inappropriately located doctype declaration.");
76790          }
76791
76792          this.openWakaBang = "";
76793          break;
76794
76795        default:
76796          // 7 happens to be the maximum length of the string that can possibly
76797          // match one of the cases above.
76798          if (this.openWakaBang.length >= 7) {
76799            this.fail("incorrect syntax.");
76800          }
76801
76802      }
76803    }
76804  }, {
76805    key: "sComment",
76806    value: function sComment() {
76807      if (this.captureToChar(MINUS)) {
76808        this.state = S_COMMENT_ENDING;
76809      }
76810    }
76811  }, {
76812    key: "sCommentEnding",
76813    value: function sCommentEnding() {
76814      var _a;
76815
76816      var c = this.getCodeNorm();
76817
76818      if (c === MINUS) {
76819        this.state = S_COMMENT_ENDED; // eslint-disable-next-line no-unused-expressions
76820
76821        (_a = this.commentHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.text);
76822        this.text = "";
76823      } else {
76824        this.text += "-".concat(String.fromCodePoint(c));
76825        this.state = S_COMMENT;
76826      }
76827    }
76828  }, {
76829    key: "sCommentEnded",
76830    value: function sCommentEnded() {
76831      var c = this.getCodeNorm();
76832
76833      if (c !== GREATER) {
76834        this.fail("malformed comment."); // <!-- blah -- bloo --> will be recorded as
76835        // a comment of " blah -- bloo "
76836
76837        this.text += "--".concat(String.fromCodePoint(c));
76838        this.state = S_COMMENT;
76839      } else {
76840        this.state = S_TEXT;
76841      }
76842    }
76843  }, {
76844    key: "sCData",
76845    value: function sCData() {
76846      if (this.captureToChar(CLOSE_BRACKET)) {
76847        this.state = S_CDATA_ENDING;
76848      }
76849    }
76850  }, {
76851    key: "sCDataEnding",
76852    value: function sCDataEnding() {
76853      var c = this.getCodeNorm();
76854
76855      if (c === CLOSE_BRACKET) {
76856        this.state = S_CDATA_ENDING_2;
76857      } else {
76858        this.text += "]".concat(String.fromCodePoint(c));
76859        this.state = S_CDATA;
76860      }
76861    }
76862  }, {
76863    key: "sCDataEnding2",
76864    value: function sCDataEnding2() {
76865      var _a;
76866
76867      var c = this.getCodeNorm();
76868
76869      switch (c) {
76870        case GREATER:
76871          {
76872            // eslint-disable-next-line no-unused-expressions
76873            (_a = this.cdataHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.text);
76874            this.text = "";
76875            this.state = S_TEXT;
76876            break;
76877          }
76878
76879        case CLOSE_BRACKET:
76880          this.text += "]";
76881          break;
76882
76883        default:
76884          this.text += "]]".concat(String.fromCodePoint(c));
76885          this.state = S_CDATA;
76886      }
76887    } // We need this separate state to check the first character fo the pi target
76888    // with this.nameStartCheck which allows less characters than this.nameCheck.
76889
76890  }, {
76891    key: "sPIFirstChar",
76892    value: function sPIFirstChar() {
76893      var c = this.getCodeNorm(); // This is first because in the case where the file is well-formed this is
76894      // the branch taken. We optimize for well-formedness.
76895
76896      if (this.nameStartCheck(c)) {
76897        this.piTarget += String.fromCodePoint(c);
76898        this.state = S_PI_REST;
76899      } else if (c === QUESTION || isS(c)) {
76900        this.fail("processing instruction without a target.");
76901        this.state = c === QUESTION ? S_PI_ENDING : S_PI_BODY;
76902      } else {
76903        this.fail("disallowed character in processing instruction name.");
76904        this.piTarget += String.fromCodePoint(c);
76905        this.state = S_PI_REST;
76906      }
76907    }
76908  }, {
76909    key: "sPIRest",
76910    value: function sPIRest() {
76911      // Capture characters into a piTarget while ``this.nameCheck`` run on the
76912      // character read returns true.
76913      var chunk = this.chunk,
76914          start = this.i; // eslint-disable-next-line no-constant-condition
76915
76916      while (true) {
76917        var c = this.getCodeNorm();
76918
76919        if (c === EOC) {
76920          this.piTarget += chunk.slice(start);
76921          return;
76922        } // NL cannot satisfy this.nameCheck so we don't have to test specifically
76923        // for it.
76924
76925
76926        if (!this.nameCheck(c)) {
76927          this.piTarget += chunk.slice(start, this.prevI);
76928          var isQuestion = c === QUESTION;
76929
76930          if (isQuestion || isS(c)) {
76931            if (this.piTarget === "xml") {
76932              if (!this.xmlDeclPossible) {
76933                this.fail("an XML declaration must be at the start of the document.");
76934              }
76935
76936              this.state = isQuestion ? S_XML_DECL_ENDING : S_XML_DECL_NAME_START;
76937            } else {
76938              this.state = isQuestion ? S_PI_ENDING : S_PI_BODY;
76939            }
76940          } else {
76941            this.fail("disallowed character in processing instruction name.");
76942            this.piTarget += String.fromCodePoint(c);
76943          }
76944
76945          break;
76946        }
76947      }
76948    }
76949  }, {
76950    key: "sPIBody",
76951    value: function sPIBody() {
76952      if (this.text.length === 0) {
76953        var c = this.getCodeNorm();
76954
76955        if (c === QUESTION) {
76956          this.state = S_PI_ENDING;
76957        } else if (!isS(c)) {
76958          this.text = String.fromCodePoint(c);
76959        }
76960      } // The question mark character is not valid inside any of the XML
76961      // declaration name/value pairs.
76962      else if (this.captureToChar(QUESTION)) {
76963          this.state = S_PI_ENDING;
76964        }
76965    }
76966  }, {
76967    key: "sPIEnding",
76968    value: function sPIEnding() {
76969      var _a;
76970
76971      var c = this.getCodeNorm();
76972
76973      if (c === GREATER) {
76974        var piTarget = this.piTarget;
76975
76976        if (piTarget.toLowerCase() === "xml") {
76977          this.fail("the XML declaration must appear at the start of the document.");
76978        } // eslint-disable-next-line no-unused-expressions
76979
76980
76981        (_a = this.piHandler) === null || _a === void 0 ? void 0 : _a.call(this, {
76982          target: piTarget,
76983          body: this.text
76984        });
76985        this.piTarget = this.text = "";
76986        this.state = S_TEXT;
76987      } else if (c === QUESTION) {
76988        // We ran into ?? as part of a processing instruction. We initially took
76989        // the first ? as a sign that the PI was ending, but it is not. So we have
76990        // to add it to the body but we take the new ? as a sign that the PI is
76991        // ending.
76992        this.text += "?";
76993      } else {
76994        this.text += "?".concat(String.fromCodePoint(c));
76995        this.state = S_PI_BODY;
76996      }
76997
76998      this.xmlDeclPossible = false;
76999    }
77000  }, {
77001    key: "sXMLDeclNameStart",
77002    value: function sXMLDeclNameStart() {
77003      var c = this.skipSpaces(); // The question mark character is not valid inside any of the XML
77004      // declaration name/value pairs.
77005
77006      if (c === QUESTION) {
77007        // It is valid to go to S_XML_DECL_ENDING from this state.
77008        this.state = S_XML_DECL_ENDING;
77009        return;
77010      }
77011
77012      if (c !== EOC) {
77013        this.state = S_XML_DECL_NAME;
77014        this.name = String.fromCodePoint(c);
77015      }
77016    }
77017  }, {
77018    key: "sXMLDeclName",
77019    value: function sXMLDeclName() {
77020      var c = this.captureTo(XML_DECL_NAME_TERMINATOR); // The question mark character is not valid inside any of the XML
77021      // declaration name/value pairs.
77022
77023      if (c === QUESTION) {
77024        this.state = S_XML_DECL_ENDING;
77025        this.name += this.text;
77026        this.text = "";
77027        this.fail("XML declaration is incomplete.");
77028        return;
77029      }
77030
77031      if (!(isS(c) || c === EQUAL)) {
77032        return;
77033      }
77034
77035      this.name += this.text;
77036      this.text = "";
77037
77038      if (!this.xmlDeclExpects.includes(this.name)) {
77039        switch (this.name.length) {
77040          case 0:
77041            this.fail("did not expect any more name/value pairs.");
77042            break;
77043
77044          case 1:
77045            this.fail("expected the name ".concat(this.xmlDeclExpects[0], "."));
77046            break;
77047
77048          default:
77049            this.fail("expected one of ".concat(this.xmlDeclExpects.join(", ")));
77050        }
77051      }
77052
77053      this.state = c === EQUAL ? S_XML_DECL_VALUE_START : S_XML_DECL_EQ;
77054    }
77055  }, {
77056    key: "sXMLDeclEq",
77057    value: function sXMLDeclEq() {
77058      var c = this.getCodeNorm(); // The question mark character is not valid inside any of the XML
77059      // declaration name/value pairs.
77060
77061      if (c === QUESTION) {
77062        this.state = S_XML_DECL_ENDING;
77063        this.fail("XML declaration is incomplete.");
77064        return;
77065      }
77066
77067      if (isS(c)) {
77068        return;
77069      }
77070
77071      if (c !== EQUAL) {
77072        this.fail("value required.");
77073      }
77074
77075      this.state = S_XML_DECL_VALUE_START;
77076    }
77077  }, {
77078    key: "sXMLDeclValueStart",
77079    value: function sXMLDeclValueStart() {
77080      var c = this.getCodeNorm(); // The question mark character is not valid inside any of the XML
77081      // declaration name/value pairs.
77082
77083      if (c === QUESTION) {
77084        this.state = S_XML_DECL_ENDING;
77085        this.fail("XML declaration is incomplete.");
77086        return;
77087      }
77088
77089      if (isS(c)) {
77090        return;
77091      }
77092
77093      if (!isQuote(c)) {
77094        this.fail("value must be quoted.");
77095        this.q = SPACE;
77096      } else {
77097        this.q = c;
77098      }
77099
77100      this.state = S_XML_DECL_VALUE;
77101    }
77102  }, {
77103    key: "sXMLDeclValue",
77104    value: function sXMLDeclValue() {
77105      var c = this.captureTo([this.q, QUESTION]); // The question mark character is not valid inside any of the XML
77106      // declaration name/value pairs.
77107
77108      if (c === QUESTION) {
77109        this.state = S_XML_DECL_ENDING;
77110        this.text = "";
77111        this.fail("XML declaration is incomplete.");
77112        return;
77113      }
77114
77115      if (c === EOC) {
77116        return;
77117      }
77118
77119      var value = this.text;
77120      this.text = "";
77121
77122      switch (this.name) {
77123        case "version":
77124          {
77125            this.xmlDeclExpects = ["encoding", "standalone"];
77126            var version = value;
77127            this.xmlDecl.version = version; // This is the test specified by XML 1.0 but it is fine for XML 1.1.
77128
77129            if (!/^1\.[0-9]+$/.test(version)) {
77130              this.fail("version number must match /^1\\.[0-9]+$/.");
77131            } // When forceXMLVersion is set, the XML declaration is ignored.
77132            else if (!this.opt.forceXMLVersion) {
77133                this.setXMLVersion(version);
77134              }
77135
77136            break;
77137          }
77138
77139        case "encoding":
77140          if (!/^[A-Za-z][A-Za-z0-9._-]*$/.test(value)) {
77141            this.fail("encoding value must match \
77142/^[A-Za-z0-9][A-Za-z0-9._-]*$/.");
77143          }
77144
77145          this.xmlDeclExpects = ["standalone"];
77146          this.xmlDecl.encoding = value;
77147          break;
77148
77149        case "standalone":
77150          if (value !== "yes" && value !== "no") {
77151            this.fail("standalone value must match \"yes\" or \"no\".");
77152          }
77153
77154          this.xmlDeclExpects = [];
77155          this.xmlDecl.standalone = value;
77156          break;
77157
77158        default: // We don't need to raise an error here since we've already raised one
77159        // when checking what name was expected.
77160
77161      }
77162
77163      this.name = "";
77164      this.state = S_XML_DECL_SEPARATOR;
77165    }
77166  }, {
77167    key: "sXMLDeclSeparator",
77168    value: function sXMLDeclSeparator() {
77169      var c = this.getCodeNorm(); // The question mark character is not valid inside any of the XML
77170      // declaration name/value pairs.
77171
77172      if (c === QUESTION) {
77173        // It is valid to go to S_XML_DECL_ENDING from this state.
77174        this.state = S_XML_DECL_ENDING;
77175        return;
77176      }
77177
77178      if (!isS(c)) {
77179        this.fail("whitespace required.");
77180        this.unget();
77181      }
77182
77183      this.state = S_XML_DECL_NAME_START;
77184    }
77185  }, {
77186    key: "sXMLDeclEnding",
77187    value: function sXMLDeclEnding() {
77188      var _a;
77189
77190      var c = this.getCodeNorm();
77191
77192      if (c === GREATER) {
77193        if (this.piTarget !== "xml") {
77194          this.fail("processing instructions are not allowed before root.");
77195        } else if (this.name !== "version" && this.xmlDeclExpects.includes("version")) {
77196          this.fail("XML declaration must contain a version.");
77197        } // eslint-disable-next-line no-unused-expressions
77198
77199
77200        (_a = this.xmldeclHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.xmlDecl);
77201        this.name = "";
77202        this.piTarget = this.text = "";
77203        this.state = S_TEXT;
77204      } else {
77205        // We got here because the previous character was a ?, but the question
77206        // mark character is not valid inside any of the XML declaration
77207        // name/value pairs.
77208        this.fail("The character ? is disallowed anywhere in XML declarations.");
77209      }
77210
77211      this.xmlDeclPossible = false;
77212    }
77213  }, {
77214    key: "sOpenTag",
77215    value: function sOpenTag() {
77216      var _a;
77217
77218      var c = this.captureNameChars();
77219
77220      if (c === EOC) {
77221        return;
77222      }
77223
77224      var tag = this.tag = {
77225        name: this.name,
77226        attributes: Object.create(null)
77227      };
77228      this.name = "";
77229
77230      if (this.xmlnsOpt) {
77231        this.topNS = tag.ns = Object.create(null);
77232      } // eslint-disable-next-line no-unused-expressions
77233
77234
77235      (_a = this.openTagStartHandler) === null || _a === void 0 ? void 0 : _a.call(this, tag);
77236      this.sawRoot = true;
77237
77238      if (!this.fragmentOpt && this.closedRoot) {
77239        this.fail("documents may contain only one root.");
77240      }
77241
77242      switch (c) {
77243        case GREATER:
77244          this.openTag();
77245          break;
77246
77247        case FORWARD_SLASH:
77248          this.state = S_OPEN_TAG_SLASH;
77249          break;
77250
77251        default:
77252          if (!isS(c)) {
77253            this.fail("disallowed character in tag name.");
77254          }
77255
77256          this.state = S_ATTRIB;
77257      }
77258    }
77259  }, {
77260    key: "sOpenTagSlash",
77261    value: function sOpenTagSlash() {
77262      if (this.getCode() === GREATER) {
77263        this.openSelfClosingTag();
77264      } else {
77265        this.fail("forward-slash in opening tag not followed by >.");
77266        this.state = S_ATTRIB;
77267      }
77268    }
77269  }, {
77270    key: "sAttrib",
77271    value: function sAttrib() {
77272      var c = this.skipSpaces();
77273
77274      if (c === EOC) {
77275        return;
77276      }
77277
77278      if (isNameStartChar(c)) {
77279        this.unget();
77280        this.state = S_ATTRIB_NAME;
77281      } else if (c === GREATER) {
77282        this.openTag();
77283      } else if (c === FORWARD_SLASH) {
77284        this.state = S_OPEN_TAG_SLASH;
77285      } else {
77286        this.fail("disallowed character in attribute name.");
77287      }
77288    }
77289  }, {
77290    key: "sAttribName",
77291    value: function sAttribName() {
77292      var c = this.captureNameChars();
77293
77294      if (c === EQUAL) {
77295        this.state = S_ATTRIB_VALUE;
77296      } else if (isS(c)) {
77297        this.state = S_ATTRIB_NAME_SAW_WHITE;
77298      } else if (c === GREATER) {
77299        this.fail("attribute without value.");
77300        this.pushAttrib(this.name, this.name);
77301        this.name = this.text = "";
77302        this.openTag();
77303      } else if (c !== EOC) {
77304        this.fail("disallowed character in attribute name.");
77305      }
77306    }
77307  }, {
77308    key: "sAttribNameSawWhite",
77309    value: function sAttribNameSawWhite() {
77310      var c = this.skipSpaces();
77311
77312      switch (c) {
77313        case EOC:
77314          return;
77315
77316        case EQUAL:
77317          this.state = S_ATTRIB_VALUE;
77318          break;
77319
77320        default:
77321          this.fail("attribute without value."); // Should we do this???
77322          // this.tag.attributes[this.name] = "";
77323
77324          this.text = "";
77325          this.name = "";
77326
77327          if (c === GREATER) {
77328            this.openTag();
77329          } else if (isNameStartChar(c)) {
77330            this.unget();
77331            this.state = S_ATTRIB_NAME;
77332          } else {
77333            this.fail("disallowed character in attribute name.");
77334            this.state = S_ATTRIB;
77335          }
77336
77337      }
77338    }
77339  }, {
77340    key: "sAttribValue",
77341    value: function sAttribValue() {
77342      var c = this.getCodeNorm();
77343
77344      if (isQuote(c)) {
77345        this.q = c;
77346        this.state = S_ATTRIB_VALUE_QUOTED;
77347      } else if (!isS(c)) {
77348        this.fail("unquoted attribute value.");
77349        this.state = S_ATTRIB_VALUE_UNQUOTED;
77350        this.unget();
77351      }
77352    }
77353  }, {
77354    key: "sAttribValueQuoted",
77355    value: function sAttribValueQuoted() {
77356      // We deliberately do not use captureTo here. The specialized code we use
77357      // here is faster than using captureTo.
77358      var q = this.q,
77359          chunk = this.chunk;
77360      var start = this.i; // eslint-disable-next-line no-constant-condition
77361
77362      while (true) {
77363        switch (this.getCode()) {
77364          case q:
77365            this.pushAttrib(this.name, this.text + chunk.slice(start, this.prevI));
77366            this.name = this.text = "";
77367            this.q = null;
77368            this.state = S_ATTRIB_VALUE_CLOSED;
77369            return;
77370
77371          case AMP:
77372            this.text += chunk.slice(start, this.prevI);
77373            this.state = S_ENTITY;
77374            this.entityReturnState = S_ATTRIB_VALUE_QUOTED;
77375            return;
77376
77377          case NL:
77378          case NL_LIKE:
77379          case TAB:
77380            this.text += "".concat(chunk.slice(start, this.prevI), " ");
77381            start = this.i;
77382            break;
77383
77384          case LESS:
77385            this.text += chunk.slice(start, this.prevI);
77386            this.fail("disallowed character.");
77387            return;
77388
77389          case EOC:
77390            this.text += chunk.slice(start);
77391            return;
77392
77393          default:
77394        }
77395      }
77396    }
77397  }, {
77398    key: "sAttribValueClosed",
77399    value: function sAttribValueClosed() {
77400      var c = this.getCodeNorm();
77401
77402      if (isS(c)) {
77403        this.state = S_ATTRIB;
77404      } else if (c === GREATER) {
77405        this.openTag();
77406      } else if (c === FORWARD_SLASH) {
77407        this.state = S_OPEN_TAG_SLASH;
77408      } else if (isNameStartChar(c)) {
77409        this.fail("no whitespace between attributes.");
77410        this.unget();
77411        this.state = S_ATTRIB_NAME;
77412      } else {
77413        this.fail("disallowed character in attribute name.");
77414      }
77415    }
77416  }, {
77417    key: "sAttribValueUnquoted",
77418    value: function sAttribValueUnquoted() {
77419      // We don't do anything regarding EOL or space handling for unquoted
77420      // attributes. We already have failed by the time we get here, and the
77421      // contract that saxes upholds states that upon failure, it is not safe to
77422      // rely on the data passed to event handlers (other than
77423      // ``onerror``). Passing "bad" data is not a problem.
77424      var c = this.captureTo(ATTRIB_VALUE_UNQUOTED_TERMINATOR);
77425
77426      switch (c) {
77427        case AMP:
77428          this.state = S_ENTITY;
77429          this.entityReturnState = S_ATTRIB_VALUE_UNQUOTED;
77430          break;
77431
77432        case LESS:
77433          this.fail("disallowed character.");
77434          break;
77435
77436        case EOC:
77437          break;
77438
77439        default:
77440          if (this.text.includes("]]>")) {
77441            this.fail("the string \"]]>\" is disallowed in char data.");
77442          }
77443
77444          this.pushAttrib(this.name, this.text);
77445          this.name = this.text = "";
77446
77447          if (c === GREATER) {
77448            this.openTag();
77449          } else {
77450            this.state = S_ATTRIB;
77451          }
77452
77453      }
77454    }
77455  }, {
77456    key: "sCloseTag",
77457    value: function sCloseTag() {
77458      var c = this.captureNameChars();
77459
77460      if (c === GREATER) {
77461        this.closeTag();
77462      } else if (isS(c)) {
77463        this.state = S_CLOSE_TAG_SAW_WHITE;
77464      } else if (c !== EOC) {
77465        this.fail("disallowed character in closing tag.");
77466      }
77467    }
77468  }, {
77469    key: "sCloseTagSawWhite",
77470    value: function sCloseTagSawWhite() {
77471      switch (this.skipSpaces()) {
77472        case GREATER:
77473          this.closeTag();
77474          break;
77475
77476        case EOC:
77477          break;
77478
77479        default:
77480          this.fail("disallowed character in closing tag.");
77481      }
77482    } // END OF STATE ENGINE METHODS
77483
77484  }, {
77485    key: "handleTextInRoot",
77486    value: function handleTextInRoot() {
77487      // This is essentially a specialized version of captureTo which is optimized
77488      // for performing the ]]> check. A previous version of this code, checked
77489      // ``this.text`` for the presence of ]]>. It simplified the code but was
77490      // very costly when character data contained a lot of entities to be parsed.
77491      //
77492      // Since we are using a specialized loop, we also keep track of the presence
77493      // of ]]> in text data. The sequence ]]> is forbidden to appear as-is.
77494      //
77495      var start = this.i,
77496          forbiddenState = this.forbiddenState;
77497      var chunk = this.chunk,
77498          handler = this.textHandler; // eslint-disable-next-line no-labels, no-restricted-syntax
77499
77500      scanLoop: // eslint-disable-next-line no-constant-condition
77501      while (true) {
77502        switch (this.getCode()) {
77503          case LESS:
77504            {
77505              this.state = S_OPEN_WAKA;
77506
77507              if (handler !== undefined) {
77508                var text = this.text;
77509                var slice = chunk.slice(start, this.prevI);
77510
77511                if (text.length !== 0) {
77512                  handler(text + slice);
77513                  this.text = "";
77514                } else if (slice.length !== 0) {
77515                  handler(slice);
77516                }
77517              }
77518
77519              forbiddenState = FORBIDDEN_START; // eslint-disable-next-line no-labels
77520
77521              break scanLoop;
77522            }
77523
77524          case AMP:
77525            this.state = S_ENTITY;
77526            this.entityReturnState = S_TEXT;
77527
77528            if (handler !== undefined) {
77529              this.text += chunk.slice(start, this.prevI);
77530            }
77531
77532            forbiddenState = FORBIDDEN_START; // eslint-disable-next-line no-labels
77533
77534            break scanLoop;
77535
77536          case CLOSE_BRACKET:
77537            switch (forbiddenState) {
77538              case FORBIDDEN_START:
77539                forbiddenState = FORBIDDEN_BRACKET;
77540                break;
77541
77542              case FORBIDDEN_BRACKET:
77543                forbiddenState = FORBIDDEN_BRACKET_BRACKET;
77544                break;
77545
77546              case FORBIDDEN_BRACKET_BRACKET:
77547                break;
77548
77549              default:
77550                throw new Error("impossible state");
77551            }
77552
77553            break;
77554
77555          case GREATER:
77556            if (forbiddenState === FORBIDDEN_BRACKET_BRACKET) {
77557              this.fail("the string \"]]>\" is disallowed in char data.");
77558            }
77559
77560            forbiddenState = FORBIDDEN_START;
77561            break;
77562
77563          case NL_LIKE:
77564            if (handler !== undefined) {
77565              this.text += "".concat(chunk.slice(start, this.prevI), "\n");
77566            }
77567
77568            start = this.i;
77569            forbiddenState = FORBIDDEN_START;
77570            break;
77571
77572          case EOC:
77573            if (handler !== undefined) {
77574              this.text += chunk.slice(start);
77575            } // eslint-disable-next-line no-labels
77576
77577
77578            break scanLoop;
77579
77580          default:
77581            forbiddenState = FORBIDDEN_START;
77582        }
77583      }
77584
77585      this.forbiddenState = forbiddenState;
77586    }
77587  }, {
77588    key: "handleTextOutsideRoot",
77589    value: function handleTextOutsideRoot() {
77590      // This is essentially a specialized version of captureTo which is optimized
77591      // for a specialized task. We keep track of the presence of non-space
77592      // characters in the text since these are errors when appearing outside the
77593      // document root element.
77594      var start = this.i;
77595      var chunk = this.chunk,
77596          handler = this.textHandler;
77597      var nonSpace = false; // eslint-disable-next-line no-labels, no-restricted-syntax
77598
77599      outRootLoop: // eslint-disable-next-line no-constant-condition
77600      while (true) {
77601        var code = this.getCode();
77602
77603        switch (code) {
77604          case LESS:
77605            {
77606              this.state = S_OPEN_WAKA;
77607
77608              if (handler !== undefined) {
77609                var text = this.text;
77610                var slice = chunk.slice(start, this.prevI);
77611
77612                if (text.length !== 0) {
77613                  handler(text + slice);
77614                  this.text = "";
77615                } else if (slice.length !== 0) {
77616                  handler(slice);
77617                }
77618              } // eslint-disable-next-line no-labels
77619
77620
77621              break outRootLoop;
77622            }
77623
77624          case AMP:
77625            this.state = S_ENTITY;
77626            this.entityReturnState = S_TEXT;
77627
77628            if (handler !== undefined) {
77629              this.text += chunk.slice(start, this.prevI);
77630            }
77631
77632            nonSpace = true; // eslint-disable-next-line no-labels
77633
77634            break outRootLoop;
77635
77636          case NL_LIKE:
77637            if (handler !== undefined) {
77638              this.text += "".concat(chunk.slice(start, this.prevI), "\n");
77639            }
77640
77641            start = this.i;
77642            break;
77643
77644          case EOC:
77645            if (handler !== undefined) {
77646              this.text += chunk.slice(start);
77647            } // eslint-disable-next-line no-labels
77648
77649
77650            break outRootLoop;
77651
77652          default:
77653            if (!isS(code)) {
77654              nonSpace = true;
77655            }
77656
77657        }
77658      }
77659
77660      if (!nonSpace) {
77661        return;
77662      } // We use the reportedTextBeforeRoot and reportedTextAfterRoot flags
77663      // to avoid reporting errors for every single character that is out of
77664      // place.
77665
77666
77667      if (!this.sawRoot && !this.reportedTextBeforeRoot) {
77668        this.fail("text data outside of root node.");
77669        this.reportedTextBeforeRoot = true;
77670      }
77671
77672      if (this.closedRoot && !this.reportedTextAfterRoot) {
77673        this.fail("text data outside of root node.");
77674        this.reportedTextAfterRoot = true;
77675      }
77676    }
77677  }, {
77678    key: "pushAttribNS",
77679    value: function pushAttribNS(name, value) {
77680      var _a;
77681
77682      var _this$qname = this.qname(name),
77683          prefix = _this$qname.prefix,
77684          local = _this$qname.local;
77685
77686      var attr = {
77687        name: name,
77688        prefix: prefix,
77689        local: local,
77690        value: value
77691      };
77692      this.attribList.push(attr); // eslint-disable-next-line no-unused-expressions
77693
77694      (_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this, attr);
77695
77696      if (prefix === "xmlns") {
77697        var trimmed = value.trim();
77698
77699        if (this.currentXMLVersion === "1.0" && trimmed === "") {
77700          this.fail("invalid attempt to undefine prefix in XML 1.0");
77701        }
77702
77703        this.topNS[local] = trimmed;
77704        nsPairCheck(this, local, trimmed);
77705      } else if (name === "xmlns") {
77706        var _trimmed = value.trim();
77707
77708        this.topNS[""] = _trimmed;
77709        nsPairCheck(this, "", _trimmed);
77710      }
77711    }
77712  }, {
77713    key: "pushAttribPlain",
77714    value: function pushAttribPlain(name, value) {
77715      var _a;
77716
77717      var attr = {
77718        name: name,
77719        value: value
77720      };
77721      this.attribList.push(attr); // eslint-disable-next-line no-unused-expressions
77722
77723      (_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this, attr);
77724    }
77725    /**
77726     * End parsing. This performs final well-formedness checks and resets the
77727     * parser to a clean state.
77728     *
77729     * @returns this
77730     */
77731
77732  }, {
77733    key: "end",
77734    value: function end() {
77735      var _a, _b;
77736
77737      if (!this.sawRoot) {
77738        this.fail("document must contain a root element.");
77739      }
77740
77741      var tags = this.tags;
77742
77743      while (tags.length > 0) {
77744        var tag = tags.pop();
77745        this.fail("unclosed tag: ".concat(tag.name));
77746      }
77747
77748      if (this.state !== S_BEGIN && this.state !== S_TEXT) {
77749        this.fail("unexpected end.");
77750      }
77751
77752      var text = this.text;
77753
77754      if (text.length !== 0) {
77755        // eslint-disable-next-line no-unused-expressions
77756        (_a = this.textHandler) === null || _a === void 0 ? void 0 : _a.call(this, text);
77757        this.text = "";
77758      }
77759
77760      this._closed = true; // eslint-disable-next-line no-unused-expressions
77761
77762      (_b = this.endHandler) === null || _b === void 0 ? void 0 : _b.call(this);
77763
77764      this._init();
77765
77766      return this;
77767    }
77768    /**
77769     * Resolve a namespace prefix.
77770     *
77771     * @param prefix The prefix to resolve.
77772     *
77773     * @returns The namespace URI or ``undefined`` if the prefix is not defined.
77774     */
77775
77776  }, {
77777    key: "resolve",
77778    value: function resolve(prefix) {
77779      var _a, _b;
77780
77781      var uri = this.topNS[prefix];
77782
77783      if (uri !== undefined) {
77784        return uri;
77785      }
77786
77787      var tags = this.tags;
77788
77789      for (var index = tags.length - 1; index >= 0; index--) {
77790        uri = tags[index].ns[prefix];
77791
77792        if (uri !== undefined) {
77793          return uri;
77794        }
77795      }
77796
77797      uri = this.ns[prefix];
77798
77799      if (uri !== undefined) {
77800        return uri;
77801      }
77802
77803      return (_b = (_a = this.opt).resolvePrefix) === null || _b === void 0 ? void 0 : _b.call(_a, prefix);
77804    }
77805    /**
77806     * Parse a qname into its prefix and local name parts.
77807     *
77808     * @param name The name to parse
77809     *
77810     * @returns
77811     */
77812
77813  }, {
77814    key: "qname",
77815    value: function qname(name) {
77816      // This is faster than using name.split(":").
77817      var colon = name.indexOf(":");
77818
77819      if (colon === -1) {
77820        return {
77821          prefix: "",
77822          local: name
77823        };
77824      }
77825
77826      var local = name.slice(colon + 1);
77827      var prefix = name.slice(0, colon);
77828
77829      if (prefix === "" || local === "" || local.includes(":")) {
77830        this.fail("malformed name: ".concat(name, "."));
77831      }
77832
77833      return {
77834        prefix: prefix,
77835        local: local
77836      };
77837    }
77838  }, {
77839    key: "processAttribsNS",
77840    value: function processAttribsNS() {
77841      var _a;
77842
77843      var attribList = this.attribList;
77844      var tag = this.tag;
77845      {
77846        // add namespace info to tag
77847        var _this$qname2 = this.qname(tag.name),
77848            prefix = _this$qname2.prefix,
77849            local = _this$qname2.local;
77850
77851        tag.prefix = prefix;
77852        tag.local = local;
77853        var uri = tag.uri = (_a = this.resolve(prefix)) !== null && _a !== void 0 ? _a : "";
77854
77855        if (prefix !== "") {
77856          if (prefix === "xmlns") {
77857            this.fail("tags may not have \"xmlns\" as prefix.");
77858          }
77859
77860          if (uri === "") {
77861            this.fail("unbound namespace prefix: ".concat(JSON.stringify(prefix), "."));
77862            tag.uri = prefix;
77863          }
77864        }
77865      }
77866
77867      if (attribList.length === 0) {
77868        return;
77869      }
77870
77871      var attributes = tag.attributes;
77872      var seen = new Set(); // Note: do not apply default ns to attributes:
77873      //   http://www.w3.org/TR/REC-xml-names/#defaulting
77874
77875      var _iterator = _createForOfIteratorHelper(attribList),
77876          _step;
77877
77878      try {
77879        for (_iterator.s(); !(_step = _iterator.n()).done;) {
77880          var attr = _step.value;
77881          var name = attr.name,
77882              _prefix = attr.prefix,
77883              _local = attr.local;
77884
77885          var _uri = void 0;
77886
77887          var eqname = void 0;
77888
77889          if (_prefix === "") {
77890            _uri = name === "xmlns" ? XMLNS_NAMESPACE : "";
77891            eqname = name;
77892          } else {
77893            _uri = this.resolve(_prefix); // if there's any attributes with an undefined namespace,
77894            // then fail on them now.
77895
77896            if (_uri === undefined) {
77897              this.fail("unbound namespace prefix: ".concat(JSON.stringify(_prefix), "."));
77898              _uri = _prefix;
77899            }
77900
77901            eqname = "{".concat(_uri, "}").concat(_local);
77902          }
77903
77904          if (seen.has(eqname)) {
77905            this.fail("duplicate attribute: ".concat(eqname, "."));
77906          }
77907
77908          seen.add(eqname);
77909          attr.uri = _uri;
77910          attributes[name] = attr;
77911        }
77912      } catch (err) {
77913        _iterator.e(err);
77914      } finally {
77915        _iterator.f();
77916      }
77917
77918      this.attribList = [];
77919    }
77920  }, {
77921    key: "processAttribsPlain",
77922    value: function processAttribsPlain() {
77923      var attribList = this.attribList; // eslint-disable-next-line prefer-destructuring
77924
77925      var attributes = this.tag.attributes;
77926
77927      var _iterator2 = _createForOfIteratorHelper(attribList),
77928          _step2;
77929
77930      try {
77931        for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
77932          var _step2$value = _step2.value,
77933              name = _step2$value.name,
77934              value = _step2$value.value;
77935
77936          if (attributes[name] !== undefined) {
77937            this.fail("duplicate attribute: ".concat(name, "."));
77938          }
77939
77940          attributes[name] = value;
77941        }
77942      } catch (err) {
77943        _iterator2.e(err);
77944      } finally {
77945        _iterator2.f();
77946      }
77947
77948      this.attribList = [];
77949    }
77950    /**
77951     * Handle a complete open tag. This parser code calls this once it has seen
77952     * the whole tag. This method checks for well-formeness and then emits
77953     * ``onopentag``.
77954     */
77955
77956  }, {
77957    key: "openTag",
77958    value: function openTag() {
77959      var _a;
77960
77961      this.processAttribs();
77962      var tags = this.tags;
77963      var tag = this.tag;
77964      tag.isSelfClosing = false; // There cannot be any pending text here due to the onopentagstart that was
77965      // necessarily emitted before we get here. So we do not check text.
77966      // eslint-disable-next-line no-unused-expressions
77967
77968      (_a = this.openTagHandler) === null || _a === void 0 ? void 0 : _a.call(this, tag);
77969      tags.push(tag);
77970      this.state = S_TEXT;
77971      this.name = "";
77972    }
77973    /**
77974     * Handle a complete self-closing tag. This parser code calls this once it has
77975     * seen the whole tag. This method checks for well-formeness and then emits
77976     * ``onopentag`` and ``onclosetag``.
77977     */
77978
77979  }, {
77980    key: "openSelfClosingTag",
77981    value: function openSelfClosingTag() {
77982      var _a, _b, _c;
77983
77984      this.processAttribs();
77985      var tags = this.tags;
77986      var tag = this.tag;
77987      tag.isSelfClosing = true; // There cannot be any pending text here due to the onopentagstart that was
77988      // necessarily emitted before we get here. So we do not check text.
77989      // eslint-disable-next-line no-unused-expressions
77990
77991      (_a = this.openTagHandler) === null || _a === void 0 ? void 0 : _a.call(this, tag); // eslint-disable-next-line no-unused-expressions
77992
77993      (_b = this.closeTagHandler) === null || _b === void 0 ? void 0 : _b.call(this, tag);
77994      var top = this.tag = (_c = tags[tags.length - 1]) !== null && _c !== void 0 ? _c : null;
77995
77996      if (top === null) {
77997        this.closedRoot = true;
77998      }
77999
78000      this.state = S_TEXT;
78001      this.name = "";
78002    }
78003    /**
78004     * Handle a complete close tag. This parser code calls this once it has seen
78005     * the whole tag. This method checks for well-formeness and then emits
78006     * ``onclosetag``.
78007     */
78008
78009  }, {
78010    key: "closeTag",
78011    value: function closeTag() {
78012      var tags = this.tags,
78013          name = this.name; // Our state after this will be S_TEXT, no matter what, and we can clear
78014      // tagName now.
78015
78016      this.state = S_TEXT;
78017      this.name = "";
78018
78019      if (name === "") {
78020        this.fail("weird empty close tag.");
78021        this.text += "</>";
78022        return;
78023      }
78024
78025      var handler = this.closeTagHandler;
78026      var l = tags.length;
78027
78028      while (l-- > 0) {
78029        var tag = this.tag = tags.pop();
78030        this.topNS = tag.ns; // eslint-disable-next-line no-unused-expressions
78031
78032        handler === null || handler === void 0 ? void 0 : handler(tag);
78033
78034        if (tag.name === name) {
78035          break;
78036        }
78037
78038        this.fail("unexpected close tag.");
78039      }
78040
78041      if (l === 0) {
78042        this.closedRoot = true;
78043      } else if (l < 0) {
78044        this.fail("unmatched closing tag: ".concat(name, "."));
78045        this.text += "</".concat(name, ">");
78046      }
78047    }
78048    /**
78049     * Resolves an entity. Makes any necessary well-formedness checks.
78050     *
78051     * @param entity The entity to resolve.
78052     *
78053     * @returns The parsed entity.
78054     */
78055
78056  }, {
78057    key: "parseEntity",
78058    value: function parseEntity(entity) {
78059      // startsWith would be significantly slower for this test.
78060      // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
78061      if (entity[0] !== "#") {
78062        var defined = this.ENTITIES[entity];
78063
78064        if (defined !== undefined) {
78065          return defined;
78066        }
78067
78068        this.fail(this.isName(entity) ? "undefined entity." : "disallowed character in entity name.");
78069        return "&".concat(entity, ";");
78070      }
78071
78072      var num = NaN;
78073
78074      if (entity[1] === "x" && /^#x[0-9a-f]+$/i.test(entity)) {
78075        num = parseInt(entity.slice(2), 16);
78076      } else if (/^#[0-9]+$/.test(entity)) {
78077        num = parseInt(entity.slice(1), 10);
78078      } // The character reference is required to match the CHAR production.
78079
78080
78081      if (!this.isChar(num)) {
78082        this.fail("malformed character entity.");
78083        return "&".concat(entity, ";");
78084      }
78085
78086      return String.fromCodePoint(num);
78087    }
78088  }, {
78089    key: "closed",
78090    get: function get() {
78091      return this._closed;
78092    }
78093  }, {
78094    key: "position",
78095    get: function get() {
78096      return this.chunkPosition + this.i;
78097    }
78098    /**
78099     * The column number of the next character to be read by the parser.  *
78100     * This field is zero-based. (The first column in a line is 0.)
78101     *
78102     * This field reports the index at which the next character would be in the
78103     * line if the line were represented as a JavaScript string.  Note that this
78104     * *can* be different to a count based on the number of *Unicode characters*
78105     * due to how JavaScript handles astral plane characters.
78106     *
78107     * See [[column]] for a number that corresponds to a count of Unicode
78108     * characters.
78109     */
78110
78111  }, {
78112    key: "columnIndex",
78113    get: function get() {
78114      return this.position - this.positionAtNewLine;
78115    }
78116  }]);
78117
78118  return SaxesParser;
78119}();
78120
78121exports.SaxesParser = SaxesParser;
78122
78123},{"xmlchars/xml/1.0/ed5":541,"xmlchars/xml/1.1/ed2":542,"xmlchars/xmlns/1.0/ed3":543}],497:[function(require,module,exports){
78124(function (setImmediate){
78125'use strict';
78126
78127module.exports = typeof setImmediate === 'function' ? setImmediate : function setImmediate() {
78128  var args = [].slice.apply(arguments);
78129  args.splice(1, 0, 0);
78130  setTimeout.apply(null, args);
78131};
78132
78133}).call(this,require("timers").setImmediate)
78134
78135},{"timers":521}],498:[function(require,module,exports){
78136"use strict";
78137
78138var Buffer = require('safe-buffer').Buffer; // prototype class for hash functions
78139
78140
78141function Hash(blockSize, finalSize) {
78142  this._block = Buffer.alloc(blockSize);
78143  this._finalSize = finalSize;
78144  this._blockSize = blockSize;
78145  this._len = 0;
78146}
78147
78148Hash.prototype.update = function (data, enc) {
78149  if (typeof data === 'string') {
78150    enc = enc || 'utf8';
78151    data = Buffer.from(data, enc);
78152  }
78153
78154  var block = this._block;
78155  var blockSize = this._blockSize;
78156  var length = data.length;
78157  var accum = this._len;
78158
78159  for (var offset = 0; offset < length;) {
78160    var assigned = accum % blockSize;
78161    var remainder = Math.min(length - offset, blockSize - assigned);
78162
78163    for (var i = 0; i < remainder; i++) {
78164      block[assigned + i] = data[offset + i];
78165    }
78166
78167    accum += remainder;
78168    offset += remainder;
78169
78170    if (accum % blockSize === 0) {
78171      this._update(block);
78172    }
78173  }
78174
78175  this._len += length;
78176  return this;
78177};
78178
78179Hash.prototype.digest = function (enc) {
78180  var rem = this._len % this._blockSize;
78181  this._block[rem] = 0x80; // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
78182  // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
78183
78184  this._block.fill(0, rem + 1);
78185
78186  if (rem >= this._finalSize) {
78187    this._update(this._block);
78188
78189    this._block.fill(0);
78190  }
78191
78192  var bits = this._len * 8; // uint32
78193
78194  if (bits <= 0xffffffff) {
78195    this._block.writeUInt32BE(bits, this._blockSize - 4); // uint64
78196
78197  } else {
78198    var lowBits = (bits & 0xffffffff) >>> 0;
78199    var highBits = (bits - lowBits) / 0x100000000;
78200
78201    this._block.writeUInt32BE(highBits, this._blockSize - 8);
78202
78203    this._block.writeUInt32BE(lowBits, this._blockSize - 4);
78204  }
78205
78206  this._update(this._block);
78207
78208  var hash = this._hash();
78209
78210  return enc ? hash.toString(enc) : hash;
78211};
78212
78213Hash.prototype._update = function () {
78214  throw new Error('_update must be implemented by subclass');
78215};
78216
78217module.exports = Hash;
78218
78219},{"safe-buffer":494}],499:[function(require,module,exports){
78220"use strict";
78221
78222var _exports = module.exports = function SHA(algorithm) {
78223  algorithm = algorithm.toLowerCase();
78224  var Algorithm = _exports[algorithm];
78225  if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)');
78226  return new Algorithm();
78227};
78228
78229_exports.sha = require('./sha');
78230_exports.sha1 = require('./sha1');
78231_exports.sha224 = require('./sha224');
78232_exports.sha256 = require('./sha256');
78233_exports.sha384 = require('./sha384');
78234_exports.sha512 = require('./sha512');
78235
78236},{"./sha":500,"./sha1":501,"./sha224":502,"./sha256":503,"./sha384":504,"./sha512":505}],500:[function(require,module,exports){
78237"use strict";
78238
78239/*
78240 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
78241 * in FIPS PUB 180-1
78242 * This source code is derived from sha1.js of the same repository.
78243 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
78244 * operation was added.
78245 */
78246var inherits = require('inherits');
78247
78248var Hash = require('./hash');
78249
78250var Buffer = require('safe-buffer').Buffer;
78251
78252var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0];
78253var W = new Array(80);
78254
78255function Sha() {
78256  this.init();
78257  this._w = W;
78258  Hash.call(this, 64, 56);
78259}
78260
78261inherits(Sha, Hash);
78262
78263Sha.prototype.init = function () {
78264  this._a = 0x67452301;
78265  this._b = 0xefcdab89;
78266  this._c = 0x98badcfe;
78267  this._d = 0x10325476;
78268  this._e = 0xc3d2e1f0;
78269  return this;
78270};
78271
78272function rotl5(num) {
78273  return num << 5 | num >>> 27;
78274}
78275
78276function rotl30(num) {
78277  return num << 30 | num >>> 2;
78278}
78279
78280function ft(s, b, c, d) {
78281  if (s === 0) return b & c | ~b & d;
78282  if (s === 2) return b & c | b & d | c & d;
78283  return b ^ c ^ d;
78284}
78285
78286Sha.prototype._update = function (M) {
78287  var W = this._w;
78288  var a = this._a | 0;
78289  var b = this._b | 0;
78290  var c = this._c | 0;
78291  var d = this._d | 0;
78292  var e = this._e | 0;
78293
78294  for (var i = 0; i < 16; ++i) {
78295    W[i] = M.readInt32BE(i * 4);
78296  }
78297
78298  for (; i < 80; ++i) {
78299    W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
78300  }
78301
78302  for (var j = 0; j < 80; ++j) {
78303    var s = ~~(j / 20);
78304    var t = rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s] | 0;
78305    e = d;
78306    d = c;
78307    c = rotl30(b);
78308    b = a;
78309    a = t;
78310  }
78311
78312  this._a = a + this._a | 0;
78313  this._b = b + this._b | 0;
78314  this._c = c + this._c | 0;
78315  this._d = d + this._d | 0;
78316  this._e = e + this._e | 0;
78317};
78318
78319Sha.prototype._hash = function () {
78320  var H = Buffer.allocUnsafe(20);
78321  H.writeInt32BE(this._a | 0, 0);
78322  H.writeInt32BE(this._b | 0, 4);
78323  H.writeInt32BE(this._c | 0, 8);
78324  H.writeInt32BE(this._d | 0, 12);
78325  H.writeInt32BE(this._e | 0, 16);
78326  return H;
78327};
78328
78329module.exports = Sha;
78330
78331},{"./hash":498,"inherits":387,"safe-buffer":494}],501:[function(require,module,exports){
78332"use strict";
78333
78334/*
78335 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
78336 * in FIPS PUB 180-1
78337 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
78338 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
78339 * Distributed under the BSD License
78340 * See http://pajhome.org.uk/crypt/md5 for details.
78341 */
78342var inherits = require('inherits');
78343
78344var Hash = require('./hash');
78345
78346var Buffer = require('safe-buffer').Buffer;
78347
78348var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0];
78349var W = new Array(80);
78350
78351function Sha1() {
78352  this.init();
78353  this._w = W;
78354  Hash.call(this, 64, 56);
78355}
78356
78357inherits(Sha1, Hash);
78358
78359Sha1.prototype.init = function () {
78360  this._a = 0x67452301;
78361  this._b = 0xefcdab89;
78362  this._c = 0x98badcfe;
78363  this._d = 0x10325476;
78364  this._e = 0xc3d2e1f0;
78365  return this;
78366};
78367
78368function rotl1(num) {
78369  return num << 1 | num >>> 31;
78370}
78371
78372function rotl5(num) {
78373  return num << 5 | num >>> 27;
78374}
78375
78376function rotl30(num) {
78377  return num << 30 | num >>> 2;
78378}
78379
78380function ft(s, b, c, d) {
78381  if (s === 0) return b & c | ~b & d;
78382  if (s === 2) return b & c | b & d | c & d;
78383  return b ^ c ^ d;
78384}
78385
78386Sha1.prototype._update = function (M) {
78387  var W = this._w;
78388  var a = this._a | 0;
78389  var b = this._b | 0;
78390  var c = this._c | 0;
78391  var d = this._d | 0;
78392  var e = this._e | 0;
78393
78394  for (var i = 0; i < 16; ++i) {
78395    W[i] = M.readInt32BE(i * 4);
78396  }
78397
78398  for (; i < 80; ++i) {
78399    W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]);
78400  }
78401
78402  for (var j = 0; j < 80; ++j) {
78403    var s = ~~(j / 20);
78404    var t = rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s] | 0;
78405    e = d;
78406    d = c;
78407    c = rotl30(b);
78408    b = a;
78409    a = t;
78410  }
78411
78412  this._a = a + this._a | 0;
78413  this._b = b + this._b | 0;
78414  this._c = c + this._c | 0;
78415  this._d = d + this._d | 0;
78416  this._e = e + this._e | 0;
78417};
78418
78419Sha1.prototype._hash = function () {
78420  var H = Buffer.allocUnsafe(20);
78421  H.writeInt32BE(this._a | 0, 0);
78422  H.writeInt32BE(this._b | 0, 4);
78423  H.writeInt32BE(this._c | 0, 8);
78424  H.writeInt32BE(this._d | 0, 12);
78425  H.writeInt32BE(this._e | 0, 16);
78426  return H;
78427};
78428
78429module.exports = Sha1;
78430
78431},{"./hash":498,"inherits":387,"safe-buffer":494}],502:[function(require,module,exports){
78432"use strict";
78433
78434/**
78435 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
78436 * in FIPS 180-2
78437 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
78438 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
78439 *
78440 */
78441var inherits = require('inherits');
78442
78443var Sha256 = require('./sha256');
78444
78445var Hash = require('./hash');
78446
78447var Buffer = require('safe-buffer').Buffer;
78448
78449var W = new Array(64);
78450
78451function Sha224() {
78452  this.init();
78453  this._w = W; // new Array(64)
78454
78455  Hash.call(this, 64, 56);
78456}
78457
78458inherits(Sha224, Sha256);
78459
78460Sha224.prototype.init = function () {
78461  this._a = 0xc1059ed8;
78462  this._b = 0x367cd507;
78463  this._c = 0x3070dd17;
78464  this._d = 0xf70e5939;
78465  this._e = 0xffc00b31;
78466  this._f = 0x68581511;
78467  this._g = 0x64f98fa7;
78468  this._h = 0xbefa4fa4;
78469  return this;
78470};
78471
78472Sha224.prototype._hash = function () {
78473  var H = Buffer.allocUnsafe(28);
78474  H.writeInt32BE(this._a, 0);
78475  H.writeInt32BE(this._b, 4);
78476  H.writeInt32BE(this._c, 8);
78477  H.writeInt32BE(this._d, 12);
78478  H.writeInt32BE(this._e, 16);
78479  H.writeInt32BE(this._f, 20);
78480  H.writeInt32BE(this._g, 24);
78481  return H;
78482};
78483
78484module.exports = Sha224;
78485
78486},{"./hash":498,"./sha256":503,"inherits":387,"safe-buffer":494}],503:[function(require,module,exports){
78487"use strict";
78488
78489/**
78490 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
78491 * in FIPS 180-2
78492 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
78493 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
78494 *
78495 */
78496var inherits = require('inherits');
78497
78498var Hash = require('./hash');
78499
78500var Buffer = require('safe-buffer').Buffer;
78501
78502var K = [0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2];
78503var W = new Array(64);
78504
78505function Sha256() {
78506  this.init();
78507  this._w = W; // new Array(64)
78508
78509  Hash.call(this, 64, 56);
78510}
78511
78512inherits(Sha256, Hash);
78513
78514Sha256.prototype.init = function () {
78515  this._a = 0x6a09e667;
78516  this._b = 0xbb67ae85;
78517  this._c = 0x3c6ef372;
78518  this._d = 0xa54ff53a;
78519  this._e = 0x510e527f;
78520  this._f = 0x9b05688c;
78521  this._g = 0x1f83d9ab;
78522  this._h = 0x5be0cd19;
78523  return this;
78524};
78525
78526function ch(x, y, z) {
78527  return z ^ x & (y ^ z);
78528}
78529
78530function maj(x, y, z) {
78531  return x & y | z & (x | y);
78532}
78533
78534function sigma0(x) {
78535  return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10);
78536}
78537
78538function sigma1(x) {
78539  return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7);
78540}
78541
78542function gamma0(x) {
78543  return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3;
78544}
78545
78546function gamma1(x) {
78547  return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ x >>> 10;
78548}
78549
78550Sha256.prototype._update = function (M) {
78551  var W = this._w;
78552  var a = this._a | 0;
78553  var b = this._b | 0;
78554  var c = this._c | 0;
78555  var d = this._d | 0;
78556  var e = this._e | 0;
78557  var f = this._f | 0;
78558  var g = this._g | 0;
78559  var h = this._h | 0;
78560
78561  for (var i = 0; i < 16; ++i) {
78562    W[i] = M.readInt32BE(i * 4);
78563  }
78564
78565  for (; i < 64; ++i) {
78566    W[i] = gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16] | 0;
78567  }
78568
78569  for (var j = 0; j < 64; ++j) {
78570    var T1 = h + sigma1(e) + ch(e, f, g) + K[j] + W[j] | 0;
78571    var T2 = sigma0(a) + maj(a, b, c) | 0;
78572    h = g;
78573    g = f;
78574    f = e;
78575    e = d + T1 | 0;
78576    d = c;
78577    c = b;
78578    b = a;
78579    a = T1 + T2 | 0;
78580  }
78581
78582  this._a = a + this._a | 0;
78583  this._b = b + this._b | 0;
78584  this._c = c + this._c | 0;
78585  this._d = d + this._d | 0;
78586  this._e = e + this._e | 0;
78587  this._f = f + this._f | 0;
78588  this._g = g + this._g | 0;
78589  this._h = h + this._h | 0;
78590};
78591
78592Sha256.prototype._hash = function () {
78593  var H = Buffer.allocUnsafe(32);
78594  H.writeInt32BE(this._a, 0);
78595  H.writeInt32BE(this._b, 4);
78596  H.writeInt32BE(this._c, 8);
78597  H.writeInt32BE(this._d, 12);
78598  H.writeInt32BE(this._e, 16);
78599  H.writeInt32BE(this._f, 20);
78600  H.writeInt32BE(this._g, 24);
78601  H.writeInt32BE(this._h, 28);
78602  return H;
78603};
78604
78605module.exports = Sha256;
78606
78607},{"./hash":498,"inherits":387,"safe-buffer":494}],504:[function(require,module,exports){
78608"use strict";
78609
78610var inherits = require('inherits');
78611
78612var SHA512 = require('./sha512');
78613
78614var Hash = require('./hash');
78615
78616var Buffer = require('safe-buffer').Buffer;
78617
78618var W = new Array(160);
78619
78620function Sha384() {
78621  this.init();
78622  this._w = W;
78623  Hash.call(this, 128, 112);
78624}
78625
78626inherits(Sha384, SHA512);
78627
78628Sha384.prototype.init = function () {
78629  this._ah = 0xcbbb9d5d;
78630  this._bh = 0x629a292a;
78631  this._ch = 0x9159015a;
78632  this._dh = 0x152fecd8;
78633  this._eh = 0x67332667;
78634  this._fh = 0x8eb44a87;
78635  this._gh = 0xdb0c2e0d;
78636  this._hh = 0x47b5481d;
78637  this._al = 0xc1059ed8;
78638  this._bl = 0x367cd507;
78639  this._cl = 0x3070dd17;
78640  this._dl = 0xf70e5939;
78641  this._el = 0xffc00b31;
78642  this._fl = 0x68581511;
78643  this._gl = 0x64f98fa7;
78644  this._hl = 0xbefa4fa4;
78645  return this;
78646};
78647
78648Sha384.prototype._hash = function () {
78649  var H = Buffer.allocUnsafe(48);
78650
78651  function writeInt64BE(h, l, offset) {
78652    H.writeInt32BE(h, offset);
78653    H.writeInt32BE(l, offset + 4);
78654  }
78655
78656  writeInt64BE(this._ah, this._al, 0);
78657  writeInt64BE(this._bh, this._bl, 8);
78658  writeInt64BE(this._ch, this._cl, 16);
78659  writeInt64BE(this._dh, this._dl, 24);
78660  writeInt64BE(this._eh, this._el, 32);
78661  writeInt64BE(this._fh, this._fl, 40);
78662  return H;
78663};
78664
78665module.exports = Sha384;
78666
78667},{"./hash":498,"./sha512":505,"inherits":387,"safe-buffer":494}],505:[function(require,module,exports){
78668"use strict";
78669
78670var inherits = require('inherits');
78671
78672var Hash = require('./hash');
78673
78674var Buffer = require('safe-buffer').Buffer;
78675
78676var K = [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817];
78677var W = new Array(160);
78678
78679function Sha512() {
78680  this.init();
78681  this._w = W;
78682  Hash.call(this, 128, 112);
78683}
78684
78685inherits(Sha512, Hash);
78686
78687Sha512.prototype.init = function () {
78688  this._ah = 0x6a09e667;
78689  this._bh = 0xbb67ae85;
78690  this._ch = 0x3c6ef372;
78691  this._dh = 0xa54ff53a;
78692  this._eh = 0x510e527f;
78693  this._fh = 0x9b05688c;
78694  this._gh = 0x1f83d9ab;
78695  this._hh = 0x5be0cd19;
78696  this._al = 0xf3bcc908;
78697  this._bl = 0x84caa73b;
78698  this._cl = 0xfe94f82b;
78699  this._dl = 0x5f1d36f1;
78700  this._el = 0xade682d1;
78701  this._fl = 0x2b3e6c1f;
78702  this._gl = 0xfb41bd6b;
78703  this._hl = 0x137e2179;
78704  return this;
78705};
78706
78707function Ch(x, y, z) {
78708  return z ^ x & (y ^ z);
78709}
78710
78711function maj(x, y, z) {
78712  return x & y | z & (x | y);
78713}
78714
78715function sigma0(x, xl) {
78716  return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25);
78717}
78718
78719function sigma1(x, xl) {
78720  return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23);
78721}
78722
78723function Gamma0(x, xl) {
78724  return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ x >>> 7;
78725}
78726
78727function Gamma0l(x, xl) {
78728  return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25);
78729}
78730
78731function Gamma1(x, xl) {
78732  return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ x >>> 6;
78733}
78734
78735function Gamma1l(x, xl) {
78736  return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26);
78737}
78738
78739function getCarry(a, b) {
78740  return a >>> 0 < b >>> 0 ? 1 : 0;
78741}
78742
78743Sha512.prototype._update = function (M) {
78744  var W = this._w;
78745  var ah = this._ah | 0;
78746  var bh = this._bh | 0;
78747  var ch = this._ch | 0;
78748  var dh = this._dh | 0;
78749  var eh = this._eh | 0;
78750  var fh = this._fh | 0;
78751  var gh = this._gh | 0;
78752  var hh = this._hh | 0;
78753  var al = this._al | 0;
78754  var bl = this._bl | 0;
78755  var cl = this._cl | 0;
78756  var dl = this._dl | 0;
78757  var el = this._el | 0;
78758  var fl = this._fl | 0;
78759  var gl = this._gl | 0;
78760  var hl = this._hl | 0;
78761
78762  for (var i = 0; i < 32; i += 2) {
78763    W[i] = M.readInt32BE(i * 4);
78764    W[i + 1] = M.readInt32BE(i * 4 + 4);
78765  }
78766
78767  for (; i < 160; i += 2) {
78768    var xh = W[i - 15 * 2];
78769    var xl = W[i - 15 * 2 + 1];
78770    var gamma0 = Gamma0(xh, xl);
78771    var gamma0l = Gamma0l(xl, xh);
78772    xh = W[i - 2 * 2];
78773    xl = W[i - 2 * 2 + 1];
78774    var gamma1 = Gamma1(xh, xl);
78775    var gamma1l = Gamma1l(xl, xh); // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
78776
78777    var Wi7h = W[i - 7 * 2];
78778    var Wi7l = W[i - 7 * 2 + 1];
78779    var Wi16h = W[i - 16 * 2];
78780    var Wi16l = W[i - 16 * 2 + 1];
78781    var Wil = gamma0l + Wi7l | 0;
78782    var Wih = gamma0 + Wi7h + getCarry(Wil, gamma0l) | 0;
78783    Wil = Wil + gamma1l | 0;
78784    Wih = Wih + gamma1 + getCarry(Wil, gamma1l) | 0;
78785    Wil = Wil + Wi16l | 0;
78786    Wih = Wih + Wi16h + getCarry(Wil, Wi16l) | 0;
78787    W[i] = Wih;
78788    W[i + 1] = Wil;
78789  }
78790
78791  for (var j = 0; j < 160; j += 2) {
78792    Wih = W[j];
78793    Wil = W[j + 1];
78794    var majh = maj(ah, bh, ch);
78795    var majl = maj(al, bl, cl);
78796    var sigma0h = sigma0(ah, al);
78797    var sigma0l = sigma0(al, ah);
78798    var sigma1h = sigma1(eh, el);
78799    var sigma1l = sigma1(el, eh); // t1 = h + sigma1 + ch + K[j] + W[j]
78800
78801    var Kih = K[j];
78802    var Kil = K[j + 1];
78803    var chh = Ch(eh, fh, gh);
78804    var chl = Ch(el, fl, gl);
78805    var t1l = hl + sigma1l | 0;
78806    var t1h = hh + sigma1h + getCarry(t1l, hl) | 0;
78807    t1l = t1l + chl | 0;
78808    t1h = t1h + chh + getCarry(t1l, chl) | 0;
78809    t1l = t1l + Kil | 0;
78810    t1h = t1h + Kih + getCarry(t1l, Kil) | 0;
78811    t1l = t1l + Wil | 0;
78812    t1h = t1h + Wih + getCarry(t1l, Wil) | 0; // t2 = sigma0 + maj
78813
78814    var t2l = sigma0l + majl | 0;
78815    var t2h = sigma0h + majh + getCarry(t2l, sigma0l) | 0;
78816    hh = gh;
78817    hl = gl;
78818    gh = fh;
78819    gl = fl;
78820    fh = eh;
78821    fl = el;
78822    el = dl + t1l | 0;
78823    eh = dh + t1h + getCarry(el, dl) | 0;
78824    dh = ch;
78825    dl = cl;
78826    ch = bh;
78827    cl = bl;
78828    bh = ah;
78829    bl = al;
78830    al = t1l + t2l | 0;
78831    ah = t1h + t2h + getCarry(al, t1l) | 0;
78832  }
78833
78834  this._al = this._al + al | 0;
78835  this._bl = this._bl + bl | 0;
78836  this._cl = this._cl + cl | 0;
78837  this._dl = this._dl + dl | 0;
78838  this._el = this._el + el | 0;
78839  this._fl = this._fl + fl | 0;
78840  this._gl = this._gl + gl | 0;
78841  this._hl = this._hl + hl | 0;
78842  this._ah = this._ah + ah + getCarry(this._al, al) | 0;
78843  this._bh = this._bh + bh + getCarry(this._bl, bl) | 0;
78844  this._ch = this._ch + ch + getCarry(this._cl, cl) | 0;
78845  this._dh = this._dh + dh + getCarry(this._dl, dl) | 0;
78846  this._eh = this._eh + eh + getCarry(this._el, el) | 0;
78847  this._fh = this._fh + fh + getCarry(this._fl, fl) | 0;
78848  this._gh = this._gh + gh + getCarry(this._gl, gl) | 0;
78849  this._hh = this._hh + hh + getCarry(this._hl, hl) | 0;
78850};
78851
78852Sha512.prototype._hash = function () {
78853  var H = Buffer.allocUnsafe(64);
78854
78855  function writeInt64BE(h, l, offset) {
78856    H.writeInt32BE(h, offset);
78857    H.writeInt32BE(l, offset + 4);
78858  }
78859
78860  writeInt64BE(this._ah, this._al, 0);
78861  writeInt64BE(this._bh, this._bl, 8);
78862  writeInt64BE(this._ch, this._cl, 16);
78863  writeInt64BE(this._dh, this._dl, 24);
78864  writeInt64BE(this._eh, this._el, 32);
78865  writeInt64BE(this._fh, this._fl, 40);
78866  writeInt64BE(this._gh, this._gl, 48);
78867  writeInt64BE(this._hh, this._hl, 56);
78868  return H;
78869};
78870
78871module.exports = Sha512;
78872
78873},{"./hash":498,"inherits":387,"safe-buffer":494}],506:[function(require,module,exports){
78874"use strict";
78875
78876// Copyright Joyent, Inc. and other Node contributors.
78877//
78878// Permission is hereby granted, free of charge, to any person obtaining a
78879// copy of this software and associated documentation files (the
78880// "Software"), to deal in the Software without restriction, including
78881// without limitation the rights to use, copy, modify, merge, publish,
78882// distribute, sublicense, and/or sell copies of the Software, and to permit
78883// persons to whom the Software is furnished to do so, subject to the
78884// following conditions:
78885//
78886// The above copyright notice and this permission notice shall be included
78887// in all copies or substantial portions of the Software.
78888//
78889// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
78890// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
78891// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
78892// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
78893// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
78894// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
78895// USE OR OTHER DEALINGS IN THE SOFTWARE.
78896module.exports = Stream;
78897
78898var EE = require('events').EventEmitter;
78899
78900var inherits = require('inherits');
78901
78902inherits(Stream, EE);
78903Stream.Readable = require('readable-stream/readable.js');
78904Stream.Writable = require('readable-stream/writable.js');
78905Stream.Duplex = require('readable-stream/duplex.js');
78906Stream.Transform = require('readable-stream/transform.js');
78907Stream.PassThrough = require('readable-stream/passthrough.js'); // Backwards-compat with node 0.4.x
78908
78909Stream.Stream = Stream; // old-style streams.  Note that the pipe method (the only relevant
78910// part of this class) is overridden in the Readable class.
78911
78912function Stream() {
78913  EE.call(this);
78914}
78915
78916Stream.prototype.pipe = function (dest, options) {
78917  var source = this;
78918
78919  function ondata(chunk) {
78920    if (dest.writable) {
78921      if (false === dest.write(chunk) && source.pause) {
78922        source.pause();
78923      }
78924    }
78925  }
78926
78927  source.on('data', ondata);
78928
78929  function ondrain() {
78930    if (source.readable && source.resume) {
78931      source.resume();
78932    }
78933  }
78934
78935  dest.on('drain', ondrain); // If the 'end' option is not supplied, dest.end() will be called when
78936  // source gets the 'end' or 'close' events.  Only dest.end() once.
78937
78938  if (!dest._isStdio && (!options || options.end !== false)) {
78939    source.on('end', onend);
78940    source.on('close', onclose);
78941  }
78942
78943  var didOnEnd = false;
78944
78945  function onend() {
78946    if (didOnEnd) return;
78947    didOnEnd = true;
78948    dest.end();
78949  }
78950
78951  function onclose() {
78952    if (didOnEnd) return;
78953    didOnEnd = true;
78954    if (typeof dest.destroy === 'function') dest.destroy();
78955  } // don't leave dangling pipes when there are errors.
78956
78957
78958  function onerror(er) {
78959    cleanup();
78960
78961    if (EE.listenerCount(this, 'error') === 0) {
78962      throw er; // Unhandled stream error in pipe.
78963    }
78964  }
78965
78966  source.on('error', onerror);
78967  dest.on('error', onerror); // remove all the event listeners that were added.
78968
78969  function cleanup() {
78970    source.removeListener('data', ondata);
78971    dest.removeListener('drain', ondrain);
78972    source.removeListener('end', onend);
78973    source.removeListener('close', onclose);
78974    source.removeListener('error', onerror);
78975    dest.removeListener('error', onerror);
78976    source.removeListener('end', cleanup);
78977    source.removeListener('close', cleanup);
78978    dest.removeListener('close', cleanup);
78979  }
78980
78981  source.on('end', cleanup);
78982  source.on('close', cleanup);
78983  dest.on('close', cleanup);
78984  dest.emit('pipe', source); // Allow for unix-like usage: A.pipe(B).pipe(C)
78985
78986  return dest;
78987};
78988
78989},{"events":367,"inherits":387,"readable-stream/duplex.js":507,"readable-stream/passthrough.js":516,"readable-stream/readable.js":517,"readable-stream/transform.js":518,"readable-stream/writable.js":519}],507:[function(require,module,exports){
78990"use strict";
78991
78992module.exports = require('./lib/_stream_duplex.js');
78993
78994},{"./lib/_stream_duplex.js":508}],508:[function(require,module,exports){
78995// Copyright Joyent, Inc. and other Node contributors.
78996//
78997// Permission is hereby granted, free of charge, to any person obtaining a
78998// copy of this software and associated documentation files (the
78999// "Software"), to deal in the Software without restriction, including
79000// without limitation the rights to use, copy, modify, merge, publish,
79001// distribute, sublicense, and/or sell copies of the Software, and to permit
79002// persons to whom the Software is furnished to do so, subject to the
79003// following conditions:
79004//
79005// The above copyright notice and this permission notice shall be included
79006// in all copies or substantial portions of the Software.
79007//
79008// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
79009// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
79010// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
79011// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
79012// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
79013// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
79014// USE OR OTHER DEALINGS IN THE SOFTWARE.
79015// a duplex stream is just a stream that is both readable and writable.
79016// Since JS doesn't have multiple prototypal inheritance, this class
79017// prototypally inherits from Readable, and then parasitically from
79018// Writable.
79019'use strict';
79020/*<replacement>*/
79021
79022var pna = require('process-nextick-args');
79023/*</replacement>*/
79024
79025/*<replacement>*/
79026
79027
79028var objectKeys = Object.keys || function (obj) {
79029  var keys = [];
79030
79031  for (var key in obj) {
79032    keys.push(key);
79033  }
79034
79035  return keys;
79036};
79037/*</replacement>*/
79038
79039
79040module.exports = Duplex;
79041/*<replacement>*/
79042
79043var util = Object.create(require('core-util-is'));
79044util.inherits = require('inherits');
79045/*</replacement>*/
79046
79047var Readable = require('./_stream_readable');
79048
79049var Writable = require('./_stream_writable');
79050
79051util.inherits(Duplex, Readable);
79052{
79053  // avoid scope creep, the keys array can then be collected
79054  var keys = objectKeys(Writable.prototype);
79055
79056  for (var v = 0; v < keys.length; v++) {
79057    var method = keys[v];
79058    if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
79059  }
79060}
79061
79062function Duplex(options) {
79063  if (!(this instanceof Duplex)) return new Duplex(options);
79064  Readable.call(this, options);
79065  Writable.call(this, options);
79066  if (options && options.readable === false) this.readable = false;
79067  if (options && options.writable === false) this.writable = false;
79068  this.allowHalfOpen = true;
79069  if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
79070  this.once('end', onend);
79071}
79072
79073Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
79074  // making it explicit this property is not enumerable
79075  // because otherwise some prototype manipulation in
79076  // userland will fail
79077  enumerable: false,
79078  get: function get() {
79079    return this._writableState.highWaterMark;
79080  }
79081}); // the no-half-open enforcer
79082
79083function onend() {
79084  // if we allow half-open state, or if the writable side ended,
79085  // then we're ok.
79086  if (this.allowHalfOpen || this._writableState.ended) return; // no more data can be written.
79087  // But allow more writes to happen in this tick.
79088
79089  pna.nextTick(onEndNT, this);
79090}
79091
79092function onEndNT(self) {
79093  self.end();
79094}
79095
79096Object.defineProperty(Duplex.prototype, 'destroyed', {
79097  get: function get() {
79098    if (this._readableState === undefined || this._writableState === undefined) {
79099      return false;
79100    }
79101
79102    return this._readableState.destroyed && this._writableState.destroyed;
79103  },
79104  set: function set(value) {
79105    // we ignore the value if the stream
79106    // has not been initialized yet
79107    if (this._readableState === undefined || this._writableState === undefined) {
79108      return;
79109    } // backward compatibility, the user is explicitly
79110    // managing destroyed
79111
79112
79113    this._readableState.destroyed = value;
79114    this._writableState.destroyed = value;
79115  }
79116});
79117
79118Duplex.prototype._destroy = function (err, cb) {
79119  this.push(null);
79120  this.end();
79121  pna.nextTick(cb, err);
79122};
79123
79124},{"./_stream_readable":510,"./_stream_writable":512,"core-util-is":328,"inherits":387,"process-nextick-args":466}],509:[function(require,module,exports){
79125// Copyright Joyent, Inc. and other Node contributors.
79126//
79127// Permission is hereby granted, free of charge, to any person obtaining a
79128// copy of this software and associated documentation files (the
79129// "Software"), to deal in the Software without restriction, including
79130// without limitation the rights to use, copy, modify, merge, publish,
79131// distribute, sublicense, and/or sell copies of the Software, and to permit
79132// persons to whom the Software is furnished to do so, subject to the
79133// following conditions:
79134//
79135// The above copyright notice and this permission notice shall be included
79136// in all copies or substantial portions of the Software.
79137//
79138// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
79139// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
79140// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
79141// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
79142// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
79143// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
79144// USE OR OTHER DEALINGS IN THE SOFTWARE.
79145// a passthrough stream.
79146// basically just the most minimal sort of Transform stream.
79147// Every written chunk gets output as-is.
79148'use strict';
79149
79150module.exports = PassThrough;
79151
79152var Transform = require('./_stream_transform');
79153/*<replacement>*/
79154
79155
79156var util = Object.create(require('core-util-is'));
79157util.inherits = require('inherits');
79158/*</replacement>*/
79159
79160util.inherits(PassThrough, Transform);
79161
79162function PassThrough(options) {
79163  if (!(this instanceof PassThrough)) return new PassThrough(options);
79164  Transform.call(this, options);
79165}
79166
79167PassThrough.prototype._transform = function (chunk, encoding, cb) {
79168  cb(null, chunk);
79169};
79170
79171},{"./_stream_transform":511,"core-util-is":328,"inherits":387}],510:[function(require,module,exports){
79172(function (process,global){
79173// Copyright Joyent, Inc. and other Node contributors.
79174//
79175// Permission is hereby granted, free of charge, to any person obtaining a
79176// copy of this software and associated documentation files (the
79177// "Software"), to deal in the Software without restriction, including
79178// without limitation the rights to use, copy, modify, merge, publish,
79179// distribute, sublicense, and/or sell copies of the Software, and to permit
79180// persons to whom the Software is furnished to do so, subject to the
79181// following conditions:
79182//
79183// The above copyright notice and this permission notice shall be included
79184// in all copies or substantial portions of the Software.
79185//
79186// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
79187// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
79188// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
79189// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
79190// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
79191// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
79192// USE OR OTHER DEALINGS IN THE SOFTWARE.
79193'use strict';
79194/*<replacement>*/
79195
79196var pna = require('process-nextick-args');
79197/*</replacement>*/
79198
79199
79200module.exports = Readable;
79201/*<replacement>*/
79202
79203var isArray = require('isarray');
79204/*</replacement>*/
79205
79206/*<replacement>*/
79207
79208
79209var Duplex;
79210/*</replacement>*/
79211
79212Readable.ReadableState = ReadableState;
79213/*<replacement>*/
79214
79215var EE = require('events').EventEmitter;
79216
79217var EElistenerCount = function EElistenerCount(emitter, type) {
79218  return emitter.listeners(type).length;
79219};
79220/*</replacement>*/
79221
79222/*<replacement>*/
79223
79224
79225var Stream = require('./internal/streams/stream');
79226/*</replacement>*/
79227
79228/*<replacement>*/
79229
79230
79231var Buffer = require('safe-buffer').Buffer;
79232
79233var OurUint8Array = global.Uint8Array || function () {};
79234
79235function _uint8ArrayToBuffer(chunk) {
79236  return Buffer.from(chunk);
79237}
79238
79239function _isUint8Array(obj) {
79240  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
79241}
79242/*</replacement>*/
79243
79244/*<replacement>*/
79245
79246
79247var util = Object.create(require('core-util-is'));
79248util.inherits = require('inherits');
79249/*</replacement>*/
79250
79251/*<replacement>*/
79252
79253var debugUtil = require('util');
79254
79255var debug = void 0;
79256
79257if (debugUtil && debugUtil.debuglog) {
79258  debug = debugUtil.debuglog('stream');
79259} else {
79260  debug = function debug() {};
79261}
79262/*</replacement>*/
79263
79264
79265var BufferList = require('./internal/streams/BufferList');
79266
79267var destroyImpl = require('./internal/streams/destroy');
79268
79269var StringDecoder;
79270util.inherits(Readable, Stream);
79271var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
79272
79273function prependListener(emitter, event, fn) {
79274  // Sadly this is not cacheable as some libraries bundle their own
79275  // event emitter implementation with them.
79276  if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
79277  // userland ones.  NEVER DO THIS. This is here only because this code needs
79278  // to continue to work with older versions of Node.js that do not include
79279  // the prependListener() method. The goal is to eventually remove this hack.
79280
79281  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]];
79282}
79283
79284function ReadableState(options, stream) {
79285  Duplex = Duplex || require('./_stream_duplex');
79286  options = options || {}; // Duplex streams are both readable and writable, but share
79287  // the same options object.
79288  // However, some cases require setting options to different
79289  // values for the readable and the writable sides of the duplex stream.
79290  // These options can be provided separately as readableXXX and writableXXX.
79291
79292  var isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
79293  // make all the buffer merging and length checks go away
79294
79295  this.objectMode = !!options.objectMode;
79296  if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
79297  // Note: 0 is a valid value, means "don't call _read preemptively ever"
79298
79299  var hwm = options.highWaterMark;
79300  var readableHwm = options.readableHighWaterMark;
79301  var defaultHwm = this.objectMode ? 16 : 16 * 1024;
79302  if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; // cast to ints.
79303
79304  this.highWaterMark = Math.floor(this.highWaterMark); // A linked list is used to store data chunks instead of an array because the
79305  // linked list can remove elements from the beginning faster than
79306  // array.shift()
79307
79308  this.buffer = new BufferList();
79309  this.length = 0;
79310  this.pipes = null;
79311  this.pipesCount = 0;
79312  this.flowing = null;
79313  this.ended = false;
79314  this.endEmitted = false;
79315  this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
79316  // immediately, or on a later tick.  We set this to true at first, because
79317  // any actions that shouldn't happen until "later" should generally also
79318  // not happen before the first read call.
79319
79320  this.sync = true; // whenever we return null, then we set a flag to say
79321  // that we're awaiting a 'readable' event emission.
79322
79323  this.needReadable = false;
79324  this.emittedReadable = false;
79325  this.readableListening = false;
79326  this.resumeScheduled = false; // has it been destroyed
79327
79328  this.destroyed = false; // Crypto is kind of old and crusty.  Historically, its default string
79329  // encoding is 'binary' so we have to make this configurable.
79330  // Everything else in the universe uses 'utf8', though.
79331
79332  this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s
79333
79334  this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
79335
79336  this.readingMore = false;
79337  this.decoder = null;
79338  this.encoding = null;
79339
79340  if (options.encoding) {
79341    if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
79342    this.decoder = new StringDecoder(options.encoding);
79343    this.encoding = options.encoding;
79344  }
79345}
79346
79347function Readable(options) {
79348  Duplex = Duplex || require('./_stream_duplex');
79349  if (!(this instanceof Readable)) return new Readable(options);
79350  this._readableState = new ReadableState(options, this); // legacy
79351
79352  this.readable = true;
79353
79354  if (options) {
79355    if (typeof options.read === 'function') this._read = options.read;
79356    if (typeof options.destroy === 'function') this._destroy = options.destroy;
79357  }
79358
79359  Stream.call(this);
79360}
79361
79362Object.defineProperty(Readable.prototype, 'destroyed', {
79363  get: function get() {
79364    if (this._readableState === undefined) {
79365      return false;
79366    }
79367
79368    return this._readableState.destroyed;
79369  },
79370  set: function set(value) {
79371    // we ignore the value if the stream
79372    // has not been initialized yet
79373    if (!this._readableState) {
79374      return;
79375    } // backward compatibility, the user is explicitly
79376    // managing destroyed
79377
79378
79379    this._readableState.destroyed = value;
79380  }
79381});
79382Readable.prototype.destroy = destroyImpl.destroy;
79383Readable.prototype._undestroy = destroyImpl.undestroy;
79384
79385Readable.prototype._destroy = function (err, cb) {
79386  this.push(null);
79387  cb(err);
79388}; // Manually shove something into the read() buffer.
79389// This returns true if the highWaterMark has not been hit yet,
79390// similar to how Writable.write() returns true if you should
79391// write() some more.
79392
79393
79394Readable.prototype.push = function (chunk, encoding) {
79395  var state = this._readableState;
79396  var skipChunkCheck;
79397
79398  if (!state.objectMode) {
79399    if (typeof chunk === 'string') {
79400      encoding = encoding || state.defaultEncoding;
79401
79402      if (encoding !== state.encoding) {
79403        chunk = Buffer.from(chunk, encoding);
79404        encoding = '';
79405      }
79406
79407      skipChunkCheck = true;
79408    }
79409  } else {
79410    skipChunkCheck = true;
79411  }
79412
79413  return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
79414}; // Unshift should *always* be something directly out of read()
79415
79416
79417Readable.prototype.unshift = function (chunk) {
79418  return readableAddChunk(this, chunk, null, true, false);
79419};
79420
79421function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
79422  var state = stream._readableState;
79423
79424  if (chunk === null) {
79425    state.reading = false;
79426    onEofChunk(stream, state);
79427  } else {
79428    var er;
79429    if (!skipChunkCheck) er = chunkInvalid(state, chunk);
79430
79431    if (er) {
79432      stream.emit('error', er);
79433    } else if (state.objectMode || chunk && chunk.length > 0) {
79434      if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
79435        chunk = _uint8ArrayToBuffer(chunk);
79436      }
79437
79438      if (addToFront) {
79439        if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
79440      } else if (state.ended) {
79441        stream.emit('error', new Error('stream.push() after EOF'));
79442      } else {
79443        state.reading = false;
79444
79445        if (state.decoder && !encoding) {
79446          chunk = state.decoder.write(chunk);
79447          if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
79448        } else {
79449          addChunk(stream, state, chunk, false);
79450        }
79451      }
79452    } else if (!addToFront) {
79453      state.reading = false;
79454    }
79455  }
79456
79457  return needMoreData(state);
79458}
79459
79460function addChunk(stream, state, chunk, addToFront) {
79461  if (state.flowing && state.length === 0 && !state.sync) {
79462    stream.emit('data', chunk);
79463    stream.read(0);
79464  } else {
79465    // update the buffer info.
79466    state.length += state.objectMode ? 1 : chunk.length;
79467    if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
79468    if (state.needReadable) emitReadable(stream);
79469  }
79470
79471  maybeReadMore(stream, state);
79472}
79473
79474function chunkInvalid(state, chunk) {
79475  var er;
79476
79477  if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
79478    er = new TypeError('Invalid non-string/buffer chunk');
79479  }
79480
79481  return er;
79482} // if it's past the high water mark, we can push in some more.
79483// Also, if we have no data yet, we can stand some
79484// more bytes.  This is to work around cases where hwm=0,
79485// such as the repl.  Also, if the push() triggered a
79486// readable event, and the user called read(largeNumber) such that
79487// needReadable was set, then we ought to push more, so that another
79488// 'readable' event will be triggered.
79489
79490
79491function needMoreData(state) {
79492  return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
79493}
79494
79495Readable.prototype.isPaused = function () {
79496  return this._readableState.flowing === false;
79497}; // backwards compatibility.
79498
79499
79500Readable.prototype.setEncoding = function (enc) {
79501  if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
79502  this._readableState.decoder = new StringDecoder(enc);
79503  this._readableState.encoding = enc;
79504  return this;
79505}; // Don't raise the hwm > 8MB
79506
79507
79508var MAX_HWM = 0x800000;
79509
79510function computeNewHighWaterMark(n) {
79511  if (n >= MAX_HWM) {
79512    n = MAX_HWM;
79513  } else {
79514    // Get the next highest power of 2 to prevent increasing hwm excessively in
79515    // tiny amounts
79516    n--;
79517    n |= n >>> 1;
79518    n |= n >>> 2;
79519    n |= n >>> 4;
79520    n |= n >>> 8;
79521    n |= n >>> 16;
79522    n++;
79523  }
79524
79525  return n;
79526} // This function is designed to be inlinable, so please take care when making
79527// changes to the function body.
79528
79529
79530function howMuchToRead(n, state) {
79531  if (n <= 0 || state.length === 0 && state.ended) return 0;
79532  if (state.objectMode) return 1;
79533
79534  if (n !== n) {
79535    // Only flow one buffer at a time
79536    if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
79537  } // If we're asking for more than the current hwm, then raise the hwm.
79538
79539
79540  if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
79541  if (n <= state.length) return n; // Don't have enough
79542
79543  if (!state.ended) {
79544    state.needReadable = true;
79545    return 0;
79546  }
79547
79548  return state.length;
79549} // you can override either this method, or the async _read(n) below.
79550
79551
79552Readable.prototype.read = function (n) {
79553  debug('read', n);
79554  n = parseInt(n, 10);
79555  var state = this._readableState;
79556  var nOrig = n;
79557  if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
79558  // already have a bunch of data in the buffer, then just trigger
79559  // the 'readable' event and move on.
79560
79561  if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
79562    debug('read: emitReadable', state.length, state.ended);
79563    if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
79564    return null;
79565  }
79566
79567  n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
79568
79569  if (n === 0 && state.ended) {
79570    if (state.length === 0) endReadable(this);
79571    return null;
79572  } // All the actual chunk generation logic needs to be
79573  // *below* the call to _read.  The reason is that in certain
79574  // synthetic stream cases, such as passthrough streams, _read
79575  // may be a completely synchronous operation which may change
79576  // the state of the read buffer, providing enough data when
79577  // before there was *not* enough.
79578  //
79579  // So, the steps are:
79580  // 1. Figure out what the state of things will be after we do
79581  // a read from the buffer.
79582  //
79583  // 2. If that resulting state will trigger a _read, then call _read.
79584  // Note that this may be asynchronous, or synchronous.  Yes, it is
79585  // deeply ugly to write APIs this way, but that still doesn't mean
79586  // that the Readable class should behave improperly, as streams are
79587  // designed to be sync/async agnostic.
79588  // Take note if the _read call is sync or async (ie, if the read call
79589  // has returned yet), so that we know whether or not it's safe to emit
79590  // 'readable' etc.
79591  //
79592  // 3. Actually pull the requested chunks out of the buffer and return.
79593  // if we need a readable event, then we need to do some reading.
79594
79595
79596  var doRead = state.needReadable;
79597  debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some
79598
79599  if (state.length === 0 || state.length - n < state.highWaterMark) {
79600    doRead = true;
79601    debug('length less than watermark', doRead);
79602  } // however, if we've ended, then there's no point, and if we're already
79603  // reading, then it's unnecessary.
79604
79605
79606  if (state.ended || state.reading) {
79607    doRead = false;
79608    debug('reading or ended', doRead);
79609  } else if (doRead) {
79610    debug('do read');
79611    state.reading = true;
79612    state.sync = true; // if the length is currently zero, then we *need* a readable event.
79613
79614    if (state.length === 0) state.needReadable = true; // call internal read method
79615
79616    this._read(state.highWaterMark);
79617
79618    state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
79619    // and we need to re-evaluate how much data we can return to the user.
79620
79621    if (!state.reading) n = howMuchToRead(nOrig, state);
79622  }
79623
79624  var ret;
79625  if (n > 0) ret = fromList(n, state);else ret = null;
79626
79627  if (ret === null) {
79628    state.needReadable = true;
79629    n = 0;
79630  } else {
79631    state.length -= n;
79632  }
79633
79634  if (state.length === 0) {
79635    // If we have nothing in the buffer, then we want to know
79636    // as soon as we *do* get something into the buffer.
79637    if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
79638
79639    if (nOrig !== n && state.ended) endReadable(this);
79640  }
79641
79642  if (ret !== null) this.emit('data', ret);
79643  return ret;
79644};
79645
79646function onEofChunk(stream, state) {
79647  if (state.ended) return;
79648
79649  if (state.decoder) {
79650    var chunk = state.decoder.end();
79651
79652    if (chunk && chunk.length) {
79653      state.buffer.push(chunk);
79654      state.length += state.objectMode ? 1 : chunk.length;
79655    }
79656  }
79657
79658  state.ended = true; // emit 'readable' now to make sure it gets picked up.
79659
79660  emitReadable(stream);
79661} // Don't emit readable right away in sync mode, because this can trigger
79662// another read() call => stack overflow.  This way, it might trigger
79663// a nextTick recursion warning, but that's not so bad.
79664
79665
79666function emitReadable(stream) {
79667  var state = stream._readableState;
79668  state.needReadable = false;
79669
79670  if (!state.emittedReadable) {
79671    debug('emitReadable', state.flowing);
79672    state.emittedReadable = true;
79673    if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
79674  }
79675}
79676
79677function emitReadable_(stream) {
79678  debug('emit readable');
79679  stream.emit('readable');
79680  flow(stream);
79681} // at this point, the user has presumably seen the 'readable' event,
79682// and called read() to consume some data.  that may have triggered
79683// in turn another _read(n) call, in which case reading = true if
79684// it's in progress.
79685// However, if we're not ended, or reading, and the length < hwm,
79686// then go ahead and try to read some more preemptively.
79687
79688
79689function maybeReadMore(stream, state) {
79690  if (!state.readingMore) {
79691    state.readingMore = true;
79692    pna.nextTick(maybeReadMore_, stream, state);
79693  }
79694}
79695
79696function maybeReadMore_(stream, state) {
79697  var len = state.length;
79698
79699  while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
79700    debug('maybeReadMore read 0');
79701    stream.read(0);
79702    if (len === state.length) // didn't get any data, stop spinning.
79703      break;else len = state.length;
79704  }
79705
79706  state.readingMore = false;
79707} // abstract method.  to be overridden in specific implementation classes.
79708// call cb(er, data) where data is <= n in length.
79709// for virtual (non-string, non-buffer) streams, "length" is somewhat
79710// arbitrary, and perhaps not very meaningful.
79711
79712
79713Readable.prototype._read = function (n) {
79714  this.emit('error', new Error('_read() is not implemented'));
79715};
79716
79717Readable.prototype.pipe = function (dest, pipeOpts) {
79718  var src = this;
79719  var state = this._readableState;
79720
79721  switch (state.pipesCount) {
79722    case 0:
79723      state.pipes = dest;
79724      break;
79725
79726    case 1:
79727      state.pipes = [state.pipes, dest];
79728      break;
79729
79730    default:
79731      state.pipes.push(dest);
79732      break;
79733  }
79734
79735  state.pipesCount += 1;
79736  debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
79737  var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
79738  var endFn = doEnd ? onend : unpipe;
79739  if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
79740  dest.on('unpipe', onunpipe);
79741
79742  function onunpipe(readable, unpipeInfo) {
79743    debug('onunpipe');
79744
79745    if (readable === src) {
79746      if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
79747        unpipeInfo.hasUnpiped = true;
79748        cleanup();
79749      }
79750    }
79751  }
79752
79753  function onend() {
79754    debug('onend');
79755    dest.end();
79756  } // when the dest drains, it reduces the awaitDrain counter
79757  // on the source.  This would be more elegant with a .once()
79758  // handler in flow(), but adding and removing repeatedly is
79759  // too slow.
79760
79761
79762  var ondrain = pipeOnDrain(src);
79763  dest.on('drain', ondrain);
79764  var cleanedUp = false;
79765
79766  function cleanup() {
79767    debug('cleanup'); // cleanup event handlers once the pipe is broken
79768
79769    dest.removeListener('close', onclose);
79770    dest.removeListener('finish', onfinish);
79771    dest.removeListener('drain', ondrain);
79772    dest.removeListener('error', onerror);
79773    dest.removeListener('unpipe', onunpipe);
79774    src.removeListener('end', onend);
79775    src.removeListener('end', unpipe);
79776    src.removeListener('data', ondata);
79777    cleanedUp = true; // if the reader is waiting for a drain event from this
79778    // specific writer, then it would cause it to never start
79779    // flowing again.
79780    // So, if this is awaiting a drain, then we just call it now.
79781    // If we don't know, then assume that we are waiting for one.
79782
79783    if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
79784  } // If the user pushes more data while we're writing to dest then we'll end up
79785  // in ondata again. However, we only want to increase awaitDrain once because
79786  // dest will only emit one 'drain' event for the multiple writes.
79787  // => Introduce a guard on increasing awaitDrain.
79788
79789
79790  var increasedAwaitDrain = false;
79791  src.on('data', ondata);
79792
79793  function ondata(chunk) {
79794    debug('ondata');
79795    increasedAwaitDrain = false;
79796    var ret = dest.write(chunk);
79797
79798    if (false === ret && !increasedAwaitDrain) {
79799      // If the user unpiped during `dest.write()`, it is possible
79800      // to get stuck in a permanently paused state if that write
79801      // also returned false.
79802      // => Check whether `dest` is still a piping destination.
79803      if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
79804        debug('false write response, pause', src._readableState.awaitDrain);
79805        src._readableState.awaitDrain++;
79806        increasedAwaitDrain = true;
79807      }
79808
79809      src.pause();
79810    }
79811  } // if the dest has an error, then stop piping into it.
79812  // however, don't suppress the throwing behavior for this.
79813
79814
79815  function onerror(er) {
79816    debug('onerror', er);
79817    unpipe();
79818    dest.removeListener('error', onerror);
79819    if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
79820  } // Make sure our error handler is attached before userland ones.
79821
79822
79823  prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.
79824
79825  function onclose() {
79826    dest.removeListener('finish', onfinish);
79827    unpipe();
79828  }
79829
79830  dest.once('close', onclose);
79831
79832  function onfinish() {
79833    debug('onfinish');
79834    dest.removeListener('close', onclose);
79835    unpipe();
79836  }
79837
79838  dest.once('finish', onfinish);
79839
79840  function unpipe() {
79841    debug('unpipe');
79842    src.unpipe(dest);
79843  } // tell the dest that it's being piped to
79844
79845
79846  dest.emit('pipe', src); // start the flow if it hasn't been started already.
79847
79848  if (!state.flowing) {
79849    debug('pipe resume');
79850    src.resume();
79851  }
79852
79853  return dest;
79854};
79855
79856function pipeOnDrain(src) {
79857  return function () {
79858    var state = src._readableState;
79859    debug('pipeOnDrain', state.awaitDrain);
79860    if (state.awaitDrain) state.awaitDrain--;
79861
79862    if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
79863      state.flowing = true;
79864      flow(src);
79865    }
79866  };
79867}
79868
79869Readable.prototype.unpipe = function (dest) {
79870  var state = this._readableState;
79871  var unpipeInfo = {
79872    hasUnpiped: false
79873  }; // if we're not piping anywhere, then do nothing.
79874
79875  if (state.pipesCount === 0) return this; // just one destination.  most common case.
79876
79877  if (state.pipesCount === 1) {
79878    // passed in one, but it's not the right one.
79879    if (dest && dest !== state.pipes) return this;
79880    if (!dest) dest = state.pipes; // got a match.
79881
79882    state.pipes = null;
79883    state.pipesCount = 0;
79884    state.flowing = false;
79885    if (dest) dest.emit('unpipe', this, unpipeInfo);
79886    return this;
79887  } // slow case. multiple pipe destinations.
79888
79889
79890  if (!dest) {
79891    // remove all.
79892    var dests = state.pipes;
79893    var len = state.pipesCount;
79894    state.pipes = null;
79895    state.pipesCount = 0;
79896    state.flowing = false;
79897
79898    for (var i = 0; i < len; i++) {
79899      dests[i].emit('unpipe', this, unpipeInfo);
79900    }
79901
79902    return this;
79903  } // try to find the right one.
79904
79905
79906  var index = indexOf(state.pipes, dest);
79907  if (index === -1) return this;
79908  state.pipes.splice(index, 1);
79909  state.pipesCount -= 1;
79910  if (state.pipesCount === 1) state.pipes = state.pipes[0];
79911  dest.emit('unpipe', this, unpipeInfo);
79912  return this;
79913}; // set up data events if they are asked for
79914// Ensure readable listeners eventually get something
79915
79916
79917Readable.prototype.on = function (ev, fn) {
79918  var res = Stream.prototype.on.call(this, ev, fn);
79919
79920  if (ev === 'data') {
79921    // Start flowing on next tick if stream isn't explicitly paused
79922    if (this._readableState.flowing !== false) this.resume();
79923  } else if (ev === 'readable') {
79924    var state = this._readableState;
79925
79926    if (!state.endEmitted && !state.readableListening) {
79927      state.readableListening = state.needReadable = true;
79928      state.emittedReadable = false;
79929
79930      if (!state.reading) {
79931        pna.nextTick(nReadingNextTick, this);
79932      } else if (state.length) {
79933        emitReadable(this);
79934      }
79935    }
79936  }
79937
79938  return res;
79939};
79940
79941Readable.prototype.addListener = Readable.prototype.on;
79942
79943function nReadingNextTick(self) {
79944  debug('readable nexttick read 0');
79945  self.read(0);
79946} // pause() and resume() are remnants of the legacy readable stream API
79947// If the user uses them, then switch into old mode.
79948
79949
79950Readable.prototype.resume = function () {
79951  var state = this._readableState;
79952
79953  if (!state.flowing) {
79954    debug('resume');
79955    state.flowing = true;
79956    resume(this, state);
79957  }
79958
79959  return this;
79960};
79961
79962function resume(stream, state) {
79963  if (!state.resumeScheduled) {
79964    state.resumeScheduled = true;
79965    pna.nextTick(resume_, stream, state);
79966  }
79967}
79968
79969function resume_(stream, state) {
79970  if (!state.reading) {
79971    debug('resume read 0');
79972    stream.read(0);
79973  }
79974
79975  state.resumeScheduled = false;
79976  state.awaitDrain = 0;
79977  stream.emit('resume');
79978  flow(stream);
79979  if (state.flowing && !state.reading) stream.read(0);
79980}
79981
79982Readable.prototype.pause = function () {
79983  debug('call pause flowing=%j', this._readableState.flowing);
79984
79985  if (false !== this._readableState.flowing) {
79986    debug('pause');
79987    this._readableState.flowing = false;
79988    this.emit('pause');
79989  }
79990
79991  return this;
79992};
79993
79994function flow(stream) {
79995  var state = stream._readableState;
79996  debug('flow', state.flowing);
79997
79998  while (state.flowing && stream.read() !== null) {}
79999} // wrap an old-style stream as the async data source.
80000// This is *not* part of the readable stream interface.
80001// It is an ugly unfortunate mess of history.
80002
80003
80004Readable.prototype.wrap = function (stream) {
80005  var _this = this;
80006
80007  var state = this._readableState;
80008  var paused = false;
80009  stream.on('end', function () {
80010    debug('wrapped end');
80011
80012    if (state.decoder && !state.ended) {
80013      var chunk = state.decoder.end();
80014      if (chunk && chunk.length) _this.push(chunk);
80015    }
80016
80017    _this.push(null);
80018  });
80019  stream.on('data', function (chunk) {
80020    debug('wrapped data');
80021    if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
80022
80023    if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
80024
80025    var ret = _this.push(chunk);
80026
80027    if (!ret) {
80028      paused = true;
80029      stream.pause();
80030    }
80031  }); // proxy all the other methods.
80032  // important when wrapping filters and duplexes.
80033
80034  for (var i in stream) {
80035    if (this[i] === undefined && typeof stream[i] === 'function') {
80036      this[i] = function (method) {
80037        return function () {
80038          return stream[method].apply(stream, arguments);
80039        };
80040      }(i);
80041    }
80042  } // proxy certain important events.
80043
80044
80045  for (var n = 0; n < kProxyEvents.length; n++) {
80046    stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
80047  } // when we try to consume some more bytes, simply unpause the
80048  // underlying stream.
80049
80050
80051  this._read = function (n) {
80052    debug('wrapped _read', n);
80053
80054    if (paused) {
80055      paused = false;
80056      stream.resume();
80057    }
80058  };
80059
80060  return this;
80061};
80062
80063Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
80064  // making it explicit this property is not enumerable
80065  // because otherwise some prototype manipulation in
80066  // userland will fail
80067  enumerable: false,
80068  get: function get() {
80069    return this._readableState.highWaterMark;
80070  }
80071}); // exposed for testing purposes only.
80072
80073Readable._fromList = fromList; // Pluck off n bytes from an array of buffers.
80074// Length is the combined lengths of all the buffers in the list.
80075// This function is designed to be inlinable, so please take care when making
80076// changes to the function body.
80077
80078function fromList(n, state) {
80079  // nothing buffered
80080  if (state.length === 0) return null;
80081  var ret;
80082  if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
80083    // read it all, truncate the list
80084    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);
80085    state.buffer.clear();
80086  } else {
80087    // read part of list
80088    ret = fromListPartial(n, state.buffer, state.decoder);
80089  }
80090  return ret;
80091} // Extracts only enough buffered data to satisfy the amount requested.
80092// This function is designed to be inlinable, so please take care when making
80093// changes to the function body.
80094
80095
80096function fromListPartial(n, list, hasStrings) {
80097  var ret;
80098
80099  if (n < list.head.data.length) {
80100    // slice is the same for buffers and strings
80101    ret = list.head.data.slice(0, n);
80102    list.head.data = list.head.data.slice(n);
80103  } else if (n === list.head.data.length) {
80104    // first chunk is a perfect match
80105    ret = list.shift();
80106  } else {
80107    // result spans more than one buffer
80108    ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
80109  }
80110
80111  return ret;
80112} // Copies a specified amount of characters from the list of buffered data
80113// chunks.
80114// This function is designed to be inlinable, so please take care when making
80115// changes to the function body.
80116
80117
80118function copyFromBufferString(n, list) {
80119  var p = list.head;
80120  var c = 1;
80121  var ret = p.data;
80122  n -= ret.length;
80123
80124  while (p = p.next) {
80125    var str = p.data;
80126    var nb = n > str.length ? str.length : n;
80127    if (nb === str.length) ret += str;else ret += str.slice(0, n);
80128    n -= nb;
80129
80130    if (n === 0) {
80131      if (nb === str.length) {
80132        ++c;
80133        if (p.next) list.head = p.next;else list.head = list.tail = null;
80134      } else {
80135        list.head = p;
80136        p.data = str.slice(nb);
80137      }
80138
80139      break;
80140    }
80141
80142    ++c;
80143  }
80144
80145  list.length -= c;
80146  return ret;
80147} // Copies a specified amount of bytes from the list of buffered data chunks.
80148// This function is designed to be inlinable, so please take care when making
80149// changes to the function body.
80150
80151
80152function copyFromBuffer(n, list) {
80153  var ret = Buffer.allocUnsafe(n);
80154  var p = list.head;
80155  var c = 1;
80156  p.data.copy(ret);
80157  n -= p.data.length;
80158
80159  while (p = p.next) {
80160    var buf = p.data;
80161    var nb = n > buf.length ? buf.length : n;
80162    buf.copy(ret, ret.length - n, 0, nb);
80163    n -= nb;
80164
80165    if (n === 0) {
80166      if (nb === buf.length) {
80167        ++c;
80168        if (p.next) list.head = p.next;else list.head = list.tail = null;
80169      } else {
80170        list.head = p;
80171        p.data = buf.slice(nb);
80172      }
80173
80174      break;
80175    }
80176
80177    ++c;
80178  }
80179
80180  list.length -= c;
80181  return ret;
80182}
80183
80184function endReadable(stream) {
80185  var state = stream._readableState; // If we get here before consuming all the bytes, then that is a
80186  // bug in node.  Should never happen.
80187
80188  if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
80189
80190  if (!state.endEmitted) {
80191    state.ended = true;
80192    pna.nextTick(endReadableNT, state, stream);
80193  }
80194}
80195
80196function endReadableNT(state, stream) {
80197  // Check that we didn't get one last unshift.
80198  if (!state.endEmitted && state.length === 0) {
80199    state.endEmitted = true;
80200    stream.readable = false;
80201    stream.emit('end');
80202  }
80203}
80204
80205function indexOf(xs, x) {
80206  for (var i = 0, l = xs.length; i < l; i++) {
80207    if (xs[i] === x) return i;
80208  }
80209
80210  return -1;
80211}
80212
80213}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
80214
80215},{"./_stream_duplex":508,"./internal/streams/BufferList":513,"./internal/streams/destroy":514,"./internal/streams/stream":515,"_process":467,"core-util-is":328,"events":367,"inherits":387,"isarray":389,"process-nextick-args":466,"safe-buffer":494,"string_decoder/":520,"util":185}],511:[function(require,module,exports){
80216// Copyright Joyent, Inc. and other Node contributors.
80217//
80218// Permission is hereby granted, free of charge, to any person obtaining a
80219// copy of this software and associated documentation files (the
80220// "Software"), to deal in the Software without restriction, including
80221// without limitation the rights to use, copy, modify, merge, publish,
80222// distribute, sublicense, and/or sell copies of the Software, and to permit
80223// persons to whom the Software is furnished to do so, subject to the
80224// following conditions:
80225//
80226// The above copyright notice and this permission notice shall be included
80227// in all copies or substantial portions of the Software.
80228//
80229// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
80230// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
80231// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
80232// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
80233// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
80234// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
80235// USE OR OTHER DEALINGS IN THE SOFTWARE.
80236// a transform stream is a readable/writable stream where you do
80237// something with the data.  Sometimes it's called a "filter",
80238// but that's not a great name for it, since that implies a thing where
80239// some bits pass through, and others are simply ignored.  (That would
80240// be a valid example of a transform, of course.)
80241//
80242// While the output is causally related to the input, it's not a
80243// necessarily symmetric or synchronous transformation.  For example,
80244// a zlib stream might take multiple plain-text writes(), and then
80245// emit a single compressed chunk some time in the future.
80246//
80247// Here's how this works:
80248//
80249// The Transform stream has all the aspects of the readable and writable
80250// stream classes.  When you write(chunk), that calls _write(chunk,cb)
80251// internally, and returns false if there's a lot of pending writes
80252// buffered up.  When you call read(), that calls _read(n) until
80253// there's enough pending readable data buffered up.
80254//
80255// In a transform stream, the written data is placed in a buffer.  When
80256// _read(n) is called, it transforms the queued up data, calling the
80257// buffered _write cb's as it consumes chunks.  If consuming a single
80258// written chunk would result in multiple output chunks, then the first
80259// outputted bit calls the readcb, and subsequent chunks just go into
80260// the read buffer, and will cause it to emit 'readable' if necessary.
80261//
80262// This way, back-pressure is actually determined by the reading side,
80263// since _read has to be called to start processing a new chunk.  However,
80264// a pathological inflate type of transform can cause excessive buffering
80265// here.  For example, imagine a stream where every byte of input is
80266// interpreted as an integer from 0-255, and then results in that many
80267// bytes of output.  Writing the 4 bytes {ff,ff,ff,ff} would result in
80268// 1kb of data being output.  In this case, you could write a very small
80269// amount of input, and end up with a very large amount of output.  In
80270// such a pathological inflating mechanism, there'd be no way to tell
80271// the system to stop doing the transform.  A single 4MB write could
80272// cause the system to run out of memory.
80273//
80274// However, even in such a pathological case, only a single written chunk
80275// would be consumed, and then the rest would wait (un-transformed) until
80276// the results of the previous transformed chunk were consumed.
80277'use strict';
80278
80279module.exports = Transform;
80280
80281var Duplex = require('./_stream_duplex');
80282/*<replacement>*/
80283
80284
80285var util = Object.create(require('core-util-is'));
80286util.inherits = require('inherits');
80287/*</replacement>*/
80288
80289util.inherits(Transform, Duplex);
80290
80291function afterTransform(er, data) {
80292  var ts = this._transformState;
80293  ts.transforming = false;
80294  var cb = ts.writecb;
80295
80296  if (!cb) {
80297    return this.emit('error', new Error('write callback called multiple times'));
80298  }
80299
80300  ts.writechunk = null;
80301  ts.writecb = null;
80302  if (data != null) // single equals check for both `null` and `undefined`
80303    this.push(data);
80304  cb(er);
80305  var rs = this._readableState;
80306  rs.reading = false;
80307
80308  if (rs.needReadable || rs.length < rs.highWaterMark) {
80309    this._read(rs.highWaterMark);
80310  }
80311}
80312
80313function Transform(options) {
80314  if (!(this instanceof Transform)) return new Transform(options);
80315  Duplex.call(this, options);
80316  this._transformState = {
80317    afterTransform: afterTransform.bind(this),
80318    needTransform: false,
80319    transforming: false,
80320    writecb: null,
80321    writechunk: null,
80322    writeencoding: null
80323  }; // start out asking for a readable event once data is transformed.
80324
80325  this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
80326  // that Readable wants before the first _read call, so unset the
80327  // sync guard flag.
80328
80329  this._readableState.sync = false;
80330
80331  if (options) {
80332    if (typeof options.transform === 'function') this._transform = options.transform;
80333    if (typeof options.flush === 'function') this._flush = options.flush;
80334  } // When the writable side finishes, then flush out anything remaining.
80335
80336
80337  this.on('prefinish', prefinish);
80338}
80339
80340function prefinish() {
80341  var _this = this;
80342
80343  if (typeof this._flush === 'function') {
80344    this._flush(function (er, data) {
80345      done(_this, er, data);
80346    });
80347  } else {
80348    done(this, null, null);
80349  }
80350}
80351
80352Transform.prototype.push = function (chunk, encoding) {
80353  this._transformState.needTransform = false;
80354  return Duplex.prototype.push.call(this, chunk, encoding);
80355}; // This is the part where you do stuff!
80356// override this function in implementation classes.
80357// 'chunk' is an input chunk.
80358//
80359// Call `push(newChunk)` to pass along transformed output
80360// to the readable side.  You may call 'push' zero or more times.
80361//
80362// Call `cb(err)` when you are done with this chunk.  If you pass
80363// an error, then that'll put the hurt on the whole operation.  If you
80364// never call cb(), then you'll never get another chunk.
80365
80366
80367Transform.prototype._transform = function (chunk, encoding, cb) {
80368  throw new Error('_transform() is not implemented');
80369};
80370
80371Transform.prototype._write = function (chunk, encoding, cb) {
80372  var ts = this._transformState;
80373  ts.writecb = cb;
80374  ts.writechunk = chunk;
80375  ts.writeencoding = encoding;
80376
80377  if (!ts.transforming) {
80378    var rs = this._readableState;
80379    if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
80380  }
80381}; // Doesn't matter what the args are here.
80382// _transform does all the work.
80383// That we got here means that the readable side wants more data.
80384
80385
80386Transform.prototype._read = function (n) {
80387  var ts = this._transformState;
80388
80389  if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
80390    ts.transforming = true;
80391
80392    this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
80393  } else {
80394    // mark that we need a transform, so that any data that comes in
80395    // will get processed, now that we've asked for it.
80396    ts.needTransform = true;
80397  }
80398};
80399
80400Transform.prototype._destroy = function (err, cb) {
80401  var _this2 = this;
80402
80403  Duplex.prototype._destroy.call(this, err, function (err2) {
80404    cb(err2);
80405
80406    _this2.emit('close');
80407  });
80408};
80409
80410function done(stream, er, data) {
80411  if (er) return stream.emit('error', er);
80412  if (data != null) // single equals check for both `null` and `undefined`
80413    stream.push(data); // if there's nothing in the write buffer, then that means
80414  // that nothing more will ever be provided
80415
80416  if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
80417  if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
80418  return stream.push(null);
80419}
80420
80421},{"./_stream_duplex":508,"core-util-is":328,"inherits":387}],512:[function(require,module,exports){
80422(function (process,global,setImmediate){
80423// Copyright Joyent, Inc. and other Node contributors.
80424//
80425// Permission is hereby granted, free of charge, to any person obtaining a
80426// copy of this software and associated documentation files (the
80427// "Software"), to deal in the Software without restriction, including
80428// without limitation the rights to use, copy, modify, merge, publish,
80429// distribute, sublicense, and/or sell copies of the Software, and to permit
80430// persons to whom the Software is furnished to do so, subject to the
80431// following conditions:
80432//
80433// The above copyright notice and this permission notice shall be included
80434// in all copies or substantial portions of the Software.
80435//
80436// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
80437// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
80438// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
80439// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
80440// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
80441// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
80442// USE OR OTHER DEALINGS IN THE SOFTWARE.
80443// A bit simpler than readable streams.
80444// Implement an async ._write(chunk, encoding, cb), and it'll handle all
80445// the drain event emission and buffering.
80446'use strict';
80447/*<replacement>*/
80448
80449var pna = require('process-nextick-args');
80450/*</replacement>*/
80451
80452
80453module.exports = Writable;
80454/* <replacement> */
80455
80456function WriteReq(chunk, encoding, cb) {
80457  this.chunk = chunk;
80458  this.encoding = encoding;
80459  this.callback = cb;
80460  this.next = null;
80461} // It seems a linked list but it is not
80462// there will be only 2 of these for each stream
80463
80464
80465function CorkedRequest(state) {
80466  var _this = this;
80467
80468  this.next = null;
80469  this.entry = null;
80470
80471  this.finish = function () {
80472    onCorkedFinish(_this, state);
80473  };
80474}
80475/* </replacement> */
80476
80477/*<replacement>*/
80478
80479
80480var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
80481/*</replacement>*/
80482
80483/*<replacement>*/
80484
80485var Duplex;
80486/*</replacement>*/
80487
80488Writable.WritableState = WritableState;
80489/*<replacement>*/
80490
80491var util = Object.create(require('core-util-is'));
80492util.inherits = require('inherits');
80493/*</replacement>*/
80494
80495/*<replacement>*/
80496
80497var internalUtil = {
80498  deprecate: require('util-deprecate')
80499};
80500/*</replacement>*/
80501
80502/*<replacement>*/
80503
80504var Stream = require('./internal/streams/stream');
80505/*</replacement>*/
80506
80507/*<replacement>*/
80508
80509
80510var Buffer = require('safe-buffer').Buffer;
80511
80512var OurUint8Array = global.Uint8Array || function () {};
80513
80514function _uint8ArrayToBuffer(chunk) {
80515  return Buffer.from(chunk);
80516}
80517
80518function _isUint8Array(obj) {
80519  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
80520}
80521/*</replacement>*/
80522
80523
80524var destroyImpl = require('./internal/streams/destroy');
80525
80526util.inherits(Writable, Stream);
80527
80528function nop() {}
80529
80530function WritableState(options, stream) {
80531  Duplex = Duplex || require('./_stream_duplex');
80532  options = options || {}; // Duplex streams are both readable and writable, but share
80533  // the same options object.
80534  // However, some cases require setting options to different
80535  // values for the readable and the writable sides of the duplex stream.
80536  // These options can be provided separately as readableXXX and writableXXX.
80537
80538  var isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
80539  // contains buffers or objects.
80540
80541  this.objectMode = !!options.objectMode;
80542  if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
80543  // Note: 0 is a valid value, means that we always return false if
80544  // the entire buffer is not flushed immediately on write()
80545
80546  var hwm = options.highWaterMark;
80547  var writableHwm = options.writableHighWaterMark;
80548  var defaultHwm = this.objectMode ? 16 : 16 * 1024;
80549  if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; // cast to ints.
80550
80551  this.highWaterMark = Math.floor(this.highWaterMark); // if _final has been called
80552
80553  this.finalCalled = false; // drain event flag.
80554
80555  this.needDrain = false; // at the start of calling end()
80556
80557  this.ending = false; // when end() has been called, and returned
80558
80559  this.ended = false; // when 'finish' is emitted
80560
80561  this.finished = false; // has it been destroyed
80562
80563  this.destroyed = false; // should we decode strings into buffers before passing to _write?
80564  // this is here so that some node-core streams can optimize string
80565  // handling at a lower level.
80566
80567  var noDecode = options.decodeStrings === false;
80568  this.decodeStrings = !noDecode; // Crypto is kind of old and crusty.  Historically, its default string
80569  // encoding is 'binary' so we have to make this configurable.
80570  // Everything else in the universe uses 'utf8', though.
80571
80572  this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
80573  // of how much we're waiting to get pushed to some underlying
80574  // socket or file.
80575
80576  this.length = 0; // a flag to see when we're in the middle of a write.
80577
80578  this.writing = false; // when true all writes will be buffered until .uncork() call
80579
80580  this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
80581  // or on a later tick.  We set this to true at first, because any
80582  // actions that shouldn't happen until "later" should generally also
80583  // not happen before the first write call.
80584
80585  this.sync = true; // a flag to know if we're processing previously buffered items, which
80586  // may call the _write() callback in the same tick, so that we don't
80587  // end up in an overlapped onwrite situation.
80588
80589  this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
80590
80591  this.onwrite = function (er) {
80592    onwrite(stream, er);
80593  }; // the callback that the user supplies to write(chunk,encoding,cb)
80594
80595
80596  this.writecb = null; // the amount that is being written when _write is called.
80597
80598  this.writelen = 0;
80599  this.bufferedRequest = null;
80600  this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
80601  // this must be 0 before 'finish' can be emitted
80602
80603  this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
80604  // This is relevant for synchronous Transform streams
80605
80606  this.prefinished = false; // True if the error was already emitted and should not be thrown again
80607
80608  this.errorEmitted = false; // count buffered requests
80609
80610  this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
80611  // one allocated and free to use, and we maintain at most two
80612
80613  this.corkedRequestsFree = new CorkedRequest(this);
80614}
80615
80616WritableState.prototype.getBuffer = function getBuffer() {
80617  var current = this.bufferedRequest;
80618  var out = [];
80619
80620  while (current) {
80621    out.push(current);
80622    current = current.next;
80623  }
80624
80625  return out;
80626};
80627
80628(function () {
80629  try {
80630    Object.defineProperty(WritableState.prototype, 'buffer', {
80631      get: internalUtil.deprecate(function () {
80632        return this.getBuffer();
80633      }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
80634    });
80635  } catch (_) {}
80636})(); // Test _writableState for inheritance to account for Duplex streams,
80637// whose prototype chain only points to Readable.
80638
80639
80640var realHasInstance;
80641
80642if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
80643  realHasInstance = Function.prototype[Symbol.hasInstance];
80644  Object.defineProperty(Writable, Symbol.hasInstance, {
80645    value: function value(object) {
80646      if (realHasInstance.call(this, object)) return true;
80647      if (this !== Writable) return false;
80648      return object && object._writableState instanceof WritableState;
80649    }
80650  });
80651} else {
80652  realHasInstance = function realHasInstance(object) {
80653    return object instanceof this;
80654  };
80655}
80656
80657function Writable(options) {
80658  Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.
80659  // `realHasInstance` is necessary because using plain `instanceof`
80660  // would return false, as no `_writableState` property is attached.
80661  // Trying to use the custom `instanceof` for Writable here will also break the
80662  // Node.js LazyTransform implementation, which has a non-trivial getter for
80663  // `_writableState` that would lead to infinite recursion.
80664
80665  if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
80666    return new Writable(options);
80667  }
80668
80669  this._writableState = new WritableState(options, this); // legacy.
80670
80671  this.writable = true;
80672
80673  if (options) {
80674    if (typeof options.write === 'function') this._write = options.write;
80675    if (typeof options.writev === 'function') this._writev = options.writev;
80676    if (typeof options.destroy === 'function') this._destroy = options.destroy;
80677    if (typeof options.final === 'function') this._final = options.final;
80678  }
80679
80680  Stream.call(this);
80681} // Otherwise people can pipe Writable streams, which is just wrong.
80682
80683
80684Writable.prototype.pipe = function () {
80685  this.emit('error', new Error('Cannot pipe, not readable'));
80686};
80687
80688function writeAfterEnd(stream, cb) {
80689  var er = new Error('write after end'); // TODO: defer error events consistently everywhere, not just the cb
80690
80691  stream.emit('error', er);
80692  pna.nextTick(cb, er);
80693} // Checks that a user-supplied chunk is valid, especially for the particular
80694// mode the stream is in. Currently this means that `null` is never accepted
80695// and undefined/non-string values are only allowed in object mode.
80696
80697
80698function validChunk(stream, state, chunk, cb) {
80699  var valid = true;
80700  var er = false;
80701
80702  if (chunk === null) {
80703    er = new TypeError('May not write null values to stream');
80704  } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
80705    er = new TypeError('Invalid non-string/buffer chunk');
80706  }
80707
80708  if (er) {
80709    stream.emit('error', er);
80710    pna.nextTick(cb, er);
80711    valid = false;
80712  }
80713
80714  return valid;
80715}
80716
80717Writable.prototype.write = function (chunk, encoding, cb) {
80718  var state = this._writableState;
80719  var ret = false;
80720
80721  var isBuf = !state.objectMode && _isUint8Array(chunk);
80722
80723  if (isBuf && !Buffer.isBuffer(chunk)) {
80724    chunk = _uint8ArrayToBuffer(chunk);
80725  }
80726
80727  if (typeof encoding === 'function') {
80728    cb = encoding;
80729    encoding = null;
80730  }
80731
80732  if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
80733  if (typeof cb !== 'function') cb = nop;
80734  if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
80735    state.pendingcb++;
80736    ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
80737  }
80738  return ret;
80739};
80740
80741Writable.prototype.cork = function () {
80742  var state = this._writableState;
80743  state.corked++;
80744};
80745
80746Writable.prototype.uncork = function () {
80747  var state = this._writableState;
80748
80749  if (state.corked) {
80750    state.corked--;
80751    if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
80752  }
80753};
80754
80755Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
80756  // node::ParseEncoding() requires lower case.
80757  if (typeof encoding === 'string') encoding = encoding.toLowerCase();
80758  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);
80759  this._writableState.defaultEncoding = encoding;
80760  return this;
80761};
80762
80763function decodeChunk(state, chunk, encoding) {
80764  if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
80765    chunk = Buffer.from(chunk, encoding);
80766  }
80767
80768  return chunk;
80769}
80770
80771Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
80772  // making it explicit this property is not enumerable
80773  // because otherwise some prototype manipulation in
80774  // userland will fail
80775  enumerable: false,
80776  get: function get() {
80777    return this._writableState.highWaterMark;
80778  }
80779}); // if we're already writing something, then just put this
80780// in the queue, and wait our turn.  Otherwise, call _write
80781// If we return false, then we need a drain event, so set that flag.
80782
80783function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
80784  if (!isBuf) {
80785    var newChunk = decodeChunk(state, chunk, encoding);
80786
80787    if (chunk !== newChunk) {
80788      isBuf = true;
80789      encoding = 'buffer';
80790      chunk = newChunk;
80791    }
80792  }
80793
80794  var len = state.objectMode ? 1 : chunk.length;
80795  state.length += len;
80796  var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
80797
80798  if (!ret) state.needDrain = true;
80799
80800  if (state.writing || state.corked) {
80801    var last = state.lastBufferedRequest;
80802    state.lastBufferedRequest = {
80803      chunk: chunk,
80804      encoding: encoding,
80805      isBuf: isBuf,
80806      callback: cb,
80807      next: null
80808    };
80809
80810    if (last) {
80811      last.next = state.lastBufferedRequest;
80812    } else {
80813      state.bufferedRequest = state.lastBufferedRequest;
80814    }
80815
80816    state.bufferedRequestCount += 1;
80817  } else {
80818    doWrite(stream, state, false, len, chunk, encoding, cb);
80819  }
80820
80821  return ret;
80822}
80823
80824function doWrite(stream, state, writev, len, chunk, encoding, cb) {
80825  state.writelen = len;
80826  state.writecb = cb;
80827  state.writing = true;
80828  state.sync = true;
80829  if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
80830  state.sync = false;
80831}
80832
80833function onwriteError(stream, state, sync, er, cb) {
80834  --state.pendingcb;
80835
80836  if (sync) {
80837    // defer the callback if we are being called synchronously
80838    // to avoid piling up things on the stack
80839    pna.nextTick(cb, er); // this can emit finish, and it will always happen
80840    // after error
80841
80842    pna.nextTick(finishMaybe, stream, state);
80843    stream._writableState.errorEmitted = true;
80844    stream.emit('error', er);
80845  } else {
80846    // the caller expect this to happen before if
80847    // it is async
80848    cb(er);
80849    stream._writableState.errorEmitted = true;
80850    stream.emit('error', er); // this can emit finish, but finish must
80851    // always follow error
80852
80853    finishMaybe(stream, state);
80854  }
80855}
80856
80857function onwriteStateUpdate(state) {
80858  state.writing = false;
80859  state.writecb = null;
80860  state.length -= state.writelen;
80861  state.writelen = 0;
80862}
80863
80864function onwrite(stream, er) {
80865  var state = stream._writableState;
80866  var sync = state.sync;
80867  var cb = state.writecb;
80868  onwriteStateUpdate(state);
80869  if (er) onwriteError(stream, state, sync, er, cb);else {
80870    // Check if we're actually ready to finish, but don't emit yet
80871    var finished = needFinish(state);
80872
80873    if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
80874      clearBuffer(stream, state);
80875    }
80876
80877    if (sync) {
80878      /*<replacement>*/
80879      asyncWrite(afterWrite, stream, state, finished, cb);
80880      /*</replacement>*/
80881    } else {
80882      afterWrite(stream, state, finished, cb);
80883    }
80884  }
80885}
80886
80887function afterWrite(stream, state, finished, cb) {
80888  if (!finished) onwriteDrain(stream, state);
80889  state.pendingcb--;
80890  cb();
80891  finishMaybe(stream, state);
80892} // Must force callback to be called on nextTick, so that we don't
80893// emit 'drain' before the write() consumer gets the 'false' return
80894// value, and has a chance to attach a 'drain' listener.
80895
80896
80897function onwriteDrain(stream, state) {
80898  if (state.length === 0 && state.needDrain) {
80899    state.needDrain = false;
80900    stream.emit('drain');
80901  }
80902} // if there's something in the buffer waiting, then process it
80903
80904
80905function clearBuffer(stream, state) {
80906  state.bufferProcessing = true;
80907  var entry = state.bufferedRequest;
80908
80909  if (stream._writev && entry && entry.next) {
80910    // Fast case, write everything using _writev()
80911    var l = state.bufferedRequestCount;
80912    var buffer = new Array(l);
80913    var holder = state.corkedRequestsFree;
80914    holder.entry = entry;
80915    var count = 0;
80916    var allBuffers = true;
80917
80918    while (entry) {
80919      buffer[count] = entry;
80920      if (!entry.isBuf) allBuffers = false;
80921      entry = entry.next;
80922      count += 1;
80923    }
80924
80925    buffer.allBuffers = allBuffers;
80926    doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
80927    // as the hot path ends with doWrite
80928
80929    state.pendingcb++;
80930    state.lastBufferedRequest = null;
80931
80932    if (holder.next) {
80933      state.corkedRequestsFree = holder.next;
80934      holder.next = null;
80935    } else {
80936      state.corkedRequestsFree = new CorkedRequest(state);
80937    }
80938
80939    state.bufferedRequestCount = 0;
80940  } else {
80941    // Slow case, write chunks one-by-one
80942    while (entry) {
80943      var chunk = entry.chunk;
80944      var encoding = entry.encoding;
80945      var cb = entry.callback;
80946      var len = state.objectMode ? 1 : chunk.length;
80947      doWrite(stream, state, false, len, chunk, encoding, cb);
80948      entry = entry.next;
80949      state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
80950      // it means that we need to wait until it does.
80951      // also, that means that the chunk and cb are currently
80952      // being processed, so move the buffer counter past them.
80953
80954      if (state.writing) {
80955        break;
80956      }
80957    }
80958
80959    if (entry === null) state.lastBufferedRequest = null;
80960  }
80961
80962  state.bufferedRequest = entry;
80963  state.bufferProcessing = false;
80964}
80965
80966Writable.prototype._write = function (chunk, encoding, cb) {
80967  cb(new Error('_write() is not implemented'));
80968};
80969
80970Writable.prototype._writev = null;
80971
80972Writable.prototype.end = function (chunk, encoding, cb) {
80973  var state = this._writableState;
80974
80975  if (typeof chunk === 'function') {
80976    cb = chunk;
80977    chunk = null;
80978    encoding = null;
80979  } else if (typeof encoding === 'function') {
80980    cb = encoding;
80981    encoding = null;
80982  }
80983
80984  if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
80985
80986  if (state.corked) {
80987    state.corked = 1;
80988    this.uncork();
80989  } // ignore unnecessary end() calls.
80990
80991
80992  if (!state.ending && !state.finished) endWritable(this, state, cb);
80993};
80994
80995function needFinish(state) {
80996  return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
80997}
80998
80999function callFinal(stream, state) {
81000  stream._final(function (err) {
81001    state.pendingcb--;
81002
81003    if (err) {
81004      stream.emit('error', err);
81005    }
81006
81007    state.prefinished = true;
81008    stream.emit('prefinish');
81009    finishMaybe(stream, state);
81010  });
81011}
81012
81013function prefinish(stream, state) {
81014  if (!state.prefinished && !state.finalCalled) {
81015    if (typeof stream._final === 'function') {
81016      state.pendingcb++;
81017      state.finalCalled = true;
81018      pna.nextTick(callFinal, stream, state);
81019    } else {
81020      state.prefinished = true;
81021      stream.emit('prefinish');
81022    }
81023  }
81024}
81025
81026function finishMaybe(stream, state) {
81027  var need = needFinish(state);
81028
81029  if (need) {
81030    prefinish(stream, state);
81031
81032    if (state.pendingcb === 0) {
81033      state.finished = true;
81034      stream.emit('finish');
81035    }
81036  }
81037
81038  return need;
81039}
81040
81041function endWritable(stream, state, cb) {
81042  state.ending = true;
81043  finishMaybe(stream, state);
81044
81045  if (cb) {
81046    if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
81047  }
81048
81049  state.ended = true;
81050  stream.writable = false;
81051}
81052
81053function onCorkedFinish(corkReq, state, err) {
81054  var entry = corkReq.entry;
81055  corkReq.entry = null;
81056
81057  while (entry) {
81058    var cb = entry.callback;
81059    state.pendingcb--;
81060    cb(err);
81061    entry = entry.next;
81062  }
81063
81064  if (state.corkedRequestsFree) {
81065    state.corkedRequestsFree.next = corkReq;
81066  } else {
81067    state.corkedRequestsFree = corkReq;
81068  }
81069}
81070
81071Object.defineProperty(Writable.prototype, 'destroyed', {
81072  get: function get() {
81073    if (this._writableState === undefined) {
81074      return false;
81075    }
81076
81077    return this._writableState.destroyed;
81078  },
81079  set: function set(value) {
81080    // we ignore the value if the stream
81081    // has not been initialized yet
81082    if (!this._writableState) {
81083      return;
81084    } // backward compatibility, the user is explicitly
81085    // managing destroyed
81086
81087
81088    this._writableState.destroyed = value;
81089  }
81090});
81091Writable.prototype.destroy = destroyImpl.destroy;
81092Writable.prototype._undestroy = destroyImpl.undestroy;
81093
81094Writable.prototype._destroy = function (err, cb) {
81095  this.end();
81096  cb(err);
81097};
81098
81099}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
81100
81101},{"./_stream_duplex":508,"./internal/streams/destroy":514,"./internal/streams/stream":515,"_process":467,"core-util-is":328,"inherits":387,"process-nextick-args":466,"safe-buffer":494,"timers":521,"util-deprecate":522}],513:[function(require,module,exports){
81102'use strict';
81103
81104function _classCallCheck(instance, Constructor) {
81105  if (!(instance instanceof Constructor)) {
81106    throw new TypeError("Cannot call a class as a function");
81107  }
81108}
81109
81110var Buffer = require('safe-buffer').Buffer;
81111
81112var util = require('util');
81113
81114function copyBuffer(src, target, offset) {
81115  src.copy(target, offset);
81116}
81117
81118module.exports = function () {
81119  function BufferList() {
81120    _classCallCheck(this, BufferList);
81121
81122    this.head = null;
81123    this.tail = null;
81124    this.length = 0;
81125  }
81126
81127  BufferList.prototype.push = function push(v) {
81128    var entry = {
81129      data: v,
81130      next: null
81131    };
81132    if (this.length > 0) this.tail.next = entry;else this.head = entry;
81133    this.tail = entry;
81134    ++this.length;
81135  };
81136
81137  BufferList.prototype.unshift = function unshift(v) {
81138    var entry = {
81139      data: v,
81140      next: this.head
81141    };
81142    if (this.length === 0) this.tail = entry;
81143    this.head = entry;
81144    ++this.length;
81145  };
81146
81147  BufferList.prototype.shift = function shift() {
81148    if (this.length === 0) return;
81149    var ret = this.head.data;
81150    if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
81151    --this.length;
81152    return ret;
81153  };
81154
81155  BufferList.prototype.clear = function clear() {
81156    this.head = this.tail = null;
81157    this.length = 0;
81158  };
81159
81160  BufferList.prototype.join = function join(s) {
81161    if (this.length === 0) return '';
81162    var p = this.head;
81163    var ret = '' + p.data;
81164
81165    while (p = p.next) {
81166      ret += s + p.data;
81167    }
81168
81169    return ret;
81170  };
81171
81172  BufferList.prototype.concat = function concat(n) {
81173    if (this.length === 0) return Buffer.alloc(0);
81174    if (this.length === 1) return this.head.data;
81175    var ret = Buffer.allocUnsafe(n >>> 0);
81176    var p = this.head;
81177    var i = 0;
81178
81179    while (p) {
81180      copyBuffer(p.data, ret, i);
81181      i += p.data.length;
81182      p = p.next;
81183    }
81184
81185    return ret;
81186  };
81187
81188  return BufferList;
81189}();
81190
81191if (util && util.inspect && util.inspect.custom) {
81192  module.exports.prototype[util.inspect.custom] = function () {
81193    var obj = util.inspect({
81194      length: this.length
81195    });
81196    return this.constructor.name + ' ' + obj;
81197  };
81198}
81199
81200},{"safe-buffer":494,"util":185}],514:[function(require,module,exports){
81201'use strict';
81202/*<replacement>*/
81203
81204var pna = require('process-nextick-args');
81205/*</replacement>*/
81206// undocumented cb() API, needed for core, not for public API
81207
81208
81209function destroy(err, cb) {
81210  var _this = this;
81211
81212  var readableDestroyed = this._readableState && this._readableState.destroyed;
81213  var writableDestroyed = this._writableState && this._writableState.destroyed;
81214
81215  if (readableDestroyed || writableDestroyed) {
81216    if (cb) {
81217      cb(err);
81218    } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
81219      pna.nextTick(emitErrorNT, this, err);
81220    }
81221
81222    return this;
81223  } // we set destroyed to true before firing error callbacks in order
81224  // to make it re-entrance safe in case destroy() is called within callbacks
81225
81226
81227  if (this._readableState) {
81228    this._readableState.destroyed = true;
81229  } // if this is a duplex stream mark the writable part as destroyed as well
81230
81231
81232  if (this._writableState) {
81233    this._writableState.destroyed = true;
81234  }
81235
81236  this._destroy(err || null, function (err) {
81237    if (!cb && err) {
81238      pna.nextTick(emitErrorNT, _this, err);
81239
81240      if (_this._writableState) {
81241        _this._writableState.errorEmitted = true;
81242      }
81243    } else if (cb) {
81244      cb(err);
81245    }
81246  });
81247
81248  return this;
81249}
81250
81251function undestroy() {
81252  if (this._readableState) {
81253    this._readableState.destroyed = false;
81254    this._readableState.reading = false;
81255    this._readableState.ended = false;
81256    this._readableState.endEmitted = false;
81257  }
81258
81259  if (this._writableState) {
81260    this._writableState.destroyed = false;
81261    this._writableState.ended = false;
81262    this._writableState.ending = false;
81263    this._writableState.finished = false;
81264    this._writableState.errorEmitted = false;
81265  }
81266}
81267
81268function emitErrorNT(self, err) {
81269  self.emit('error', err);
81270}
81271
81272module.exports = {
81273  destroy: destroy,
81274  undestroy: undestroy
81275};
81276
81277},{"process-nextick-args":466}],515:[function(require,module,exports){
81278arguments[4][490][0].apply(exports,arguments)
81279},{"dup":490,"events":367}],516:[function(require,module,exports){
81280"use strict";
81281
81282module.exports = require('./readable').PassThrough;
81283
81284},{"./readable":517}],517:[function(require,module,exports){
81285"use strict";
81286
81287exports = module.exports = require('./lib/_stream_readable.js');
81288exports.Stream = exports;
81289exports.Readable = exports;
81290exports.Writable = require('./lib/_stream_writable.js');
81291exports.Duplex = require('./lib/_stream_duplex.js');
81292exports.Transform = require('./lib/_stream_transform.js');
81293exports.PassThrough = require('./lib/_stream_passthrough.js');
81294
81295},{"./lib/_stream_duplex.js":508,"./lib/_stream_passthrough.js":509,"./lib/_stream_readable.js":510,"./lib/_stream_transform.js":511,"./lib/_stream_writable.js":512}],518:[function(require,module,exports){
81296"use strict";
81297
81298module.exports = require('./readable').Transform;
81299
81300},{"./readable":517}],519:[function(require,module,exports){
81301"use strict";
81302
81303module.exports = require('./lib/_stream_writable.js');
81304
81305},{"./lib/_stream_writable.js":512}],520:[function(require,module,exports){
81306// Copyright Joyent, Inc. and other Node contributors.
81307//
81308// Permission is hereby granted, free of charge, to any person obtaining a
81309// copy of this software and associated documentation files (the
81310// "Software"), to deal in the Software without restriction, including
81311// without limitation the rights to use, copy, modify, merge, publish,
81312// distribute, sublicense, and/or sell copies of the Software, and to permit
81313// persons to whom the Software is furnished to do so, subject to the
81314// following conditions:
81315//
81316// The above copyright notice and this permission notice shall be included
81317// in all copies or substantial portions of the Software.
81318//
81319// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
81320// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81321// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
81322// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
81323// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
81324// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
81325// USE OR OTHER DEALINGS IN THE SOFTWARE.
81326'use strict';
81327/*<replacement>*/
81328
81329var Buffer = require('safe-buffer').Buffer;
81330/*</replacement>*/
81331
81332
81333var isEncoding = Buffer.isEncoding || function (encoding) {
81334  encoding = '' + encoding;
81335
81336  switch (encoding && encoding.toLowerCase()) {
81337    case 'hex':
81338    case 'utf8':
81339    case 'utf-8':
81340    case 'ascii':
81341    case 'binary':
81342    case 'base64':
81343    case 'ucs2':
81344    case 'ucs-2':
81345    case 'utf16le':
81346    case 'utf-16le':
81347    case 'raw':
81348      return true;
81349
81350    default:
81351      return false;
81352  }
81353};
81354
81355function _normalizeEncoding(enc) {
81356  if (!enc) return 'utf8';
81357  var retried;
81358
81359  while (true) {
81360    switch (enc) {
81361      case 'utf8':
81362      case 'utf-8':
81363        return 'utf8';
81364
81365      case 'ucs2':
81366      case 'ucs-2':
81367      case 'utf16le':
81368      case 'utf-16le':
81369        return 'utf16le';
81370
81371      case 'latin1':
81372      case 'binary':
81373        return 'latin1';
81374
81375      case 'base64':
81376      case 'ascii':
81377      case 'hex':
81378        return enc;
81379
81380      default:
81381        if (retried) return; // undefined
81382
81383        enc = ('' + enc).toLowerCase();
81384        retried = true;
81385    }
81386  }
81387}
81388
81389; // Do not cache `Buffer.isEncoding` when checking encoding names as some
81390// modules monkey-patch it to support additional encodings
81391
81392function normalizeEncoding(enc) {
81393  var nenc = _normalizeEncoding(enc);
81394
81395  if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
81396  return nenc || enc;
81397} // StringDecoder provides an interface for efficiently splitting a series of
81398// buffers into a series of JS strings without breaking apart multi-byte
81399// characters.
81400
81401
81402exports.StringDecoder = StringDecoder;
81403
81404function StringDecoder(encoding) {
81405  this.encoding = normalizeEncoding(encoding);
81406  var nb;
81407
81408  switch (this.encoding) {
81409    case 'utf16le':
81410      this.text = utf16Text;
81411      this.end = utf16End;
81412      nb = 4;
81413      break;
81414
81415    case 'utf8':
81416      this.fillLast = utf8FillLast;
81417      nb = 4;
81418      break;
81419
81420    case 'base64':
81421      this.text = base64Text;
81422      this.end = base64End;
81423      nb = 3;
81424      break;
81425
81426    default:
81427      this.write = simpleWrite;
81428      this.end = simpleEnd;
81429      return;
81430  }
81431
81432  this.lastNeed = 0;
81433  this.lastTotal = 0;
81434  this.lastChar = Buffer.allocUnsafe(nb);
81435}
81436
81437StringDecoder.prototype.write = function (buf) {
81438  if (buf.length === 0) return '';
81439  var r;
81440  var i;
81441
81442  if (this.lastNeed) {
81443    r = this.fillLast(buf);
81444    if (r === undefined) return '';
81445    i = this.lastNeed;
81446    this.lastNeed = 0;
81447  } else {
81448    i = 0;
81449  }
81450
81451  if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
81452  return r || '';
81453};
81454
81455StringDecoder.prototype.end = utf8End; // Returns only complete characters in a Buffer
81456
81457StringDecoder.prototype.text = utf8Text; // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
81458
81459StringDecoder.prototype.fillLast = function (buf) {
81460  if (this.lastNeed <= buf.length) {
81461    buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
81462    return this.lastChar.toString(this.encoding, 0, this.lastTotal);
81463  }
81464
81465  buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
81466  this.lastNeed -= buf.length;
81467}; // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
81468// continuation byte. If an invalid byte is detected, -2 is returned.
81469
81470
81471function utf8CheckByte(byte) {
81472  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;
81473  return byte >> 6 === 0x02 ? -1 : -2;
81474} // Checks at most 3 bytes at the end of a Buffer in order to detect an
81475// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
81476// needed to complete the UTF-8 character (if applicable) are returned.
81477
81478
81479function utf8CheckIncomplete(self, buf, i) {
81480  var j = buf.length - 1;
81481  if (j < i) return 0;
81482  var nb = utf8CheckByte(buf[j]);
81483
81484  if (nb >= 0) {
81485    if (nb > 0) self.lastNeed = nb - 1;
81486    return nb;
81487  }
81488
81489  if (--j < i || nb === -2) return 0;
81490  nb = utf8CheckByte(buf[j]);
81491
81492  if (nb >= 0) {
81493    if (nb > 0) self.lastNeed = nb - 2;
81494    return nb;
81495  }
81496
81497  if (--j < i || nb === -2) return 0;
81498  nb = utf8CheckByte(buf[j]);
81499
81500  if (nb >= 0) {
81501    if (nb > 0) {
81502      if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
81503    }
81504
81505    return nb;
81506  }
81507
81508  return 0;
81509} // Validates as many continuation bytes for a multi-byte UTF-8 character as
81510// needed or are available. If we see a non-continuation byte where we expect
81511// one, we "replace" the validated continuation bytes we've seen so far with
81512// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
81513// behavior. The continuation byte check is included three times in the case
81514// where all of the continuation bytes for a character exist in the same buffer.
81515// It is also done this way as a slight performance increase instead of using a
81516// loop.
81517
81518
81519function utf8CheckExtraBytes(self, buf, p) {
81520  if ((buf[0] & 0xC0) !== 0x80) {
81521    self.lastNeed = 0;
81522    return "\uFFFD";
81523  }
81524
81525  if (self.lastNeed > 1 && buf.length > 1) {
81526    if ((buf[1] & 0xC0) !== 0x80) {
81527      self.lastNeed = 1;
81528      return "\uFFFD";
81529    }
81530
81531    if (self.lastNeed > 2 && buf.length > 2) {
81532      if ((buf[2] & 0xC0) !== 0x80) {
81533        self.lastNeed = 2;
81534        return "\uFFFD";
81535      }
81536    }
81537  }
81538} // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
81539
81540
81541function utf8FillLast(buf) {
81542  var p = this.lastTotal - this.lastNeed;
81543  var r = utf8CheckExtraBytes(this, buf, p);
81544  if (r !== undefined) return r;
81545
81546  if (this.lastNeed <= buf.length) {
81547    buf.copy(this.lastChar, p, 0, this.lastNeed);
81548    return this.lastChar.toString(this.encoding, 0, this.lastTotal);
81549  }
81550
81551  buf.copy(this.lastChar, p, 0, buf.length);
81552  this.lastNeed -= buf.length;
81553} // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
81554// partial character, the character's bytes are buffered until the required
81555// number of bytes are available.
81556
81557
81558function utf8Text(buf, i) {
81559  var total = utf8CheckIncomplete(this, buf, i);
81560  if (!this.lastNeed) return buf.toString('utf8', i);
81561  this.lastTotal = total;
81562  var end = buf.length - (total - this.lastNeed);
81563  buf.copy(this.lastChar, 0, end);
81564  return buf.toString('utf8', i, end);
81565} // For UTF-8, a replacement character is added when ending on a partial
81566// character.
81567
81568
81569function utf8End(buf) {
81570  var r = buf && buf.length ? this.write(buf) : '';
81571  if (this.lastNeed) return r + "\uFFFD";
81572  return r;
81573} // UTF-16LE typically needs two bytes per character, but even if we have an even
81574// number of bytes available, we need to check if we end on a leading/high
81575// surrogate. In that case, we need to wait for the next two bytes in order to
81576// decode the last character properly.
81577
81578
81579function utf16Text(buf, i) {
81580  if ((buf.length - i) % 2 === 0) {
81581    var r = buf.toString('utf16le', i);
81582
81583    if (r) {
81584      var c = r.charCodeAt(r.length - 1);
81585
81586      if (c >= 0xD800 && c <= 0xDBFF) {
81587        this.lastNeed = 2;
81588        this.lastTotal = 4;
81589        this.lastChar[0] = buf[buf.length - 2];
81590        this.lastChar[1] = buf[buf.length - 1];
81591        return r.slice(0, -1);
81592      }
81593    }
81594
81595    return r;
81596  }
81597
81598  this.lastNeed = 1;
81599  this.lastTotal = 2;
81600  this.lastChar[0] = buf[buf.length - 1];
81601  return buf.toString('utf16le', i, buf.length - 1);
81602} // For UTF-16LE we do not explicitly append special replacement characters if we
81603// end on a partial character, we simply let v8 handle that.
81604
81605
81606function utf16End(buf) {
81607  var r = buf && buf.length ? this.write(buf) : '';
81608
81609  if (this.lastNeed) {
81610    var end = this.lastTotal - this.lastNeed;
81611    return r + this.lastChar.toString('utf16le', 0, end);
81612  }
81613
81614  return r;
81615}
81616
81617function base64Text(buf, i) {
81618  var n = (buf.length - i) % 3;
81619  if (n === 0) return buf.toString('base64', i);
81620  this.lastNeed = 3 - n;
81621  this.lastTotal = 3;
81622
81623  if (n === 1) {
81624    this.lastChar[0] = buf[buf.length - 1];
81625  } else {
81626    this.lastChar[0] = buf[buf.length - 2];
81627    this.lastChar[1] = buf[buf.length - 1];
81628  }
81629
81630  return buf.toString('base64', i, buf.length - n);
81631}
81632
81633function base64End(buf) {
81634  var r = buf && buf.length ? this.write(buf) : '';
81635  if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
81636  return r;
81637} // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
81638
81639
81640function simpleWrite(buf) {
81641  return buf.toString(this.encoding);
81642}
81643
81644function simpleEnd(buf) {
81645  return buf && buf.length ? this.write(buf) : '';
81646}
81647
81648},{"safe-buffer":494}],521:[function(require,module,exports){
81649(function (setImmediate,clearImmediate){
81650"use strict";
81651
81652var nextTick = require('process/browser.js').nextTick;
81653
81654var apply = Function.prototype.apply;
81655var slice = Array.prototype.slice;
81656var immediateIds = {};
81657var nextImmediateId = 0; // DOM APIs, for completeness
81658
81659exports.setTimeout = function () {
81660  return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
81661};
81662
81663exports.setInterval = function () {
81664  return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
81665};
81666
81667exports.clearTimeout = exports.clearInterval = function (timeout) {
81668  timeout.close();
81669};
81670
81671function Timeout(id, clearFn) {
81672  this._id = id;
81673  this._clearFn = clearFn;
81674}
81675
81676Timeout.prototype.unref = Timeout.prototype.ref = function () {};
81677
81678Timeout.prototype.close = function () {
81679  this._clearFn.call(window, this._id);
81680}; // Does not start the time, just sets up the members needed.
81681
81682
81683exports.enroll = function (item, msecs) {
81684  clearTimeout(item._idleTimeoutId);
81685  item._idleTimeout = msecs;
81686};
81687
81688exports.unenroll = function (item) {
81689  clearTimeout(item._idleTimeoutId);
81690  item._idleTimeout = -1;
81691};
81692
81693exports._unrefActive = exports.active = function (item) {
81694  clearTimeout(item._idleTimeoutId);
81695  var msecs = item._idleTimeout;
81696
81697  if (msecs >= 0) {
81698    item._idleTimeoutId = setTimeout(function onTimeout() {
81699      if (item._onTimeout) item._onTimeout();
81700    }, msecs);
81701  }
81702}; // That's not how node.js implements it but the exposed api is the same.
81703
81704
81705exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function (fn) {
81706  var id = nextImmediateId++;
81707  var args = arguments.length < 2 ? false : slice.call(arguments, 1);
81708  immediateIds[id] = true;
81709  nextTick(function onNextTick() {
81710    if (immediateIds[id]) {
81711      // fn.call() is faster so we optimize for the common use-case
81712      // @see http://jsperf.com/call-apply-segu
81713      if (args) {
81714        fn.apply(null, args);
81715      } else {
81716        fn.call(null);
81717      } // Prevent ids from leaking
81718
81719
81720      exports.clearImmediate(id);
81721    }
81722  });
81723  return id;
81724};
81725exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function (id) {
81726  delete immediateIds[id];
81727};
81728
81729}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
81730
81731},{"process/browser.js":467,"timers":521}],522:[function(require,module,exports){
81732(function (global){
81733"use strict";
81734
81735/**
81736 * Module exports.
81737 */
81738module.exports = deprecate;
81739/**
81740 * Mark that a method should not be used.
81741 * Returns a modified function which warns once by default.
81742 *
81743 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
81744 *
81745 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
81746 * will throw an Error when invoked.
81747 *
81748 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
81749 * will invoke `console.trace()` instead of `console.error()`.
81750 *
81751 * @param {Function} fn - the function to deprecate
81752 * @param {String} msg - the string to print to the console when `fn` is invoked
81753 * @returns {Function} a new "deprecated" version of `fn`
81754 * @api public
81755 */
81756
81757function deprecate(fn, msg) {
81758  if (config('noDeprecation')) {
81759    return fn;
81760  }
81761
81762  var warned = false;
81763
81764  function deprecated() {
81765    if (!warned) {
81766      if (config('throwDeprecation')) {
81767        throw new Error(msg);
81768      } else if (config('traceDeprecation')) {
81769        console.trace(msg);
81770      } else {
81771        console.warn(msg);
81772      }
81773
81774      warned = true;
81775    }
81776
81777    return fn.apply(this, arguments);
81778  }
81779
81780  return deprecated;
81781}
81782/**
81783 * Checks `localStorage` for boolean values for the given `name`.
81784 *
81785 * @param {String} name
81786 * @returns {Boolean}
81787 * @api private
81788 */
81789
81790
81791function config(name) {
81792  // accessing global.localStorage can trigger a DOMException in sandboxed iframes
81793  try {
81794    if (!global.localStorage) return false;
81795  } catch (_) {
81796    return false;
81797  }
81798
81799  var val = global.localStorage[name];
81800  if (null == val) return false;
81801  return String(val).toLowerCase() === 'true';
81802}
81803
81804}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
81805
81806},{}],523:[function(require,module,exports){
81807"use strict";
81808
81809if (typeof Object.create === 'function') {
81810  // implementation from standard node.js 'util' module
81811  module.exports = function inherits(ctor, superCtor) {
81812    ctor.super_ = superCtor;
81813    ctor.prototype = Object.create(superCtor.prototype, {
81814      constructor: {
81815        value: ctor,
81816        enumerable: false,
81817        writable: true,
81818        configurable: true
81819      }
81820    });
81821  };
81822} else {
81823  // old school shim for old browsers
81824  module.exports = function inherits(ctor, superCtor) {
81825    ctor.super_ = superCtor;
81826
81827    var TempCtor = function TempCtor() {};
81828
81829    TempCtor.prototype = superCtor.prototype;
81830    ctor.prototype = new TempCtor();
81831    ctor.prototype.constructor = ctor;
81832  };
81833}
81834
81835},{}],524:[function(require,module,exports){
81836"use strict";
81837
81838function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
81839
81840module.exports = function isBuffer(arg) {
81841  return arg && _typeof(arg) === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function';
81842};
81843
81844},{}],525:[function(require,module,exports){
81845(function (process,global){
81846"use strict";
81847
81848function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
81849
81850// Copyright Joyent, Inc. and other Node contributors.
81851//
81852// Permission is hereby granted, free of charge, to any person obtaining a
81853// copy of this software and associated documentation files (the
81854// "Software"), to deal in the Software without restriction, including
81855// without limitation the rights to use, copy, modify, merge, publish,
81856// distribute, sublicense, and/or sell copies of the Software, and to permit
81857// persons to whom the Software is furnished to do so, subject to the
81858// following conditions:
81859//
81860// The above copyright notice and this permission notice shall be included
81861// in all copies or substantial portions of the Software.
81862//
81863// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
81864// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81865// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
81866// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
81867// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
81868// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
81869// USE OR OTHER DEALINGS IN THE SOFTWARE.
81870var formatRegExp = /%[sdj%]/g;
81871
81872exports.format = function (f) {
81873  if (!isString(f)) {
81874    var objects = [];
81875
81876    for (var i = 0; i < arguments.length; i++) {
81877      objects.push(inspect(arguments[i]));
81878    }
81879
81880    return objects.join(' ');
81881  }
81882
81883  var i = 1;
81884  var args = arguments;
81885  var len = args.length;
81886  var str = String(f).replace(formatRegExp, function (x) {
81887    if (x === '%%') return '%';
81888    if (i >= len) return x;
81889
81890    switch (x) {
81891      case '%s':
81892        return String(args[i++]);
81893
81894      case '%d':
81895        return Number(args[i++]);
81896
81897      case '%j':
81898        try {
81899          return JSON.stringify(args[i++]);
81900        } catch (_) {
81901          return '[Circular]';
81902        }
81903
81904      default:
81905        return x;
81906    }
81907  });
81908
81909  for (var x = args[i]; i < len; x = args[++i]) {
81910    if (isNull(x) || !isObject(x)) {
81911      str += ' ' + x;
81912    } else {
81913      str += ' ' + inspect(x);
81914    }
81915  }
81916
81917  return str;
81918}; // Mark that a method should not be used.
81919// Returns a modified function which warns once by default.
81920// If --no-deprecation is set, then it is a no-op.
81921
81922
81923exports.deprecate = function (fn, msg) {
81924  // Allow for deprecating things in the process of starting up.
81925  if (isUndefined(global.process)) {
81926    return function () {
81927      return exports.deprecate(fn, msg).apply(this, arguments);
81928    };
81929  }
81930
81931  if (process.noDeprecation === true) {
81932    return fn;
81933  }
81934
81935  var warned = false;
81936
81937  function deprecated() {
81938    if (!warned) {
81939      if (process.throwDeprecation) {
81940        throw new Error(msg);
81941      } else if (process.traceDeprecation) {
81942        console.trace(msg);
81943      } else {
81944        console.error(msg);
81945      }
81946
81947      warned = true;
81948    }
81949
81950    return fn.apply(this, arguments);
81951  }
81952
81953  return deprecated;
81954};
81955
81956var debugs = {};
81957var debugEnviron;
81958
81959exports.debuglog = function (set) {
81960  if (isUndefined(debugEnviron)) debugEnviron = process.env.NODE_DEBUG || '';
81961  set = set.toUpperCase();
81962
81963  if (!debugs[set]) {
81964    if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
81965      var pid = process.pid;
81966
81967      debugs[set] = function () {
81968        var msg = exports.format.apply(exports, arguments);
81969        console.error('%s %d: %s', set, pid, msg);
81970      };
81971    } else {
81972      debugs[set] = function () {};
81973    }
81974  }
81975
81976  return debugs[set];
81977};
81978/**
81979 * Echos the value of a value. Trys to print the value out
81980 * in the best way possible given the different types.
81981 *
81982 * @param {Object} obj The object to print out.
81983 * @param {Object} opts Optional options object that alters the output.
81984 */
81985
81986/* legacy: obj, showHidden, depth, colors*/
81987
81988
81989function inspect(obj, opts) {
81990  // default options
81991  var ctx = {
81992    seen: [],
81993    stylize: stylizeNoColor
81994  }; // legacy...
81995
81996  if (arguments.length >= 3) ctx.depth = arguments[2];
81997  if (arguments.length >= 4) ctx.colors = arguments[3];
81998
81999  if (isBoolean(opts)) {
82000    // legacy...
82001    ctx.showHidden = opts;
82002  } else if (opts) {
82003    // got an "options" object
82004    exports._extend(ctx, opts);
82005  } // set default options
82006
82007
82008  if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
82009  if (isUndefined(ctx.depth)) ctx.depth = 2;
82010  if (isUndefined(ctx.colors)) ctx.colors = false;
82011  if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
82012  if (ctx.colors) ctx.stylize = stylizeWithColor;
82013  return formatValue(ctx, obj, ctx.depth);
82014}
82015
82016exports.inspect = inspect; // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
82017
82018inspect.colors = {
82019  'bold': [1, 22],
82020  'italic': [3, 23],
82021  'underline': [4, 24],
82022  'inverse': [7, 27],
82023  'white': [37, 39],
82024  'grey': [90, 39],
82025  'black': [30, 39],
82026  'blue': [34, 39],
82027  'cyan': [36, 39],
82028  'green': [32, 39],
82029  'magenta': [35, 39],
82030  'red': [31, 39],
82031  'yellow': [33, 39]
82032}; // Don't use 'blue' not visible on cmd.exe
82033
82034inspect.styles = {
82035  'special': 'cyan',
82036  'number': 'yellow',
82037  'boolean': 'yellow',
82038  'undefined': 'grey',
82039  'null': 'bold',
82040  'string': 'green',
82041  'date': 'magenta',
82042  // "name": intentionally not styling
82043  'regexp': 'red'
82044};
82045
82046function stylizeWithColor(str, styleType) {
82047  var style = inspect.styles[styleType];
82048
82049  if (style) {
82050    return "\x1B[" + inspect.colors[style][0] + 'm' + str + "\x1B[" + inspect.colors[style][1] + 'm';
82051  } else {
82052    return str;
82053  }
82054}
82055
82056function stylizeNoColor(str, styleType) {
82057  return str;
82058}
82059
82060function arrayToHash(array) {
82061  var hash = {};
82062  array.forEach(function (val, idx) {
82063    hash[val] = true;
82064  });
82065  return hash;
82066}
82067
82068function formatValue(ctx, value, recurseTimes) {
82069  // Provide a hook for user-specified inspect functions.
82070  // Check that value is an object with an inspect function on it
82071  if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special
82072  value.inspect !== exports.inspect && // Also filter out any prototype objects using the circular check.
82073  !(value.constructor && value.constructor.prototype === value)) {
82074    var ret = value.inspect(recurseTimes, ctx);
82075
82076    if (!isString(ret)) {
82077      ret = formatValue(ctx, ret, recurseTimes);
82078    }
82079
82080    return ret;
82081  } // Primitive types cannot have properties
82082
82083
82084  var primitive = formatPrimitive(ctx, value);
82085
82086  if (primitive) {
82087    return primitive;
82088  } // Look up the keys of the object.
82089
82090
82091  var keys = Object.keys(value);
82092  var visibleKeys = arrayToHash(keys);
82093
82094  if (ctx.showHidden) {
82095    keys = Object.getOwnPropertyNames(value);
82096  } // IE doesn't make error fields non-enumerable
82097  // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
82098
82099
82100  if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
82101    return formatError(value);
82102  } // Some type of object without properties can be shortcutted.
82103
82104
82105  if (keys.length === 0) {
82106    if (isFunction(value)) {
82107      var name = value.name ? ': ' + value.name : '';
82108      return ctx.stylize('[Function' + name + ']', 'special');
82109    }
82110
82111    if (isRegExp(value)) {
82112      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
82113    }
82114
82115    if (isDate(value)) {
82116      return ctx.stylize(Date.prototype.toString.call(value), 'date');
82117    }
82118
82119    if (isError(value)) {
82120      return formatError(value);
82121    }
82122  }
82123
82124  var base = '',
82125      array = false,
82126      braces = ['{', '}']; // Make Array say that they are Array
82127
82128  if (isArray(value)) {
82129    array = true;
82130    braces = ['[', ']'];
82131  } // Make functions say that they are functions
82132
82133
82134  if (isFunction(value)) {
82135    var n = value.name ? ': ' + value.name : '';
82136    base = ' [Function' + n + ']';
82137  } // Make RegExps say that they are RegExps
82138
82139
82140  if (isRegExp(value)) {
82141    base = ' ' + RegExp.prototype.toString.call(value);
82142  } // Make dates with properties first say the date
82143
82144
82145  if (isDate(value)) {
82146    base = ' ' + Date.prototype.toUTCString.call(value);
82147  } // Make error with message first say the error
82148
82149
82150  if (isError(value)) {
82151    base = ' ' + formatError(value);
82152  }
82153
82154  if (keys.length === 0 && (!array || value.length == 0)) {
82155    return braces[0] + base + braces[1];
82156  }
82157
82158  if (recurseTimes < 0) {
82159    if (isRegExp(value)) {
82160      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
82161    } else {
82162      return ctx.stylize('[Object]', 'special');
82163    }
82164  }
82165
82166  ctx.seen.push(value);
82167  var output;
82168
82169  if (array) {
82170    output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
82171  } else {
82172    output = keys.map(function (key) {
82173      return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
82174    });
82175  }
82176
82177  ctx.seen.pop();
82178  return reduceToSingleString(output, base, braces);
82179}
82180
82181function formatPrimitive(ctx, value) {
82182  if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
82183
82184  if (isString(value)) {
82185    var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
82186    return ctx.stylize(simple, 'string');
82187  }
82188
82189  if (isNumber(value)) return ctx.stylize('' + value, 'number');
82190  if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here.
82191
82192  if (isNull(value)) return ctx.stylize('null', 'null');
82193}
82194
82195function formatError(value) {
82196  return '[' + Error.prototype.toString.call(value) + ']';
82197}
82198
82199function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
82200  var output = [];
82201
82202  for (var i = 0, l = value.length; i < l; ++i) {
82203    if (hasOwnProperty(value, String(i))) {
82204      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
82205    } else {
82206      output.push('');
82207    }
82208  }
82209
82210  keys.forEach(function (key) {
82211    if (!key.match(/^\d+$/)) {
82212      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
82213    }
82214  });
82215  return output;
82216}
82217
82218function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
82219  var name, str, desc;
82220  desc = Object.getOwnPropertyDescriptor(value, key) || {
82221    value: value[key]
82222  };
82223
82224  if (desc.get) {
82225    if (desc.set) {
82226      str = ctx.stylize('[Getter/Setter]', 'special');
82227    } else {
82228      str = ctx.stylize('[Getter]', 'special');
82229    }
82230  } else {
82231    if (desc.set) {
82232      str = ctx.stylize('[Setter]', 'special');
82233    }
82234  }
82235
82236  if (!hasOwnProperty(visibleKeys, key)) {
82237    name = '[' + key + ']';
82238  }
82239
82240  if (!str) {
82241    if (ctx.seen.indexOf(desc.value) < 0) {
82242      if (isNull(recurseTimes)) {
82243        str = formatValue(ctx, desc.value, null);
82244      } else {
82245        str = formatValue(ctx, desc.value, recurseTimes - 1);
82246      }
82247
82248      if (str.indexOf('\n') > -1) {
82249        if (array) {
82250          str = str.split('\n').map(function (line) {
82251            return '  ' + line;
82252          }).join('\n').substr(2);
82253        } else {
82254          str = '\n' + str.split('\n').map(function (line) {
82255            return '   ' + line;
82256          }).join('\n');
82257        }
82258      }
82259    } else {
82260      str = ctx.stylize('[Circular]', 'special');
82261    }
82262  }
82263
82264  if (isUndefined(name)) {
82265    if (array && key.match(/^\d+$/)) {
82266      return str;
82267    }
82268
82269    name = JSON.stringify('' + key);
82270
82271    if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
82272      name = name.substr(1, name.length - 2);
82273      name = ctx.stylize(name, 'name');
82274    } else {
82275      name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
82276      name = ctx.stylize(name, 'string');
82277    }
82278  }
82279
82280  return name + ': ' + str;
82281}
82282
82283function reduceToSingleString(output, base, braces) {
82284  var numLinesEst = 0;
82285  var length = output.reduce(function (prev, cur) {
82286    numLinesEst++;
82287    if (cur.indexOf('\n') >= 0) numLinesEst++;
82288    return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
82289  }, 0);
82290
82291  if (length > 60) {
82292    return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n  ') + ' ' + braces[1];
82293  }
82294
82295  return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
82296} // NOTE: These type checking functions intentionally don't use `instanceof`
82297// because it is fragile and can be easily faked with `Object.create()`.
82298
82299
82300function isArray(ar) {
82301  return Array.isArray(ar);
82302}
82303
82304exports.isArray = isArray;
82305
82306function isBoolean(arg) {
82307  return typeof arg === 'boolean';
82308}
82309
82310exports.isBoolean = isBoolean;
82311
82312function isNull(arg) {
82313  return arg === null;
82314}
82315
82316exports.isNull = isNull;
82317
82318function isNullOrUndefined(arg) {
82319  return arg == null;
82320}
82321
82322exports.isNullOrUndefined = isNullOrUndefined;
82323
82324function isNumber(arg) {
82325  return typeof arg === 'number';
82326}
82327
82328exports.isNumber = isNumber;
82329
82330function isString(arg) {
82331  return typeof arg === 'string';
82332}
82333
82334exports.isString = isString;
82335
82336function isSymbol(arg) {
82337  return _typeof(arg) === 'symbol';
82338}
82339
82340exports.isSymbol = isSymbol;
82341
82342function isUndefined(arg) {
82343  return arg === void 0;
82344}
82345
82346exports.isUndefined = isUndefined;
82347
82348function isRegExp(re) {
82349  return isObject(re) && objectToString(re) === '[object RegExp]';
82350}
82351
82352exports.isRegExp = isRegExp;
82353
82354function isObject(arg) {
82355  return _typeof(arg) === 'object' && arg !== null;
82356}
82357
82358exports.isObject = isObject;
82359
82360function isDate(d) {
82361  return isObject(d) && objectToString(d) === '[object Date]';
82362}
82363
82364exports.isDate = isDate;
82365
82366function isError(e) {
82367  return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error);
82368}
82369
82370exports.isError = isError;
82371
82372function isFunction(arg) {
82373  return typeof arg === 'function';
82374}
82375
82376exports.isFunction = isFunction;
82377
82378function isPrimitive(arg) {
82379  return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || _typeof(arg) === 'symbol' || // ES6 symbol
82380  typeof arg === 'undefined';
82381}
82382
82383exports.isPrimitive = isPrimitive;
82384exports.isBuffer = require('./support/isBuffer');
82385
82386function objectToString(o) {
82387  return Object.prototype.toString.call(o);
82388}
82389
82390function pad(n) {
82391  return n < 10 ? '0' + n.toString(10) : n.toString(10);
82392}
82393
82394var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // 26 Feb 16:19:34
82395
82396function timestamp() {
82397  var d = new Date();
82398  var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':');
82399  return [d.getDate(), months[d.getMonth()], time].join(' ');
82400} // log is just a thin wrapper to console.log that prepends a timestamp
82401
82402
82403exports.log = function () {
82404  console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
82405};
82406/**
82407 * Inherit the prototype methods from one constructor into another.
82408 *
82409 * The Function.prototype.inherits from lang.js rewritten as a standalone
82410 * function (not on Function.prototype). NOTE: If this file is to be loaded
82411 * during bootstrapping this function needs to be rewritten using some native
82412 * functions as prototype setup using normal JavaScript does not work as
82413 * expected during bootstrapping (see mirror.js in r114903).
82414 *
82415 * @param {function} ctor Constructor function which needs to inherit the
82416 *     prototype.
82417 * @param {function} superCtor Constructor function to inherit prototype from.
82418 */
82419
82420
82421exports.inherits = require('inherits');
82422
82423exports._extend = function (origin, add) {
82424  // Don't do anything if add isn't an object
82425  if (!add || !isObject(add)) return origin;
82426  var keys = Object.keys(add);
82427  var i = keys.length;
82428
82429  while (i--) {
82430    origin[keys[i]] = add[keys[i]];
82431  }
82432
82433  return origin;
82434};
82435
82436function hasOwnProperty(obj, prop) {
82437  return Object.prototype.hasOwnProperty.call(obj, prop);
82438}
82439
82440}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
82441
82442},{"./support/isBuffer":524,"_process":467,"inherits":523}],526:[function(require,module,exports){
82443"use strict";
82444
82445Object.defineProperty(exports, "__esModule", {
82446  value: true
82447});
82448Object.defineProperty(exports, "v1", {
82449  enumerable: true,
82450  get: function get() {
82451    return _v.default;
82452  }
82453});
82454Object.defineProperty(exports, "v3", {
82455  enumerable: true,
82456  get: function get() {
82457    return _v2.default;
82458  }
82459});
82460Object.defineProperty(exports, "v4", {
82461  enumerable: true,
82462  get: function get() {
82463    return _v3.default;
82464  }
82465});
82466Object.defineProperty(exports, "v5", {
82467  enumerable: true,
82468  get: function get() {
82469    return _v4.default;
82470  }
82471});
82472Object.defineProperty(exports, "NIL", {
82473  enumerable: true,
82474  get: function get() {
82475    return _nil.default;
82476  }
82477});
82478Object.defineProperty(exports, "version", {
82479  enumerable: true,
82480  get: function get() {
82481    return _version.default;
82482  }
82483});
82484Object.defineProperty(exports, "validate", {
82485  enumerable: true,
82486  get: function get() {
82487    return _validate.default;
82488  }
82489});
82490Object.defineProperty(exports, "stringify", {
82491  enumerable: true,
82492  get: function get() {
82493    return _stringify.default;
82494  }
82495});
82496Object.defineProperty(exports, "parse", {
82497  enumerable: true,
82498  get: function get() {
82499    return _parse.default;
82500  }
82501});
82502
82503var _v = _interopRequireDefault(require("./v1.js"));
82504
82505var _v2 = _interopRequireDefault(require("./v3.js"));
82506
82507var _v3 = _interopRequireDefault(require("./v4.js"));
82508
82509var _v4 = _interopRequireDefault(require("./v5.js"));
82510
82511var _nil = _interopRequireDefault(require("./nil.js"));
82512
82513var _version = _interopRequireDefault(require("./version.js"));
82514
82515var _validate = _interopRequireDefault(require("./validate.js"));
82516
82517var _stringify = _interopRequireDefault(require("./stringify.js"));
82518
82519var _parse = _interopRequireDefault(require("./parse.js"));
82520
82521function _interopRequireDefault(obj) {
82522  return obj && obj.__esModule ? obj : {
82523    default: obj
82524  };
82525}
82526
82527},{"./nil.js":528,"./parse.js":529,"./stringify.js":533,"./v1.js":534,"./v3.js":535,"./v4.js":537,"./v5.js":538,"./validate.js":539,"./version.js":540}],527:[function(require,module,exports){
82528"use strict";
82529
82530Object.defineProperty(exports, "__esModule", {
82531  value: true
82532});
82533exports.default = void 0;
82534/*
82535 * Browser-compatible JavaScript MD5
82536 *
82537 * Modification of JavaScript MD5
82538 * https://github.com/blueimp/JavaScript-MD5
82539 *
82540 * Copyright 2011, Sebastian Tschan
82541 * https://blueimp.net
82542 *
82543 * Licensed under the MIT license:
82544 * https://opensource.org/licenses/MIT
82545 *
82546 * Based on
82547 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
82548 * Digest Algorithm, as defined in RFC 1321.
82549 * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
82550 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
82551 * Distributed under the BSD License
82552 * See http://pajhome.org.uk/crypt/md5 for more info.
82553 */
82554
82555function md5(bytes) {
82556  if (typeof bytes === 'string') {
82557    var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
82558
82559    bytes = new Uint8Array(msg.length);
82560
82561    for (var i = 0; i < msg.length; ++i) {
82562      bytes[i] = msg.charCodeAt(i);
82563    }
82564  }
82565
82566  return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
82567}
82568/*
82569 * Convert an array of little-endian words to an array of bytes
82570 */
82571
82572
82573function md5ToHexEncodedArray(input) {
82574  var output = [];
82575  var length32 = input.length * 32;
82576  var hexTab = '0123456789abcdef';
82577
82578  for (var i = 0; i < length32; i += 8) {
82579    var x = input[i >> 5] >>> i % 32 & 0xff;
82580    var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
82581    output.push(hex);
82582  }
82583
82584  return output;
82585}
82586/**
82587 * Calculate output length with padding and bit length
82588 */
82589
82590
82591function getOutputLength(inputLength8) {
82592  return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
82593}
82594/*
82595 * Calculate the MD5 of an array of little-endian words, and a bit length.
82596 */
82597
82598
82599function wordsToMd5(x, len) {
82600  /* append padding */
82601  x[len >> 5] |= 0x80 << len % 32;
82602  x[getOutputLength(len) - 1] = len;
82603  var a = 1732584193;
82604  var b = -271733879;
82605  var c = -1732584194;
82606  var d = 271733878;
82607
82608  for (var i = 0; i < x.length; i += 16) {
82609    var olda = a;
82610    var oldb = b;
82611    var oldc = c;
82612    var oldd = d;
82613    a = md5ff(a, b, c, d, x[i], 7, -680876936);
82614    d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
82615    c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
82616    b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
82617    a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
82618    d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
82619    c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
82620    b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
82621    a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
82622    d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
82623    c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
82624    b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
82625    a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
82626    d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
82627    c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
82628    b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
82629    a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
82630    d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
82631    c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
82632    b = md5gg(b, c, d, a, x[i], 20, -373897302);
82633    a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
82634    d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
82635    c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
82636    b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
82637    a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
82638    d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
82639    c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
82640    b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
82641    a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
82642    d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
82643    c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
82644    b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
82645    a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
82646    d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
82647    c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
82648    b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
82649    a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
82650    d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
82651    c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
82652    b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
82653    a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
82654    d = md5hh(d, a, b, c, x[i], 11, -358537222);
82655    c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
82656    b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
82657    a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
82658    d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
82659    c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
82660    b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
82661    a = md5ii(a, b, c, d, x[i], 6, -198630844);
82662    d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
82663    c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
82664    b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
82665    a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
82666    d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
82667    c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
82668    b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
82669    a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
82670    d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
82671    c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
82672    b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
82673    a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
82674    d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
82675    c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
82676    b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
82677    a = safeAdd(a, olda);
82678    b = safeAdd(b, oldb);
82679    c = safeAdd(c, oldc);
82680    d = safeAdd(d, oldd);
82681  }
82682
82683  return [a, b, c, d];
82684}
82685/*
82686 * Convert an array bytes to an array of little-endian words
82687 * Characters >255 have their high-byte silently ignored.
82688 */
82689
82690
82691function bytesToWords(input) {
82692  if (input.length === 0) {
82693    return [];
82694  }
82695
82696  var length8 = input.length * 8;
82697  var output = new Uint32Array(getOutputLength(length8));
82698
82699  for (var i = 0; i < length8; i += 8) {
82700    output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
82701  }
82702
82703  return output;
82704}
82705/*
82706 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
82707 * to work around bugs in some JS interpreters.
82708 */
82709
82710
82711function safeAdd(x, y) {
82712  var lsw = (x & 0xffff) + (y & 0xffff);
82713  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
82714  return msw << 16 | lsw & 0xffff;
82715}
82716/*
82717 * Bitwise rotate a 32-bit number to the left.
82718 */
82719
82720
82721function bitRotateLeft(num, cnt) {
82722  return num << cnt | num >>> 32 - cnt;
82723}
82724/*
82725 * These functions implement the four basic operations the algorithm uses.
82726 */
82727
82728
82729function md5cmn(q, a, b, x, s, t) {
82730  return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
82731}
82732
82733function md5ff(a, b, c, d, x, s, t) {
82734  return md5cmn(b & c | ~b & d, a, b, x, s, t);
82735}
82736
82737function md5gg(a, b, c, d, x, s, t) {
82738  return md5cmn(b & d | c & ~d, a, b, x, s, t);
82739}
82740
82741function md5hh(a, b, c, d, x, s, t) {
82742  return md5cmn(b ^ c ^ d, a, b, x, s, t);
82743}
82744
82745function md5ii(a, b, c, d, x, s, t) {
82746  return md5cmn(c ^ (b | ~d), a, b, x, s, t);
82747}
82748
82749var _default = md5;
82750exports.default = _default;
82751
82752},{}],528:[function(require,module,exports){
82753"use strict";
82754
82755Object.defineProperty(exports, "__esModule", {
82756  value: true
82757});
82758exports.default = void 0;
82759var _default = '00000000-0000-0000-0000-000000000000';
82760exports.default = _default;
82761
82762},{}],529:[function(require,module,exports){
82763"use strict";
82764
82765Object.defineProperty(exports, "__esModule", {
82766  value: true
82767});
82768exports.default = void 0;
82769
82770var _validate = _interopRequireDefault(require("./validate.js"));
82771
82772function _interopRequireDefault(obj) {
82773  return obj && obj.__esModule ? obj : {
82774    default: obj
82775  };
82776}
82777
82778function parse(uuid) {
82779  if (!(0, _validate.default)(uuid)) {
82780    throw TypeError('Invalid UUID');
82781  }
82782
82783  var v;
82784  var arr = new Uint8Array(16); // Parse ########-....-....-....-............
82785
82786  arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
82787  arr[1] = v >>> 16 & 0xff;
82788  arr[2] = v >>> 8 & 0xff;
82789  arr[3] = v & 0xff; // Parse ........-####-....-....-............
82790
82791  arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
82792  arr[5] = v & 0xff; // Parse ........-....-####-....-............
82793
82794  arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
82795  arr[7] = v & 0xff; // Parse ........-....-....-####-............
82796
82797  arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
82798  arr[9] = v & 0xff; // Parse ........-....-....-....-############
82799  // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
82800
82801  arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
82802  arr[11] = v / 0x100000000 & 0xff;
82803  arr[12] = v >>> 24 & 0xff;
82804  arr[13] = v >>> 16 & 0xff;
82805  arr[14] = v >>> 8 & 0xff;
82806  arr[15] = v & 0xff;
82807  return arr;
82808}
82809
82810var _default = parse;
82811exports.default = _default;
82812
82813},{"./validate.js":539}],530:[function(require,module,exports){
82814"use strict";
82815
82816Object.defineProperty(exports, "__esModule", {
82817  value: true
82818});
82819exports.default = void 0;
82820var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
82821exports.default = _default;
82822
82823},{}],531:[function(require,module,exports){
82824"use strict";
82825
82826Object.defineProperty(exports, "__esModule", {
82827  value: true
82828});
82829exports.default = rng; // Unique ID creation requires a high quality random # generator. In the browser we therefore
82830// require the crypto API and do not support built-in fallback to lower quality random number
82831// generators (like Math.random()).
82832// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
82833// find the complete implementation of crypto (msCrypto) on IE11.
82834
82835var getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
82836var rnds8 = new Uint8Array(16);
82837
82838function rng() {
82839  if (!getRandomValues) {
82840    throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
82841  }
82842
82843  return getRandomValues(rnds8);
82844}
82845
82846},{}],532:[function(require,module,exports){
82847"use strict";
82848
82849Object.defineProperty(exports, "__esModule", {
82850  value: true
82851});
82852exports.default = void 0; // Adapted from Chris Veness' SHA1 code at
82853// http://www.movable-type.co.uk/scripts/sha1.html
82854
82855function f(s, x, y, z) {
82856  switch (s) {
82857    case 0:
82858      return x & y ^ ~x & z;
82859
82860    case 1:
82861      return x ^ y ^ z;
82862
82863    case 2:
82864      return x & y ^ x & z ^ y & z;
82865
82866    case 3:
82867      return x ^ y ^ z;
82868  }
82869}
82870
82871function ROTL(x, n) {
82872  return x << n | x >>> 32 - n;
82873}
82874
82875function sha1(bytes) {
82876  var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
82877  var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
82878
82879  if (typeof bytes === 'string') {
82880    var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
82881
82882    bytes = [];
82883
82884    for (var i = 0; i < msg.length; ++i) {
82885      bytes.push(msg.charCodeAt(i));
82886    }
82887  } else if (!Array.isArray(bytes)) {
82888    // Convert Array-like to Array
82889    bytes = Array.prototype.slice.call(bytes);
82890  }
82891
82892  bytes.push(0x80);
82893  var l = bytes.length / 4 + 2;
82894  var N = Math.ceil(l / 16);
82895  var M = new Array(N);
82896
82897  for (var _i = 0; _i < N; ++_i) {
82898    var arr = new Uint32Array(16);
82899
82900    for (var j = 0; j < 16; ++j) {
82901      arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
82902    }
82903
82904    M[_i] = arr;
82905  }
82906
82907  M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
82908  M[N - 1][14] = Math.floor(M[N - 1][14]);
82909  M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
82910
82911  for (var _i2 = 0; _i2 < N; ++_i2) {
82912    var W = new Uint32Array(80);
82913
82914    for (var t = 0; t < 16; ++t) {
82915      W[t] = M[_i2][t];
82916    }
82917
82918    for (var _t = 16; _t < 80; ++_t) {
82919      W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
82920    }
82921
82922    var a = H[0];
82923    var b = H[1];
82924    var c = H[2];
82925    var d = H[3];
82926    var e = H[4];
82927
82928    for (var _t2 = 0; _t2 < 80; ++_t2) {
82929      var s = Math.floor(_t2 / 20);
82930      var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
82931      e = d;
82932      d = c;
82933      c = ROTL(b, 30) >>> 0;
82934      b = a;
82935      a = T;
82936    }
82937
82938    H[0] = H[0] + a >>> 0;
82939    H[1] = H[1] + b >>> 0;
82940    H[2] = H[2] + c >>> 0;
82941    H[3] = H[3] + d >>> 0;
82942    H[4] = H[4] + e >>> 0;
82943  }
82944
82945  return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
82946}
82947
82948var _default = sha1;
82949exports.default = _default;
82950
82951},{}],533:[function(require,module,exports){
82952"use strict";
82953
82954Object.defineProperty(exports, "__esModule", {
82955  value: true
82956});
82957exports.default = void 0;
82958
82959var _validate = _interopRequireDefault(require("./validate.js"));
82960
82961function _interopRequireDefault(obj) {
82962  return obj && obj.__esModule ? obj : {
82963    default: obj
82964  };
82965}
82966/**
82967 * Convert array of 16 byte values to UUID string format of the form:
82968 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
82969 */
82970
82971
82972var byteToHex = [];
82973
82974for (var i = 0; i < 256; ++i) {
82975  byteToHex.push((i + 0x100).toString(16).substr(1));
82976}
82977
82978function stringify(arr) {
82979  var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
82980  // Note: Be careful editing this code!  It's been tuned for performance
82981  // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
82982  var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID.  If this throws, it's likely due to one
82983  // of the following:
82984  // - One or more input array values don't map to a hex octet (leading to
82985  // "undefined" in the uuid)
82986  // - Invalid input values for the RFC `version` or `variant` fields
82987
82988  if (!(0, _validate.default)(uuid)) {
82989    throw TypeError('Stringified UUID is invalid');
82990  }
82991
82992  return uuid;
82993}
82994
82995var _default = stringify;
82996exports.default = _default;
82997
82998},{"./validate.js":539}],534:[function(require,module,exports){
82999"use strict";
83000
83001Object.defineProperty(exports, "__esModule", {
83002  value: true
83003});
83004exports.default = void 0;
83005
83006var _rng = _interopRequireDefault(require("./rng.js"));
83007
83008var _stringify = _interopRequireDefault(require("./stringify.js"));
83009
83010function _interopRequireDefault(obj) {
83011  return obj && obj.__esModule ? obj : {
83012    default: obj
83013  };
83014} // **`v1()` - Generate time-based UUID**
83015//
83016// Inspired by https://github.com/LiosK/UUID.js
83017// and http://docs.python.org/library/uuid.html
83018
83019
83020var _nodeId;
83021
83022var _clockseq; // Previous uuid creation time
83023
83024
83025var _lastMSecs = 0;
83026var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
83027
83028function v1(options, buf, offset) {
83029  var i = buf && offset || 0;
83030  var b = buf || new Array(16);
83031  options = options || {};
83032  var node = options.node || _nodeId;
83033  var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
83034  // specified.  We do this lazily to minimize issues related to insufficient
83035  // system entropy.  See #189
83036
83037  if (node == null || clockseq == null) {
83038    var seedBytes = options.random || (options.rng || _rng.default)();
83039
83040    if (node == null) {
83041      // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
83042      node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
83043    }
83044
83045    if (clockseq == null) {
83046      // Per 4.2.2, randomize (14 bit) clockseq
83047      clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
83048    }
83049  } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
83050  // (1582-10-15 00:00).  JSNumbers aren't precise enough for this, so
83051  // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
83052  // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
83053
83054
83055  var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
83056  // cycle to simulate higher resolution clock
83057
83058  var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
83059
83060  var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
83061
83062  if (dt < 0 && options.clockseq === undefined) {
83063    clockseq = clockseq + 1 & 0x3fff;
83064  } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
83065  // time interval
83066
83067
83068  if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
83069    nsecs = 0;
83070  } // Per 4.2.1.2 Throw error if too many uuids are requested
83071
83072
83073  if (nsecs >= 10000) {
83074    throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
83075  }
83076
83077  _lastMSecs = msecs;
83078  _lastNSecs = nsecs;
83079  _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
83080
83081  msecs += 12219292800000; // `time_low`
83082
83083  var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
83084  b[i++] = tl >>> 24 & 0xff;
83085  b[i++] = tl >>> 16 & 0xff;
83086  b[i++] = tl >>> 8 & 0xff;
83087  b[i++] = tl & 0xff; // `time_mid`
83088
83089  var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
83090  b[i++] = tmh >>> 8 & 0xff;
83091  b[i++] = tmh & 0xff; // `time_high_and_version`
83092
83093  b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
83094
83095  b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
83096
83097  b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
83098
83099  b[i++] = clockseq & 0xff; // `node`
83100
83101  for (var n = 0; n < 6; ++n) {
83102    b[i + n] = node[n];
83103  }
83104
83105  return buf || (0, _stringify.default)(b);
83106}
83107
83108var _default = v1;
83109exports.default = _default;
83110
83111},{"./rng.js":531,"./stringify.js":533}],535:[function(require,module,exports){
83112"use strict";
83113
83114Object.defineProperty(exports, "__esModule", {
83115  value: true
83116});
83117exports.default = void 0;
83118
83119var _v = _interopRequireDefault(require("./v35.js"));
83120
83121var _md = _interopRequireDefault(require("./md5.js"));
83122
83123function _interopRequireDefault(obj) {
83124  return obj && obj.__esModule ? obj : {
83125    default: obj
83126  };
83127}
83128
83129var v3 = (0, _v.default)('v3', 0x30, _md.default);
83130var _default = v3;
83131exports.default = _default;
83132
83133},{"./md5.js":527,"./v35.js":536}],536:[function(require,module,exports){
83134"use strict";
83135
83136Object.defineProperty(exports, "__esModule", {
83137  value: true
83138});
83139exports.default = _default;
83140exports.URL = exports.DNS = void 0;
83141
83142var _stringify = _interopRequireDefault(require("./stringify.js"));
83143
83144var _parse = _interopRequireDefault(require("./parse.js"));
83145
83146function _interopRequireDefault(obj) {
83147  return obj && obj.__esModule ? obj : {
83148    default: obj
83149  };
83150}
83151
83152function stringToBytes(str) {
83153  str = unescape(encodeURIComponent(str)); // UTF8 escape
83154
83155  var bytes = [];
83156
83157  for (var i = 0; i < str.length; ++i) {
83158    bytes.push(str.charCodeAt(i));
83159  }
83160
83161  return bytes;
83162}
83163
83164var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
83165exports.DNS = DNS;
83166var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
83167exports.URL = URL;
83168
83169function _default(name, version, hashfunc) {
83170  function generateUUID(value, namespace, buf, offset) {
83171    if (typeof value === 'string') {
83172      value = stringToBytes(value);
83173    }
83174
83175    if (typeof namespace === 'string') {
83176      namespace = (0, _parse.default)(namespace);
83177    }
83178
83179    if (namespace.length !== 16) {
83180      throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
83181    } // Compute hash of namespace and value, Per 4.3
83182    // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
83183    // hashfunc([...namespace, ... value])`
83184
83185
83186    var bytes = new Uint8Array(16 + value.length);
83187    bytes.set(namespace);
83188    bytes.set(value, namespace.length);
83189    bytes = hashfunc(bytes);
83190    bytes[6] = bytes[6] & 0x0f | version;
83191    bytes[8] = bytes[8] & 0x3f | 0x80;
83192
83193    if (buf) {
83194      offset = offset || 0;
83195
83196      for (var i = 0; i < 16; ++i) {
83197        buf[offset + i] = bytes[i];
83198      }
83199
83200      return buf;
83201    }
83202
83203    return (0, _stringify.default)(bytes);
83204  } // Function#name is not settable on some platforms (#270)
83205
83206
83207  try {
83208    generateUUID.name = name; // eslint-disable-next-line no-empty
83209  } catch (err) {} // For CommonJS default export support
83210
83211
83212  generateUUID.DNS = DNS;
83213  generateUUID.URL = URL;
83214  return generateUUID;
83215}
83216
83217},{"./parse.js":529,"./stringify.js":533}],537:[function(require,module,exports){
83218"use strict";
83219
83220Object.defineProperty(exports, "__esModule", {
83221  value: true
83222});
83223exports.default = void 0;
83224
83225var _rng = _interopRequireDefault(require("./rng.js"));
83226
83227var _stringify = _interopRequireDefault(require("./stringify.js"));
83228
83229function _interopRequireDefault(obj) {
83230  return obj && obj.__esModule ? obj : {
83231    default: obj
83232  };
83233}
83234
83235function v4(options, buf, offset) {
83236  options = options || {};
83237
83238  var rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
83239
83240
83241  rnds[6] = rnds[6] & 0x0f | 0x40;
83242  rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
83243
83244  if (buf) {
83245    offset = offset || 0;
83246
83247    for (var i = 0; i < 16; ++i) {
83248      buf[offset + i] = rnds[i];
83249    }
83250
83251    return buf;
83252  }
83253
83254  return (0, _stringify.default)(rnds);
83255}
83256
83257var _default = v4;
83258exports.default = _default;
83259
83260},{"./rng.js":531,"./stringify.js":533}],538:[function(require,module,exports){
83261"use strict";
83262
83263Object.defineProperty(exports, "__esModule", {
83264  value: true
83265});
83266exports.default = void 0;
83267
83268var _v = _interopRequireDefault(require("./v35.js"));
83269
83270var _sha = _interopRequireDefault(require("./sha1.js"));
83271
83272function _interopRequireDefault(obj) {
83273  return obj && obj.__esModule ? obj : {
83274    default: obj
83275  };
83276}
83277
83278var v5 = (0, _v.default)('v5', 0x50, _sha.default);
83279var _default = v5;
83280exports.default = _default;
83281
83282},{"./sha1.js":532,"./v35.js":536}],539:[function(require,module,exports){
83283"use strict";
83284
83285Object.defineProperty(exports, "__esModule", {
83286  value: true
83287});
83288exports.default = void 0;
83289
83290var _regex = _interopRequireDefault(require("./regex.js"));
83291
83292function _interopRequireDefault(obj) {
83293  return obj && obj.__esModule ? obj : {
83294    default: obj
83295  };
83296}
83297
83298function validate(uuid) {
83299  return typeof uuid === 'string' && _regex.default.test(uuid);
83300}
83301
83302var _default = validate;
83303exports.default = _default;
83304
83305},{"./regex.js":530}],540:[function(require,module,exports){
83306"use strict";
83307
83308Object.defineProperty(exports, "__esModule", {
83309  value: true
83310});
83311exports.default = void 0;
83312
83313var _validate = _interopRequireDefault(require("./validate.js"));
83314
83315function _interopRequireDefault(obj) {
83316  return obj && obj.__esModule ? obj : {
83317    default: obj
83318  };
83319}
83320
83321function version(uuid) {
83322  if (!(0, _validate.default)(uuid)) {
83323    throw TypeError('Invalid UUID');
83324  }
83325
83326  return parseInt(uuid.substr(14, 1), 16);
83327}
83328
83329var _default = version;
83330exports.default = _default;
83331
83332},{"./validate.js":539}],541:[function(require,module,exports){
83333"use strict";
83334/**
83335 * Character classes and associated utilities for the 5th edition of XML 1.0.
83336 *
83337 * @author Louis-Dominique Dubeau
83338 * @license MIT
83339 * @copyright Louis-Dominique Dubeau
83340 */
83341
83342Object.defineProperty(exports, "__esModule", {
83343  value: true
83344}); //
83345// Fragments.
83346//
83347
83348exports.CHAR = "\t\n\r -\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF";
83349exports.S = " \t\r\n"; // tslint:disable-next-line:max-line-length
83350
83351exports.NAME_START_CHAR = ":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\uD800\uDC00-\uDB7F\uDFFF";
83352exports.NAME_CHAR = "-" + exports.NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040"; //
83353// Regular expressions.
83354//
83355
83356exports.CHAR_RE = new RegExp("^[" + exports.CHAR + "]$", "u");
83357exports.S_RE = new RegExp("^[" + exports.S + "]+$", "u");
83358exports.NAME_START_CHAR_RE = new RegExp("^[" + exports.NAME_START_CHAR + "]$", "u");
83359exports.NAME_CHAR_RE = new RegExp("^[" + exports.NAME_CHAR + "]$", "u");
83360exports.NAME_RE = new RegExp("^[" + exports.NAME_START_CHAR + "][" + exports.NAME_CHAR + "]*$", "u");
83361exports.NMTOKEN_RE = new RegExp("^[" + exports.NAME_CHAR + "]+$", "u");
83362var TAB = 9;
83363var NL = 0xA;
83364var CR = 0xD;
83365var SPACE = 0x20; //
83366// Lists.
83367//
83368
83369/** All characters in the ``S`` production. */
83370
83371exports.S_LIST = [SPACE, NL, CR, TAB];
83372/**
83373 * Determines whether a codepoint matches the ``CHAR`` production.
83374 *
83375 * @param c The code point.
83376 *
83377 * @returns ``true`` if the codepoint matches ``CHAR``.
83378 */
83379
83380function isChar(c) {
83381  return c >= SPACE && c <= 0xD7FF || c === NL || c === CR || c === TAB || c >= 0xE000 && c <= 0xFFFD || c >= 0x10000 && c <= 0x10FFFF;
83382}
83383
83384exports.isChar = isChar;
83385/**
83386 * Determines whether a codepoint matches the ``S`` (space) production.
83387 *
83388 * @param c The code point.
83389 *
83390 * @returns ``true`` if the codepoint matches ``S``.
83391 */
83392
83393function isS(c) {
83394  return c === SPACE || c === NL || c === CR || c === TAB;
83395}
83396
83397exports.isS = isS;
83398/**
83399 * Determines whether a codepoint matches the ``NAME_START_CHAR`` production.
83400 *
83401 * @param c The code point.
83402 *
83403 * @returns ``true`` if the codepoint matches ``NAME_START_CHAR``.
83404 */
83405
83406function isNameStartChar(c) {
83407  return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A || c === 0x3A || c === 0x5F || c === 0x200C || c === 0x200D || c >= 0xC0 && c <= 0xD6 || c >= 0xD8 && c <= 0xF6 || c >= 0x00F8 && c <= 0x02FF || c >= 0x0370 && c <= 0x037D || c >= 0x037F && c <= 0x1FFF || c >= 0x2070 && c <= 0x218F || c >= 0x2C00 && c <= 0x2FEF || c >= 0x3001 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF || c >= 0xFDF0 && c <= 0xFFFD || c >= 0x10000 && c <= 0xEFFFF;
83408}
83409
83410exports.isNameStartChar = isNameStartChar;
83411/**
83412 * Determines whether a codepoint matches the ``NAME_CHAR`` production.
83413 *
83414 * @param c The code point.
83415 *
83416 * @returns ``true`` if the codepoint matches ``NAME_CHAR``.
83417 */
83418
83419function isNameChar(c) {
83420  return isNameStartChar(c) || c >= 0x30 && c <= 0x39 || c === 0x2D || c === 0x2E || c === 0xB7 || c >= 0x0300 && c <= 0x036F || c >= 0x203F && c <= 0x2040;
83421}
83422
83423exports.isNameChar = isNameChar;
83424
83425},{}],542:[function(require,module,exports){
83426"use strict";
83427/**
83428 * Character classes and associated utilities for the 2nd edition of XML 1.1.
83429 *
83430 * @author Louis-Dominique Dubeau
83431 * @license MIT
83432 * @copyright Louis-Dominique Dubeau
83433 */
83434
83435Object.defineProperty(exports, "__esModule", {
83436  value: true
83437}); //
83438// Fragments.
83439//
83440
83441exports.CHAR = "\x01-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF";
83442exports.RESTRICTED_CHAR = "\x01-\b\x0B\f\x0E-\x1F\x7F-\x84\x86-\x9F";
83443exports.S = " \t\r\n"; // tslint:disable-next-line:max-line-length
83444
83445exports.NAME_START_CHAR = ":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\uD800\uDC00-\uDB7F\uDFFF";
83446exports.NAME_CHAR = "-" + exports.NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040"; //
83447// Regular expressions.
83448//
83449
83450exports.CHAR_RE = new RegExp("^[" + exports.CHAR + "]$", "u");
83451exports.RESTRICTED_CHAR_RE = new RegExp("^[" + exports.RESTRICTED_CHAR + "]$", "u");
83452exports.S_RE = new RegExp("^[" + exports.S + "]+$", "u");
83453exports.NAME_START_CHAR_RE = new RegExp("^[" + exports.NAME_START_CHAR + "]$", "u");
83454exports.NAME_CHAR_RE = new RegExp("^[" + exports.NAME_CHAR + "]$", "u");
83455exports.NAME_RE = new RegExp("^[" + exports.NAME_START_CHAR + "][" + exports.NAME_CHAR + "]*$", "u");
83456exports.NMTOKEN_RE = new RegExp("^[" + exports.NAME_CHAR + "]+$", "u");
83457var TAB = 9;
83458var NL = 0xA;
83459var CR = 0xD;
83460var SPACE = 0x20; //
83461// Lists.
83462//
83463
83464/** All characters in the ``S`` production. */
83465
83466exports.S_LIST = [SPACE, NL, CR, TAB];
83467/**
83468 * Determines whether a codepoint matches the ``CHAR`` production.
83469 *
83470 * @param c The code point.
83471 *
83472 * @returns ``true`` if the codepoint matches ``CHAR``.
83473 */
83474
83475function isChar(c) {
83476  return c >= 0x0001 && c <= 0xD7FF || c >= 0xE000 && c <= 0xFFFD || c >= 0x10000 && c <= 0x10FFFF;
83477}
83478
83479exports.isChar = isChar;
83480/**
83481 * Determines whether a codepoint matches the ``RESTRICTED_CHAR`` production.
83482 *
83483 * @param c The code point.
83484 *
83485 * @returns ``true`` if the codepoint matches ``RESTRICTED_CHAR``.
83486 */
83487
83488function isRestrictedChar(c) {
83489  return c >= 0x1 && c <= 0x8 || c === 0xB || c === 0xC || c >= 0xE && c <= 0x1F || c >= 0x7F && c <= 0x84 || c >= 0x86 && c <= 0x9F;
83490}
83491
83492exports.isRestrictedChar = isRestrictedChar;
83493/**
83494 * Determines whether a codepoint matches the ``CHAR`` production and does not
83495 * match the ``RESTRICTED_CHAR`` production. ``isCharAndNotRestricted(x)`` is
83496 * equivalent to ``isChar(x) && !isRestrictedChar(x)``. This function is faster
83497 * than running the two-call equivalent.
83498 *
83499 * @param c The code point.
83500 *
83501 * @returns ``true`` if the codepoint matches ``CHAR`` and does not match
83502 * ``RESTRICTED_CHAR``.
83503 */
83504
83505function isCharAndNotRestricted(c) {
83506  return c === 0x9 || c === 0xA || c === 0xD || c > 0x1F && c < 0x7F || c === 0x85 || c > 0x9F && c <= 0xD7FF || c >= 0xE000 && c <= 0xFFFD || c >= 0x10000 && c <= 0x10FFFF;
83507}
83508
83509exports.isCharAndNotRestricted = isCharAndNotRestricted;
83510/**
83511 * Determines whether a codepoint matches the ``S`` (space) production.
83512 *
83513 * @param c The code point.
83514 *
83515 * @returns ``true`` if the codepoint matches ``S``.
83516 */
83517
83518function isS(c) {
83519  return c === SPACE || c === NL || c === CR || c === TAB;
83520}
83521
83522exports.isS = isS;
83523/**
83524 * Determines whether a codepoint matches the ``NAME_START_CHAR`` production.
83525 *
83526 * @param c The code point.
83527 *
83528 * @returns ``true`` if the codepoint matches ``NAME_START_CHAR``.
83529 */
83530// tslint:disable-next-line:cyclomatic-complexity
83531
83532function isNameStartChar(c) {
83533  return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A || c === 0x3A || c === 0x5F || c === 0x200C || c === 0x200D || c >= 0xC0 && c <= 0xD6 || c >= 0xD8 && c <= 0xF6 || c >= 0x00F8 && c <= 0x02FF || c >= 0x0370 && c <= 0x037D || c >= 0x037F && c <= 0x1FFF || c >= 0x2070 && c <= 0x218F || c >= 0x2C00 && c <= 0x2FEF || c >= 0x3001 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF || c >= 0xFDF0 && c <= 0xFFFD || c >= 0x10000 && c <= 0xEFFFF;
83534}
83535
83536exports.isNameStartChar = isNameStartChar;
83537/**
83538 * Determines whether a codepoint matches the ``NAME_CHAR`` production.
83539 *
83540 * @param c The code point.
83541 *
83542 * @returns ``true`` if the codepoint matches ``NAME_CHAR``.
83543 */
83544
83545function isNameChar(c) {
83546  return isNameStartChar(c) || c >= 0x30 && c <= 0x39 || c === 0x2D || c === 0x2E || c === 0xB7 || c >= 0x0300 && c <= 0x036F || c >= 0x203F && c <= 0x2040;
83547}
83548
83549exports.isNameChar = isNameChar;
83550
83551},{}],543:[function(require,module,exports){
83552"use strict";
83553/**
83554 * Character class utilities for XML NS 1.0 edition 3.
83555 *
83556 * @author Louis-Dominique Dubeau
83557 * @license MIT
83558 * @copyright Louis-Dominique Dubeau
83559 */
83560
83561Object.defineProperty(exports, "__esModule", {
83562  value: true
83563}); //
83564// Fragments.
83565//
83566// tslint:disable-next-line:max-line-length
83567
83568exports.NC_NAME_START_CHAR = "A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\uD800\uDC00-\uDB7F\uDFFF";
83569exports.NC_NAME_CHAR = "-" + exports.NC_NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040"; //
83570// Regular expressions.
83571//
83572
83573exports.NC_NAME_START_CHAR_RE = new RegExp("^[" + exports.NC_NAME_START_CHAR + "]$", "u");
83574exports.NC_NAME_CHAR_RE = new RegExp("^[" + exports.NC_NAME_CHAR + "]$", "u");
83575exports.NC_NAME_RE = new RegExp("^[" + exports.NC_NAME_START_CHAR + "][" + exports.NC_NAME_CHAR + "]*$", "u");
83576/**
83577 * Determines whether a codepoint matches [[NC_NAME_START_CHAR]].
83578 *
83579 * @param c The code point.
83580 *
83581 * @returns ``true`` if the codepoint matches.
83582 */
83583// tslint:disable-next-line:cyclomatic-complexity
83584
83585function isNCNameStartChar(c) {
83586  return c >= 0x41 && c <= 0x5A || c === 0x5F || c >= 0x61 && c <= 0x7A || c >= 0xC0 && c <= 0xD6 || c >= 0xD8 && c <= 0xF6 || c >= 0x00F8 && c <= 0x02FF || c >= 0x0370 && c <= 0x037D || c >= 0x037F && c <= 0x1FFF || c >= 0x200C && c <= 0x200D || c >= 0x2070 && c <= 0x218F || c >= 0x2C00 && c <= 0x2FEF || c >= 0x3001 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF || c >= 0xFDF0 && c <= 0xFFFD || c >= 0x10000 && c <= 0xEFFFF;
83587}
83588
83589exports.isNCNameStartChar = isNCNameStartChar;
83590/**
83591 * Determines whether a codepoint matches [[NC_NAME_CHAR]].
83592 *
83593 * @param c The code point.
83594 *
83595 * @returns ``true`` if the codepoint matches.
83596 */
83597
83598function isNCNameChar(c) {
83599  return isNCNameStartChar(c) || c === 0x2D || c === 0x2E || c >= 0x30 && c <= 0x39 || c === 0x00B7 || c >= 0x0300 && c <= 0x036F || c >= 0x203F && c <= 0x2040;
83600}
83601
83602exports.isNCNameChar = isNCNameChar;
83603
83604},{}]},{},[15])(15)
83605});
83606//# sourceMappingURL=exceljs.js.map
83607