From 83f1e054bfa892eac7c2cc38ccf9d5762e04dfbe Mon Sep 17 00:00:00 2001 From: antelle Date: Fri, 4 Oct 2019 20:06:46 +0200 Subject: [PATCH] fixed a bug in importing entries --- dist/kdbxweb.js | 6 +++--- dist/kdbxweb.js.map | 2 +- dist/kdbxweb.min.js | 4 ++-- lib/format/kdbx.js | 4 ++-- package-lock.json | 2 +- package.json | 2 +- release-notes.md | 3 +++ 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dist/kdbxweb.js b/dist/kdbxweb.js index cbba64a..1921228 100644 --- a/dist/kdbxweb.js +++ b/dist/kdbxweb.js @@ -1,4 +1,4 @@ -/*! kdbxweb v1.5.4, (c) 2019 Antelle, opensource.org/licenses/MIT */ +/*! kdbxweb v1.5.5, (c) 2019 Antelle, opensource.org/licenses/MIT */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("crypto"), require("xmldom")); @@ -4897,8 +4897,8 @@ Kdbx.prototype.importEntry = function(entry, group, file) { group.entries.push(newEntry); - entry.parentGroup = group; - entry.times.update(); + newEntry.parentGroup = group; + newEntry.times.update(); return newEntry; }; diff --git a/dist/kdbxweb.js.map b/dist/kdbxweb.js.map index 5ff8413..07b472b 100644 --- a/dist/kdbxweb.js.map +++ b/dist/kdbxweb.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://kdbxweb/webpack/universalModuleDefinition","webpack://kdbxweb/webpack/bootstrap","webpack://kdbxweb/./utils/byte-utils.js","webpack://kdbxweb/./defs/consts.js","webpack://kdbxweb/./errors/kdbx-error.js","webpack://kdbxweb/./crypto/crypto-engine.js","webpack://kdbxweb/./utils/xml-utils.js","webpack://kdbxweb/../node_modules/pako/lib/utils/common.js","webpack://kdbxweb/./defs/xml-names.js","webpack://kdbxweb/./format/kdbx-uuid.js","webpack://kdbxweb/./utils/int64.js","webpack://kdbxweb/./crypto/protected-value.js","webpack://kdbxweb/./crypto/random.js","webpack://kdbxweb/./utils/binary-stream.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/messages.js","webpack://kdbxweb/../node_modules/webpack/buildin/global.js","webpack://kdbxweb/./utils/var-dictionary.js","webpack://kdbxweb/./format/kdbx-custom-data.js","webpack://kdbxweb/../node_modules/pako/index.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/adler32.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/crc32.js","webpack://kdbxweb/../node_modules/pako/lib/utils/strings.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/zstream.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/constants.js","webpack://kdbxweb/./format/kdbx-header.js","webpack://kdbxweb/./crypto/salsa20.js","webpack://kdbxweb/./crypto/chacha20.js","webpack://kdbxweb/./crypto/key-encryptor-aes.js","webpack://kdbxweb/./format/kdbx-credentials.js","webpack://kdbxweb/./format/kdbx-times.js","webpack://kdbxweb/./format/kdbx-entry.js","webpack://kdbxweb/./index.js","webpack://kdbxweb/./format/kdbx.js","webpack://kdbxweb/./format/kdbx-format.js","webpack://kdbxweb/../node_modules/pako/lib/deflate.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/deflate.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/trees.js","webpack://kdbxweb/../node_modules/pako/lib/inflate.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/inflate.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/inffast.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/inftrees.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/gzheader.js","webpack://kdbxweb/../node_modules/text-encoding/index.js","webpack://kdbxweb/../node_modules/text-encoding/lib/encoding.js","webpack://kdbxweb/external \"crypto\"","webpack://kdbxweb/./format/kdbx-context.js","webpack://kdbxweb/external \"xmldom\"","webpack://kdbxweb/./crypto/hashed-block-transform.js","webpack://kdbxweb/./crypto/hmac-block-transform.js","webpack://kdbxweb/./crypto/protect-salt-generator.js","webpack://kdbxweb/./crypto/key-encryptor-kdf.js","webpack://kdbxweb/./format/kdbx-meta.js","webpack://kdbxweb/./format/kdbx-binaries.js","webpack://kdbxweb/./format/kdbx-group.js","webpack://kdbxweb/./format/kdbx-deleted-object.js"],"names":[],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;AClFA,8CAAa;;AAEb;AACA;;AAEA;AACA,uBAAuB,mBAAO,CAAC,uBAAe;AAC9C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,SAAS;AAC/C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,6BAA6B;AACxC,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,6BAA6B;AACxC,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,6BAA6B;AACxC,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,uBAAuB;AAClC,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,uBAAuB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACnKa;;AAEb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;AC5Ha;;AAEb;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;;;;;;;;ACVA,8CAAa;;AAEb,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,eAAe,mBAAO,CAAC,oBAAY;;AAEnC;AACA;AACA,6FAA6F,mBAAO,CAAC,gBAAQ;;AAE7G;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,kBAAkB;AAChD,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,kBAAkB;AAChD,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA,oBAAoB,sBAAsB,kBAAkB;AAC5D;AACA;AACA;AACA,aAAa;AACb,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,yCAAyC,gBAAgB;AACzD,6BAA6B,gBAAgB,EAAE;AAC/C;;AAEA;AACA,2BAA2B,wBAAwB;AACnD;;AAEA;AACA,2BAA2B,wBAAwB;AACnD,2BAA2B,kEAAkE,EAAE;AAC/F;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,oBAAoB,kEAAkE,EAAE;AAC7F;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,WAAW;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa;AACb;AACA,yFAAyF;AACzF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;;AC7OA,8CAAa;;AAEb,gBAAgB,mBAAO,CAAC,+BAAwB;AAChD,aAAa,mBAAO,CAAC,yBAAkB;AACvC,eAAe,mBAAO,CAAC,0BAAmB;AAC1C,eAAe,mBAAO,CAAC,8BAAuB;AAC9C,qBAAqB,mBAAO,CAAC,oCAA6B;AAC1D,gBAAgB,mBAAO,CAAC,qBAAc;AACtC,YAAY,mBAAO,CAAC,gBAAS;AAC7B,WAAW,mBAAO,CAAC,cAAM;;AAEzB;;AAEA,sCAAsC,mBAAO,CAAC,gBAAQ;AACtD;AACA;AACA,4BAA4B,SAAS,EAAE;AACvC,iCAAiC,SAAS;AAC1C;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,QAAQ;AACnB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,uBAAuB;AAC1C;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,SAAS;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA,8DAA8D,SAAS;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,iBAAiB;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,YAAY;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,wCAAwC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,eAAe;AAC1B,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,iBAAiB;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,iBAAiB;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,kBAAkB;AAC9B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,kBAAkB;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,sBAAsB;AACjC;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,4BAA4B,aAAa;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,4BAA4B,YAAY,QAAQ;AAC3D;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,SAAS;AACpB;AACA;AACA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,qBAAqB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,qBAAqB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACzea;;;AAGb;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA,kBAAkB,UAAU;;AAE5B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA,4BAA4B,YAAY;AACxC,qBAAqB,8BAA8B;AACnD;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;;AAEA;AACA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACrGa;;AAEb;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;AC9Ga;;AAEb,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,aAAa,mBAAO,CAAC,0BAAkB;;AAEvC;;AAEA;AACA;AACA,WAAW,mBAAmB;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,SAAS;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,gBAAgB;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACpEa;;AAEb;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACrDa;;AAEb,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,mBAAmB,mBAAO,CAAC,wBAAiB;AAC5C,aAAa,mBAAO,CAAC,kBAAU;;AAE/B;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB;AACA;AACA;AACA,2CAA2C,+BAA+B;AAC1E,0CAA0C,8BAA8B;AACxE;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;AACA;;AAEA;AACA,qEAAqE;AACrE,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,oBAAoB;AAC/C,0BAA0B,sBAAsB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,kCAAkC,QAAQ;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;;;;;;;;;;;;;AC5Ia;;AAEb,cAAc,mBAAO,CAAC,mBAAW;AACjC,mBAAmB,mBAAO,CAAC,wBAAiB;;AAE5C;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,WAAW;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,QAAQ;AAChD;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AChCa;;AAEb;AACA;AACA,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;;;;;;;;;;;;;AC9Ga;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACZA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C;;;;;;;;;;;;;;ACnBa;;AAEb,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,YAAY,mBAAO,CAAC,uBAAgB;;AAEpC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA,2CAA2C,iBAAiB,EAAE;AAC9D;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,qBAAqB,2BAA2B;AAChD,CAAC;;AAED;AACA;AACA,WAAW,OAAO;AAClB,WAAW,+BAA+B;AAC1C,WAAW,EAAE;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA,qDAAqD,yBAAyB,EAAE;AAChF;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;;AAEA;AACA;AACA,WAAW,aAAa;AACxB;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC5Ra;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;;AAE7C;AACA;AACA;AACA,eAAe,KAAK;AACpB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,8DAA8D,SAAS;AACvE;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,eAAe,KAAK;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA,8DAA8D,SAAS;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC7DA;AACa;;AAEb,gBAAgB,mBAAO,CAAC,2BAAoB;;AAE5C,gBAAgB,mBAAO,CAAC,uBAAe;AACvC,gBAAgB,mBAAO,CAAC,uBAAe;AACvC,gBAAgB,mBAAO,CAAC,8BAAsB;;AAE9C;;AAEA;;AAEA;;;;;;;;;;;;;;ACba;;AAEb;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;;;AAGA;;;;;;;;;;;;;;AC/Ba;;AAEb;AACA;AACA;;;AAGA;AACA;AACA;;AAEA,iBAAiB,SAAS;AAC1B;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA,mBAAmB,SAAS;AAC5B;AACA;;AAEA,sBAAsB;AACtB;;;AAGA;;;;;;;;;;;;;;ACxCA;AACa;;;AAGb,YAAY,mBAAO,CAAC,iBAAU;;;AAG9B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK,wCAAwC,EAAE,aAAa,sBAAsB;AAClF,KAAK,oDAAoD,EAAE,aAAa,0BAA0B;;;AAGlG;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA,kCAAkC;;;AAGlC;AACA;AACA;;AAEA;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,wBAAwB,aAAa;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,mCAAmC,SAAS;AAC5C;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,sBAAsB,SAAS;AAC/B;AACA;AACA,mBAAmB,qBAAqB,UAAU;;AAElD;AACA;AACA,oBAAoB,0BAA0B,gBAAgB,UAAU;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB,0BAA0B,UAAU;;AAExD;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yBAAyB,kBAAkB;;AAE3C;AACA;AACA,kDAAkD,OAAO;;AAEzD;AACA;AACA,gBAAgB,YAAY;;AAE5B;AACA;AACA,kBAAkB,YAAY;;AAE9B;AACA;;;;;;;;;;;;;;ACxLa;;;AAGb;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC5Ba;;;AAGb;;AAEA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjDa;;AAEb;AACA;AACA;;AAEA,eAAe,mBAAO,CAAC,oBAAa;AACpC,aAAa,mBAAO,CAAC,yBAAkB;AACvC,qBAAqB,mBAAO,CAAC,oCAA6B;AAC1D,gBAAgB,mBAAO,CAAC,+BAAwB;AAChD,mBAAmB,mBAAO,CAAC,kCAA0B;AACrD,gBAAgB,mBAAO,CAAC,8BAAuB;AAC/C,oBAAoB,mBAAO,CAAC,mCAA2B;AACvD,YAAY,mBAAO,CAAC,yBAAkB;AACtC,aAAa,mBAAO,CAAC,0BAAkB;;AAEvC;AACA,KAAK,sBAAsB;;AAE3B,KAAK,kBAAkB;AACvB,KAAK,mBAAmB;AACxB,KAAK,2BAA2B;AAChC,KAAK,qBAAqB;AAC1B,KAAK,kCAAkC;AACvC,KAAK,oCAAoC;AACzC,KAAK,uBAAuB;AAC5B,KAAK,uCAAuC;AAC5C,KAAK,qCAAqC;AAC1C,KAAK,wCAAwC;;AAE7C,KAAK,kCAAkC;AACvC,KAAK;AACL;;AAEA;AACA,KAAK,sBAAsB;;AAE3B,KAAK,8BAA8B;AACnC,KAAK,+BAA+B;AACpC,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,oCAAoC;;AAEpC;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,uBAAuB,6BAA6B;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB;AACA;AACA;AACA;AACA;AACA,oBAAoB,0BAA0B;AAC9C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,YAAY;AACvB;AACA;AACA;AACA,oBAAoB,+BAA+B;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,YAAY;AACvB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;;;;;;;;AC7gBa;;AAEb;;AAEA;AACA;AACA,qBAAqB;AACrB;;AAEA;AACA,uBAAuB;AACvB,6BAA6B;AAC7B,+BAA+B;;AAE/B;AACA,oBAAoB;AACpB,wBAAwB;;AAExB;AACA;AACA;;AAEA;AACA;AACA,0BAA0B,OAAO;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB,kBAAkB;AACpC;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC;;AAEA;;;;;;;;;;;;;;AC/Oa;;AAEb;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;;AAElB;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC7Ha;;AAEb,gBAAgB,mBAAO,CAAC,8BAAuB;AAC/C,mBAAmB,mBAAO,CAAC,wBAAiB;;AAE5C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,6BAA6B,sBAAsB;AACnD;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,+BAA+B,kBAAkB;AACjD;AACA;AACA;AACA,aAAa;AACb;AACA,SAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,sCAAsC,4BAA4B,EAAE;AACpE;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;;;;;;;;;;;;;;ACrEa;;AAEb,qBAAqB,mBAAO,CAAC,kCAA2B;AACxD,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,eAAe,mBAAO,CAAC,2BAAoB;AAC3C,aAAa,mBAAO,CAAC,0BAAkB;AACvC,mBAAmB,mBAAO,CAAC,gCAAyB;;AAEpD;AACA;AACA,WAAW,eAAe;AAC1B,WAAW,8BAA8B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,oBAAoB;AAC/B;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA,WAAW,uBAAuB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,GAAG;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,aAAa;AACb;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,mBAAmB,eAAe;AAClC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AClJa;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACrHa;;AAEb,qBAAqB,mBAAO,CAAC,kCAA2B;AACxD,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;AAC7C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,qBAAqB,mBAAO,CAAC,4BAAoB;AACjD,eAAe,mBAAO,CAAC,oBAAa;AACpC,gBAAgB,mBAAO,CAAC,sBAAc;;AAEtC,2BAA2B;;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,yDAAyD,UAAU,EAAE;AACrE;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,gCAAgC;AACnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,yBAAyB;AAC5C;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA,wBAAwB,oBAAoB;AAC5C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,mCAAmC;AACnC;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,YAAY,0BAA0B;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA,KAAK;AACL,6BAA6B;AAC7B;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,KAAK;AAChB,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA,sCAAsC,kDAAkD,EAAE;AAC1F,uCAAuC,kDAAkD,EAAE;AAC3F,uBAAuB;AACvB,2CAA2C,yDAAyD,EAAE;AACtG,4CAA4C,+DAA+D,EAAE;AAC7G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,UAAU;AACrB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;ACxdA,sBAAsB,mBAAO,CAAC,uBAAe;AAC7C,0BAA0B,mBAAO,CAAC,2BAAoB;AACtD,2BAA2B,mBAAO,CAAC,4BAAqB;AACxD,6BAA6B,mBAAO,CAAC,mCAA2B;AAChE,wBAAwB,mBAAO,CAAC,sBAAe;AAC/C,gCAAgC,mBAAO,CAAC,iCAA0B;AAClE,2BAA2B,mBAAO,CAAC,2BAAoB;AACvD,+BAA+B,mBAAO,CAAC,gCAAwB;AAC/D,uBAAuB,mBAAO,CAAC,sBAAe;AAC9C,wBAAwB,mBAAO,CAAC,yBAAiB;AACjD,8BAA8B,mBAAO,CAAC,+BAAwB;;;;;;;;;;;;;;ACVjD;;AAEb;AACA,iBAAiB,mBAAO,CAAC,uBAAe;AACxC,gBAAgB,mBAAO,CAAC,+BAAwB;AAChD,sBAAsB,mBAAO,CAAC,4BAAoB;AAClD,iBAAiB,mBAAO,CAAC,uBAAe;AACxC,eAAe,mBAAO,CAAC,qBAAa;AACpC,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,gBAAgB,mBAAO,CAAC,sBAAc;AACtC,gBAAgB,mBAAO,CAAC,sBAAc;AACtC,wBAAwB,mBAAO,CAAC,+BAAuB;AACvD,eAAe,mBAAO,CAAC,oBAAa;AACpC,aAAa,mBAAO,CAAC,yBAAkB;AACvC,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,gBAAgB;AAC3B,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,gBAAgB;AAC3B,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,gBAAgB;AAC3B,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,oBAAoB;AAC/B,WAAW,UAAU;AACrB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,oBAAoB;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,2BAA2B;AACtC,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,UAAU;AACrB,WAAW,UAAU;AACrB,WAAW,KAAK;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,kBAAkB,wDAAwD;AAC1E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL,YAAY;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qCAAqC,wBAAwB,EAAE;AAC/D;AACA,8CAA8C,0BAA0B,EAAE;AAC1E;AACA;;AAEA;;;;;;;;;;;;;;ACljBa;;AAEb,WAAW,mBAAO,CAAC,cAAM;;AAEzB,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,iBAAiB,mBAAO,CAAC,uBAAe;AACxC,kBAAkB,mBAAO,CAAC,wBAAgB;;AAE1C,mBAAmB,mBAAO,CAAC,gCAAyB;AACpD,mBAAmB,mBAAO,CAAC,gCAAwB;AACnD,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,eAAe,mBAAO,CAAC,2BAAoB;AAC3C,YAAY,mBAAO,CAAC,uBAAgB;AACpC,aAAa,mBAAO,CAAC,uBAAgB;AACrC,2BAA2B,mBAAO,CAAC,0CAAkC;AACrE,yBAAyB,mBAAO,CAAC,wCAAgC;AACjE,2BAA2B,mBAAO,CAAC,0CAAkC;AACrE,sBAAsB,mBAAO,CAAC,qCAA6B;AAC3D,sBAAsB,mBAAO,CAAC,qCAA6B;;AAE3D;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,gCAAgC,aAAa;AAC7C;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA,+BAA+B,aAAa;AAC5C;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,gCAAgC,aAAa;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,mCAAmC,8BAA8B;AACjE;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC/Xa;;;AAGb,mBAAmB,mBAAO,CAAC,wBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,uBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,mBAAmB,mBAAO,CAAC,wBAAgB;;AAE3C;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,UAAU;AAC7C;AACA;AACA,8BAA8B;AAC9B;AACA,qBAAqB,8BAA8B;AACnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,eAAe;;AAElB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,kBAAkB;AAClB,mBAAmB;AACnB,sBAAsB;AACtB,mBAAmB;;AAEnB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,cAAc;;AAEjC;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,qBAAqB,oBAAoB;;AAEzC;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;;;;;;;;;;;;AC/Ya;;AAEb,cAAc,mBAAO,CAAC,wBAAiB;AACvC,cAAc,mBAAO,CAAC,iBAAS;AAC/B,cAAc,mBAAO,CAAC,mBAAW;AACjC,cAAc,mBAAO,CAAC,iBAAS;AAC/B,cAAc,mBAAO,CAAC,oBAAY;;AAElC;AACA;;;AAGA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,gCAAgC;AAChC;;;AAGA;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;AAC1B,0BAA0B;AAC1B,0BAA0B;;AAE1B,mBAAmB;;AAEnB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,oBAAoB,sBAAsB,qBAAqB,cAAc,EAAE;;;AAG/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,QAAQ;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,YAAY;AAC/B,kBAAkB,UAAU;;AAE5B;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC;AACxC,wBAAwB;AACxB,YAAY;AACZ,UAAU;AACV,+BAA+B;AAC/B,gCAAgC;AAChC;AACA;;AAEA,sBAAsB;;AAEtB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,0BAA0B;;AAE3D;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,wDAAwD;AACxD;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,sDAAsD;AACtD;AACA;AACA;AACA;AACA;AACA,kEAAkE;AAClE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,aAAa;;AAEb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mEAAmE;;AAEnE;AACA,yDAAyD;AACzD;;AAEA;;AAEA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,2DAA2D;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,0DAA0D;AAC1D;;AAEA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,aAAa;;AAEb;;AAEA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,OAAO,EAAE;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,wDAAwD;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,4DAA4D;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0DAA0D;AAC1D;;AAEA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,WAAW;AACX,mBAAmB;;AAEnB;;AAEA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,OAAO,EAAE;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,oEAAoE;AACpE;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,0DAA0D;AAC1D;;AAEA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa;;AAEb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA,wDAAwD;AACxD;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA,qBAAqB;AACrB,eAAe;;AAEf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA,mBAAmB;AACnB,kBAAkB;AAClB,0BAA0B;AAC1B,4BAA4B;AAC5B,uBAAuB;AACvB,mBAAmB;AACnB,gBAAgB;AAChB,qBAAqB;AACrB,mBAAmB;AACnB,2BAA2B;AAC3B,uBAAuB;;AAEvB,kBAAkB;AAClB,kBAAkB;AAClB,kBAAkB;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB;;AAEnB,iBAAiB;AACjB,qBAAqB;AACrB,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,wBAAwB;AACxB,sBAAsB;AACtB,2BAA2B;AAC3B,oBAAoB;AACpB,uBAAuB;AACvB,qBAAqB;;AAErB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB;AACjB,oBAAoB;;AAEpB;AACA;;AAEA,sBAAsB;;AAEtB;;AAEA;;AAEA,2CAA2C;AAC3C,6CAA6C;AAC7C,4CAA4C;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;;AAEvB;AACA;AACA;;AAEA,0BAA0B;AAC1B,+CAA+C;AAC/C;;AAEA,oBAAoB;AACpB,oBAAoB;AACpB;AACA;AACA;;AAEA,gDAAgD;AAChD;AACA;AACA;;AAEA,iBAAiB;;AAEjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB;;AAEpB;AACA;AACA;AACA;AACA;;AAEA,mBAAmB;AACnB,sBAAsB;AACtB,mBAAmB;AACnB,kBAAkB;;;AAGlB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA,6BAA6B,uBAAuB;AACpD,8BAA8B,uBAAuB;AACrD;AACA;AACA;;;AAGA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;;AAEA,uBAAuB;AACvB;AACA;AACA;;AAEA;AACA,aAAa;AACb;AACA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,qBAAqB;;AAErB,sCAAsC;;AAEtC;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,gBAAgB;AAChB;AACA;;AAEA;AACA;;AAEA,uBAAuB;AACvB,qBAAqB;AACrB;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;AACA,6BAA6B,uBAAuB;AACpD;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;;AAEA;AACA;AACA;AACA,sBAAsB;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;;AAEnC;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B,uBAAuB;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA,8BAA8B;;AAE9B,2BAA2B,aAAa;AACxC,oBAAoB,qBAAqB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,oDAAoD;AACpD;AACA;;AAEA,aAAa;;AAEb;AACA;AACA,qBAAqB;AACrB,yBAAyB;AACzB,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE;AAChE;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;AC9zDa;;;AAGb,YAAY,mBAAO,CAAC,wBAAiB;;AAErC;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,8BAA8B;AAC9B;;AAEA;;;AAGA,oBAAoB,sBAAsB,qBAAqB,cAAc,EAAE;;AAE/E;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,wBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;;AAEA,kCAAkC;AAClC,iCAAiC;AACjC,iCAAiC;AACjC,4BAA4B;AAC5B,iCAAiC;;AAEjC;AACA;AACA;;;AAGA;AACA;AACA;;;AAGA;AACA,2BAA2B;AAC3B,oBAAoB;AACpB,6BAA6B;AAC7B;;;;AAIA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;;AAGA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR,WAAW;AACX,WAAW;AACX,YAAY;AACZ,QAAQ;AACR,mBAAmB;;AAEnB,gBAAgB,kBAAkB;AAClC;AACA;;AAEA;AACA;AACA;AACA,+CAA+C;;AAE/C,0BAA0B,eAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,uBAAuB,UAAU,EAAE;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,QAAQ;;AAE/B;AACA;;AAEA;AACA;AACA;AACA,oCAAoC,QAAQ;AAC5C,uBAAuB;AACvB,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,yBAAyB,YAAY;AACrC;AACA;AACA;AACA,yBAAyB,UAAU;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,mBAAmB;AACnB,qBAAqB;AACrB;AACA,0CAA0C;AAC1C,eAAe;AACf,WAAW;AACX,QAAQ;;AAER;AACA;AACA;AACA,gBAAgB,kBAAkB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,aAAa,gBAAgB;AAC7B;AACA,oBAAoB,UAAU;AAC9B;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA,QAAQ;AACR,WAAW;AACX,aAAa;AACb,WAAW;AACX,WAAW;AACX;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB,yBAAyB;AACzC;AACA,eAAe,8BAA8B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB,WAAW;AAC3B;AACA,eAAe,8BAA8B;AAC7C;AACA;AACA;AACA;AACA,aAAa;AACb,QAAQ,gBAAgB;AACxB;AACA,eAAe,oCAAoC;AACnD;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,kBAAkB;AAClC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,aAAa;AAC1B;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA,QAAQ;;AAER;AACA,aAAa,aAAa,QAAQ,iCAAiC;AACnE,aAAa,aAAa,QAAQ,iCAAiC;AACnE,aAAa,cAAc,OAAO,+BAA+B;;AAEjE;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,eAAe;AACf,kBAAkB;AAClB;AACA,eAAe;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,YAAY;AACZ;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,OAAO;;AAEtD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B,2BAA2B;AAC3B;AACA,WAAW;AACX,SAAS;AACT,aAAa;AACb,WAAW;AACX,YAAY;;AAEZ;AACA;AACA;AACA;AACA;;AAEA;AACA,gCAAgC;AAChC;AACA,OAAO;AACP;AACA;AACA,iDAAiD;AACjD;AACA;AACA;AACA,kCAAkC;AAClC;AACA,eAAe;AACf;AACA;;AAEA,kCAAkC;AAClC;AACA;AACA;AACA,oCAAoC;AACpC;AACA,OAAO;;AAEP;AACA;AACA;;AAEA,KAAK;AACL;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA,6DAA6D;AAC7D;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,oBAAoB;AACpB,WAAW;;AAEX;AACA;AACA;AACA;AACA;AACA;;AAEA,aAAa,WAAW;AACxB;AACA;AACA;;AAEA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uCAAuC,QAAQ,OAAO,wBAAwB;;AAE9E;AACA;AACA;AACA,eAAe;AACf;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;;AAEA,8BAA8B;;AAE9B,6BAA6B;AAC7B;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,GAAG;;AAEH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,mBAAmB;AACnB;AACA,QAAQ;AACR,mBAAmB;AACnB,aAAa;;AAEb,wCAAwC;;AAExC,gBAAgB;AAChB,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;AACA;AACA,gDAAgD;;AAEhD,aAAa,eAAe;AAC5B;AACA;;AAEA;AACA;;AAEA,KAAK;AACL;;AAEA,KAAK;;AAEL,+BAA+B,kCAAkC;AACjE;;AAEA,KAAK;AACL;;AAEA,KAAK;AACL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,KAAK;AACL;AACA;;AAEA,KAAK;AACL;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,mBAAmB;AACnB;AACA,QAAQ;AACR,mBAAmB;AACnB,aAAa;;AAEb,wCAAwC;;AAExC,gBAAgB;AAChB,oBAAoB;AACpB,oBAAoB;;AAEpB,+BAA+B;AAC/B;AACA;AACA;AACA;;AAEA,aAAa,eAAe;AAC5B;AACA;;AAEA;AACA;;AAEA,KAAK;AACL,UAAU,iCAAiC,EAAE;;AAE7C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;AACL;AACA;;AAEA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,KAAK;AACL;AACA;;AAEA,KAAK;AACL;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA,kBAAkB;;AAElB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kCAAkC,kBAAkB;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA,WAAW;;AAEX;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA,gCAAgC;AAChC,gBAAgB,gBAAgB;AAChC;AACA;AACA;AACA;;AAEA,wCAAwC;AACxC;;AAEA,wCAAwC;AACxC;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,IAAI,MAAM,GAAG,MAAM,GAAG;AAChD;AACA;AACA;AACA,SAAS,IAAI,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IAAI,MAAM,IAAI;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc,cAAc;AAC5B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,iBAAiB;AACjB,WAAW;AACX;AACA,wDAAwD;AACxD,uCAAuC;AACvC;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,iBAAiB;AACjB,WAAW;AACX;AACA,4BAA4B;AAC5B,sBAAsB;;AAEtB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,kCAAkC,wBAAwB;;AAE1D,GAAG;AACH;AACA,4CAA4C;AAC5C;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;;AAEH;AACA;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,kBAAkB;AAClB;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,WAAW;AACX;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjrCa;;;AAGb,mBAAmB,mBAAO,CAAC,wBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,uBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,mBAAmB,mBAAO,CAAC,0BAAkB;AAC7C,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,mBAAmB,mBAAO,CAAC,wBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,yBAAiB;;AAE5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,UAAU;AAC7C;AACA;AACA,8BAA8B;AAC9B;AACA,qBAAqB,8BAA8B;AACnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG,eAAe;;AAElB;;AAEA;AACA;AACA;AACA;AACA,+BAA+B,sBAAsB;AACrD;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB,mBAAmB;AACnB,sBAAsB;AACtB,mBAAmB;;AAEnB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,mBAAmB,cAAc;AACjC;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,sDAAsD;;AAEtD;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB,kEAAkE;;AAEvF;;AAEA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,qBAAqB,oBAAoB;;AAEzC;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjaa;;;AAGb,oBAAoB,mBAAO,CAAC,wBAAiB;AAC7C,oBAAoB,mBAAO,CAAC,mBAAW;AACvC,oBAAoB,mBAAO,CAAC,iBAAS;AACrC,oBAAoB,mBAAO,CAAC,mBAAW;AACvC,oBAAoB,mBAAO,CAAC,oBAAY;;AAExC;AACA;AACA;;AAEA;AACA;;;AAGA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;;;AAGA,gBAAgB;AAChB,iBAAiB;AACjB,gBAAgB;AAChB,cAAc;AACd,iBAAiB;AACjB,iBAAiB;AACjB,gBAAgB;AAChB,mBAAmB;AACnB,gBAAgB;AAChB,mBAAmB;AACnB,iBAAiB;AACjB,qBAAqB;AACrB,uBAAuB;AACvB,uBAAuB;AACvB,sBAAsB;AACtB,qBAAqB;AACrB,sBAAsB;AACtB,wBAAwB;AACxB,yBAAyB;AACzB,yBAAyB;AACzB,wBAAwB;AACxB,2BAA2B;AAC3B,yBAAyB;AACzB,4BAA4B;AAC5B,0BAA0B;AAC1B,wBAAwB;AACxB,kBAAkB;AAClB,mBAAmB;AACnB,iBAAiB;AACjB,gBAAgB;AAChB,gBAAgB;AAChB,iBAAiB;;AAEjB;;;;AAIA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA,gBAAgB;AAChB,oBAAoB;AACpB,gBAAgB;AAChB,wBAAwB;AACxB,iBAAiB;AACjB,gBAAgB;AAChB,iBAAiB;AACjB,iBAAiB;AACjB;AACA,mBAAmB;;AAEnB;AACA,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,qBAAqB;;AAErB;AACA,gBAAgB;AAChB,gBAAgB;;AAEhB;AACA,kBAAkB;AAClB,kBAAkB;;AAElB;AACA,iBAAiB;;AAEjB;AACA,sBAAsB;AACtB,uBAAuB;AACvB,mBAAmB;AACnB,oBAAoB;;AAEpB;AACA,iBAAiB;AACjB,gBAAgB;AAChB,iBAAiB;AACjB,gBAAgB;AAChB,mBAAmB;;AAEnB,mCAAmC;AACnC,mCAAmC;;AAEnC;AACA;AACA;AACA;AACA,yCAAyC;AACzC,qBAAqB;AACrB,sBAAsB;AACtB,gBAAgB;AAChB,gBAAgB;AAChB,eAAe;AACf;;AAEA;AACA;;AAEA,6BAA6B,uBAAuB;AACpD;AACA;AACA,gBAAgB;AAChB,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,6BAA6B,uBAAuB;AACpD;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,6BAA6B,uBAAuB;AACpD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,cAAc,uBAAuB;AACrC,sBAAsB;;AAEtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB;;AAEpB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,uBAAuB,uBAAuB;AAC9C,uBAAuB,uBAAuB;AAC9C,uBAAuB,uBAAuB;AAC9C,uBAAuB,uBAAuB;;AAE9C,uEAAuE,UAAU;;AAEjF;AACA;AACA,sBAAsB,uBAAuB;;AAE7C,uEAAuE,UAAU;;AAEjF;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,iBAAiB;AACzD,sCAAsC,qBAAqB;AAC3D;AACA;AACA;AACA;;AAEA;AACA;AACA,oBAAoB;AACpB,WAAW;AACX,UAAU;AACV,iBAAiB;AACjB,WAAW;AACX,WAAW;AACX,gBAAgB;AAChB,WAAW;AACX,WAAW;AACX;AACA,eAAe;AACf,mCAAmC;AACnC,aAAa;AACb,mCAAmC;AACnC,UAAU;AACV,UAAU;AACV,+BAA+B;AAC/B;;AAEA,QAAQ;;AAER;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA,4BAA4B,qBAAqB,EAAE;;;AAGnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,aAAa;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,iBAAiB;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,iBAAiB;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,aAAa;AACvC,0BAA0B,aAAa;AACvC,yBAAyB,iBAAiB;AAC1C,uCAAuC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA,wDAAwD;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf,kEAAkE;AAClE;AACA;AACA;;AAEA,oCAAoC,OAAO;AAC3C;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,+BAA+B,OAAO;;AAEtC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,iBAAiB;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,gEAAgE;AAChE;AACA;AACA;;AAEA,gCAAgC,OAAO;AACvC;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA,gDAAgD,OAAO;AACvD;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,kEAAkE;AAClE;AACA;AACA;;AAEA,kCAAkC,OAAO;AACzC;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA,gDAAgD,OAAO;AACvD;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,qBAAqB;AAC3D,8BAA8B,aAAa;AAC3C;AACA;AACA;AACA;AACA,aAAa;AACb,qCAAqC,kBAAkB;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,qBAAqB;AACvD;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA,wBAAwB,aAAa;AACrC;AACA;AACA;AACA;AACA,OAAO;AACP,+BAA+B,kBAAkB;AACjD;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iFAAiF;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,6BAA6B,uBAAuB;AACpD;AACA,+BAA+B,uBAAuB;;AAEtD;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,6DAA6D,uBAAuB;AACpF;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf,wDAAwD;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjgDa;;AAEb;AACA,aAAa;AACb,cAAc;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,WAAW;AACX,WAAW;AACX,UAAU;AACV,UAAU;AACV;AACA,WAAW;AACX;AACA,YAAY;AACZ,YAAY;AACZ,YAAY;AACZ;AACA,eAAe;AACf,WAAW;AACX,WAAW;AACX,YAAY;AACZ,YAAY;AACZ,YAAY;AACZ,YAAY;AACZ,WAAW;AACX,SAAS;AACT;AACA,UAAU;AACV,WAAW;AACX,WAAW;AACX;;;AAGA,oBAAoB;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,WAAW,GAAG;AACd;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,GAAG;AAClB;AACA;AACA;AACA;;AAEA,wBAAwB;AACxB;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B,4BAA4B;AAC5B,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA,gCAAgC;AAChC;AACA,+BAA+B;AAC/B;AACA;AACA;AACA,mBAAmB;AACnB,qCAAqC;AACrC;AACA;AACA;AACA,oCAAoC;AACpC;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA,mBAAmB;AACnB;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA,qBAAqB;AACrB,uCAAuC;AACvC;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA,+BAA+B;AAC/B;AACA;AACA;AACA,mBAAmB;AACnB,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC,kBAAkB;AAClB;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,gBAAgB;AAChB;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,YAAY;AACZ;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACrUa;;;AAGb,YAAY,mBAAO,CAAC,wBAAiB;;AAErC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,yBAAyB;;AAEzB,cAAc;AACd,cAAc;AACd,uBAAuB;AACvB,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,WAAW;AACX,WAAW;AACX,UAAU;AACV,WAAW;AACX,WAAW;AACX,kBAAkB;AAClB;AACA,iBAAiB;AACjB,UAAU;AACV,2CAA2C,eAAe;AAC1D,0CAA0C,eAAe;AACzD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA,eAAe,aAAa;AAC5B;AACA;;AAEA;AACA;AACA,qBAAqB,UAAU;AAC/B,2BAA2B,OAAO;AAClC;AACA;AACA;AACA;AACA,kBAAkB;AAClB,sCAAsC,2BAA2B;AACjE,uCAAuC;AACvC,wCAAwC;AACxC;;;AAGA;AACA;AACA;AACA;;AAEA;AACA,aAAa;AACb;AACA,eAAe,WAAW;AAC1B,2BAA2B,OAAO;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,cAAc;AACd;;AAEA;AACA;AACA,eAAe,eAAe;AAC9B;AACA;;AAEA;AACA,eAAe,aAAa;AAC5B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA,GAAG,OAAO;AACV;AACA;AACA;AACA;;AAEA;AACA,WAAW;AACX,UAAU;AACV,YAAY;AACZ,qBAAqB;AACrB,cAAc;AACd,WAAW;AACX,WAAW;AACX,mBAAmB;AACnB,kBAAkB;;AAElB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;;AAEA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,wBAAwB,OAAO;AAC/B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kBAAkB;;AAElB;AACA;AACA;AACA;AACA;AACA,wBAAwB,OAAO;AAC/B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACtUa;;;AAGb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;ACvCA;AACA;;AAEA,eAAe,mBAAO,CAAC,2BAAmB;;AAE1C;AACA;AACA;AACA;;;;;;;;;;;;;ACRA;AACA;;AAEA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA,aAAa,WAAW;AACxB,aAAa,EAAE;AACf,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA,aAAa,EAAE;AACf,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,cAAc,gBAAgB;AAC9B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,aAAa,gBAAgB;AAC7B,cAAc,OAAO;AACrB;AACA;AACA;AACA,mBAAmB,wBAAwB;AAC3C;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,6BAA6B;AAC1C;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;;AAEN;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA;AACA;AACA;AACA,+BAA+B,gBAAgB;AAC/C;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA;AACA;AACA;AACA,+BAA+B,gBAAgB;AAC/C;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,cAAc,OAAO;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,0BAA0B;AAC1C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,yBAAyB;AACzC;AACA;AACA;;AAEA;;AAEA,0CAA0C;AAC1C;;AAEA;AACA,aAAa,OAAO;AACpB,cAAc,EAAE;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY;AACZ;AACA,iCAAiC,kCAAkC;AACnE,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,gBAAgB,kCAAkC,EAAE;AACjE;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL,GAAG;;AAEH;AACA,aAAa,0BAA0B,cAAc,YAAY;AACjE;AACA,aAAa,0BAA0B,cAAc,YAAY;AACjE;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,wBAAwB,SAAS;AACjC;AACA,wBAAwB,QAAQ;AAChC;AACA,wBAAwB,QAAQ;AAChC;AACA,wBAAwB,OAAO;AAC/B;AACA,wBAAwB,QAAQ;AAChC;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,uBAAuB,0CAA0C;AACjE,KAAK;;AAEL;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,uBAAuB,qCAAqC;AAC5D,KAAK;;AAEL;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,uBAAuB,wBAAwB;AAC/C,KAAK;AACL;;AAEA;AACA,aAAa,cAAc;AAC3B,aAAa,QAAQ;AACrB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,4CAA4C;AAC5C;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,eAAe,0BAA0B;AACzC;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,8CAA8C,gBAAgB;AAC9D;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,gBAAgB;AAC9D;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,gBAAgB;AAChB,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,wBAAwB,SAAS;AACjC;;AAEA;AACA,wBAAwB,QAAQ;AAChC;AACA,wBAAwB,OAAO;AAC/B;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,uBAAuB,0CAA0C;AACjE,KAAK;AACL;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,cAAc,YAAY;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;;AAEA;AACA;;AAEA;AACA;;AAEA,eAAe,0BAA0B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,gBAAgB;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,gBAAgB;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB,cAAc,gBAAgB;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,OAAO;AAC1B,mBAAmB,OAAO;AAC1B,mBAAmB,OAAO;AAC1B,mBAAmB,OAAO;;AAE1B;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,0BAA0B;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB,cAAc,gBAAgB;AAC9B;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,yBAAyB;AACzC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,eAAe,gBAAgB;AAC/B;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,MAAM,KAA6B;AACnC;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;;;;;ACp6BD,iD;;;;;;;;;;;;;ACAa;;AAEb,eAAe,mBAAO,CAAC,2BAAoB;;AAE3C;AACA;AACA,WAAW,KAAK;AAChB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;ACzBA,iD;;;;;;;;;;;;;ACAa;;AAEb;AACA,mBAAmB,mBAAO,CAAC,kCAA0B;AACrD,gBAAgB,mBAAO,CAAC,+BAAwB;AAChD,aAAa,mBAAO,CAAC,yBAAkB;AACvC,gBAAgB,mBAAO,CAAC,8BAAuB;AAC/C,mBAAmB,mBAAO,CAAC,wBAAiB;;AAE5C;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA,+BAA+B,oBAAoB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,+BAA+B,oBAAoB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;;;;;;;;;;;;;;AC1Ga;;AAEb;AACA,YAAY,mBAAO,CAAC,uBAAgB;AACpC,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,mBAAmB,mBAAO,CAAC,gCAAwB;AACnD,mBAAmB,mBAAO,CAAC,wBAAiB;;AAE5C;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,MAAM;AACjB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA,+BAA+B,oBAAoB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,mCAAmC,oBAAoB;AACvD;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;;;;;;;;;;;;;AC3Ia;;AAEb,cAAc,mBAAO,CAAC,mBAAW;AACjC,eAAe,mBAAO,CAAC,oBAAY;AACnC,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,mBAAmB,mBAAO,CAAC,wBAAiB;AAC5C,gBAAgB,mBAAO,CAAC,8BAAuB;;AAE/C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,YAAY;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,uBAAuB;AAClC,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACtDa;;AAEb,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,oBAAoB,mBAAO,CAAC,iCAAyB;AACrD,YAAY,mBAAO,CAAC,uBAAgB;AACpC,mBAAmB,mBAAO,CAAC,gCAAyB;AACpD,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,sBAAsB,mBAAO,CAAC,6BAAqB;;AAEnD;AACA,KAAK,gEAAgE;AACrE,KAAK,wEAAwE;AAC7E,KAAK,mEAAmE;AACxE,KAAK,uEAAuE;AAC5E,KAAK,oEAAoE;AACzE,KAAK,qEAAqE;AAC1E,KAAK,qEAAqE;AAC1E,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,cAAc;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;;;;;;;;;;;;;;ACpGa;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,oBAAa;AACpC,qBAAqB,mBAAO,CAAC,4BAAoB;AACjD,eAAe,mBAAO,CAAC,6BAAsB;AAC7C,aAAa,mBAAO,CAAC,yBAAkB;;AAEvC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA,yBAAyB,oBAAoB,EAAE;AAC/C;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,YAAY,0BAA0B;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL,+DAA+D,+CAA+C;AAC9G,8DAA8D,6CAA6C;AAC3G,4DAA4D,yCAAyC;AACrG,8DAA8D,6CAA6C;AAC3G,gEAAgE,iDAAiD;AACjH,qDAAqD,2BAA2B;AAChF;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC3aa;;AAEb,qBAAqB,mBAAO,CAAC,oCAA6B;AAC1D,mBAAmB,mBAAO,CAAC,kCAA2B;AACtD,gBAAgB,mBAAO,CAAC,8BAAuB;;AAE/C;AACA;AACA,mBAAmB,UAAU,EAAE;AAC/B,oBAAoB;AACpB,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C,+CAA+C;AAC7F;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,KAAK;AACL;;AAEA;;;;;;;;;;;;;;ACpDa;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;AAC7C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,qBAAqB,mBAAO,CAAC,4BAAoB;AACjD,gBAAgB,mBAAO,CAAC,sBAAc;AACtC,eAAe,mBAAO,CAAC,oBAAa;AACpC,gBAAgB,mBAAO,CAAC,sBAAc;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,oBAAoB,EAAE;AAC3D,sCAAsC,oBAAoB,EAAE;AAC5D;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,SAAS;AACpB;AACA;AACA;AACA,0CAA0C,+BAA+B,EAAE;AAC3E,yCAAyC,kCAAkC,EAAE;AAC7E;;AAEA;AACA;AACA,YAAY,0BAA0B;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,wBAAwB,EAAE;AACnE,0CAA0C,wBAAwB,EAAE;AACpE;;AAEA;AACA;AACA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,SAAS;AACpB,YAAY,0BAA0B;AACtC,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA,gCAAgC;AAChC,SAAS;AACT,gCAAgC;AAChC;AACA,KAAK;AACL;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA,oCAAoC;AACpC;AACA,SAAS;AACT,uDAAuD;AACvD;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,SAAS;AACpB,WAAW,IAAI;AACf,aAAa,IAAI;AACjB;AACA;AACA;AACA;AACA,uBAAuB,qBAAqB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB,SAAS;AACT,uBAAuB;AACvB;AACA;AACA,uBAAuB;AACvB,SAAS;AACT,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,UAAU;AACrB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACzQa;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA","file":"kdbxweb.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"crypto\"), require(\"xmldom\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"crypto\", \"xmldom\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"kdbxweb\"] = factory(require(\"crypto\"), require(\"xmldom\"));\n\telse\n\t\troot[\"kdbxweb\"] = factory(root[\"crypto\"], root[\"xmldom\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE__42__, __WEBPACK_EXTERNAL_MODULE__44__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 29);\n","'use strict';\n\nvar TextEncoder = global.TextEncoder;\nvar TextDecoder = global.TextDecoder;\n\nif (!TextEncoder || !TextDecoder) {\n var textEncoding = require('text-encoding');\n TextEncoder = textEncoding.TextEncoder;\n TextDecoder = textEncoding.TextDecoder;\n}\n\nvar textEncoder = new TextEncoder();\nvar textDecoder = new TextDecoder();\n\n/**\n * Checks if two ArrayBuffers are equal\n * @param {ArrayBuffer} ab1\n * @param {ArrayBuffer} ab2\n * @returns {boolean}\n */\nfunction arrayBufferEquals(ab1, ab2) {\n if (ab1.byteLength !== ab2.byteLength) {\n return false;\n }\n var arr1 = new Uint8Array(ab1);\n var arr2 = new Uint8Array(ab2);\n for (var i = 0, len = arr1.length; i < len; i++) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Converts Array or ArrayBuffer to string\n * @param {Array|Uint8Array|ArrayBuffer} arr\n * @return {string}\n */\nfunction bytesToString(arr) {\n if (arr instanceof ArrayBuffer) {\n arr = new Uint8Array(arr);\n }\n return textDecoder.decode(arr);\n}\n\n/**\n * Converts string to byte array\n * @param {string} str\n * @return {Uint8Array}\n */\nfunction stringToBytes(str) {\n return textEncoder.encode(str);\n}\n\n/**\n * Converts base64 string to array\n * @param {string} str\n * @return {Uint8Array}\n */\nfunction base64ToBytes(str) {\n if (typeof atob === 'undefined' && typeof Buffer === 'function') {\n // node.js doesn't have atob\n var buffer = Buffer.from(str, 'base64');\n return new Uint8Array(buffer);\n }\n var byteStr = atob(str);\n var arr = new Uint8Array(byteStr.length);\n for (var i = 0; i < byteStr.length; i++) {\n arr[i] = byteStr.charCodeAt(i);\n }\n return arr;\n}\n\n/**\n * Converts Array or ArrayBuffer to base64-string\n * @param {Array|Uint8Array|ArrayBuffer} arr\n * @return {string}\n */\nfunction bytesToBase64(arr) {\n if (arr instanceof ArrayBuffer) {\n arr = new Uint8Array(arr);\n }\n if (typeof btoa === 'undefined' && typeof Buffer === 'function') {\n // node.js doesn't have btoa\n var buffer = Buffer.from(arr);\n return buffer.toString('base64');\n }\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n return btoa(str);\n}\n\n/**\n * Convert hex-string to byte array\n * @param {string} hex\n * @return Uint8Array\n */\nfunction hexToBytes(hex) {\n var arr = new Uint8Array(Math.ceil(hex.length / 2));\n for (var i = 0; i < arr.length; i++) {\n arr[i] = parseInt(hex.substr(i * 2, 2), 16);\n }\n return arr;\n}\n\n/**\n * Convert hex-string to byte array\n * @param {Array|Uint8Array|ArrayBuffer} arr\n * @return {string}\n */\nfunction bytesToHex(arr) {\n if (arr instanceof ArrayBuffer) {\n arr = new Uint8Array(arr);\n }\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var byte = arr[i].toString(16);\n if (byte.length === 1) {\n str += '0';\n }\n str += byte;\n }\n return str;\n}\n\n/**\n * Converts byte array to array buffer\n * @param {Uint8Array|ArrayBuffer} arr\n * @returns {ArrayBuffer}\n */\nfunction arrayToBuffer(arr) {\n if (arr instanceof ArrayBuffer) {\n return arr;\n }\n var ab = arr.buffer;\n if (arr.byteOffset === 0 && arr.byteLength === ab.byteLength) {\n return ab;\n }\n return arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength);\n}\n\n/**\n * Fills array or arraybuffer with zeroes\n * @param {Uint8Array|ArrayBuffer} buffer\n */\nfunction zeroBuffer(buffer) {\n if (buffer instanceof ArrayBuffer) {\n buffer = new Uint8Array(buffer);\n }\n buffer.fill(0);\n}\n\nmodule.exports.arrayBufferEquals = arrayBufferEquals;\nmodule.exports.bytesToString = bytesToString;\nmodule.exports.stringToBytes = stringToBytes;\nmodule.exports.base64ToBytes = base64ToBytes;\nmodule.exports.bytesToBase64 = bytesToBase64;\nmodule.exports.hexToBytes = hexToBytes;\nmodule.exports.bytesToHex = bytesToHex;\nmodule.exports.arrayToBuffer = arrayToBuffer;\nmodule.exports.zeroBuffer = zeroBuffer;\n","'use strict';\n\nmodule.exports.Signatures = {\n FileMagic: 0x9AA2D903,\n Sig2Kdbx: 0xB54BFB67,\n Sig2Kdb: 0xB54BFB65\n};\n\nmodule.exports.ErrorCodes = {\n NotImplemented: 'NotImplemented',\n InvalidArg: 'InvalidArg',\n BadSignature: 'BadSignature',\n InvalidVersion: 'InvalidVersion',\n Unsupported: 'Unsupported',\n FileCorrupt: 'FileCorrupt',\n InvalidKey: 'InvalidKey',\n MergeError: 'MergeError'\n};\n\nmodule.exports.CompressionAlgorithm = {\n None: 0,\n GZip: 1\n};\n\nmodule.exports.CrsAlgorithm = {\n Null: 0,\n ArcFourVariant: 1,\n Salsa20: 2,\n ChaCha20: 3\n};\n\nmodule.exports.KdfId = {\n Argon2: '72Nt34wpREuR96mkA+MKDA==',\n Aes: 'ydnzmmKKRGC/dA0IwYpP6g=='\n};\n\nmodule.exports.CipherId = {\n Aes: 'McHy5r9xQ1C+WAUhavxa/w==',\n ChaCha20: '1gOKK4tvTLWlJDOaMdu1mg=='\n};\n\nmodule.exports.AutoTypeObfuscationOptions = {\n None: 0,\n UseClipboard: 1\n};\n\nmodule.exports.Defaults = {\n KeyEncryptionRounds: 300000,\n MntncHistoryDays: 365,\n HistoryMaxItems: 10,\n HistoryMaxSize: 6 * 1024 * 1024,\n RecycleBinName: 'Recycle Bin'\n};\n\nmodule.exports.Icons = {\n Key: 0,\n World: 1,\n Warning: 2,\n NetworkServer: 3,\n MarkedDirectory: 4,\n UserCommunication: 5,\n Parts: 6,\n Notepad: 7,\n WorldSocket: 8,\n Identity: 9,\n PaperReady: 10,\n Digicam: 11,\n IRCommunication: 12,\n MultiKeys: 13,\n Energy: 14,\n Scanner: 15,\n WorldStar: 16,\n CDRom: 17,\n Monitor: 18,\n EMail: 19,\n Configuration: 20,\n ClipboardReady: 21,\n PaperNew: 22,\n Screen: 23,\n EnergyCareful: 24,\n EMailBox: 25,\n Disk: 26,\n Drive: 27,\n PaperQ: 28,\n TerminalEncrypted: 29,\n Console: 30,\n Printer: 31,\n ProgramIcons: 32,\n Run: 33,\n Settings: 34,\n WorldComputer: 35,\n Archive: 36,\n Homebanking: 37,\n DriveWindows: 39,\n Clock: 39,\n EMailSearch: 40,\n PaperFlag: 41,\n Memory: 42,\n TrashBin: 43,\n Note: 44,\n Expired: 45,\n Info: 46,\n Package: 47,\n Folder: 48,\n FolderOpen: 49,\n FolderPackage: 50,\n LockOpen: 51,\n PaperLocked: 52,\n Checked: 53,\n Pen: 54,\n Thumbnail: 55,\n Book: 56,\n List: 57,\n UserKey: 58,\n Tool: 59,\n Home: 60,\n Star: 61,\n Tux: 62,\n Feather: 63,\n Apple: 64,\n Wiki: 65,\n Money: 66,\n Certificate: 67,\n BlackBerry: 68\n};\n","'use strict';\n\nfunction KdbxError(code, message) {\n this.name = 'KdbxError';\n this.code = code;\n this.message = 'Error ' + code + (message ? ': ' + message : '');\n}\n\nKdbxError.prototype = Error.prototype;\n\nmodule.exports = KdbxError;\n","'use strict';\n\nvar ByteUtils = require('../utils/byte-utils'),\n KdbxError = require('../errors/kdbx-error'),\n Consts = require('../defs/consts'),\n ChaCha20 = require('./chacha20');\n\nvar webCrypto = global.crypto;\nvar subtle = webCrypto ? webCrypto.subtle || webCrypto.webkitSubtle : null;\nvar nodeCrypto = global.process && global.process.versions && global.process.versions.node ? require('crypto') : null;\n\nvar EmptySha256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';\nvar EmptySha512 = 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce' +\n '47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e';\n// maxRandomQuota is the max number of random bytes you can asks for from the cryptoEngine\n// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\nvar maxRandomQuota = 65536;\n\n\n/**\n * SHA-256 hash\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction sha256(data) {\n if (!data.byteLength) {\n return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256)));\n }\n if (subtle) {\n return subtle.digest({ name: 'SHA-256' }, data);\n } else if (nodeCrypto) {\n return new Promise(function(resolve) {\n var sha = nodeCrypto.createHash('sha256');\n var hash = sha.update(Buffer.from(data)).digest();\n resolve(hash.buffer);\n });\n } else {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA256 not implemented'));\n }\n}\n\n/**\n * SHA-512 hash\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction sha512(data) {\n if (!data.byteLength) {\n return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha512)));\n }\n if (subtle) {\n return subtle.digest({ name: 'SHA-512' }, data);\n } else if (nodeCrypto) {\n return new Promise(function(resolve) {\n var sha = nodeCrypto.createHash('sha512');\n var hash = sha.update(Buffer.from(data)).digest();\n resolve(hash.buffer);\n });\n } else {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA512 not implemented'));\n }\n}\n\n/**\n * HMAC-SHA-256 hash\n * @param {ArrayBuffer} key\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction hmacSha256(key, data) {\n if (subtle) {\n var algo = { name: 'HMAC', hash: { name: 'SHA-256' } };\n return subtle.importKey('raw', key, algo, false, ['sign'])\n .then(function(subtleKey) {\n return subtle.sign(algo, subtleKey, data);\n });\n } else if (nodeCrypto) {\n return new Promise(function(resolve) {\n var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key));\n var hash = hmac.update(Buffer.from(data)).digest();\n resolve(hash.buffer);\n });\n } else {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'HMAC-SHA256 not implemented'));\n }\n}\n\n/**\n * AES-CBC using WebCrypto\n * @constructor\n */\nfunction AesCbcSubtle() {\n}\n\nAesCbcSubtle.prototype.importKey = function(key) {\n var that = this;\n return subtle.importKey('raw', key, {name: 'AES-CBC'}, false, ['encrypt', 'decrypt'])\n .then(function(key) { that.key = key; });\n};\n\nAesCbcSubtle.prototype.encrypt = function(data, iv) {\n return subtle.encrypt({name: 'AES-CBC', iv: iv}, this.key, data);\n};\n\nAesCbcSubtle.prototype.decrypt = function(data, iv) {\n return subtle.decrypt({name: 'AES-CBC', iv: iv}, this.key, data)\n .catch(function() { throw new KdbxError(Consts.ErrorCodes.InvalidKey, 'invalid key'); });\n};\n\n/**\n * AES-CBC using node crypto\n * @constructor\n */\nfunction AesCbcNode() {\n}\n\nAesCbcNode.prototype.importKey = function(key) {\n this.key = key;\n return Promise.resolve();\n};\n\nAesCbcNode.prototype.encrypt = function(data, iv) {\n var that = this;\n return Promise.resolve().then(function() {\n var cipher = nodeCrypto.createCipheriv('aes-256-cbc', Buffer.from(that.key), Buffer.from(iv));\n var block = cipher.update(Buffer.from(data));\n return ByteUtils.arrayToBuffer(Buffer.concat([block, cipher.final()]));\n });\n};\n\nAesCbcNode.prototype.decrypt = function(data, iv) {\n var that = this;\n return Promise.resolve().then(function() {\n var cipher = nodeCrypto.createDecipheriv('aes-256-cbc', Buffer.from(that.key), Buffer.from(iv));\n var block = cipher.update(Buffer.from(data));\n return ByteUtils.arrayToBuffer(Buffer.concat([block, cipher.final()]));\n }).catch(function() { throw new KdbxError(Consts.ErrorCodes.InvalidKey, 'invalid key'); });\n};\n\n/**\n * Creates AES-CBC implementation\n * @returns AesCbc\n */\nfunction createAesCbc() {\n if (subtle) {\n return new AesCbcSubtle();\n } else if (nodeCrypto) {\n return new AesCbcNode();\n } else {\n throw new KdbxError(Consts.ErrorCodes.NotImplemented, 'AES-CBC not implemented');\n }\n}\n\n/**\n * Gets random bytes from the CryptoEngine\n * @param {number} len - bytes count\n * @return {Uint8Array} - random bytes\n */\nfunction safeRandom(len) {\n var randomBytes = new Uint8Array(len);\n while (len > 0) {\n var segmentSize = len % maxRandomQuota;\n segmentSize = segmentSize > 0 ? segmentSize : maxRandomQuota;\n var randomBytesSegment = new Uint8Array(segmentSize);\n webCrypto.getRandomValues(randomBytesSegment);\n len -= segmentSize;\n randomBytes.set(randomBytesSegment, len);\n }\n return randomBytes;\n}\n\n/**\n * Generates random bytes of specified length\n * @param {Number} len\n * @returns {Uint8Array}\n */\nfunction random(len) {\n if (subtle) {\n return safeRandom(len);\n } else if (nodeCrypto) {\n return new Uint8Array(nodeCrypto.randomBytes(len));\n } else {\n throw new KdbxError(Consts.ErrorCodes.NotImplemented, 'Random not implemented');\n }\n}\n\n/**\n * Encrypts with ChaCha20\n * @param {ArrayBuffer} data\n * @param {ArrayBuffer} key\n * @param {ArrayBuffer} iv\n * @returns {Promise.}\n */\nfunction chacha20(data, key, iv) {\n return Promise.resolve().then(function() {\n var algo = new ChaCha20(new Uint8Array(key), new Uint8Array(iv));\n return ByteUtils.arrayToBuffer(algo.encrypt(new Uint8Array(data)));\n });\n}\n\n/**\n * Argon2 hash\n * @param {ArrayBuffer} password\n * @param {ArrayBuffer} salt\n * @param {Number} memory - memory in KiB\n * @param {Number} iterations - number of iterations\n * @param {Number} length - hash length\n * @param {Number} parallelism - threads count (threads will be emulated if they are not supported)\n * @param {Number} type - 0 = argon2d, 1 = argon2i\n * @param {Number} version - 0x10 or 0x13\n * @returns {Promise.}\n */\nfunction argon2(password, salt, memory, iterations, length, parallelism, type, version) { // jshint ignore:line\n return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'Argon2 not implemented'));\n}\n\n/**\n * Configures globals, for tests\n */\nfunction configure(newSubtle, newWebCrypto, newNodeCrypto) {\n subtle = newSubtle;\n webCrypto = newWebCrypto;\n nodeCrypto = newNodeCrypto;\n}\n\nmodule.exports.subtle = subtle;\nmodule.exports.webCrypto = webCrypto;\nmodule.exports.nodeCrypto = nodeCrypto;\n\nmodule.exports.sha256 = sha256;\nmodule.exports.sha512 = sha512;\nmodule.exports.hmacSha256 = hmacSha256;\nmodule.exports.random = random;\nmodule.exports.createAesCbc = createAesCbc;\nmodule.exports.chacha20 = chacha20;\nmodule.exports.argon2 = argon2;\n\nmodule.exports.configure = configure;\n","'use strict';\n\nvar KdbxError = require('./../errors/kdbx-error'),\n Consts = require('./../defs/consts'),\n XmlNames = require('../defs/xml-names'),\n KdbxUuid = require('./../format/kdbx-uuid'),\n ProtectedValue = require('./../crypto/protected-value'),\n ByteUtils = require('./byte-utils'),\n Int64 = require('./int64'),\n pako = require('pako');\n\nvar dateRegex = /\\.\\d\\d\\d/;\n\nvar dom = global.DOMParser ? global : require('xmldom');\nvar domParserArg = global.DOMParser ? undefined : {\n errorHandler: {\n error: function(e) { throw e; },\n fatalError: function(e) { throw e; }\n }\n};\n\nvar EpochSeconds = 62135596800;\n\n/**\n * Parses XML document\n * Throws an error in case of invalid XML\n * @param {string} xml - xml document\n * @returns {Document}\n */\nfunction parse(xml) {\n var parser = domParserArg ? new dom.DOMParser(domParserArg) : new dom.DOMParser();\n var doc;\n try {\n doc = parser.parseFromString(xml, 'application/xml');\n } catch (e) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + e.message);\n }\n if (!doc.documentElement) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml');\n }\n var parserError = doc.getElementsByTagName('parsererror')[0];\n if (parserError) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + parserError.textContent);\n }\n return doc;\n}\n\n/**\n * Serializes document to XML string\n * @param {Document} doc - source document\n * @param {boolean} [prettyPrint=false] - whether to add whitespace around tags\n * @returns {string} - xml content\n */\nfunction serialize(doc, prettyPrint) {\n if (prettyPrint) {\n prettyPrintXmlNode(doc, 0);\n }\n var xml = new dom.XMLSerializer().serializeToString(doc);\n if (prettyPrint && xml.startsWith(') 0 ? '\\n' + ' '.repeat(indentationLevel - 1) : '';\n var doc = node.ownerDocument || node;\n\n var childNodes = [];\n var childNode;\n\n for (var i = 0; i < numChildNodes; i++) {\n childNode = node.childNodes[i];\n if (childNode.nodeType !== doc.TEXT_NODE && childNode.nodeType !== doc.PROCESSING_INSTRUCTION_NODE) {\n childNodes.push(childNode);\n }\n }\n\n for (var j = 0; j < childNodes.length; j++) {\n childNode = childNodes[j];\n\n var isFirstDocumentNode = indentationLevel === 0 && j === 0;\n if (!isFirstDocumentNode) {\n var textNodeBefore = doc.createTextNode(formatStr);\n node.insertBefore(textNodeBefore, childNode);\n }\n\n if (!childNode.nextSibling && indentationLevel > 0) {\n var textNodeAfter = doc.createTextNode(prevFormatStr);\n node.appendChild(textNodeAfter);\n }\n\n prettyPrintXmlNode(childNode, indentationLevel + 1);\n }\n}\n\n/**\n * Creates a document with specified root node name\n * @param {string} rootNode - root node name\n * @returns {Document} - created XML document\n */\nfunction create(rootNode) {\n return parse('<' + rootNode + '/>');\n}\n\n/**\n * Gets first child node from xml\n * @param {Node} node - parent node for search\n * @param {string} tagName - child node tag name\n * @param {string} [errorMsgIfAbsent] - if set, error will be thrown if node is absent\n * @returns {Node} - first found node, or null, if there's no such node\n */\nfunction getChildNode(node, tagName, errorMsgIfAbsent) {\n if (node && node.childNodes) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n if (cn[i].tagName === tagName) {\n return cn[i];\n }\n }\n }\n if (errorMsgIfAbsent) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, errorMsgIfAbsent);\n } else {\n return null;\n }\n}\n\n/**\n * Adds child node to xml\n * @param {Node} node - parent node\n * @param {string} tagName - child node tag name\n * @returns {Node} - created node\n */\nfunction addChildNode(node, tagName) {\n return node.appendChild((node.ownerDocument || node).createElement(tagName));\n}\n\n/**\n * Gets node inner text\n * @param {Node} node - xml node\n * @return {string|undefined} - node inner text or undefined, if the node is empty\n */\nfunction getText(node) {\n if (!node || !node.childNodes) {\n return undefined;\n }\n return node.protectedValue ? node.protectedValue.text : node.textContent;\n}\n\n/**\n * Sets node inner text\n * @param {Node} node\n * @param {string} text\n */\nfunction setText(node, text) {\n node.textContent = text || '';\n}\n\n/**\n * Parses bytes saved by KeePass from XML\n * @param {Node} node - xml node with bytes saved by KeePass (base64 format)\n * @return {ArrayBuffer} - ArrayBuffer or undefined, if the tag is empty\n */\nfunction getBytes(node) {\n var text = getText(node);\n return text ? ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(text)) : undefined;\n}\n\n/**\n * Sets bytes for node\n * @param {Node} node\n * @param {ArrayBuffer|Uint8Array|string|undefined} bytes\n */\nfunction setBytes(node, bytes) {\n if (typeof bytes === 'string') {\n bytes = ByteUtils.base64ToBytes(bytes);\n }\n setText(node, bytes ? ByteUtils.bytesToBase64(ByteUtils.arrayToBuffer(bytes)) : undefined);\n}\n\n/**\n * Parses date saved by KeePass from XML\n * @param {Node} node - xml node with date saved by KeePass (ISO format or base64-uint64) format\n * @return {Date} - date or undefined, if the tag is empty\n */\nfunction getDate(node) {\n var text = getText(node);\n if (!text) {\n return undefined;\n }\n if (text.indexOf(':') > 0) {\n return new Date(text);\n }\n var bytes = new DataView(ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(text)));\n var secondsFrom00 = new Int64(bytes.getUint32(0, true), bytes.getUint32(4, true)).value;\n var diff = (secondsFrom00 - EpochSeconds) * 1000;\n return new Date(diff);\n}\n\n/**\n * Sets node date as string or binary\n * @param {Node} node\n * @param {Date|undefined} date\n * @param {boolean} [binary=false]\n */\nfunction setDate(node, date, binary) {\n if (date) {\n if (binary) {\n var secondsFrom00 = Math.floor(date.getTime() / 1000) + EpochSeconds;\n var bytes = new DataView(new ArrayBuffer(8));\n var val64 = Int64.from(secondsFrom00);\n bytes.setUint32(0, val64.lo, true);\n bytes.setUint32(4, val64.hi, true);\n setText(node, ByteUtils.bytesToBase64(bytes.buffer));\n } else {\n setText(node, date.toISOString().replace(dateRegex, ''));\n }\n } else {\n setText(node, '');\n }\n}\n\n/**\n * Parses number saved by KeePass from XML\n * @param {Node} node - xml node with number saved by KeePass\n * @return {Number|undefined} - number or undefined, if the tag is empty\n */\nfunction getNumber(node) {\n var text = getText(node);\n return text ? +text : undefined;\n}\n\n/**\n * Sets node number\n * @param {Node} node\n * @return {Number|undefined} number\n */\nfunction setNumber(node, number) {\n setText(node, typeof number === 'number' && !isNaN(number) ? number.toString() : undefined);\n}\n\n/**\n * Parses boolean saved by KeePass from XML\n * @param {Node} node - xml node with boolean saved by KeePass\n * @return {boolean|undefined} - boolean or undefined, if the tag is empty\n */\nfunction getBoolean(node) {\n var text = getText(node);\n return text ? strToBoolean(text) : undefined;\n}\n\n/**\n * Sets node boolean\n * @param {Node} node\n * @param {boolean|undefined} boolean\n */\nfunction setBoolean(node, boolean) {\n setText(node, boolean === undefined ? '' : boolean === null ? 'null' : boolean ? 'True' : 'False');\n}\n\n/**\n * Converts saved string to boolean\n * @param {string} str\n * @returns {boolean}\n */\nfunction strToBoolean(str) {\n switch (str && str.toLowerCase && str.toLowerCase()) {\n case 'true':\n return true;\n case 'false':\n return false;\n case 'null':\n return null;\n }\n return undefined;\n}\n\n/**\n * Parses Uuid saved by KeePass from XML\n * @param {Node} node - xml node with Uuid saved by KeePass\n * @return {KdbxUuid} - Uuid or undefined, if the tag is empty\n */\nfunction getUuid(node) {\n var bytes = getBytes(node);\n return bytes ? new KdbxUuid(bytes) : undefined;\n}\n\n/**\n * Sets node uuid\n * @param {Node} node\n * @param {KdbxUuid} uuid\n */\nfunction setUuid(node, uuid) {\n var uuidBytes = uuid instanceof KdbxUuid ? uuid.toBytes() : uuid;\n setBytes(node, uuidBytes);\n}\n\n/**\n * Gets node protected text from inner text\n * @param {Node} node\n * @return {ProtectedValue|string}\n */\nfunction getProtectedText(node) {\n return node.protectedValue || node.textContent;\n}\n\n/**\n * Sets node protected text\n * @param {Node} node\n * @param {ProtectedValue|string} text\n */\nfunction setProtectedText(node, text) {\n if (text instanceof ProtectedValue) {\n node.protectedValue = text;\n node.setAttribute(XmlNames.Attr.Protected, 'True');\n } else {\n setText(node, text);\n }\n}\n\n/**\n * Gets node protected text from inner text\n * @param {Node} node\n * @return {ProtectedValue|ArrayBuffer|{ref: string}} - protected value, or array buffer, or reference to binary\n */\nfunction getProtectedBinary(node) {\n if (node.protectedValue) {\n return node.protectedValue;\n }\n var text = node.textContent;\n var ref = node.getAttribute(XmlNames.Attr.Ref);\n if (ref) {\n return { ref: ref };\n }\n if (!text) {\n return undefined;\n }\n var compressed = strToBoolean(node.getAttribute(XmlNames.Attr.Compressed));\n var bytes = ByteUtils.base64ToBytes(text);\n if (compressed) {\n bytes = pako.ungzip(bytes);\n }\n return ByteUtils.arrayToBuffer(bytes);\n}\n\n/**\n * Sets node protected binary\n * @param {Node} node\n * @param {ProtectedValue|ArrayBuffer|{ref: string}|string} binary\n */\nfunction setProtectedBinary(node, binary) {\n if (binary instanceof ProtectedValue) {\n node.protectedValue = binary;\n node.setAttribute(XmlNames.Attr.Protected, 'True');\n } else if (binary && binary.ref) {\n node.setAttribute(XmlNames.Attr.Ref, binary.ref);\n } else {\n setBytes(node, binary);\n }\n}\n\n/**\n * Traversed XML tree with depth-first preorder search\n * @param {Node} node\n * @param {function} callback\n */\nfunction traverse(node, callback) {\n callback(node);\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n traverse(childNode, callback);\n }\n }\n}\n\n/**\n * Reads protected values for all nodes in tree\n * @param {Node} node\n * @param {ProtectSaltGenerator} protectSaltGenerator\n */\nfunction setProtectedValues(node, protectSaltGenerator) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected))) {\n try {\n var value = ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(node.textContent));\n if (value.byteLength) {\n var salt = protectSaltGenerator.getSalt(value.byteLength);\n node.protectedValue = new ProtectedValue(value, salt);\n }\n } catch (e) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad protected value at line ' +\n node.lineNumber + ': ' + e);\n }\n }\n });\n}\n\n/**\n * Updates protected values salt for all nodes in tree which have protected values assigned\n * @param {Node} node\n * @param {ProtectSaltGenerator} protectSaltGenerator\n */\nfunction updateProtectedValuesSalt(node, protectSaltGenerator) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected)) && node.protectedValue) {\n var newSalt = protectSaltGenerator.getSalt(node.protectedValue.byteLength);\n node.protectedValue.setSalt(newSalt);\n node.textContent = node.protectedValue.toString();\n }\n });\n}\n\n/**\n * Unprotect protected values for all nodes in tree which have protected values assigned\n * @param {Node} node\n */\nfunction unprotectValues(node) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected)) && node.protectedValue) {\n node.removeAttribute(XmlNames.Attr.Protected);\n node.setAttribute(XmlNames.Attr.ProtectedInMemPlainXml, 'True');\n node.textContent = node.protectedValue.getText();\n }\n });\n}\n\n/**\n * Protect protected values back for all nodes in tree which have been unprotected\n * @param {Node} node\n */\nfunction protectUnprotectedValues(node) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.ProtectedInMemPlainXml)) && node.protectedValue) {\n node.removeAttribute(XmlNames.Attr.ProtectedInMemPlainXml);\n node.setAttribute(XmlNames.Attr.Protected, 'True');\n node.textContent = node.protectedValue.toString();\n }\n });\n}\n\n/**\n * Protect plain values in xml for all nodes in tree which should be protected\n * @param {Node} node\n */\nfunction protectPlainValues(node) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.ProtectedInMemPlainXml))) {\n node.protectedValue = ProtectedValue.fromString(node.textContent);\n node.textContent = node.protectedValue.toString();\n node.removeAttribute(XmlNames.Attr.ProtectedInMemPlainXml);\n node.setAttribute(XmlNames.Attr.Protected, 'True');\n }\n });\n}\n\nmodule.exports.parse = parse;\nmodule.exports.serialize = serialize;\nmodule.exports.create = create;\nmodule.exports.getChildNode = getChildNode;\nmodule.exports.addChildNode = addChildNode;\nmodule.exports.getText = getText;\nmodule.exports.setText = setText;\nmodule.exports.getBytes = getBytes;\nmodule.exports.setBytes = setBytes;\nmodule.exports.getDate = getDate;\nmodule.exports.setDate = setDate;\nmodule.exports.getNumber = getNumber;\nmodule.exports.setNumber = setNumber;\nmodule.exports.getBoolean = getBoolean;\nmodule.exports.setBoolean = setBoolean;\nmodule.exports.strToBoolean = strToBoolean;\nmodule.exports.getUuid = getUuid;\nmodule.exports.setUuid = setUuid;\nmodule.exports.getProtectedText = getProtectedText;\nmodule.exports.setProtectedText = setProtectedText;\nmodule.exports.getProtectedBinary = getProtectedBinary;\nmodule.exports.setProtectedBinary = setProtectedBinary;\nmodule.exports.setProtectedValues = setProtectedValues;\nmodule.exports.updateProtectedValuesSalt = updateProtectedValuesSalt;\nmodule.exports.unprotectValues = unprotectValues;\nmodule.exports.protectUnprotectedValues = protectUnprotectedValues;\nmodule.exports.protectPlainValues = protectPlainValues;\n","'use strict';\n\n\nvar TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n (typeof Uint16Array !== 'undefined') &&\n (typeof Int32Array !== 'undefined');\n\n\nexports.assign = function (obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n};\n\n\n// reduce buffer size, avoiding mem copy\nexports.shrinkBuf = function (buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n};\n\n\nvar fnTyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n }\n};\n\nvar fnUntyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n return [].concat.apply([], chunks);\n }\n};\n\n\n// Enable/Disable typed arrays use, for testing\n//\nexports.setTyped = function (on) {\n if (on) {\n exports.Buf8 = Uint8Array;\n exports.Buf16 = Uint16Array;\n exports.Buf32 = Int32Array;\n exports.assign(exports, fnTyped);\n } else {\n exports.Buf8 = Array;\n exports.Buf16 = Array;\n exports.Buf32 = Array;\n exports.assign(exports, fnUntyped);\n }\n};\n\nexports.setTyped(TYPED_OK);\n","'use strict';\n\nmodule.exports = {\n Elem: {\n DocNode: 'KeePassFile',\n\n Meta: 'Meta',\n Root: 'Root',\n Group: 'Group',\n Entry: 'Entry',\n\n Generator: 'Generator',\n HeaderHash: 'HeaderHash',\n SettingsChanged: 'SettingsChanged',\n DbName: 'DatabaseName',\n DbNameChanged: 'DatabaseNameChanged',\n DbDesc: 'DatabaseDescription',\n DbDescChanged: 'DatabaseDescriptionChanged',\n DbDefaultUser: 'DefaultUserName',\n DbDefaultUserChanged: 'DefaultUserNameChanged',\n DbMntncHistoryDays: 'MaintenanceHistoryDays',\n DbColor: 'Color',\n DbKeyChanged: 'MasterKeyChanged',\n DbKeyChangeRec: 'MasterKeyChangeRec',\n DbKeyChangeForce: 'MasterKeyChangeForce',\n RecycleBinEnabled: 'RecycleBinEnabled',\n RecycleBinUuid: 'RecycleBinUUID',\n RecycleBinChanged: 'RecycleBinChanged',\n EntryTemplatesGroup: 'EntryTemplatesGroup',\n EntryTemplatesGroupChanged: 'EntryTemplatesGroupChanged',\n HistoryMaxItems: 'HistoryMaxItems',\n HistoryMaxSize: 'HistoryMaxSize',\n LastSelectedGroup: 'LastSelectedGroup',\n LastTopVisibleGroup: 'LastTopVisibleGroup',\n\n MemoryProt: 'MemoryProtection',\n ProtTitle: 'ProtectTitle',\n ProtUserName: 'ProtectUserName',\n ProtPassword: 'ProtectPassword',\n ProtUrl: 'ProtectURL',\n ProtNotes: 'ProtectNotes',\n\n CustomIcons: 'CustomIcons',\n CustomIconItem: 'Icon',\n CustomIconItemID: 'UUID',\n CustomIconItemData: 'Data',\n\n AutoType: 'AutoType',\n History: 'History',\n\n Name: 'Name',\n Notes: 'Notes',\n Uuid: 'UUID',\n Icon: 'IconID',\n CustomIconID: 'CustomIconUUID',\n FgColor: 'ForegroundColor',\n BgColor: 'BackgroundColor',\n OverrideUrl: 'OverrideURL',\n Times: 'Times',\n Tags: 'Tags',\n\n CreationTime: 'CreationTime',\n LastModTime: 'LastModificationTime',\n LastAccessTime: 'LastAccessTime',\n ExpiryTime: 'ExpiryTime',\n Expires: 'Expires',\n UsageCount: 'UsageCount',\n LocationChanged: 'LocationChanged',\n\n GroupDefaultAutoTypeSeq: 'DefaultAutoTypeSequence',\n EnableAutoType: 'EnableAutoType',\n EnableSearching: 'EnableSearching',\n\n String: 'String',\n Binary: 'Binary',\n Key: 'Key',\n Value: 'Value',\n\n AutoTypeEnabled: 'Enabled',\n AutoTypeObfuscation: 'DataTransferObfuscation',\n AutoTypeDefaultSeq: 'DefaultSequence',\n AutoTypeItem: 'Association',\n Window: 'Window',\n KeystrokeSequence: 'KeystrokeSequence',\n\n Binaries: 'Binaries',\n\n IsExpanded: 'IsExpanded',\n LastTopVisibleEntry: 'LastTopVisibleEntry',\n\n DeletedObjects: 'DeletedObjects',\n DeletedObject: 'DeletedObject',\n DeletionTime: 'DeletionTime',\n\n CustomData: 'CustomData',\n StringDictExItem: 'Item'\n },\n\n Attr: {\n Id: 'ID',\n Ref: 'Ref',\n Protected: 'Protected',\n ProtectedInMemPlainXml: 'ProtectInMemory',\n Compressed: 'Compressed'\n },\n\n Val: {\n False: 'False',\n True: 'True'\n }\n};\n","'use strict';\n\nvar ByteUtils = require('../utils/byte-utils'),\n Random = require('../crypto/random');\n\nvar UuidLength = 16;\n\n/**\n * Uuid for passwords\n * @param {ArrayBuffer|string} ab - ArrayBuffer with data\n * @constructor\n */\nfunction KdbxUuid(ab) {\n if (ab === undefined) {\n ab = new ArrayBuffer(UuidLength);\n }\n if (typeof ab === 'string') {\n ab = ByteUtils.base64ToBytes(ab);\n }\n this.id = ab.byteLength === 16 ? ByteUtils.bytesToBase64(ab) : undefined;\n this.empty = true;\n if (ab) {\n var bytes = new Uint8Array(ab);\n for (var i = 0, len = bytes.length; i < len; i++) {\n if (bytes[i] !== 0) {\n this.empty = false;\n return;\n }\n }\n }\n}\n\n/**\n * Checks whether two uuids are equal\n * @param {KdbxUuid|string} other\n */\nKdbxUuid.prototype.equals = function(other) {\n return other && other.toString() === this.toString() || false;\n};\n\nObject.defineProperty(KdbxUuid.prototype, 'bytes', {\n enumerable: true,\n get: function() {\n return ByteUtils.base64ToBytes(this.id);\n }\n});\n\n/**\n * Generated random uuid\n * @return {KdbxUuid}\n * @static\n */\nKdbxUuid.random = function() {\n return new KdbxUuid(Random.getBytes(UuidLength));\n};\n\nKdbxUuid.prototype.toString = function() {\n return this.id;\n};\n\nKdbxUuid.prototype.valueOf = function() {\n return this.id;\n};\n\nKdbxUuid.prototype.toBytes = function() {\n return this.id ? ByteUtils.base64ToBytes(this.id) : undefined;\n};\n\nmodule.exports = KdbxUuid;\n","'use strict';\n\n/**\n * Represents 64-bit number\n * @param {number} [lo=0]\n * @param {number} [hi=0]\n * @constructor\n */\nfunction Int64(lo, hi) {\n this.lo = lo || 0;\n this.hi = hi || 0;\n}\n\n/**\n * Number value as float\n * @returns {Number}\n */\nObject.defineProperty(Int64.prototype, 'value', {\n enumerable: true,\n get: function() {\n if (this.hi) {\n if (this.hi >= 0x200000) {\n throw new Error('too large number');\n }\n return this.hi * 0x100000000 + this.lo;\n }\n return this.lo;\n }\n});\n\n/**\n * Gets number value\n * @returns {Number}\n */\nInt64.prototype.valueOf = function() {\n return this.value;\n};\n\n/**\n * Creates int64 from number\n * @param {number} value\n * @returns {Int64}\n * @static\n */\nInt64.from = function(value) {\n if (value > 0x1fffffffffffff) {\n throw new Error('too large number');\n }\n var lo = value >>> 0;\n var hi = ((value - lo) / 0x100000000) >>> 0;\n return new Int64(lo, hi);\n};\n\nmodule.exports = Int64;\n","'use strict';\n\nvar ByteUtils = require('../utils/byte-utils'),\n CryptoEngine = require('./crypto-engine'),\n Random = require('./random');\n\n/**\n * Protected value, used for protected entry fields\n * @param {ArrayBuffer} value - encrypted value\n * @param {ArrayBuffer} salt - salt bytes\n * @constructor\n */\nvar ProtectedValue = function(value, salt) {\n Object.defineProperty(this, '_value', { value: new Uint8Array(value) });\n Object.defineProperty(this, '_salt', { value: new Uint8Array(salt) });\n};\n\n/**\n * Returns protected value as base64 string\n * @returns {string}\n */\nProtectedValue.prototype.toString = function() {\n return ByteUtils.bytesToBase64(this._value);\n};\n\n/**\n * Creates protected value from string with new random salt\n * @param {string} str\n */\nProtectedValue.fromString = function(str) {\n var bytes = ByteUtils.stringToBytes(str),\n salt = Random.getBytes(bytes.length);\n for (var i = 0, len = bytes.length; i < len; i++) {\n bytes[i] ^= salt[i];\n }\n return new ProtectedValue(ByteUtils.arrayToBuffer(bytes), ByteUtils.arrayToBuffer(salt));\n};\n\n/**\n * Creates protected value from binary with new random salt\n * @param {ArrayBuffer} binary\n */\nProtectedValue.fromBinary = function(binary) {\n var bytes = new Uint8Array(binary),\n salt = Random.getBytes(bytes.length);\n for (var i = 0, len = bytes.length; i < len; i++) {\n bytes[i] ^= salt[i];\n }\n return new ProtectedValue(ByteUtils.arrayToBuffer(bytes), ByteUtils.arrayToBuffer(salt));\n};\n\n/**\n * Determines whether the value is included as substring (safe check; doesn't decrypt full string)\n * @param {string} str\n * @return {boolean}\n */\nProtectedValue.prototype.includes = function(str) {\n if (str.length === 0) {\n return false;\n }\n var source = this._value,\n salt = this._salt,\n search = ByteUtils.stringToBytes(str),\n sourceLen = source.length, searchLen = search.length, maxPos = sourceLen - searchLen,\n sourceIx, searchIx;\n src: for (sourceIx = 0; sourceIx <= maxPos; sourceIx++) {\n for (searchIx = 0; searchIx < searchLen; searchIx++) {\n if ((source[sourceIx + searchIx] ^ salt[sourceIx + searchIx]) !== search[searchIx]) {\n continue src;\n }\n }\n return true;\n }\n return false;\n};\n\n/**\n * Calculates SHA256 hash of saved value\n * @return {Promise.}\n */\nProtectedValue.prototype.getHash = function() {\n var binary = ByteUtils.arrayToBuffer(this.getBinary());\n return CryptoEngine.sha256(binary).then(function(hash) {\n ByteUtils.zeroBuffer(binary);\n return hash;\n });\n};\n\n/**\n * Decrypted text\n * @returns {string}\n */\nProtectedValue.prototype.getText = function() {\n return ByteUtils.bytesToString(this.getBinary());\n};\n\n/**\n * Decrypted binary. Don't forget to zero it after usage\n * @returns {Uint8Array}\n */\nProtectedValue.prototype.getBinary = function() {\n var value = this._value, salt = this._salt;\n var bytes = new Uint8Array(value.byteLength);\n for (var i = bytes.length - 1; i >= 0; i--) {\n bytes[i] = value[i] ^ salt[i];\n }\n return bytes;\n};\n\n/**\n * Sets new salt\n * @param {ArrayBuffer} newSalt\n */\nProtectedValue.prototype.setSalt = function(newSalt) {\n var newSaltArr = new Uint8Array(newSalt);\n var value = this._value, salt = this._salt;\n for (var i = 0, len = value.length; i < len; i++) {\n value[i] = value[i] ^ salt[i] ^ newSaltArr[i];\n salt[i] = newSaltArr[i];\n }\n};\n\n/**\n * Clones object\n * @return {ProtectedValue}\n */\nProtectedValue.prototype.clone = function() {\n return new ProtectedValue(this._value, this._salt);\n};\n\n/**\n * Value byte length\n */\nObject.defineProperty(ProtectedValue.prototype, 'byteLength', {\n enumerable: true,\n get: function() {\n return this._value.byteLength;\n }\n});\n\nmodule.exports = ProtectedValue;\n","'use strict';\n\nvar Salsa20 = require('./salsa20'),\n CryptoEngine = require('./crypto-engine');\n\nvar key = new Uint8Array(32), nonce = new Uint8Array(8);\nfor (var i = 0; i < key.length; i++) {\n key[i] = Math.random() * 0xff;\n}\nfor (var j = 0; j < nonce.length; j++) {\n nonce[i] = Math.random() * 0xff;\n}\nvar algo = new Salsa20(key, nonce);\n\n/**\n * Gets random bytes\n * @param {number} len - bytes count\n * @return {Uint8Array} - random bytes\n */\nfunction getBytes(len) {\n if (!len) {\n return new Uint8Array(0);\n }\n algo.getBytes(Math.round(Math.random() * len) + 1);\n var result = algo.getBytes(len);\n var cryptoBytes = CryptoEngine.random(len);\n for (var i = cryptoBytes.length - 1; i >= 0; --i) {\n result[i] ^= cryptoBytes[i];\n }\n return result;\n}\n\nmodule.exports.getBytes = getBytes;\n","'use strict';\n\n/**\n * Stream for accessing array buffer with auto-advanced position\n * @param {ArrayBuffer} [arrayBuffer]\n * @constructor\n */\nfunction BinaryStream(arrayBuffer) {\n this._arrayBuffer = arrayBuffer || new ArrayBuffer(1024);\n this._dataView = new DataView(this._arrayBuffer);\n this._pos = 0;\n this._canExpand = !arrayBuffer;\n}\n\n['Int', 'Uint', 'Float'].forEach(function(type) {\n (type === 'Float' ? [4, 8] : [1, 2, 4]).forEach(function(bytes) {\n var getMethod = 'get' + type + bytes * 8;\n BinaryStream.prototype[getMethod] = function(littleEndian) {\n var res = this._dataView[getMethod].call(this._dataView, this._pos, littleEndian);\n this._pos += bytes;\n return res;\n };\n var setMethod = 'set' + type + bytes * 8;\n BinaryStream.prototype[setMethod] = function(value, littleEndian) {\n this._checkCapacity(bytes);\n this._dataView[setMethod].call(this._dataView, this._pos, value, littleEndian);\n this._pos += bytes;\n };\n });\n});\n\nBinaryStream.prototype.getUint64 = function(littleEndian) {\n var part1 = this.getUint32(littleEndian),\n part2 = this.getUint32(littleEndian);\n if (littleEndian) {\n part2 *= 0x100000000;\n } else {\n part1 *= 0x100000000;\n }\n return part1 + part2;\n};\n\nBinaryStream.prototype.setUint64 = function(value, littleEndian) {\n if (littleEndian) {\n this.setUint32(value & 0xffffffff, true);\n this.setUint32(Math.floor(value / 0x100000000), true);\n } else {\n this._checkCapacity(8);\n this.setUint32(Math.floor(value / 0x100000000), false);\n this.setUint32(value & 0xffffffff, false);\n }\n};\n\nBinaryStream.prototype.readBytes = function(size) {\n var buffer = this._arrayBuffer.slice(this._pos, this._pos + size);\n this._pos += size;\n return buffer;\n};\n\nBinaryStream.prototype.readBytesToEnd = function() {\n var size = this._arrayBuffer.byteLength - this._pos;\n return this.readBytes(size);\n};\n\nBinaryStream.prototype.readBytesNoAdvance = function(startPos, endPos) {\n return this._arrayBuffer.slice(startPos, endPos);\n};\n\nBinaryStream.prototype.writeBytes = function(bytes) {\n if (bytes instanceof ArrayBuffer) {\n bytes = new Uint8Array(bytes);\n }\n this._checkCapacity(bytes.length);\n new Uint8Array(this._arrayBuffer).set(bytes, this._pos);\n this._pos += bytes.length;\n};\n\nBinaryStream.prototype.getWrittenBytes = function() {\n return this._arrayBuffer.slice(0, this._pos);\n};\n\nBinaryStream.prototype._checkCapacity = function(addBytes) {\n var available = this._arrayBuffer.byteLength - this._pos;\n if (this._canExpand && available < addBytes) {\n var newLen = this._arrayBuffer.byteLength,\n requestedLen = this._pos + addBytes;\n while (newLen < requestedLen) {\n newLen *= 2;\n }\n var newData = new Uint8Array(newLen);\n newData.set(new Uint8Array(this._arrayBuffer));\n this._arrayBuffer = newData.buffer;\n this._dataView = new DataView(this._arrayBuffer);\n }\n};\n\nObject.defineProperty(BinaryStream.prototype, 'pos', {\n enumerable: true,\n get: function() {\n return this._pos;\n }\n});\n\nObject.defineProperty(BinaryStream.prototype, 'byteLength', {\n enumerable: true,\n get: function() {\n return this._arrayBuffer.byteLength;\n }\n});\n\nmodule.exports = BinaryStream;\n","'use strict';\n\nmodule.exports = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","'use strict';\n\nvar KdbxError = require('../errors/kdbx-error');\nvar Consts = require('../defs/consts');\nvar ByteUtils = require('../utils/byte-utils');\nvar Int64 = require('../utils/int64');\n\nvar MaxSupportedVersion = 1;\nvar DefaultVersion = 0x0100;\n\n/**\n * Value type\n * @enum\n */\nvar ValueType = {\n UInt32: 0x04,\n UInt64: 0x05,\n Bool: 0x08,\n Int32: 0x0C,\n Int64: 0x0D,\n String: 0x18,\n Bytes: 0x42\n};\n\n/**\n * Variant dictionary, capable to store/load different values from byte array\n * @constructor\n */\nfunction VarDictionary() {\n this._items = [];\n this._dict = {};\n Object.preventExtensions(this);\n}\n\n/**\n * Available value types enum\n * @enum\n */\nVarDictionary.ValueType = ValueType;\n\n/**\n * Gets value or undefined\n * @param {string} key\n * @returns {*}\n */\nVarDictionary.prototype.get = function(key) {\n var item = this._dict[key];\n return item ? item.value : undefined;\n};\n\n/**\n * Get all keys\n * @return {string[]} keys array\n */\nVarDictionary.prototype.keys = function() {\n return this._items.map(function(item) { return item.key; });\n};\n\n/**\n * Keys count\n * @returns {Number}\n */\nObject.defineProperty(VarDictionary.prototype, 'length', {\n enumberable: true,\n get: function() { return this._items.length; }\n});\n\n/**\n * Sets or replaces existing item\n * @param {String} key\n * @param {VarDictionary.ValueType|Number} type\n * @param {*} value\n */\nVarDictionary.prototype.set = function(key, type, value) {\n switch (type) {\n case ValueType.UInt32:\n if (typeof value !== 'number' || value < 0) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.UInt64:\n if (!(value instanceof Int64)) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.Bool:\n if (typeof value !== 'boolean') {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.Int32:\n if (typeof value !== 'number') {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.Int64:\n if (!(value instanceof Int64)) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.String:\n if (typeof value !== 'string') {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.Bytes:\n if (value instanceof Uint8Array) {\n value = ByteUtils.arrayToBuffer(value);\n }\n if (!(value instanceof ArrayBuffer)) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n default:\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n var item = { key: key, type: type, value: value };\n if (this._dict[key]) {\n var ix = this._items.indexOf(this._dict[key]);\n this._items.splice(ix, 1, item);\n } else {\n this._items.push(item);\n }\n this._dict[key] = item;\n};\n\n/**\n * Removes key from dictionary\n * @param {string} key\n */\nVarDictionary.prototype.remove = function(key) {\n this._items = this._items.filter(function(item) { return item.key !== key; });\n delete this._dict[key];\n};\n\n/**\n * Reads dictionary from stream\n * @param {BinaryStream} stm\n * @returns {VarDictionary}\n * @static\n */\nVarDictionary.read = function(stm) {\n var dict = new VarDictionary();\n dict._readVersion(stm);\n while (true) {\n var item = dict._readItem(stm);\n if (!item) {\n break;\n }\n dict._items.push(item);\n dict._dict[item.key] = item;\n }\n return dict;\n};\n\nVarDictionary.prototype._readVersion = function(stm) {\n stm.getUint8();\n var versionMajor = stm.getUint8();\n if (versionMajor === 0 || versionMajor > MaxSupportedVersion) {\n throw new KdbxError(Consts.ErrorCodes.InvalidVersion);\n }\n};\n\nVarDictionary.prototype._readItem = function(stm) {\n var type = stm.getUint8();\n if (!type) {\n return false;\n }\n var keyLength = stm.getInt32(true);\n if (keyLength <= 0) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad key length');\n }\n var key = ByteUtils.bytesToString(stm.readBytes(keyLength));\n var valueLength = stm.getInt32(true);\n if (valueLength < 0) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad value length');\n }\n var value;\n switch (type) {\n case ValueType.UInt32:\n if (valueLength !== 4) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad uint32');\n }\n value = stm.getUint32(true);\n break;\n case ValueType.UInt64:\n if (valueLength !== 8) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad uint64');\n }\n var loInt = stm.getUint32(true);\n var hiInt = stm.getUint32(true);\n value = new Int64(loInt, hiInt);\n break;\n case ValueType.Bool:\n if (valueLength !== 1) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad bool');\n }\n value = stm.getUint8() !== 0;\n break;\n case ValueType.Int32:\n if (valueLength !== 4) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad int32');\n }\n value = stm.getInt32(true);\n break;\n case ValueType.Int64:\n if (valueLength !== 8) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad int64');\n }\n var loUint = stm.getUint32(true);\n var hiUint = stm.getUint32(true);\n value = new Int64(loUint, hiUint);\n break;\n case ValueType.String:\n value = ByteUtils.bytesToString(stm.readBytes(valueLength));\n break;\n case ValueType.Bytes:\n value = stm.readBytes(valueLength);\n break;\n default:\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad value type: ' + type);\n }\n return { key: key, type: type, value: value };\n};\n\n/**\n * Writes self to binary stream\n * @param {BinaryStream} stm\n */\nVarDictionary.prototype.write = function(stm) {\n this._writeVersion(stm);\n Object.keys(this._items).forEach(function(key) {\n this._writeItem(stm, this._items[key]);\n }, this);\n stm.setUint8(0);\n};\n\nVarDictionary.prototype._writeVersion = function(stm) {\n stm.setUint16(DefaultVersion, true);\n};\n\nVarDictionary.prototype._writeItem = function(stm, item) {\n stm.setUint8(item.type);\n var keyBytes = ByteUtils.stringToBytes(item.key);\n stm.setInt32(keyBytes.length, true);\n stm.writeBytes(keyBytes);\n switch (item.type) {\n case ValueType.UInt32:\n stm.setInt32(4, true);\n stm.setUint32(item.value, true);\n break;\n case ValueType.UInt64:\n stm.setInt32(8, true);\n stm.setUint32(item.value.lo, true);\n stm.setUint32(item.value.hi, true);\n break;\n case ValueType.Bool:\n stm.setInt32(1, true);\n stm.setUint8(item.value ? 1 : 0);\n break;\n case ValueType.Int32:\n stm.setInt32(4, true);\n stm.setInt32(item.value, true);\n break;\n case ValueType.Int64:\n stm.setInt32(8, true);\n stm.setUint32(item.value.lo, true);\n stm.setUint32(item.value.hi, true);\n break;\n case ValueType.String:\n var strBytes = ByteUtils.stringToBytes(item.value);\n stm.setInt32(strBytes.length, true);\n stm.writeBytes(strBytes);\n break;\n case ValueType.Bytes:\n var bytesBuffer = ByteUtils.arrayToBuffer(item.value);\n stm.setInt32(bytesBuffer.byteLength, true);\n stm.writeBytes(bytesBuffer);\n break;\n default:\n throw new KdbxError(Consts.ErrorCodes.Unsupported);\n }\n};\n\nmodule.exports = VarDictionary;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils');\n\nvar KdbxCustomData = {\n /**\n * Reads custom data from xml\n * @param {Node} node - xml node\n * @returns {object} - custom data dictionary\n */\n read: function(node) {\n var customData = {};\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName === XmlNames.Elem.StringDictExItem) {\n KdbxCustomData._readItem(childNode, customData);\n }\n }\n return customData;\n },\n\n /**\n * Writes custom data to xml\n * @param {Node} parentNode - xml node\n * @param {object} customData - custom data dictionary\n */\n write: function(parentNode, customData) {\n if (!customData) {\n return;\n }\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.CustomData);\n Object.keys(customData).forEach(function(key) {\n var value = customData[key];\n if (value) {\n var itemNode = XmlUtils.addChildNode(node, XmlNames.Elem.StringDictExItem);\n XmlUtils.setText(XmlUtils.addChildNode(itemNode, XmlNames.Elem.Key), key);\n XmlUtils.setText(XmlUtils.addChildNode(itemNode, XmlNames.Elem.Value), value);\n }\n });\n },\n\n _readItem: function(node, customData) {\n var key, value;\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.Key:\n key = XmlUtils.getText(childNode);\n break;\n case XmlNames.Elem.Value:\n value = XmlUtils.getText(childNode);\n break;\n }\n }\n if (key) {\n customData[key] = value;\n }\n }\n};\n\nmodule.exports = KdbxCustomData;\n","// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign = require('./lib/utils/common').assign;\n\nvar deflate = require('./lib/deflate');\nvar inflate = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n","'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n","'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n","// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new utils.Buf8(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n var buf = new utils.Buf8(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n","'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\nmodule.exports = ZStream;\n","'use strict';\n\n\nmodule.exports = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n //Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\n","'use strict';\n\n/* Docs for the KDBX header schema:\n * https://keepass.info/help/kb/kdbx_4.html#innerhdr\n */\n\nvar KdbxUuid = require('./kdbx-uuid'),\n Consts = require('./../defs/consts'),\n ProtectedValue = require('./../crypto/protected-value'),\n KdbxError = require('./../errors/kdbx-error'),\n BinaryStream = require('./../utils/binary-stream'),\n ByteUtils = require('./../utils/byte-utils'),\n VarDictionary = require('./../utils/var-dictionary'),\n Int64 = require('./../utils/int64'),\n Random = require('../crypto/random');\n\nvar HeaderFields = [\n { name: 'EndOfHeader' },\n\n { name: 'Comment' },\n { name: 'CipherID' },\n { name: 'CompressionFlags' },\n { name: 'MasterSeed' },\n { name: 'TransformSeed', ver: [3] },\n { name: 'TransformRounds', ver: [3] },\n { name: 'EncryptionIV' },\n { name: 'ProtectedStreamKey', ver: [3] },\n { name: 'StreamStartBytes', ver: [3] },\n { name: 'InnerRandomStreamID', ver: [3] },\n\n { name: 'KdfParameters', ver: [4] },\n { name: 'PublicCustomData', ver: [4] }\n];\n\nvar InnerHeaderFields = [\n { name: 'EndOfHeader' },\n\n { name: 'InnerRandomStreamID' },\n { name: 'InnerRandomStreamKey' },\n { name: 'Binary', skipHeader: true }\n];\n\nvar HeaderConst = {\n DefaultFileVersionMajor: 3,\n DefaultFileVersionMinor: 1,\n MaxFileVersionMajor: 4,\n MaxFileVersionMinor: 1,\n MaxSupportedVersion: 4,\n FlagBinaryProtected: 0x01,\n InnerHeaderBinaryFieldId: 0x03,\n\n DefaultKdfAlgo: Consts.KdfId.Argon2,\n DefaultKdfSaltLength: 32,\n DefaultKdfParallelism: 1,\n DefaultKdfIterations: 2,\n DefaultKdfMemory: 1024 * 1024,\n DefaultKdfVersion: 0x13\n};\n\nvar LastMinorVersions = {\n 3: 1,\n 4: 1\n};\n\n/**\n * Binary file header reader/writer\n * @constructor\n */\nvar KdbxHeader = function() {\n this.versionMajor = undefined;\n this.versionMinor = undefined;\n this.dataCipherUuid = undefined;\n this.compression = undefined;\n this.masterSeed = undefined;\n this.transformSeed = undefined;\n this.keyEncryptionRounds = undefined;\n this.encryptionIV = undefined;\n this.protectedStreamKey = undefined;\n this.streamStartBytes = undefined;\n this.crsAlgorithm = undefined;\n this.endPos = undefined;\n this.kdfParameters = undefined;\n this.publicCustomData = undefined;\n Object.preventExtensions(this);\n};\n\nKdbxHeader.prototype._readSignature = function(stm) {\n if (stm.byteLength < 8) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'not enough data');\n }\n var sig1 = stm.getUint32(true), sig2 = stm.getUint32(true);\n if (!(sig1 === Consts.Signatures.FileMagic && sig2 === Consts.Signatures.Sig2Kdbx)) {\n throw new KdbxError(Consts.ErrorCodes.BadSignature);\n }\n};\n\nKdbxHeader.prototype._writeSignature = function(stm) {\n stm.setUint32(Consts.Signatures.FileMagic, true);\n stm.setUint32(Consts.Signatures.Sig2Kdbx, true);\n};\n\nKdbxHeader.prototype._readVersion = function(stm) {\n var versionMinor = stm.getUint16(true);\n var versionMajor = stm.getUint16(true);\n if (versionMajor > HeaderConst.MaxSupportedVersion) {\n throw new KdbxError(Consts.ErrorCodes.InvalidVersion);\n }\n this.versionMinor = versionMinor;\n this.versionMajor = versionMajor;\n};\n\nKdbxHeader.prototype._writeVersion = function(stm) {\n stm.setUint16(this.versionMinor, true);\n stm.setUint16(this.versionMajor, true);\n};\n\nKdbxHeader.prototype._readCipherID = function(bytes) {\n if (bytes.byteLength !== 16) {\n throw new KdbxError(Consts.ErrorCodes.Unsupported, 'cipher');\n }\n this.dataCipherUuid = new KdbxUuid(bytes);\n};\n\nKdbxHeader.prototype._writeCipherID = function(stm) {\n this._writeFieldSize(stm, 16);\n stm.writeBytes(this.dataCipherUuid.bytes);\n};\n\nKdbxHeader.prototype._readCompressionFlags = function(bytes) {\n var id = new DataView(bytes).getUint32(bytes, true);\n if (id < 0 || id >= Object.keys(Consts.CompressionAlgorithm).length) {\n throw new KdbxError(Consts.ErrorCodes.Unsupported, 'compression');\n }\n this.compression = id;\n};\n\nKdbxHeader.prototype._writeCompressionFlags = function(stm) {\n this._writeFieldSize(stm, 4);\n stm.setUint32(this.compression, true);\n};\n\nKdbxHeader.prototype._readMasterSeed = function(bytes) {\n this.masterSeed = bytes;\n};\n\nKdbxHeader.prototype._writeMasterSeed = function(stm) {\n this._writeFieldBytes(stm, this.masterSeed);\n};\n\nKdbxHeader.prototype._readTransformSeed = function(bytes) {\n this.transformSeed = bytes;\n};\n\nKdbxHeader.prototype._writeTransformSeed = function(stm) {\n this._writeFieldBytes(stm, this.transformSeed);\n};\n\nKdbxHeader.prototype._readTransformRounds = function(bytes) {\n this.keyEncryptionRounds = new BinaryStream(bytes).getUint64(true);\n};\n\nKdbxHeader.prototype._writeTransformRounds = function(stm) {\n this._writeFieldSize(stm, 8);\n stm.setUint64(this.keyEncryptionRounds, true);\n};\n\nKdbxHeader.prototype._readEncryptionIV = function(bytes) {\n this.encryptionIV = bytes;\n};\n\nKdbxHeader.prototype._writeEncryptionIV = function(stm) {\n this._writeFieldBytes(stm, this.encryptionIV);\n};\n\nKdbxHeader.prototype._readProtectedStreamKey = function(bytes) {\n this.protectedStreamKey = bytes;\n};\n\nKdbxHeader.prototype._writeProtectedStreamKey = function(stm) {\n this._writeFieldBytes(stm, this.protectedStreamKey);\n};\n\nKdbxHeader.prototype._readStreamStartBytes = function(bytes) {\n this.streamStartBytes = bytes;\n};\n\nKdbxHeader.prototype._writeStreamStartBytes = function(stm) {\n this._writeFieldBytes(stm, this.streamStartBytes);\n};\n\nKdbxHeader.prototype._readInnerRandomStreamID = function(bytes) {\n this.crsAlgorithm = new DataView(bytes).getUint32(bytes, true);\n};\n\nKdbxHeader.prototype._writeInnerRandomStreamID = function(stm) {\n this._writeFieldSize(stm, 4);\n stm.setUint32(this.crsAlgorithm, true);\n};\n\nKdbxHeader.prototype._readInnerRandomStreamKey = function(bytes) {\n this.protectedStreamKey = bytes;\n};\n\nKdbxHeader.prototype._writeInnerRandomStreamKey = function(stm) {\n this._writeFieldBytes(stm, this.protectedStreamKey);\n};\n\nKdbxHeader.prototype._readKdfParameters = function(bytes) {\n this.kdfParameters = VarDictionary.read(new BinaryStream(bytes));\n};\n\nKdbxHeader.prototype._writeKdfParameters = function(stm) {\n var innerStream = new BinaryStream();\n this.kdfParameters.write(innerStream);\n this._writeFieldBytes(stm, innerStream.getWrittenBytes());\n};\n\nKdbxHeader.prototype._readPublicCustomData = function(bytes) {\n this.publicCustomData = VarDictionary.read(new BinaryStream(bytes));\n};\n\nKdbxHeader.prototype._hasPublicCustomData = function() {\n return this.publicCustomData;\n};\n\nKdbxHeader.prototype._writePublicCustomData = function(stm) {\n if (this.publicCustomData) {\n var innerStream = new BinaryStream();\n this.publicCustomData.write(innerStream);\n this._writeFieldBytes(stm, innerStream.getWrittenBytes());\n }\n};\n\nKdbxHeader.prototype._readBinary = function(bytes, ctx) {\n var view = new DataView(bytes);\n var flags = view.getUint8(0);\n var isProtected = flags & HeaderConst.FlagBinaryProtected;\n var binaryData = bytes.slice(1); // Actual data comes after the flag byte\n\n var binary = isProtected ? ProtectedValue.fromBinary(binaryData) : binaryData;\n\n var binaryIndex = Object.keys(ctx.kdbx.binaries).length;\n ctx.kdbx.binaries[binaryIndex] = binary;\n};\n\nKdbxHeader.prototype._writeBinary = function(stm, ctx) {\n if (this.versionMajor < 4) {\n return;\n }\n var binaryHashes = ctx.kdbx.binaries.hashOrder;\n for (var index = 0; index < binaryHashes.length; index++) {\n stm.setUint8(HeaderConst.InnerHeaderBinaryFieldId);\n var binary = ctx.kdbx.binaries[binaryHashes[index]];\n if (!binary) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no binary ' + index);\n }\n if (binary instanceof ProtectedValue) {\n var binaryData = binary.getBinary();\n this._writeFieldSize(stm, binaryData.byteLength + 1);\n stm.setUint8(HeaderConst.FlagBinaryProtected);\n stm.writeBytes(binaryData);\n ByteUtils.zeroBuffer(binaryData);\n } else {\n binary = ByteUtils.arrayToBuffer(binary);\n this._writeFieldSize(stm, binary.byteLength + 1);\n stm.setUint8(0);\n stm.writeBytes(binary);\n }\n }\n};\n\nKdbxHeader.prototype._writeEndOfHeader = function(stm) {\n this._writeFieldSize(stm, 4);\n stm.setUint32(0x0d0ad0a);\n};\n\nKdbxHeader.prototype._readField = function(stm, fields, ctx) {\n var headerId = stm.getUint8();\n var size = this._readFieldSize(stm);\n var bytes;\n if (size > 0) {\n bytes = stm.readBytes(size);\n }\n\n var headerField = fields[headerId];\n if (headerField) {\n var method = this['_read' + headerField.name];\n if (method) {\n method.call(this, bytes, ctx);\n }\n }\n return headerId !== 0;\n};\n\nKdbxHeader.prototype._writeField = function(stm, headerId, fields, ctx) {\n var headerField = fields[headerId];\n if (headerField) {\n if (headerField.ver && headerField.ver.indexOf(this.versionMajor) < 0) {\n return;\n }\n var method = this['_write' + headerField.name];\n if (method) {\n var hasMethod = this['_has' + headerField.name];\n if (hasMethod && !hasMethod.call(this)) {\n return;\n }\n if (!headerField.skipHeader) {\n stm.setUint8(headerId);\n }\n method.call(this, stm, ctx);\n }\n }\n};\n\nKdbxHeader.prototype._readFieldSize = function(stm) {\n return this.versionMajor >= 4 ? stm.getUint32(true) : stm.getUint16(true);\n};\n\nKdbxHeader.prototype._writeFieldSize = function(stm, size) {\n if (this.versionMajor >= 4) {\n stm.setUint32(size, true);\n } else {\n stm.setUint16(size, true);\n }\n};\n\nKdbxHeader.prototype._writeFieldBytes = function(stm, bytes) {\n this._writeFieldSize(stm, bytes.byteLength);\n stm.writeBytes(bytes);\n};\n\nKdbxHeader.prototype._validate = function() {\n if (this.dataCipherUuid === undefined) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no cipher in header');\n }\n if (this.compression === undefined) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no compression in header');\n }\n if (!this.masterSeed) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no master seed in header');\n }\n if (this.versionMajor < 4 && !this.transformSeed) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no transform seed in header');\n }\n if (this.versionMajor < 4 && !this.keyEncryptionRounds) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no key encryption rounds in header');\n }\n if (!this.encryptionIV) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no encryption iv in header');\n }\n if (this.versionMajor < 4 && !this.protectedStreamKey) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no protected stream key in header');\n }\n if (this.versionMajor < 4 && !this.streamStartBytes) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no stream start bytes in header');\n }\n if (this.versionMajor < 4 && !this.crsAlgorithm) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no crs algorithm in header');\n }\n if (this.versionMajor >= 4 && !this.kdfParameters) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no kdf parameters in header');\n }\n};\n\nKdbxHeader.prototype._validateInner = function() {\n if (!this.protectedStreamKey) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no protected stream key in header');\n }\n if (!this.crsAlgorithm) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no crs algorithm in header');\n }\n};\n\nKdbxHeader.prototype._createKdfParameters = function(algo) {\n if (!algo) {\n algo = HeaderConst.DefaultKdfAlgo;\n }\n switch (algo) {\n case Consts.KdfId.Argon2:\n this.kdfParameters = new VarDictionary();\n this.kdfParameters.set('$UUID', VarDictionary.ValueType.Bytes, ByteUtils.base64ToBytes(Consts.KdfId.Argon2));\n this.kdfParameters.set('S', VarDictionary.ValueType.Bytes, Random.getBytes(HeaderConst.DefaultKdfSaltLength));\n this.kdfParameters.set('P', VarDictionary.ValueType.UInt32, HeaderConst.DefaultKdfParallelism);\n this.kdfParameters.set('I', VarDictionary.ValueType.UInt64, new Int64(HeaderConst.DefaultKdfIterations));\n this.kdfParameters.set('M', VarDictionary.ValueType.UInt64, new Int64(HeaderConst.DefaultKdfMemory));\n this.kdfParameters.set('V', VarDictionary.ValueType.UInt32, HeaderConst.DefaultKdfVersion);\n break;\n case Consts.KdfId.Aes:\n this.kdfParameters = new VarDictionary();\n this.kdfParameters.set('$UUID', VarDictionary.ValueType.Bytes, ByteUtils.base64ToBytes(Consts.KdfId.Aes));\n this.kdfParameters.set('S', VarDictionary.ValueType.Bytes, Random.getBytes(HeaderConst.DefaultKdfSaltLength));\n this.kdfParameters.set('R', VarDictionary.ValueType.UInt32, Consts.Defaults.KeyEncryptionRounds);\n break;\n default:\n throw new KdbxError(Consts.ErrorCodes.InvalidArg, 'bad KDF algo');\n }\n};\n\n/**\n * Saves header to stream\n * @param {BinaryStream} stm\n */\nKdbxHeader.prototype.write = function(stm) {\n this._validate();\n this._writeSignature(stm);\n this._writeVersion(stm);\n for (var id = 1; id < HeaderFields.length; id++) {\n this._writeField(stm, id, HeaderFields);\n }\n this._writeField(stm, 0, HeaderFields);\n this.endPos = stm.pos;\n};\n\n/**\n * Saves inner header to stream\n * @param {BinaryStream} stm\n * @param {KdbxContext} ctx\n */\nKdbxHeader.prototype.writeInnerHeader = function(stm, ctx) {\n this._validateInner();\n for (var id = 1; id < InnerHeaderFields.length; id++) {\n this._writeField(stm, id, InnerHeaderFields, ctx);\n }\n this._writeField(stm, 0, InnerHeaderFields);\n};\n\n/**\n * Updates header random salts\n */\nKdbxHeader.prototype.generateSalts = function() {\n this.masterSeed = Random.getBytes(32);\n if (this.versionMajor < 4) {\n this.transformSeed = Random.getBytes(32);\n this.streamStartBytes = Random.getBytes(32);\n this.protectedStreamKey = Random.getBytes(32);\n this.encryptionIV = Random.getBytes(16);\n } else {\n this.protectedStreamKey = Random.getBytes(64);\n this.kdfParameters.set('S', VarDictionary.ValueType.Bytes, Random.getBytes(32));\n var ivLength = this.dataCipherUuid.toString() === Consts.CipherId.ChaCha20 ? 12 : 16;\n this.encryptionIV = Random.getBytes(ivLength);\n }\n};\n\n/**\n * Upgrade the header to the specified version\n * @param {Number} version - major file version\n */\nKdbxHeader.prototype.setVersion = function(version) {\n if (version !== 3 && version !== 4) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg, 'bad file version');\n }\n this.versionMajor = version;\n this.versionMinor = LastMinorVersions[version];\n if (this.versionMajor === 4) {\n if (!this.kdfParameters) {\n this._createKdfParameters();\n }\n this.crsAlgorithm = Consts.CrsAlgorithm.ChaCha20;\n this.keyEncryptionRounds = undefined;\n } else {\n this.kdfParameters = undefined;\n this.crsAlgorithm = Consts.CrsAlgorithm.Salsa20;\n this.keyEncryptionRounds = Consts.Defaults.KeyEncryptionRounds;\n }\n};\n\n/**\n * Set file KDF\n * @param kdf - KDF ID, from Consts.KdfId\n */\nKdbxHeader.prototype.setKdf = function(kdf) {\n this._createKdfParameters(kdf);\n};\n\n/**\n * Read header from stream\n * @param {BinaryStream} stm\n * @param {KdbxContext} ctx\n * @return {KdbxHeader}\n * @static\n */\nKdbxHeader.read = function(stm, ctx) {\n var header = new KdbxHeader();\n header._readSignature(stm);\n header._readVersion(stm);\n while (header._readField(stm, HeaderFields, ctx)) {\n continue;\n }\n header.endPos = stm.pos;\n header._validate();\n return header;\n};\n\n/**\n * Reads inner header from stream\n * @param {BinaryStream} stm\n * @param {KdbxContext} ctx\n */\nKdbxHeader.prototype.readInnerHeader = function(stm, ctx) {\n while (this._readField(stm, InnerHeaderFields, ctx)) {\n continue;\n }\n this._validateInner();\n};\n\n/**\n * Creates new header\n * @param {Kdbx} kdbx\n * @return {KdbxHeader}\n * @static\n */\nKdbxHeader.create = function() {\n var header = new KdbxHeader();\n header.versionMajor = HeaderConst.DefaultFileVersionMajor;\n header.versionMinor = HeaderConst.DefaultFileVersionMinor;\n header.dataCipherUuid = new KdbxUuid(Consts.CipherId.Aes);\n header.compression = Consts.CompressionAlgorithm.GZip;\n header.keyEncryptionRounds = Consts.Defaults.KeyEncryptionRounds;\n header.crsAlgorithm = Consts.CrsAlgorithm.Salsa20;\n return header;\n};\n\nKdbxHeader.MaxFileVersion = HeaderConst.MaxFileVersionMajor;\n\nmodule.exports = KdbxHeader;\n","'use strict';\n\n// code from this gist: https://gist.github.com/dchest/4582374 (no license declared)\n\nfunction Salsa20(key, nonce) {\n // Constants.\n this.rounds = 20; // number of Salsa rounds\n this.sigmaWords = [0x61707865, 0x3320646e, 0x79622d32, 0x6b206574];\n\n // State.\n this.keyWords = []; // key words\n this.nonceWords = [0, 0]; // nonce words\n this.counterWords = [0, 0]; // block counter words\n\n // Output buffer.\n this.block = []; // output block of 64 bytes\n this.blockUsed = 64; // number of block bytes used\n\n this.setKey(key);\n this.setNonce(nonce);\n}\n\n// setKey sets the key to the given 32-byte array.\nSalsa20.prototype.setKey = function(key) {\n for (var i = 0, j = 0; i < 8; i++, j += 4) {\n this.keyWords[i] = (key[j] & 0xff) |\n ((key[j+1] & 0xff)<<8) |\n ((key[j+2] & 0xff)<<16) |\n ((key[j+3] & 0xff)<<24);\n }\n this._reset();\n};\n\n// setNonce sets the nonce to the given 8-byte array.\nSalsa20.prototype.setNonce = function(nonce) {\n this.nonceWords[0] = (nonce[0] & 0xff) |\n ((nonce[1] & 0xff)<<8) |\n ((nonce[2] & 0xff)<<16) |\n ((nonce[3] & 0xff)<<24);\n this.nonceWords[1] = (nonce[4] & 0xff) |\n ((nonce[5] & 0xff)<<8) |\n ((nonce[6] & 0xff)<<16) |\n ((nonce[7] & 0xff)<<24);\n this._reset();\n};\n\n// getBytes returns the next numberOfBytes bytes of stream.\nSalsa20.prototype.getBytes = function(numberOfBytes) {\n var out = new Uint8Array(numberOfBytes);\n for (var i = 0; i < numberOfBytes; i++) {\n if (this.blockUsed === 64) {\n this._generateBlock();\n this._incrementCounter();\n this.blockUsed = 0;\n }\n out[i] = this.block[this.blockUsed];\n this.blockUsed++;\n }\n return out;\n};\n\nSalsa20.prototype.getHexString = function(numberOfBytes) {\n var hex=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];\n var out = [];\n var bytes = this.getBytes(numberOfBytes);\n for(var i = 0; i < bytes.length; i++) {\n out.push(hex[(bytes[i] >> 4) & 15]);\n out.push(hex[bytes[i] & 15]);\n }\n return out.join('');\n};\n\n// Private methods.\n\nSalsa20.prototype._reset = function() {\n this.counterWords[0] = 0;\n this.counterWords[1] = 0;\n this.blockUsed = 64;\n};\n\n// _incrementCounter increments block counter.\nSalsa20.prototype._incrementCounter = function() {\n // Note: maximum 2^64 blocks.\n this.counterWords[0] = (this.counterWords[0] + 1) & 0xffffffff;\n if (this.counterWords[0] === 0) {\n this.counterWords[1] = (this.counterWords[1] + 1) & 0xffffffff;\n }\n};\n\n// _generateBlock generates 64 bytes from key, nonce, and counter,\n// and puts the result into this.block.\nSalsa20.prototype._generateBlock = function() {\n var j0 = this.sigmaWords[0],\n j1 = this.keyWords[0],\n j2 = this.keyWords[1],\n j3 = this.keyWords[2],\n j4 = this.keyWords[3],\n j5 = this.sigmaWords[1],\n j6 = this.nonceWords[0],\n j7 = this.nonceWords[1],\n j8 = this.counterWords[0],\n j9 = this.counterWords[1],\n j10 = this.sigmaWords[2],\n j11 = this.keyWords[4],\n j12 = this.keyWords[5],\n j13 = this.keyWords[6],\n j14 = this.keyWords[7],\n j15 = this.sigmaWords[3];\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15;\n\n var u;\n\n for (var i = 0; i < this.rounds; i += 2) {\n u = x0 + x12;\n x4 ^= (u<<7) | (u>>>(32-7));\n u = x4 + x0;\n x8 ^= (u<<9) | (u>>>(32-9));\n u = x8 + x4;\n x12 ^= (u<<13) | (u>>>(32-13));\n u = x12 + x8;\n x0 ^= (u<<18) | (u>>>(32-18));\n\n u = x5 + x1;\n x9 ^= (u<<7) | (u>>>(32-7));\n u = x9 + x5;\n x13 ^= (u<<9) | (u>>>(32-9));\n u = x13 + x9;\n x1 ^= (u<<13) | (u>>>(32-13));\n u = x1 + x13;\n x5 ^= (u<<18) | (u>>>(32-18));\n\n u = x10 + x6;\n x14 ^= (u<<7) | (u>>>(32-7));\n u = x14 + x10;\n x2 ^= (u<<9) | (u>>>(32-9));\n u = x2 + x14;\n x6 ^= (u<<13) | (u>>>(32-13));\n u = x6 + x2;\n x10 ^= (u<<18) | (u>>>(32-18));\n\n u = x15 + x11;\n x3 ^= (u<<7) | (u>>>(32-7));\n u = x3 + x15;\n x7 ^= (u<<9) | (u>>>(32-9));\n u = x7 + x3;\n x11 ^= (u<<13) | (u>>>(32-13));\n u = x11 + x7;\n x15 ^= (u<<18) | (u>>>(32-18));\n\n u = x0 + x3;\n x1 ^= (u<<7) | (u>>>(32-7));\n u = x1 + x0;\n x2 ^= (u<<9) | (u>>>(32-9));\n u = x2 + x1;\n x3 ^= (u<<13) | (u>>>(32-13));\n u = x3 + x2;\n x0 ^= (u<<18) | (u>>>(32-18));\n\n u = x5 + x4;\n x6 ^= (u<<7) | (u>>>(32-7));\n u = x6 + x5;\n x7 ^= (u<<9) | (u>>>(32-9));\n u = x7 + x6;\n x4 ^= (u<<13) | (u>>>(32-13));\n u = x4 + x7;\n x5 ^= (u<<18) | (u>>>(32-18));\n\n u = x10 + x9;\n x11 ^= (u<<7) | (u>>>(32-7));\n u = x11 + x10;\n x8 ^= (u<<9) | (u>>>(32-9));\n u = x8 + x11;\n x9 ^= (u<<13) | (u>>>(32-13));\n u = x9 + x8;\n x10 ^= (u<<18) | (u>>>(32-18));\n\n u = x15 + x14;\n x12 ^= (u<<7) | (u>>>(32-7));\n u = x12 + x15;\n x13 ^= (u<<9) | (u>>>(32-9));\n u = x13 + x12;\n x14 ^= (u<<13) | (u>>>(32-13));\n u = x14 + x13;\n x15 ^= (u<<18) | (u>>>(32-18));\n }\n\n x0 += j0;\n x1 += j1;\n x2 += j2;\n x3 += j3;\n x4 += j4;\n x5 += j5;\n x6 += j6;\n x7 += j7;\n x8 += j8;\n x9 += j9;\n x10 += j10;\n x11 += j11;\n x12 += j12;\n x13 += j13;\n x14 += j14;\n x15 += j15;\n\n this.block[ 0] = ( x0 >>> 0) & 0xff; this.block[ 1] = ( x0 >>> 8) & 0xff;\n this.block[ 2] = ( x0 >>> 16) & 0xff; this.block[ 3] = ( x0 >>> 24) & 0xff;\n this.block[ 4] = ( x1 >>> 0) & 0xff; this.block[ 5] = ( x1 >>> 8) & 0xff;\n this.block[ 6] = ( x1 >>> 16) & 0xff; this.block[ 7] = ( x1 >>> 24) & 0xff;\n this.block[ 8] = ( x2 >>> 0) & 0xff; this.block[ 9] = ( x2 >>> 8) & 0xff;\n this.block[10] = ( x2 >>> 16) & 0xff; this.block[11] = ( x2 >>> 24) & 0xff;\n this.block[12] = ( x3 >>> 0) & 0xff; this.block[13] = ( x3 >>> 8) & 0xff;\n this.block[14] = ( x3 >>> 16) & 0xff; this.block[15] = ( x3 >>> 24) & 0xff;\n this.block[16] = ( x4 >>> 0) & 0xff; this.block[17] = ( x4 >>> 8) & 0xff;\n this.block[18] = ( x4 >>> 16) & 0xff; this.block[19] = ( x4 >>> 24) & 0xff;\n this.block[20] = ( x5 >>> 0) & 0xff; this.block[21] = ( x5 >>> 8) & 0xff;\n this.block[22] = ( x5 >>> 16) & 0xff; this.block[23] = ( x5 >>> 24) & 0xff;\n this.block[24] = ( x6 >>> 0) & 0xff; this.block[25] = ( x6 >>> 8) & 0xff;\n this.block[26] = ( x6 >>> 16) & 0xff; this.block[27] = ( x6 >>> 24) & 0xff;\n this.block[28] = ( x7 >>> 0) & 0xff; this.block[29] = ( x7 >>> 8) & 0xff;\n this.block[30] = ( x7 >>> 16) & 0xff; this.block[31] = ( x7 >>> 24) & 0xff;\n this.block[32] = ( x8 >>> 0) & 0xff; this.block[33] = ( x8 >>> 8) & 0xff;\n this.block[34] = ( x8 >>> 16) & 0xff; this.block[35] = ( x8 >>> 24) & 0xff;\n this.block[36] = ( x9 >>> 0) & 0xff; this.block[37] = ( x9 >>> 8) & 0xff;\n this.block[38] = ( x9 >>> 16) & 0xff; this.block[39] = ( x9 >>> 24) & 0xff;\n this.block[40] = (x10 >>> 0) & 0xff; this.block[41] = (x10 >>> 8) & 0xff;\n this.block[42] = (x10 >>> 16) & 0xff; this.block[43] = (x10 >>> 24) & 0xff;\n this.block[44] = (x11 >>> 0) & 0xff; this.block[45] = (x11 >>> 8) & 0xff;\n this.block[46] = (x11 >>> 16) & 0xff; this.block[47] = (x11 >>> 24) & 0xff;\n this.block[48] = (x12 >>> 0) & 0xff; this.block[49] = (x12 >>> 8) & 0xff;\n this.block[50] = (x12 >>> 16) & 0xff; this.block[51] = (x12 >>> 24) & 0xff;\n this.block[52] = (x13 >>> 0) & 0xff; this.block[53] = (x13 >>> 8) & 0xff;\n this.block[54] = (x13 >>> 16) & 0xff; this.block[55] = (x13 >>> 24) & 0xff;\n this.block[56] = (x14 >>> 0) & 0xff; this.block[57] = (x14 >>> 8) & 0xff;\n this.block[58] = (x14 >>> 16) & 0xff; this.block[59] = (x14 >>> 24) & 0xff;\n this.block[60] = (x15 >>> 0) & 0xff; this.block[61] = (x15 >>> 8) & 0xff;\n this.block[62] = (x15 >>> 16) & 0xff; this.block[63] = (x15 >>> 24) & 0xff;\n};\n\nmodule.exports = Salsa20;\n","'use strict';\n\nfunction ChaCha20(key, nonce) {\n this.sigmaWords = [0x61707865, 0x3320646e, 0x79622d32, 0x6b206574];\n this.block = new Uint8Array(64);\n this.blockUsed = 64;\n this.x = new Uint32Array(16);\n\n var input = new Uint32Array(16);\n\n input[0] = this.sigmaWords[0];\n input[1] = this.sigmaWords[1];\n input[2] = this.sigmaWords[2];\n input[3] = this.sigmaWords[3];\n input[4] = u8to32le(key, 0);\n input[5] = u8to32le(key, 4);\n input[6] = u8to32le(key, 8);\n input[7] = u8to32le(key, 12);\n input[8] = u8to32le(key, 16);\n input[9] = u8to32le(key, 20);\n input[10] = u8to32le(key, 24);\n input[11] = u8to32le(key, 28);\n input[12] = 0; // counter\n\n if (nonce.length === 12) {\n input[13] = u8to32le(nonce, 0);\n input[14] = u8to32le(nonce, 4);\n input[15] = u8to32le(nonce, 8);\n } else {\n input[13] = 0;\n input[14] = u8to32le(nonce, 0);\n input[15] = u8to32le(nonce, 4);\n }\n\n this.input = input;\n}\n\nChaCha20.prototype.getBytes = function(numberOfBytes) {\n var out = new Uint8Array(numberOfBytes);\n for (var i = 0; i < numberOfBytes; i++) {\n if (this.blockUsed === 64) {\n this._generateBlock();\n this.blockUsed = 0;\n }\n out[i] = this.block[this.blockUsed];\n this.blockUsed++;\n }\n return out;\n};\n\nChaCha20.prototype._generateBlock = function() {\n var input = this.input;\n var x = this.x;\n var block = this.block;\n var i;\n\n x.set(input);\n for (i = 20; i > 0; i -= 2) {\n quarterRound(x, 0, 4, 8, 12);\n quarterRound(x, 1, 5, 9, 13);\n quarterRound(x, 2, 6, 10, 14);\n quarterRound(x, 3, 7, 11, 15);\n quarterRound(x, 0, 5, 10, 15);\n quarterRound(x, 1, 6, 11, 12);\n quarterRound(x, 2, 7, 8, 13);\n quarterRound(x, 3, 4, 9, 14);\n }\n for (i = 16; i--;) {\n x[i] += input[i];\n }\n for (i = 16; i--;) {\n u32to8le(block, 4 * i, x[i]);\n }\n\n input[12] += 1;\n if (!input[12]) {\n input[13] += 1;\n }\n};\n\nChaCha20.prototype.encrypt = function(data) {\n var length = data.length;\n var res = new Uint8Array(length);\n var pos = 0;\n var block = this.block;\n while (pos < length) {\n this._generateBlock();\n var blockLength = Math.min(length - pos, 64);\n for (var i = 0; i < blockLength; i++) {\n res[pos] = data[pos] ^ block[i];\n pos++;\n }\n }\n return res;\n};\n\nfunction quarterRound(x, a, b, c, d) {\n x[a] += x[b];\n x[d] = rotate(x[d] ^ x[a], 16);\n x[c] += x[d];\n x[b] = rotate(x[b] ^ x[c], 12);\n x[a] += x[b];\n x[d] = rotate(x[d] ^ x[a], 8);\n x[c] += x[d];\n x[b] = rotate(x[b] ^ x[c], 7);\n}\n\nfunction u8to32le(x, i) {\n return x[i] | (x[i + 1] << 8) | (x[i + 2] << 16) | (x[i + 3] << 24);\n}\n\nfunction u32to8le(x, i, u) {\n x[i] = u;\n u >>>= 8;\n x[i + 1] = u;\n u >>>= 8;\n x[i + 2] = u;\n u >>>= 8;\n x[i + 3] = u;\n}\n\nfunction rotate(v, c) {\n return (v << c) | (v >>> (32 - c));\n}\n\nmodule.exports = ChaCha20;\n","'use strict';\n\nvar ByteUtils = require('./../utils/byte-utils'),\n CryptoEngine = require('./crypto-engine');\n\nvar maxRoundsPreIteration = 10000;\nvar aesBlockSize = 16;\nvar credentialSize = 32;\n\n/*\nIn order to simulate multiple rounds of ECB encryption, we do CBC encryption\nacross a zero buffer of large length with the IV being the desired plaintext.\nThe zero buffer does not contribute to the xor, so xoring the previous block\nwith the next one simulates running ECB multiple times. We limit the maximum\nsize of the zero buffer to prevent enormous memory usage.\n*/\n\nfunction encrypt(credentials, key, rounds) {\n var algo = CryptoEngine.createAesCbc();\n return algo.importKey(ByteUtils.arrayToBuffer(key))\n .then(function() {\n var resolvers = [];\n for (var idx = 0; idx < credentialSize; idx += aesBlockSize) {\n resolvers.push(encryptBlock(algo,\n credentials.subarray(idx, idx + aesBlockSize), rounds));\n }\n return Promise.all(resolvers);\n })\n .then(function(results) {\n var res = new Uint8Array(credentialSize);\n results.forEach(function (result, idx) {\n var base = idx * aesBlockSize;\n for (var i = 0; i < aesBlockSize; ++i) {\n res[i + base] = result[i];\n }\n ByteUtils.zeroBuffer(result);\n });\n return res;\n });\n}\n\nfunction encryptBlock(algo, iv, rounds) {\n var result = Promise.resolve(ByteUtils.arrayToBuffer(iv));\n var buffer = new Uint8Array(aesBlockSize * Math.min(rounds, maxRoundsPreIteration));\n\n while (rounds > 0) {\n var currentRounds = Math.min(rounds, maxRoundsPreIteration);\n rounds -= currentRounds;\n\n var dataLen = aesBlockSize * currentRounds;\n var zeroData = buffer.length === dataLen ? buffer.buffer : ByteUtils.arrayToBuffer(buffer.subarray(0, dataLen));\n result = encryptBlockBuffer(algo, result, zeroData);\n }\n\n return result.then(function(res) { return new Uint8Array(res); });\n}\n\nfunction encryptBlockBuffer(algo, promisedIv, buffer) {\n return promisedIv\n .then(function(iv) {\n return algo.encrypt(buffer, iv);\n })\n .then(function(buf) {\n var res = ByteUtils.arrayToBuffer(new Uint8Array(buf).subarray(-2 * aesBlockSize, -aesBlockSize));\n ByteUtils.zeroBuffer(buf);\n return res;\n });\n}\n\nmodule.exports.encrypt = encrypt;\n","'use strict';\n\nvar ProtectedValue = require('../crypto/protected-value'),\n KdbxError = require('../errors/kdbx-error'),\n Consts = require('../defs/consts'),\n ByteUtils = require('../utils/byte-utils'),\n XmlUtils = require('../utils/xml-utils'),\n Random = require('../crypto/random'),\n CryptoEngine = require('../crypto/crypto-engine');\n\n/**\n * Credentials\n * @param {ProtectedValue} password\n * @param {String|ArrayBuffer|Uint8Array} [keyFile]\n * @constructor\n */\nvar KdbxCredentials = function(password, keyFile) {\n var that = this;\n this.ready = Promise.all([\n this.setPassword(password),\n this.setKeyFile(keyFile)\n ]).then(function() {\n return that;\n });\n};\n\n/**\n * Set password\n * @param {ProtectedValue|null} password\n */\nKdbxCredentials.prototype.setPassword = function(password) {\n if (password === null) {\n this.passwordHash = null;\n } else if (!(password instanceof ProtectedValue)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'password'));\n } else {\n var that = this;\n return password.getHash().then(function(hash) {\n that.passwordHash = ProtectedValue.fromBinary(hash);\n });\n }\n return Promise.resolve();\n};\n\n/**\n * Set keyfile\n * @param {ArrayBuffer|Uint8Array} [keyFile]\n */\nKdbxCredentials.prototype.setKeyFile = function(keyFile) {\n if (keyFile && !(keyFile instanceof ArrayBuffer) && !(keyFile instanceof Uint8Array)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'keyFile'));\n }\n if (keyFile) {\n if (keyFile.byteLength === 32) {\n this.keyFileHash = ProtectedValue.fromBinary(ByteUtils.arrayToBuffer(keyFile));\n return Promise.resolve();\n }\n try {\n var keyFileStr;\n keyFileStr = ByteUtils.bytesToString(ByteUtils.arrayToBuffer(keyFile));\n if (keyFileStr.match(/^[a-f\\d]{64}$/i)) {\n var bytes = ByteUtils.hexToBytes(keyFileStr);\n this.keyFileHash = ProtectedValue.fromBinary(bytes);\n return;\n }\n var xml = XmlUtils.parse(keyFileStr.trim());\n var keyEl = XmlUtils.getChildNode(xml.documentElement, 'Key');\n var dataEl = XmlUtils.getChildNode(keyEl, 'Data');\n this.keyFileHash = ProtectedValue.fromBinary(ByteUtils.base64ToBytes(dataEl.textContent));\n } catch (e) {\n var that = this;\n return CryptoEngine.sha256(keyFile).then(function(hash) {\n that.keyFileHash = ProtectedValue.fromBinary(hash);\n });\n }\n } else {\n this.keyFileHash = null;\n }\n return Promise.resolve();\n};\n\n/**\n * Get credentials hash\n * @returns {Promise.}\n */\nKdbxCredentials.prototype.getHash = function() {\n var that = this;\n return this.ready.then(function() {\n var buffers = [];\n if (that.passwordHash) {\n buffers.push(that.passwordHash.getBinary());\n }\n if (that.keyFileHash) {\n buffers.push(that.keyFileHash.getBinary());\n }\n var totalLength = buffers.reduce(function (acc, buf) {\n return acc + buf.byteLength;\n }, 0);\n var allBytes = new Uint8Array(totalLength);\n var offset = 0;\n buffers.forEach(function (buffer) {\n allBytes.set(buffer, offset);\n ByteUtils.zeroBuffer(buffer);\n offset += buffer.length;\n });\n return CryptoEngine.sha256(ByteUtils.arrayToBuffer(allBytes)).then(function (hash) {\n ByteUtils.zeroBuffer(allBytes);\n return hash;\n });\n });\n};\n\n/**\n * Creates random keyfile\n * @returns {Uint8Array}\n */\nKdbxCredentials.createRandomKeyFile = function() {\n var keyLength = 32;\n var keyBytes = Random.getBytes(keyLength),\n salt = Random.getBytes(keyLength);\n for (var i = 0; i < keyLength; i++) {\n keyBytes[i] ^= salt[i];\n keyBytes[i] ^= (Math.random() * 1000 % 255);\n }\n var key = ByteUtils.bytesToBase64(keyBytes);\n return KdbxCredentials.createKeyFileWithHash(key);\n};\n\n/**\n * Creates keyfile by given hash\n * @param {string} hash base64-encoded hash\n * @returns {Uint8Array}\n */\nKdbxCredentials.createKeyFileWithHash = function(hash) {\n var xml = '\\n' +\n '\\n' +\n ' \\n' +\n ' 1.00\\n' +\n ' \\n' +\n ' \\n' +\n ' ' + hash + '\\n' +\n ' \\n' +\n '';\n return ByteUtils.stringToBytes(xml);\n};\n\nmodule.exports = KdbxCredentials;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils');\n\n/**\n * Kdbx times\n * @constructor\n */\nvar KdbxTimes = function() {\n this.creationTime = undefined;\n this.lastModTime = undefined;\n this.lastAccessTime = undefined;\n this.expiryTime = undefined;\n this.expires = undefined;\n this.usageCount = undefined;\n this.locationChanged = new Date();\n Object.preventExtensions(this);\n};\n\nKdbxTimes.prototype._readNode = function(node) {\n switch (node.tagName) {\n case XmlNames.Elem.CreationTime:\n this.creationTime = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.LastModTime:\n this.lastModTime = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.LastAccessTime:\n this.lastAccessTime = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.ExpiryTime:\n this.expiryTime = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.Expires:\n this.expires = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.UsageCount:\n this.usageCount = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.LocationChanged:\n this.locationChanged = XmlUtils.getDate(node);\n break;\n }\n};\n\n/**\n * Clones object\n * @returns {KdbxTimes}\n */\nKdbxTimes.prototype.clone = function() {\n var clone = new KdbxTimes();\n clone.creationTime = this.creationTime;\n clone.lastModTime = this.lastModTime;\n clone.lastAccessTime = this.lastAccessTime;\n clone.expiryTime = this.expiryTime;\n clone.expires = this.expires;\n clone.usageCount = this.usageCount;\n clone.locationChanged = this.locationChanged;\n return clone;\n};\n\nKdbxTimes.prototype.update = function() {\n var now = new Date();\n this.lastModTime = now;\n this.lastAccessTime = now;\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxTimes.prototype.write = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Times);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.CreationTime), this.creationTime);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.LastModTime), this.lastModTime);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.LastAccessTime), this.lastAccessTime);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.ExpiryTime), this.expiryTime);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.Expires), this.expires);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.UsageCount), this.usageCount);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.LocationChanged), this.locationChanged);\n};\n\n/**\n * Creates new times\n * @return {KdbxTimes}\n */\nKdbxTimes.create = function() {\n var times = new KdbxTimes();\n var now = new Date();\n times.creationTime = now;\n times.lastModTime = now;\n times.lastAccessTime = now;\n times.expiryTime = now;\n times.expires = false;\n times.usageCount = 0;\n times.locationChanged = now;\n return times;\n};\n\n/**\n * Read times from xml\n * @param {Node} xmlNode\n * @return {KdbxTimes}\n */\nKdbxTimes.read = function(xmlNode) {\n var obj = new KdbxTimes();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n obj._readNode(childNode);\n }\n }\n return obj;\n};\n\nmodule.exports = KdbxTimes;\n","'use strict';\n\nvar ProtectedValue = require('../crypto/protected-value'),\n XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils'),\n Consts = require('../defs/consts'),\n KdbxCustomData = require('./kdbx-custom-data'),\n KdbxUuid = require('./kdbx-uuid'),\n KdbxTimes = require('./kdbx-times');\n\nvar tagsSplitRegex = /\\s*[;,:]\\s*/;\n\n/**\n * Entry\n * @constructor\n */\nvar KdbxEntry = function() {\n this.uuid = undefined;\n this.icon = undefined;\n this.customIcon = undefined;\n this.fgColor = undefined;\n this.bgColor = undefined;\n this.overrideUrl = undefined;\n this.tags = [];\n this.times = new KdbxTimes();\n this.fields = {};\n this.binaries = {};\n this.autoType = {\n enabled: true, obfuscation: undefined, defaultSequence: undefined, items: []\n };\n this.history = [];\n this.parentGroup = undefined;\n this.customData = undefined;\n this._editState = undefined;\n Object.preventExtensions(this);\n};\n\nKdbxEntry.prototype._readNode = function(node, ctx) {\n switch (node.tagName) {\n case XmlNames.Elem.Uuid:\n this.uuid = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.Icon:\n this.icon = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.CustomIconID:\n this.customIcon = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.FgColor:\n this.fgColor = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.BgColor:\n this.bgColor = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.OverrideUrl:\n this.overrideUrl = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.Tags:\n this.tags = this._stringToTags(XmlUtils.getText(node));\n break;\n case XmlNames.Elem.Times:\n this.times = KdbxTimes.read(node);\n break;\n case XmlNames.Elem.String:\n this._readField(node);\n break;\n case XmlNames.Elem.Binary:\n this._readBinary(node, ctx);\n break;\n case XmlNames.Elem.AutoType:\n this._readAutoType(node);\n break;\n case XmlNames.Elem.History:\n this._readHistory(node, ctx);\n break;\n case XmlNames.Elem.CustomData:\n this._readCustomData(node);\n break;\n }\n};\n\nKdbxEntry.prototype._readField = function(node) {\n var keyNode = XmlUtils.getChildNode(node, XmlNames.Elem.Key),\n valueNode = XmlUtils.getChildNode(node, XmlNames.Elem.Value),\n key = XmlUtils.getText(keyNode),\n value = XmlUtils.getProtectedText(valueNode);\n if (key) {\n this.fields[key] = value;\n }\n};\n\nKdbxEntry.prototype._writeFields = function(parentNode) {\n var fields = this.fields;\n Object.keys(fields).forEach(function(field) {\n var value = fields[field];\n if (value !== undefined && value !== null) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.String);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Key), field);\n XmlUtils.setProtectedText(XmlUtils.addChildNode(node, XmlNames.Elem.Value), value);\n }\n });\n};\n\nKdbxEntry.prototype._readBinary = function(node, ctx) {\n var keyNode = XmlUtils.getChildNode(node, XmlNames.Elem.Key),\n valueNode = XmlUtils.getChildNode(node, XmlNames.Elem.Value),\n key = XmlUtils.getText(keyNode),\n value = XmlUtils.getProtectedBinary(valueNode);\n if (key && value) {\n if (value.ref) {\n value.ref = ctx.kdbx.binaries.idToHash[value.ref];\n if (value.ref) {\n value.value = ctx.kdbx.binaries[value.ref];\n } else {\n value = null;\n }\n }\n if (value) {\n this.binaries[key] = value;\n }\n }\n};\n\nKdbxEntry.prototype._writeBinaries = function(parentNode, ctx) {\n var binaries = this.binaries;\n Object.keys(binaries).forEach(function(id) {\n var data = binaries[id];\n if (data) {\n if (data.ref) {\n var index = ctx.kdbx.binaries.hashOrder.indexOf(data.ref);\n if (index < 0) {\n return;\n }\n data = { ref: index.toString() };\n }\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Binary);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Key), id);\n XmlUtils.setProtectedBinary(XmlUtils.addChildNode(node, XmlNames.Elem.Value), data);\n }\n });\n};\n\nKdbxEntry.prototype._stringToTags = function(str) {\n if (!str) {\n return [];\n }\n return str.split(tagsSplitRegex).filter(function(s) { return s; });\n};\n\nKdbxEntry.prototype._readAutoType = function(node) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.AutoTypeEnabled:\n this.autoType.enabled = XmlUtils.getBoolean(childNode);\n if (typeof this.autoType.enabled !== 'boolean') {\n this.autoType.enabled = true;\n }\n break;\n case XmlNames.Elem.AutoTypeObfuscation:\n this.autoType.obfuscation = XmlUtils.getNumber(childNode);\n break;\n case XmlNames.Elem.AutoTypeDefaultSeq:\n this.autoType.defaultSequence = XmlUtils.getText(childNode);\n break;\n case XmlNames.Elem.AutoTypeItem:\n this._readAutoTypeItem(childNode);\n break;\n }\n }\n};\n\nKdbxEntry.prototype._readAutoTypeItem = function(node) {\n var item = {};\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.Window:\n item.window = XmlUtils.getText(childNode);\n break;\n case XmlNames.Elem.KeystrokeSequence:\n item.keystrokeSequence = XmlUtils.getText(childNode);\n break;\n }\n }\n this.autoType.items.push(item);\n};\n\nKdbxEntry.prototype._writeAutoType = function(parentNode) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.AutoType);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.AutoTypeEnabled), this.autoType.enabled);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.AutoTypeObfuscation), this.autoType.obfuscation);\n if (this.autoType.defaultSequence) {\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.AutoTypeDefaultSeq), this.autoType.defaultSequence);\n }\n for (var i = 0; i < this.autoType.items.length; i++) {\n var item = this.autoType.items[i];\n var itemNode = XmlUtils.addChildNode(node, XmlNames.Elem.AutoTypeItem);\n XmlUtils.setText(XmlUtils.addChildNode(itemNode, XmlNames.Elem.Window), item.window);\n XmlUtils.setText(XmlUtils.addChildNode(itemNode, XmlNames.Elem.KeystrokeSequence), item.keystrokeSequence);\n }\n};\n\nKdbxEntry.prototype._readHistory = function(node, ctx) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.Entry:\n this.history.push(KdbxEntry.read(childNode, ctx));\n break;\n }\n }\n};\n\nKdbxEntry.prototype._writeHistory = function(parentNode, ctx) {\n var historyNode = XmlUtils.addChildNode(parentNode, XmlNames.Elem.History);\n for (var i = 0; i < this.history.length; i++) {\n this.history[i].write(historyNode, ctx);\n }\n};\n\nKdbxEntry.prototype._readCustomData = function(node) {\n this.customData = KdbxCustomData.read(node);\n};\n\nKdbxEntry.prototype._writeCustomData = function(parentNode) {\n KdbxCustomData.write(parentNode, this.customData);\n};\n\nKdbxEntry.prototype._setField = function(name, str, secure) {\n this.fields[name] = secure ? ProtectedValue.fromString(str) : str;\n};\n\nKdbxEntry.prototype._addHistoryTombstone = function(isAdded, dt) {\n if (!this._editState) {\n this._editState = { added: [], deleted: [] };\n }\n this._editState[isAdded ? 'added' : 'deleted'].push(dt.getTime());\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxEntry.prototype.write = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Entry);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.Uuid), this.uuid);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.Icon), this.icon);\n if (this.customIcon) {\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.CustomIconID), this.customIcon);\n }\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.FgColor), this.fgColor);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.BgColor), this.bgColor);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.OverrideUrl), this.overrideUrl);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Tags), this.tags.join(','));\n this.times.write(node, ctx);\n this._writeFields(node);\n this._writeBinaries(node, ctx);\n this._writeAutoType(node);\n this._writeCustomData(node);\n if (parentNode.tagName !== XmlNames.Elem.History) {\n this._writeHistory(node, ctx);\n }\n};\n\n/**\n * Push current entry state to the top of history\n */\nKdbxEntry.prototype.pushHistory = function() {\n var historyEntry = new KdbxEntry();\n historyEntry.copyFrom(this);\n this.history.push(historyEntry);\n this._addHistoryTombstone(true, historyEntry.times.lastModTime);\n};\n\n/**\n * Remove some entry history states at index\n * @param {number} index - history state start index\n * @param {number} [count=1] - deleted states count\n */\nKdbxEntry.prototype.removeHistory = function(index, count) {\n if (count === undefined) {\n count = 1;\n }\n for (var ix = index; ix < index + count; ix++) {\n if (ix < this.history.length) {\n this._addHistoryTombstone(false, this.history[ix].times.lastModTime);\n }\n }\n this.history.splice(index, count);\n};\n\n/**\n * Clone entry state from another entry, or history entry\n */\nKdbxEntry.prototype.copyFrom = function(entry) {\n this.uuid = entry.uuid;\n this.icon = entry.icon;\n this.customIcon = entry.customIcon;\n this.fgColor = entry.fgColor;\n this.bgColor = entry.bgColor;\n this.overrideUrl = entry.overrideUrl;\n this.tags = entry.tags.slice();\n this.times = entry.times.clone();\n this.fields = {};\n Object.keys(entry.fields).forEach(function(name) {\n if (entry.fields[name] instanceof ProtectedValue) {\n this.fields[name] = entry.fields[name].clone();\n } else {\n this.fields[name] = entry.fields[name];\n }\n }, this);\n this.binaries = {};\n Object.keys(entry.binaries).forEach(function(name) {\n if (entry.binaries[name] instanceof ProtectedValue) {\n this.binaries[name] = entry.binaries[name].clone();\n } else if (entry.binaries[name] && entry.binaries[name].ref) {\n this.binaries[name] = { ref: entry.binaries[name].ref };\n if (entry.binaries[name].value) {\n this.binaries[name].value = entry.binaries[name].value;\n }\n } else {\n this.binaries[name] = entry.binaries[name];\n }\n }, this);\n this.autoType = JSON.parse(JSON.stringify(entry.autoType));\n};\n\n/**\n * Merge entry with remote entry\n * @param {{objects, remote, deleted}} objectMap\n */\nKdbxEntry.prototype.merge = function(objectMap) {\n var remoteEntry = objectMap.remote[this.uuid];\n if (!remoteEntry) {\n return;\n }\n var remoteHistory = remoteEntry.history.slice();\n if (this.times.lastModTime < remoteEntry.times.lastModTime) {\n // remote is more new; push current state to history and update\n this.pushHistory();\n this.copyFrom(remoteEntry);\n } else if (this.times.lastModTime > remoteEntry.times.lastModTime) {\n // local is more new; if remote state is not in history, push it\n var existsInHistory = this.history.some(function(historyEntry) {\n return +historyEntry.times.lastModTime === +remoteEntry.times.lastModTime;\n });\n if (!existsInHistory) {\n var historyEntry = new KdbxEntry();\n historyEntry.copyFrom(remoteEntry);\n remoteHistory.push(historyEntry);\n }\n }\n this.history = this._mergeHistory(remoteHistory, remoteEntry.times.lastModTime);\n};\n\n/**\n * Merge entry history with remote entry history\n * Tombstones are stored locally and must be immediately discarded by replica after successful upstream push.\n * It's client responsibility, to save and load tombstones for local replica, and to clear them after successful upstream push.\n *\n * Implements remove-win OR-set CRDT with local tombstones stored in _editState.\n *\n * Format doesn't allow saving tombstones for history entries, so they are stored locally.\n * Any unmodified state from past or modifications of current state synced with central upstream will be successfully merged.\n * Assumes there's only one central upstream, may produce inconsistencies while merging outdated replica outside main upstream.\n * Phantom entries and phantom deletions will appear if remote replica checked out an old state and has just added a new state.\n * If a client is using central upstream for sync, the remote replica must first sync it state and\n * only after it update the upstream, so this should never happen.\n *\n * References:\n *\n * An Optimized Conflict-free Replicated Set arXiv:1210.3368 [cs.DC]\n * http://arxiv.org/abs/1210.3368\n *\n * Gene T. J. Wuu and Arthur J. Bernstein. Efficient solutions to the replicated log and dictionary\n * problems. In Symp. on Principles of Dist. Comp. (PODC), pages 233–242, Vancouver, BC, Canada, August 1984.\n * https://pages.lip6.fr/Marc.Shapiro/papers/RR-7687.pdf\n *\n * @param {KdbxEntry[]} remoteHistory - history records from remote entry\n * @param {Date} remoteLastModTime - last mod time for remote entry\n * @returns {KdbxEntry[]} - new history\n * @private\n */\nKdbxEntry.prototype._mergeHistory = function(remoteHistory, remoteLastModTime) {\n // we can skip sorting but the history may not have been sorted\n this.history.sort(function(x, y) { return x.times.lastModTime - y.times.lastModTime; });\n remoteHistory.sort(function(x, y) { return x.times.lastModTime - y.times.lastModTime; });\n var historyMap = {}, remoteHistoryMap = {};\n this.history.forEach(function(record) { historyMap[record.times.lastModTime.getTime()] = record; });\n remoteHistory.forEach(function(record) { remoteHistoryMap[record.times.lastModTime.getTime()] = record; });\n var historyIx = 0, remoteHistoryIx = 0;\n var newHistory = [];\n while (historyIx < this.history.length || remoteHistoryIx < remoteHistory.length) {\n var historyEntry = this.history[historyIx],\n remoteHistoryEntry = remoteHistory[remoteHistoryIx],\n entryTime = historyEntry && historyEntry.times.lastModTime.getTime(),\n remoteEntryTime = remoteHistoryEntry && remoteHistoryEntry.times.lastModTime.getTime();\n if (entryTime === remoteEntryTime) {\n // exists in local and remote\n newHistory.push(historyEntry);\n historyIx++;\n remoteHistoryIx++;\n continue;\n }\n if (!historyEntry || entryTime > remoteEntryTime) {\n // local is absent\n if (!this._editState || this._editState.deleted.indexOf(remoteEntryTime) < 0) {\n // added remotely\n var remoteHistoryEntryClone = new KdbxEntry();\n remoteHistoryEntryClone.copyFrom(remoteHistoryEntry);\n newHistory.push(remoteHistoryEntryClone);\n } // else: deleted locally\n remoteHistoryIx++;\n continue;\n }\n // (!remoteHistoryEntry || entryTime < remoteEntryTime) && historyEntry\n // remote is absent\n if (this._editState && this._editState.added.indexOf(entryTime) >= 0) {\n // added locally\n newHistory.push(historyEntry);\n } else if (entryTime > remoteLastModTime) {\n // outdated replica history has ended\n newHistory.push(historyEntry);\n } // else: deleted remotely\n historyIx++;\n }\n return newHistory;\n};\n\n/**\n * Creates new entry\n * @param {KdbxMeta} meta - db metadata\n * @param {KdbxGroup} parentGroup - parent group\n * @returns {KdbxEntry}\n */\nKdbxEntry.create = function(meta, parentGroup) {\n var entry = new KdbxEntry(parentGroup);\n entry.uuid = KdbxUuid.random();\n entry.icon = Consts.Icons.Key;\n entry.times = KdbxTimes.create();\n entry.parentGroup = parentGroup;\n entry._setField('Title', '', meta.memoryProtection.title);\n entry._setField('UserName', meta.defaultUser || '', meta.memoryProtection.userName);\n entry._setField('Password', '', meta.memoryProtection.password);\n entry._setField('URL', '', meta.memoryProtection.url);\n entry._setField('Notes', '', meta.memoryProtection.notes);\n entry.autoType.enabled = typeof parentGroup.enableAutoType === 'boolean' ? parentGroup.enableAutoType : true;\n entry.autoType.obfuscation = Consts.AutoTypeObfuscationOptions.None;\n return entry;\n};\n\n/**\n * Read entry from xml\n * @param {Node} xmlNode\n * @param {KdbxContext} ctx\n * @param {KdbxGroup} [parentGroup]\n * @return {KdbxEntry}\n */\nKdbxEntry.read = function(xmlNode, ctx, parentGroup) {\n var entry = new KdbxEntry();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n entry._readNode(childNode, ctx);\n }\n }\n entry.parentGroup = parentGroup;\n return entry;\n};\n\nmodule.exports = KdbxEntry;\n","module.exports.Kdbx = require('./format/kdbx');\nmodule.exports.KdbxUuid = require('./format/kdbx-uuid');\nmodule.exports.KdbxError = require('./errors/kdbx-error');\nmodule.exports.Credentials = require('./format/kdbx-credentials');\nmodule.exports.Consts = require('./defs/consts');\nmodule.exports.ProtectedValue = require('./crypto/protected-value');\nmodule.exports.ByteUtils = require('./utils/byte-utils');\nmodule.exports.VarDictionary = require('./utils/var-dictionary');\nmodule.exports.Int64 = require('./utils/int64');\nmodule.exports.Random = require('./crypto/random');\nmodule.exports.CryptoEngine = require('./crypto/crypto-engine');\n","'use strict';\n\nvar\n KdbxFormat = require('./kdbx-format'),\n KdbxError = require('./../errors/kdbx-error'),\n KdbxCredentials = require('./kdbx-credentials'),\n KdbxHeader = require('./kdbx-header'),\n KdbxMeta = require('./kdbx-meta'),\n KdbxBinaries = require('./kdbx-binaries'),\n KdbxGroup = require('./kdbx-group'),\n KdbxEntry = require('./kdbx-entry'),\n KdbxDeletedObject = require('./kdbx-deleted-object'),\n KdbxUuid = require('./kdbx-uuid'),\n Consts = require('./../defs/consts'),\n XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils');\n\n/**\n * Kdbx file (KeePass database v2)\n * @constructor\n */\nvar Kdbx = function() {\n this.header = undefined;\n this.credentials = undefined;\n this.meta = undefined;\n this.xml = undefined;\n this.binaries = new KdbxBinaries();\n this.groups = [];\n this.deletedObjects = [];\n Object.preventExtensions(this);\n};\n\n/**\n * Creates new database\n * @return {Kdbx}\n */\nKdbx.create = function(credentials, name) {\n if (!(credentials instanceof KdbxCredentials)) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg, 'credentials');\n }\n var kdbx = new Kdbx();\n kdbx.credentials = credentials;\n kdbx.header = KdbxHeader.create();\n kdbx.meta = KdbxMeta.create();\n kdbx.meta._name = name;\n kdbx.createDefaultGroup();\n kdbx.createRecycleBin();\n kdbx.meta._lastSelectedGroup = kdbx.getDefaultGroup().id;\n kdbx.meta._lastTopVisibleGroup = kdbx.getDefaultGroup().id;\n return kdbx;\n};\n\n/**\n * Load kdbx file\n * If there was an error loading file, throws an exception\n * @param {ArrayBuffer} data - database file contents\n * @param {KdbxCredentials} credentials\n * @return {Promise.}\n */\nKdbx.load = function(data, credentials) {\n if (!(data instanceof ArrayBuffer)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'data'));\n }\n if (!(credentials instanceof KdbxCredentials)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'credentials'));\n }\n var kdbx = new Kdbx();\n kdbx.credentials = credentials;\n var format = new KdbxFormat(kdbx);\n return format.load(data);\n};\n\n/**\n * Import database from xml file\n * If there was an error loading xml file, throws an exception\n * @param {String} data - xml file contents\n * @param {KdbxCredentials} credentials\n * @return {Promise.}\n */\nKdbx.loadXml = function(data, credentials) {\n if ((typeof data !== 'string')) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'data'));\n }\n if (!(credentials instanceof KdbxCredentials)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'credentials'));\n }\n var kdbx = new Kdbx();\n kdbx.credentials = credentials;\n var format = new KdbxFormat(kdbx);\n return format.loadXml(data);\n};\n\n/**\n * Save db to ArrayBuffer\n * @return {Promise.}\n */\nKdbx.prototype.save = function() {\n var format = new KdbxFormat(this);\n return format.save();\n};\n\n/**\n * Save db to XML\n * @param {boolean} [prettyPrint=false] - pretty print XML\n * @return {Promise.}\n */\nKdbx.prototype.saveXml = function(prettyPrint) {\n var format = new KdbxFormat(this);\n return format.saveXml(prettyPrint);\n};\n\n/**\n * Creates default group, if it's not yet created\n */\nKdbx.prototype.createDefaultGroup = function() {\n if (this.groups.length) {\n return;\n }\n var defaultGroup = KdbxGroup.create(this.meta.name);\n defaultGroup.icon = Consts.Icons.FolderOpen;\n defaultGroup.expanded = true;\n this.groups.push(defaultGroup);\n};\n\n/**\n * Creates recycle bin, if it's not yet created\n */\nKdbx.prototype.createRecycleBin = function() {\n this.meta.recycleBinEnabled = true;\n if (this.meta.recycleBinUuid && this.getGroup(this.meta.recycleBinUuid)) {\n return;\n }\n var defGrp = this.getDefaultGroup();\n var recycleBin = KdbxGroup.create(Consts.Defaults.RecycleBinName, defGrp);\n recycleBin.icon = Consts.Icons.TrashBin;\n recycleBin.enableAutoType = false;\n recycleBin.enableSearching = false;\n this.meta.recycleBinUuid = recycleBin.uuid;\n defGrp.groups.push(recycleBin);\n};\n\n/**\n * Adds new group to group\n * @param {string} name - new group name\n * @param {KdbxGroup} group - parent group\n * @return {KdbxGroup}\n */\nKdbx.prototype.createGroup = function(group, name) {\n var subGroup = KdbxGroup.create(name, group);\n group.groups.push(subGroup);\n return subGroup;\n};\n\n/**\n * Adds new entry to group\n * @param {KdbxGroup} group - parent group\n * @return {KdbxEntry}\n */\nKdbx.prototype.createEntry = function(group) {\n var entry = KdbxEntry.create(this.meta, group);\n group.entries.push(entry);\n return entry;\n};\n\n/**\n * Gets default group\n * @return {KdbxGroup}\n */\nKdbx.prototype.getDefaultGroup = function() {\n return this.groups[0];\n};\n\n/**\n * Get group by uuid\n * @param {KdbxUuid|string} uuid\n * @param {KdbxGroup} [parentGroup]\n * @return {KdbxGroup|undefined}\n */\nKdbx.prototype.getGroup = function(uuid, parentGroup) {\n var groups = parentGroup ? parentGroup.groups : this.groups;\n for (var i = 0; i < groups.length; i++) {\n if (groups[i].uuid.id === uuid.id) {\n return groups[i];\n }\n var res = this.getGroup(uuid, groups[i]);\n if (res) {\n return res;\n }\n }\n};\n\n/**\n * Move object from one group to another\n * @param {KdbxEntry|KdbxGroup} object - object to be moved\n * @param {KdbxGroup} toGroup - target parent group\n * @param {Number} [atIndex] - index in target group (by default, insert to the end of the group)\n */\nKdbx.prototype.move = function(object, toGroup, atIndex) {\n var containerProp = object instanceof KdbxGroup ? 'groups' : 'entries';\n var fromContainer = object.parentGroup[containerProp];\n var ix = fromContainer.indexOf(object);\n if (ix < 0) {\n return;\n }\n fromContainer.splice(ix, 1);\n if (toGroup) {\n if (typeof atIndex === 'number' && atIndex >= 0) {\n toGroup[containerProp].splice(atIndex, 0, object);\n } else {\n toGroup[containerProp].push(object);\n }\n } else {\n var now = new Date();\n if (object instanceof KdbxGroup) {\n object.forEach(function (group, entry) {\n this.addDeletedObject((group || entry).uuid, now);\n }, this);\n } else {\n this.addDeletedObject(object.uuid, now);\n }\n }\n object.parentGroup = toGroup;\n object.times.locationChanged = new Date();\n};\n\n/**\n * Adds deleted object\n * @param {KdbxUuid} uuid - object uuid\n * @param {Date} dt - deletion date\n */\nKdbx.prototype.addDeletedObject = function(uuid, dt) {\n var deletedObject = new KdbxDeletedObject();\n deletedObject.uuid = uuid;\n deletedObject.deletionTime = dt;\n this.deletedObjects.push(deletedObject);\n};\n\n/**\n * Delete entry or group\n * Depending on settings, removes either to trash, or completely\n * @param {KdbxEntry|KdbxGroup} object - object to be deleted\n */\nKdbx.prototype.remove = function(object) {\n var toGroup = null;\n if (this.meta.recycleBinEnabled) {\n this.createRecycleBin();\n toGroup = this.getGroup(this.meta.recycleBinUuid);\n }\n this.move(object, toGroup);\n};\n\n/**\n * Creates a binary in the db and returns a reference to it\n * @param {ProtectedValue|ArrayBuffer} value\n * @return {Promise}\n */\nKdbx.prototype.createBinary = function(value) {\n return this.binaries.add(value);\n};\n\n/**\n * Import entry from another file\n * It's up to caller to decide what should happen to the original entry in the source file\n * @param {KdbxEntry} entry - entry to be imported\n * @param {KdbxGroup} group - target parent group\n * @param {Kdbx} file - the source file containing the group\n */\nKdbx.prototype.importEntry = function(entry, group, file) {\n var newEntry = new KdbxEntry();\n var uuid = KdbxUuid.random();\n\n newEntry.copyFrom(entry);\n newEntry.uuid = uuid;\n entry.history.forEach(function(historyEntry) {\n var newHistoryEntry = new KdbxEntry();\n newHistoryEntry.copyFrom(historyEntry);\n newHistoryEntry.uuid = uuid;\n newEntry.history.push(newHistoryEntry);\n });\n\n var binaries = {};\n var customIcons = {};\n newEntry.history.concat(newEntry).forEach(function(e) {\n if (e.customIcon) {\n customIcons[e.customIcon] = e.customIcon;\n }\n Object.values(e.binaries).forEach(function(binary) {\n if (binary.ref) {\n binaries[binary.ref] = binary;\n }\n });\n });\n\n Object.values(binaries).forEach(function(binary) {\n var fileBinary = file.binaries[binary.ref];\n if (fileBinary && !this.binaries[binary.ref]) {\n this.binaries[binary.ref] = fileBinary;\n }\n }, this);\n\n Object.values(customIcons).forEach(function(customIconId) {\n var customIcon = file.meta.customIcons[customIconId];\n if (customIcon) {\n this.meta.customIcons[customIconId] = customIcon;\n }\n }, this);\n\n group.entries.push(newEntry);\n\n entry.parentGroup = group;\n entry.times.update();\n\n return newEntry;\n};\n\n/**\n * Perform database cleanup\n * @param {object} settings - cleanup settings\n * @param {boolean} [settings.historyRules=false] - remove extra history, it it doesn't match defined rules, e.g. records number\n * @param {boolean} [settings.customIcons=false] - remove unused custom icons\n * @param {boolean} [settings.binaries=false] - remove unused binaries\n */\nKdbx.prototype.cleanup = function(settings) {\n var now = new Date();\n var historyMaxItems = settings && settings.historyRules && this.meta.historyMaxItems && this.meta.historyMaxItems > 0 ?\n this.meta.historyMaxItems : Infinity;\n var usedCustomIcons = {};\n var usedBinaries = {};\n var processEntry = function(entry) {\n if (entry && entry.customIcon) {\n usedCustomIcons[entry.customIcon] = true;\n }\n if (entry && entry.binaries) {\n Object.keys(entry.binaries).forEach(function(key) {\n if (entry.binaries[key] && entry.binaries[key].ref) {\n usedBinaries[entry.binaries[key].ref] = true;\n }\n });\n }\n };\n this.getDefaultGroup().forEach(function (entry, group) {\n if (entry && entry.history.length > historyMaxItems) {\n entry.removeHistory(0, entry.history.length - historyMaxItems);\n }\n if (entry) {\n processEntry(entry);\n }\n if (entry && entry.history) {\n entry.history.forEach(function(historyEntry) {\n processEntry(historyEntry);\n });\n }\n if (group && group.customIcon) {\n usedCustomIcons[group.customIcon] = true;\n }\n });\n if (settings && settings.customIcons) {\n Object.keys(this.meta.customIcons).forEach(function(customIcon) {\n if (!usedCustomIcons[customIcon]) {\n var uuid = new KdbxUuid(customIcon);\n this.addDeletedObject(uuid, now);\n delete this.meta.customIcons[customIcon];\n }\n }, this);\n }\n if (settings && settings.binaries) {\n Object.keys(this.binaries).forEach(function(bin) {\n if (!usedBinaries[bin]) {\n delete this.binaries[bin];\n }\n }, this);\n }\n};\n\n/**\n * Merge db with another db\n * Some parts of remote DB are copied by reference, so it should NOT be modified after merge\n * Suggested use case:\n * - open local db\n * - get remote db somehow and open in\n * - merge remote into local: local.merge(remote)\n * - close remote db\n * @param {Kdbx} remote - database to merge in\n */\nKdbx.prototype.merge = function(remote) {\n var root = this.getDefaultGroup();\n var remoteRoot = remote.getDefaultGroup();\n if (!root || !remoteRoot) {\n throw new KdbxError(Consts.ErrorCodes.MergeError, 'no default group');\n }\n if (!root.uuid.equals(remoteRoot.uuid)) {\n throw new KdbxError(Consts.ErrorCodes.MergeError, 'default group is different');\n }\n var objectMap = this._getObjectMap();\n remote.deletedObjects.forEach(function(rem) {\n if (!objectMap.deleted[rem.uuid]) {\n this.deletedObjects.push(rem);\n objectMap.deleted[rem.uuid] = rem.deletionTime;\n }\n }, this);\n Object.keys(remote.binaries).forEach(function(key) {\n if (!this.binaries[key] && !objectMap.deleted[key]) {\n this.binaries[key] = remote.binaries[key];\n }\n }, this);\n objectMap.remote = remote._getObjectMap().objects;\n this.meta.merge(remote.meta, objectMap);\n root.merge(objectMap);\n this.cleanup({ historyRules: true, customIcons: true, binaries: true });\n};\n\n/**\n * Gets editing state tombstones (for successful merge)\n * Replica must save this state with the db, assign in on db open and call removeLocalEditState on successful upstream push\n * This state is JSON serializable\n */\nKdbx.prototype.getLocalEditState = function() {\n var editingState = {};\n this.getDefaultGroup().forEach(function(entry) {\n if (entry && entry._editState) {\n editingState[entry.uuid] = entry._editState;\n }\n });\n if (this.meta._editState) {\n editingState.meta = this.meta._editState;\n }\n return editingState;\n};\n\n/**\n * Sets editing state tombstones returned previously by getLocalEditState\n * Replica must call this method on db open with state returned previously on getLocalEditState\n * @param editingState - result of getLocalEditState invoked before db save\n */\nKdbx.prototype.setLocalEditState = function(editingState) {\n this.getDefaultGroup().forEach(function(entry) {\n if (entry && editingState[entry.uuid]) {\n entry._editState = editingState[entry.uuid];\n }\n });\n if (editingState.meta) {\n this.meta._editState = editingState.meta;\n }\n};\n\n/**\n * Removes editing state tombstones\n * Immediately after successful upstream push replica must:\n * - call this method\n * - discard previous state obtained by getLocalEditState call\n */\nKdbx.prototype.removeLocalEditState = function() {\n this.getDefaultGroup().forEach(function(entry) {\n if (entry) {\n entry._editState = undefined;\n }\n });\n this.meta._editState = undefined;\n};\n\n/**\n * Upgrade the file to latest version\n */\nKdbx.prototype.upgrade = function() {\n this.setVersion(KdbxHeader.MaxFileVersion);\n};\n\n/**\n * Set file version to a specified number\n * @param {Number} version - 3 or 4\n */\nKdbx.prototype.setVersion = function(version) {\n this.meta.headerHash = null;\n this.meta.settingsChanged = new Date();\n this.header.setVersion(version);\n};\n\n/**\n * Set file key derivation function\n * @param {String} kdf - KDF id, from Consts.KdfId\n */\nKdbx.prototype.setKdf = function(kdf) {\n this.meta.headerHash = null;\n this.meta.settingsChanged = new Date();\n this.header.setKdf(kdf);\n};\n\nKdbx.prototype._getObjectMap = function() {\n var objects = {}, deleted = {};\n this.getDefaultGroup().forEach(function(entry, group) {\n var object = entry || group;\n if (objects[object.uuid]) {\n throw new KdbxError(Consts.ErrorCodes.MergeError, 'Duplicate: ' + object.uuid);\n }\n objects[object.uuid] = object;\n });\n this.deletedObjects.forEach(function(deletedObject) {\n deleted[deletedObject.uuid] = deletedObject.deletionTime;\n });\n return { objects: objects, deleted: deleted };\n};\n\nKdbx.prototype._loadFromXml = function(ctx) {\n var doc = this.xml.documentElement;\n if (doc.tagName !== XmlNames.Elem.DocNode) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml root');\n }\n this._parseMeta(ctx);\n var that = this;\n return this.binaries.hash().then(function() {\n that._parseRoot(ctx);\n return that;\n });\n};\n\nKdbx.prototype._parseMeta = function(ctx) {\n var node = XmlUtils.getChildNode(this.xml.documentElement, XmlNames.Elem.Meta, 'no meta node');\n this.meta = KdbxMeta.read(node, ctx);\n};\n\nKdbx.prototype._parseRoot = function(ctx) {\n this.groups = [];\n this.deletedObjects = [];\n var node = XmlUtils.getChildNode(this.xml.documentElement, XmlNames.Elem.Root, 'no root node');\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.Group:\n this._readGroup(childNode, ctx);\n break;\n case XmlNames.Elem.DeletedObjects:\n this._readDeletedObjects(childNode);\n break;\n }\n }\n};\n\nKdbx.prototype._readDeletedObjects = function(node) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.DeletedObject:\n this.deletedObjects.push(KdbxDeletedObject.read(childNode));\n break;\n }\n }\n};\n\nKdbx.prototype._readGroup = function(node, ctx) {\n this.groups.push(KdbxGroup.read(node, ctx));\n};\n\nKdbx.prototype._buildXml = function(ctx) {\n var xml = XmlUtils.create(XmlNames.Elem.DocNode);\n this.meta.write(xml.documentElement, ctx);\n var rootNode = XmlUtils.addChildNode(xml.documentElement, XmlNames.Elem.Root);\n this.groups.forEach(function(g) { g.write(rootNode, ctx); }, this);\n var delObjNode = XmlUtils.addChildNode(rootNode, XmlNames.Elem.DeletedObjects);\n this.deletedObjects.forEach(function (d) { d.write(delObjNode, ctx); }, this);\n this.xml = xml;\n};\n\nmodule.exports = Kdbx;\n","'use strict';\r\n\r\nvar pako = require('pako'),\r\n\r\n KdbxError = require('../errors/kdbx-error'),\r\n KdbxHeader = require('./kdbx-header'),\r\n KdbxContext = require('./kdbx-context'),\r\n\r\n CryptoEngine = require('../crypto/crypto-engine'),\r\n BinaryStream = require('../utils/binary-stream'),\r\n ByteUtils = require('../utils/byte-utils'),\r\n XmlUtils = require('../utils/xml-utils'),\r\n Int64 = require('../utils/int64'),\r\n Consts = require('../defs/consts'),\r\n HashedBlockTransform = require('../crypto/hashed-block-transform'),\r\n HmacBlockTransform = require('../crypto/hmac-block-transform'),\r\n ProtectSaltGenerator = require('../crypto/protect-salt-generator'),\r\n KeyEncryptorAes = require('../crypto/key-encryptor-aes'),\r\n KeyEncryptorKdf = require('../crypto/key-encryptor-kdf');\r\n\r\nvar KdbxFormat = function(kdbx) {\r\n this.kdbx = kdbx;\r\n};\r\n\r\n/**\r\n * Load kdbx file\r\n * If there was an error loading file, throws an exception\r\n * @param {ArrayBuffer} data - database file contents\r\n * @returns {Promise.}\r\n */\r\nKdbxFormat.prototype.load = function(data) {\r\n var stm = new BinaryStream(data);\r\n var kdbx = this.kdbx;\r\n var that = this;\r\n that.ctx = new KdbxContext({ kdbx: kdbx });\r\n return kdbx.credentials.ready.then(function() {\r\n kdbx.header = KdbxHeader.read(stm, that.ctx);\r\n if (kdbx.header.versionMajor === 3) {\r\n return that._loadV3(stm);\r\n } else if (kdbx.header.versionMajor === 4) {\r\n return that._loadV4(stm);\r\n } else {\r\n throw new KdbxError(Consts.ErrorCodes.InvalidVersion, 'bad version: ' + kdbx.header.versionMajor);\r\n }\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._loadV3 = function(stm) {\r\n var kdbx = this.kdbx;\r\n var that = this;\r\n return that._decryptXmlV3(kdbx, stm).then(function(xmlStr) {\r\n kdbx.xml = XmlUtils.parse(xmlStr);\r\n return that._setProtectedValues().then(function() {\r\n return kdbx._loadFromXml(that.ctx).then(function() {\r\n return that._checkHeaderHashV3(stm).then(function () {\r\n return kdbx;\r\n });\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._loadV4 = function(stm) {\r\n var that = this;\r\n return that._getHeaderHash(stm).then(function(headerSha) {\r\n var expectedHeaderSha = stm.readBytes(headerSha.byteLength);\r\n if (!ByteUtils.arrayBufferEquals(expectedHeaderSha, headerSha)) {\r\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'header hash mismatch');\r\n }\r\n return that._computeKeysV4().then(function(keys) {\r\n return that._getHeaderHmac(stm, keys.hmacKey).then(function(headerHmac) {\r\n var expectedHeaderHmac = stm.readBytes(headerHmac.byteLength);\r\n if (!ByteUtils.arrayBufferEquals(expectedHeaderHmac, headerHmac)) {\r\n throw new KdbxError(Consts.ErrorCodes.InvalidKey);\r\n }\r\n return HmacBlockTransform.decrypt(stm.readBytesToEnd(), keys.hmacKey).then(function(data) {\r\n ByteUtils.zeroBuffer(keys.hmacKey);\r\n return that._decryptData(data, keys.cipherKey).then(function(data) {\r\n ByteUtils.zeroBuffer(keys.cipherKey);\r\n if (that.kdbx.header.compression === Consts.CompressionAlgorithm.GZip) {\r\n data = pako.ungzip(data);\r\n }\r\n stm = new BinaryStream(ByteUtils.arrayToBuffer(data));\r\n that.kdbx.header.readInnerHeader(stm, that.ctx);\r\n data = stm.readBytesToEnd();\r\n var xmlStr = ByteUtils.bytesToString(data);\r\n that.kdbx.xml = XmlUtils.parse(xmlStr);\r\n return that._setProtectedValues().then(function() {\r\n return that.kdbx._loadFromXml(that.ctx);\r\n });\r\n });\r\n });\r\n });\r\n });\r\n });\r\n};\r\n\r\n/**\r\n * Load XML file\r\n * @param {string} xmlStr\r\n * @returns {Promise.}\r\n */\r\nKdbxFormat.prototype.loadXml = function(xmlStr) {\r\n var kdbx = this.kdbx;\r\n var ctx = new KdbxContext({ kdbx: kdbx });\r\n return kdbx.credentials.ready.then(function() {\r\n kdbx.header = KdbxHeader.create();\r\n kdbx.xml = XmlUtils.parse(xmlStr);\r\n XmlUtils.protectPlainValues(kdbx.xml.documentElement);\r\n return kdbx._loadFromXml(ctx);\r\n });\r\n};\r\n\r\n/**\r\n * Save kdbx file\r\n * @returns {Promise.}\r\n */\r\nKdbxFormat.prototype.save = function() {\r\n var kdbx = this.kdbx;\r\n var that = this;\r\n that.ctx = new KdbxContext({ kdbx: kdbx });\r\n kdbx.binaries.assignIds();\r\n return kdbx.credentials.ready.then(function() {\r\n var stm = new BinaryStream();\r\n kdbx.header.generateSalts();\r\n kdbx.header.write(stm);\r\n if (kdbx.header.versionMajor === 3) {\r\n return that._saveV3(stm);\r\n } else if (kdbx.header.versionMajor === 4) {\r\n return that._saveV4(stm);\r\n } else {\r\n throw new KdbxError(Consts.ErrorCodes.InvalidVersion, 'bad version: ' + kdbx.header.versionMajor);\r\n }\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._saveV3 = function(stm) {\r\n var that = this;\r\n return that._getHeaderHash(stm).then(function(headerHash) {\r\n that.kdbx.meta.headerHash = headerHash;\r\n that.kdbx._buildXml(that.ctx);\r\n return that._getProtectSaltGenerator().then(function(gen) {\r\n XmlUtils.updateProtectedValuesSalt(that.kdbx.xml.documentElement, gen);\r\n return that._encryptXmlV3().then(function(data) {\r\n stm.writeBytes(data);\r\n return stm.getWrittenBytes();\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._saveV4 = function(stm) {\r\n var that = this;\r\n that.kdbx._buildXml(that.ctx);\r\n return that._getHeaderHash(stm).then(function(headerSha) {\r\n stm.writeBytes(headerSha);\r\n return that._computeKeysV4().then(function(keys) {\r\n return that._getHeaderHmac(stm, keys.hmacKey).then(function(headerHmac) {\r\n stm.writeBytes(headerHmac);\r\n return that._getProtectSaltGenerator().then(function(gen) {\r\n XmlUtils.updateProtectedValuesSalt(that.kdbx.xml.documentElement, gen);\r\n var xml = XmlUtils.serialize(that.kdbx.xml);\r\n var innerHeaderStm = new BinaryStream();\r\n that.kdbx.header.writeInnerHeader(innerHeaderStm, that.ctx);\r\n var innerHeaderData = innerHeaderStm.getWrittenBytes();\r\n var xmlData = ByteUtils.arrayToBuffer(ByteUtils.stringToBytes(xml));\r\n var data = new ArrayBuffer(innerHeaderData.byteLength + xmlData.byteLength);\r\n var dataArr = new Uint8Array(data);\r\n dataArr.set(new Uint8Array(innerHeaderData));\r\n dataArr.set(new Uint8Array(xmlData), innerHeaderData.byteLength);\r\n ByteUtils.zeroBuffer(xmlData);\r\n ByteUtils.zeroBuffer(innerHeaderData);\r\n if (that.kdbx.header.compression === Consts.CompressionAlgorithm.GZip) {\r\n data = pako.gzip(data);\r\n }\r\n return that._encryptData(ByteUtils.arrayToBuffer(data), keys.cipherKey).then(function(data) {\r\n ByteUtils.zeroBuffer(keys.cipherKey);\r\n return HmacBlockTransform.encrypt(data, keys.hmacKey).then(function(data) {\r\n ByteUtils.zeroBuffer(keys.hmacKey);\r\n stm.writeBytes(data);\r\n return stm.getWrittenBytes();\r\n });\r\n });\r\n });\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype.saveXml = function(prettyPrint) {\r\n var kdbx = this.kdbx;\r\n return kdbx.credentials.ready.then(function() {\r\n kdbx.header.generateSalts();\r\n var ctx = new KdbxContext({ kdbx: kdbx, exportXml: true });\r\n kdbx.binaries.assignIds();\r\n kdbx._buildXml(ctx);\r\n XmlUtils.unprotectValues(kdbx.xml.documentElement);\r\n var xml = XmlUtils.serialize(kdbx.xml, prettyPrint);\r\n XmlUtils.protectUnprotectedValues(kdbx.xml.documentElement);\r\n return xml;\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._decryptXmlV3 = function(kdbx, stm) {\r\n var data = stm.readBytesToEnd();\r\n var that = this;\r\n return that._getMasterKeyV3().then(function(masterKey) {\r\n return that._decryptData(data, masterKey).then(function(data) {\r\n ByteUtils.zeroBuffer(masterKey);\r\n data = that._trimStartBytesV3(data);\r\n return HashedBlockTransform.decrypt(data).then(function(data) {\r\n if (that.kdbx.header.compression === Consts.CompressionAlgorithm.GZip) {\r\n data = pako.ungzip(data);\r\n }\r\n return ByteUtils.bytesToString(data);\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._encryptXmlV3 = function() {\r\n var kdbx = this.kdbx;\r\n var that = this;\r\n var xml = XmlUtils.serialize(kdbx.xml);\r\n var data = ByteUtils.arrayToBuffer(ByteUtils.stringToBytes(xml));\r\n if (kdbx.header.compression === Consts.CompressionAlgorithm.GZip) {\r\n data = pako.gzip(data);\r\n }\r\n return HashedBlockTransform.encrypt(ByteUtils.arrayToBuffer(data)).then(function(data) {\r\n var ssb = new Uint8Array(kdbx.header.streamStartBytes);\r\n var newData = new Uint8Array(data.byteLength + ssb.length);\r\n newData.set(ssb);\r\n newData.set(new Uint8Array(data), ssb.length);\r\n data = newData;\r\n return that._getMasterKeyV3().then(function(masterKey) {\r\n return that._encryptData(ByteUtils.arrayToBuffer(data), masterKey).then(function(data) {\r\n ByteUtils.zeroBuffer(masterKey);\r\n return data;\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._getMasterKeyV3 = function() {\r\n var kdbx = this.kdbx;\r\n return kdbx.credentials.getHash().then(function(credHash) {\r\n var transformSeed = kdbx.header.transformSeed;\r\n var transformRounds = kdbx.header.keyEncryptionRounds;\r\n var masterSeed = kdbx.header.masterSeed;\r\n\r\n return KeyEncryptorAes.encrypt(new Uint8Array(credHash), transformSeed, transformRounds).then(function(encKey) {\r\n ByteUtils.zeroBuffer(credHash);\r\n return CryptoEngine.sha256(encKey).then(function(keyHash) {\r\n ByteUtils.zeroBuffer(encKey);\r\n var all = new Uint8Array(masterSeed.byteLength + keyHash.byteLength);\r\n all.set(new Uint8Array(masterSeed), 0);\r\n all.set(new Uint8Array(keyHash), masterSeed.byteLength);\r\n ByteUtils.zeroBuffer(keyHash);\r\n ByteUtils.zeroBuffer(masterSeed);\r\n return CryptoEngine.sha256(all.buffer).then(function(masterKey) {\r\n ByteUtils.zeroBuffer(all.buffer);\r\n return masterKey;\r\n });\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._trimStartBytesV3 = function(data) {\r\n var ssb = this.kdbx.header.streamStartBytes;\r\n if (data.byteLength < ssb.byteLength) {\r\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'short start bytes');\r\n }\r\n if (!ByteUtils.arrayBufferEquals(data.slice(0, this.kdbx.header.streamStartBytes.byteLength), ssb)) {\r\n throw new KdbxError(Consts.ErrorCodes.InvalidKey);\r\n }\r\n return data.slice(ssb.byteLength);\r\n};\r\n\r\nKdbxFormat.prototype._setProtectedValues = function() {\r\n var kdbx = this.kdbx;\r\n return this._getProtectSaltGenerator().then(function(gen) {\r\n XmlUtils.setProtectedValues(kdbx.xml.documentElement, gen);\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._getProtectSaltGenerator = function() {\r\n return ProtectSaltGenerator.create(this.kdbx.header.protectedStreamKey, this.kdbx.header.crsAlgorithm);\r\n};\r\n\r\nKdbxFormat.prototype._getHeaderHash = function(stm) {\r\n var src = stm.readBytesNoAdvance(0, this.kdbx.header.endPos);\r\n return CryptoEngine.sha256(src);\r\n};\r\n\r\nKdbxFormat.prototype._getHeaderHmac = function(stm, key) {\r\n var src = stm.readBytesNoAdvance(0, this.kdbx.header.endPos);\r\n return HmacBlockTransform.getHmacKey(key, new Int64(0xffffffff, 0xffffffff)).then(function(keySha) {\r\n return CryptoEngine.hmacSha256(keySha, src);\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._checkHeaderHashV3 = function(stm) {\r\n if (this.kdbx.meta.headerHash) {\r\n var metaHash = this.kdbx.meta.headerHash;\r\n return this._getHeaderHash(stm).then(function(actualHash) {\r\n if (!ByteUtils.arrayBufferEquals(metaHash, actualHash)) {\r\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'header hash mismatch');\r\n }\r\n });\r\n } else {\r\n return Promise.resolve();\r\n }\r\n};\r\n\r\nKdbxFormat.prototype._computeKeysV4 = function() {\r\n var that = this;\r\n var masterSeed = that.kdbx.header.masterSeed;\r\n if (!masterSeed || masterSeed.byteLength !== 32) {\r\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad master seed'));\r\n }\r\n var kdfParams = that.kdbx.header.kdfParameters;\r\n return that.kdbx.credentials.getHash().then(function(credHash) {\r\n return KeyEncryptorKdf.encrypt(credHash, kdfParams).then(function (encKey) {\r\n ByteUtils.zeroBuffer(credHash);\r\n if (!encKey || encKey.byteLength !== 32) {\r\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'bad derived key'));\r\n }\r\n var keyWithSeed = new Uint8Array(65);\r\n keyWithSeed.set(new Uint8Array(masterSeed), 0);\r\n keyWithSeed.set(new Uint8Array(encKey), masterSeed.byteLength);\r\n keyWithSeed[64] = 1;\r\n ByteUtils.zeroBuffer(encKey);\r\n ByteUtils.zeroBuffer(masterSeed);\r\n return Promise.all([\r\n CryptoEngine.sha256(keyWithSeed.buffer.slice(0, 64)),\r\n CryptoEngine.sha512(keyWithSeed.buffer)\r\n ]).then(function (keys) {\r\n ByteUtils.zeroBuffer(keyWithSeed);\r\n return { cipherKey: keys[0], hmacKey: keys[1] };\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._decryptData = function(data, cipherKey) {\r\n var cipherId = this.kdbx.header.dataCipherUuid;\r\n switch (cipherId.toString()) {\r\n case Consts.CipherId.Aes:\r\n return this._transformDataV4Aes(data, cipherKey, false);\r\n case Consts.CipherId.ChaCha20:\r\n return this._transformDataV4ChaCha20(data, cipherKey);\r\n default:\r\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'unsupported cipher'));\r\n }\r\n};\r\n\r\nKdbxFormat.prototype._encryptData = function(data, cipherKey) {\r\n var cipherId = this.kdbx.header.dataCipherUuid;\r\n switch (cipherId.toString()) {\r\n case Consts.CipherId.Aes:\r\n return this._transformDataV4Aes(data, cipherKey, true);\r\n case Consts.CipherId.ChaCha20:\r\n return this._transformDataV4ChaCha20(data, cipherKey);\r\n default:\r\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'unsupported cipher'));\r\n }\r\n};\r\n\r\nKdbxFormat.prototype._transformDataV4Aes = function(data, cipherKey, encrypt) {\r\n var that = this;\r\n var aesCbc = CryptoEngine.createAesCbc();\r\n return aesCbc.importKey(cipherKey).then(function() {\r\n return encrypt ?\r\n aesCbc.encrypt(data, that.kdbx.header.encryptionIV) :\r\n aesCbc.decrypt(data, that.kdbx.header.encryptionIV);\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._transformDataV4ChaCha20 = function(data, cipherKey) {\r\n return CryptoEngine.chacha20(data, cipherKey, this.kdbx.header.encryptionIV);\r\n};\r\n\r\nmodule.exports = KdbxFormat;\r\n","'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH = 0;\nvar Z_FINISH = 4;\n\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_SYNC_FLUSH = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY = 0;\n\nvar Z_DEFLATED = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overriden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n * - `text` (Boolean) - true if compressed data believed to be text\n * - `time` (Number) - modification time, unix timestamp\n * - `os` (Number) - operation system code\n * - `extra` (Array) - array of bytes with extra data (max 65536)\n * - `name` (String) - file name (binary string)\n * - `comment` (String) - comment (binary string)\n * - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true); // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n if (!(this instanceof Deflate)) return new Deflate(options);\n\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n if (opt.raw && (opt.windowBits > 0)) {\n opt.windowBits = -opt.windowBits;\n }\n\n else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n opt.windowBits += 16;\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n\n if (opt.dictionary) {\n var dict;\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n // If we need to compress text, change encoding to utf8.\n dict = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n this._dict_set = true;\n }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n * converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var status, _mode;\n\n if (this.ended) { return false; }\n\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // If we need to compress text, change encoding to utf8.\n strm.input = strings.string2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_deflate.deflate(strm, _mode); /* no bad return value */\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n if (this.options.to === 'string') {\n this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n var deflator = new Deflate(options);\n\n deflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (deflator.err) { throw deflator.msg; }\n\n return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n","'use strict';\n\nvar utils = require('../utils/common');\nvar trees = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar msg = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\nvar Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\n//var Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\n//var Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\n//var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION = 0;\n//var Z_BEST_SPEED = 1;\n//var Z_BEST_COMPRESSION = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED = 1;\nvar Z_HUFFMAN_ONLY = 2;\nvar Z_RLE = 3;\nvar Z_FIXED = 4;\nvar Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY = 0;\n//var Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES = 30;\n/* number of distance codes */\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n strm.msg = msg[errorCode];\n return errorCode;\n}\n\nfunction rank(f) {\n return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n var s = strm.state;\n\n //_tr_flush_bits(s);\n var len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) { return; }\n\n utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n}\n\n\nfunction flush_block_only(s, last) {\n trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n// put_byte(s, (Byte)(b >> 8));\n// put_byte(s, (Byte)(b & 0xff));\n s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read. All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n var len = strm.avail_in;\n\n if (len > size) { len = size; }\n if (len === 0) { return 0; }\n\n strm.avail_in -= len;\n\n // zmemcpy(buf, strm->next_in, len);\n utils.arraySet(buf, strm.input, strm.next_in, len, start);\n if (strm.state.wrap === 1) {\n strm.adler = adler32(strm.adler, buf, len, start);\n }\n\n else if (strm.state.wrap === 2) {\n strm.adler = crc32(strm.adler, buf, len, start);\n }\n\n strm.next_in += len;\n strm.total_in += len;\n\n return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n var chain_length = s.max_chain_length; /* max hash chain length */\n var scan = s.strstart; /* current string */\n var match; /* matched string */\n var len; /* length of current match */\n var best_len = s.prev_length; /* best match length so far */\n var nice_match = s.nice_match; /* stop if match long enough */\n var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n var _win = s.window; // shortcut\n\n var wmask = s.w_mask;\n var prev = s.prev;\n\n /* Stop when cur_match becomes <= limit. To simplify the code,\n * we prevent matches with the string of window index 0.\n */\n\n var strend = s.strstart + MAX_MATCH;\n var scan_end1 = _win[scan + best_len - 1];\n var scan_end = _win[scan + best_len];\n\n /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n * It is easy to get rid of this optimization if necessary.\n */\n // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n /* Do not waste too much time if we already have a good match: */\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n /* Do not look for matches beyond the end of the input. This is necessary\n * to make deflate deterministic.\n */\n if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n do {\n // Assert(cur_match < s->strstart, \"no future\");\n match = cur_match;\n\n /* Skip to next match if the match length cannot increase\n * or if the match length is less than 2. Note that the checks below\n * for insufficient lookahead only occur occasionally for performance\n * reasons. Therefore uninitialized memory will be accessed, and\n * conditional jumps will be made that depend on those values.\n * However the length of the match is limited to the lookahead, so\n * the output of deflate is not affected by the uninitialized values.\n */\n\n if (_win[match + best_len] !== scan_end ||\n _win[match + best_len - 1] !== scan_end1 ||\n _win[match] !== _win[scan] ||\n _win[++match] !== _win[scan + 1]) {\n continue;\n }\n\n /* The check at best_len-1 can be removed because it will be made\n * again later. (This heuristic is not always a win.)\n * It is not necessary to compare scan[2] and match[2] since they\n * are always equal when the other bytes match, given that\n * the hash keys are equal and that HASH_BITS >= 8.\n */\n scan += 2;\n match++;\n // Assert(*scan == *match, \"match[2]?\");\n\n /* We check for insufficient lookahead only every 8th comparison;\n * the 256th check will be made at strstart+258.\n */\n do {\n /*jshint noempty:false*/\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n scan < strend);\n\n // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n * At least one byte has been read, or avail_in == 0; reads are\n * performed for at least two bytes (required for the zip translate_eol\n * option -- not supported here).\n */\nfunction fill_window(s) {\n var _w_size = s.w_size;\n var p, n, m, more, str;\n\n //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n do {\n more = s.window_size - s.lookahead - s.strstart;\n\n // JS ints have 32 bit, block below not needed\n /* Deal with !@#$% 64K limit: */\n //if (sizeof(int) <= 2) {\n // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n // more = wsize;\n //\n // } else if (more == (unsigned)(-1)) {\n // /* Very unlikely, but possible on 16 bit machine if\n // * strstart == 0 && lookahead == 1 (input done a byte at time)\n // */\n // more--;\n // }\n //}\n\n\n /* If the window is almost full and there is insufficient lookahead,\n * move the upper half to the lower one to make room in the upper half.\n */\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n /* we now have strstart >= MAX_DIST */\n s.block_start -= _w_size;\n\n /* Slide the hash table (could be avoided with 32 bit values\n at the expense of memory usage). We slide even when level == 0\n to keep the hash table consistent if we switch back to level > 0\n later. (Using level 0 permanently is not an optimal usage of\n zlib, so we don't care about this pathological case.)\n */\n\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = (m >= _w_size ? m - _w_size : 0);\n } while (--n);\n\n n = _w_size;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n /* If n is not on any hash chain, prev[n] is garbage but\n * its value will never be used.\n */\n } while (--n);\n\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n\n /* If there was no sliding:\n * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n * more == window_size - lookahead - strstart\n * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n * => more >= window_size - 2*WSIZE + 2\n * In the BIG_MEM or MMAP case (not yet supported),\n * window_size == input_size + MIN_LOOKAHEAD &&\n * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n * Otherwise, window_size == 2*WSIZE so more >= 2.\n * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n */\n //Assert(more >= 2, \"more < 2\");\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n\n /* Initialize the hash value now that we have some input: */\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n\n /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n// Call update_hash() MIN_MATCH-3 more times\n//#endif\n while (s.insert) {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n * but this is not important since only literal bytes will be emitted.\n */\n\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n /* If the WIN_INIT bytes after the end of the current data have never been\n * written, then zero those bytes in order to avoid memory check reports of\n * the use of uninitialized (or uninitialised as Julian writes) bytes by\n * the longest match routines. Update the high water mark for the next\n * time through here. WIN_INIT is set to MAX_MATCH since the longest match\n * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n */\n// if (s.high_water < s.window_size) {\n// var curr = s.strstart + s.lookahead;\n// var init = 0;\n//\n// if (s.high_water < curr) {\n// /* Previous high water mark below current data -- zero WIN_INIT\n// * bytes or up to end of window, whichever is less.\n// */\n// init = s.window_size - curr;\n// if (init > WIN_INIT)\n// init = WIN_INIT;\n// zmemzero(s->window + curr, (unsigned)init);\n// s->high_water = curr + init;\n// }\n// else if (s->high_water < (ulg)curr + WIN_INIT) {\n// /* High water mark at or above current data, but below current data\n// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n// * to end of window, whichever is less.\n// */\n// init = (ulg)curr + WIN_INIT - s->high_water;\n// if (init > s->window_size - s->high_water)\n// init = s->window_size - s->high_water;\n// zmemzero(s->window + s->high_water, (unsigned)init);\n// s->high_water += init;\n// }\n// }\n//\n// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n// \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n * to pending_buf_size, and each stored block has a 5 byte header:\n */\n var max_block_size = 0xffff;\n\n if (max_block_size > s.pending_buf_size - 5) {\n max_block_size = s.pending_buf_size - 5;\n }\n\n /* Copy as much as possible from input to output: */\n for (;;) {\n /* Fill the window as much as possible: */\n if (s.lookahead <= 1) {\n\n //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n // s->block_start >= (long)s->w_size, \"slide too late\");\n// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n// s.block_start >= s.w_size)) {\n// throw new Error(\"slide too late\");\n// }\n\n fill_window(s);\n if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n\n if (s.lookahead === 0) {\n break;\n }\n /* flush the current block */\n }\n //Assert(s->block_start >= 0L, \"block gone\");\n// if (s.block_start < 0) throw new Error(\"block gone\");\n\n s.strstart += s.lookahead;\n s.lookahead = 0;\n\n /* Emit a stored block if pending_buf will be full: */\n var max_start = s.block_start + max_block_size;\n\n if (s.strstart === 0 || s.strstart >= max_start) {\n /* strstart == 0 is possible when wraparound on 16-bit machine */\n s.lookahead = s.strstart - max_start;\n s.strstart = max_start;\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n\n\n }\n /* Flush if we may have to slide, otherwise block_start may become\n * negative and the data will be gone:\n */\n if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n\n s.insert = 0;\n\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n\n if (s.strstart > s.block_start) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n var hash_head; /* head of the hash chain */\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break; /* flush the current block */\n }\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n * At this point we have always match_length < MIN_MATCH\n */\n if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n }\n if (s.match_length >= MIN_MATCH) {\n // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n /*** _tr_tally_dist(s, s.strstart - s.match_start,\n s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n\n /* Insert new strings in the hash table only if the match length\n * is not too large. This saves time but degrades compression.\n */\n if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n s.match_length--; /* string at strstart already in table */\n do {\n s.strstart++;\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n * always MIN_MATCH bytes ahead.\n */\n } while (--s.match_length !== 0);\n s.strstart++;\n } else\n {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n// Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n * matter since it will be recomputed at next deflate call.\n */\n }\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n var hash_head; /* head of hash chain */\n var bflush; /* set if current block must be flushed */\n\n var max_insert;\n\n /* Process the input block. */\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n */\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n\n if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n\n if (s.match_length <= 5 &&\n (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n /* If prev_match is also MIN_MATCH, match_start is garbage\n * but we will ignore the current match anyway.\n */\n s.match_length = MIN_MATCH - 1;\n }\n }\n /* If there was a match at the previous step and the current\n * match is not better, output the previous match:\n */\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n /* Do not insert strings in hash table beyond this. */\n\n //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n s.prev_length - MIN_MATCH, bflush);***/\n bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n /* Insert in hash table all strings up to the end of the match.\n * strstart-1 and strstart are already inserted. If there is not\n * enough lookahead, the last two strings are not inserted in\n * the hash table.\n */\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n } else if (s.match_available) {\n /* If there was no match at the previous position, output a\n * single literal. If there was a match but the current match\n * is longer, truncate the previous match to a single literal.\n */\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n if (bflush) {\n /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n flush_block_only(s, false);\n /***/\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n /* There is no previous match to compare with, wait for\n * the next step to decide.\n */\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n if (s.match_available) {\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one. Do not maintain a hash table. (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n var bflush; /* set if current block must be flushed */\n var prev; /* byte at distance one to match */\n var scan, strend; /* scan goes up to strend for length of run */\n\n var _win = s.window;\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the longest run, plus one for the unrolled loop.\n */\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* See how many times the previous byte repeats */\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n /*jshint noempty:false*/\n } while (prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n }\n\n /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n if (s.match_length >= MIN_MATCH) {\n //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s.match_length = 0;\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast), /* 2 */\n new Config(4, 6, 32, 32, deflate_fast), /* 3 */\n\n new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow), /* 5 */\n new Config(8, 16, 128, 128, deflate_slow), /* 6 */\n new Config(8, 32, 128, 256, deflate_slow), /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow), /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n s.window_size = 2 * s.w_size;\n\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n\n /* Set the default configuration parameters:\n */\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n this.strm = null; /* pointer back to this zlib stream */\n this.status = 0; /* as the name implies */\n this.pending_buf = null; /* output still pending */\n this.pending_buf_size = 0; /* size of pending_buf */\n this.pending_out = 0; /* next pending byte to output to the stream */\n this.pending = 0; /* nb of bytes in the pending buffer */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.gzhead = null; /* gzip header information to write */\n this.gzindex = 0; /* where in extra, name, or comment */\n this.method = Z_DEFLATED; /* can only be DEFLATED */\n this.last_flush = -1; /* value of flush param for previous deflate call */\n\n this.w_size = 0; /* LZ77 window size (32K by default) */\n this.w_bits = 0; /* log2(w_size) (8..16) */\n this.w_mask = 0; /* w_size - 1 */\n\n this.window = null;\n /* Sliding window. Input bytes are read into the second half of the window,\n * and move to the first half later to keep a dictionary of at least wSize\n * bytes. With this organization, matches are limited to a distance of\n * wSize-MAX_MATCH bytes, but this ensures that IO is always\n * performed with a length multiple of the block size.\n */\n\n this.window_size = 0;\n /* Actual size of window: 2*wSize, except when the user input buffer\n * is directly used as sliding window.\n */\n\n this.prev = null;\n /* Link to older string with same hash index. To limit the size of this\n * array to 64K, this link is maintained only for the last 32K strings.\n * An index in this array is thus a window index modulo 32K.\n */\n\n this.head = null; /* Heads of the hash chains or NIL. */\n\n this.ins_h = 0; /* hash index of string to be inserted */\n this.hash_size = 0; /* number of elements in hash table */\n this.hash_bits = 0; /* log2(hash_size) */\n this.hash_mask = 0; /* hash_size-1 */\n\n this.hash_shift = 0;\n /* Number of bits by which ins_h must be shifted at each input\n * step. It must be such that after MIN_MATCH steps, the oldest\n * byte no longer takes part in the hash key, that is:\n * hash_shift * MIN_MATCH >= hash_bits\n */\n\n this.block_start = 0;\n /* Window position at the beginning of the current output block. Gets\n * negative when the window is moved backwards.\n */\n\n this.match_length = 0; /* length of best match */\n this.prev_match = 0; /* previous match */\n this.match_available = 0; /* set if previous match exists */\n this.strstart = 0; /* start of string to insert */\n this.match_start = 0; /* start of matching string */\n this.lookahead = 0; /* number of valid bytes ahead in window */\n\n this.prev_length = 0;\n /* Length of the best match at previous step. Matches not greater than this\n * are discarded. This is used in the lazy match evaluation.\n */\n\n this.max_chain_length = 0;\n /* To speed up deflation, hash chains are never searched beyond this\n * length. A higher limit improves compression ratio but degrades the\n * speed.\n */\n\n this.max_lazy_match = 0;\n /* Attempt to find a better match only when the current match is strictly\n * smaller than this value. This mechanism is used only for compression\n * levels >= 4.\n */\n // That's alias to max_lazy_match, don't use directly\n //this.max_insert_length = 0;\n /* Insert new strings in the hash table only if the match length is not\n * greater than this length. This saves time but degrades compression.\n * max_insert_length is used only for compression levels <= 3.\n */\n\n this.level = 0; /* compression level (1..9) */\n this.strategy = 0; /* favor or force Huffman coding*/\n\n this.good_match = 0;\n /* Use a faster search when the previous match is longer than this */\n\n this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n /* used by trees.c: */\n\n /* Didn't use ct_data typedef below to suppress compiler warning */\n\n // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */\n // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */\n\n // Use flat array of DOUBLE size, with interleaved fata,\n // because JS does not support effective\n this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);\n this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);\n this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n\n this.l_desc = null; /* desc. for literal tree */\n this.d_desc = null; /* desc. for distance tree */\n this.bl_desc = null; /* desc. for bit length tree */\n\n //ush bl_count[MAX_BITS+1];\n this.bl_count = new utils.Buf16(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */\n this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */\n zero(this.heap);\n\n this.heap_len = 0; /* number of elements in the heap */\n this.heap_max = 0; /* element of largest frequency */\n /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n * The same heap array is used to build all trees.\n */\n\n this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n zero(this.depth);\n /* Depth of each subtree used as tie breaker for trees of equal frequency\n */\n\n this.l_buf = 0; /* buffer index for literals or lengths */\n\n this.lit_bufsize = 0;\n /* Size of match buffer for literals/lengths. There are 4 reasons for\n * limiting lit_bufsize to 64K:\n * - frequencies can be kept in 16 bit counters\n * - if compression is not successful for the first block, all input\n * data is still in the window so we can still emit a stored block even\n * when input comes from standard input. (This can also be done for\n * all blocks if lit_bufsize is not greater than 32K.)\n * - if compression is not successful for a file smaller than 64K, we can\n * even emit a stored file instead of a stored block (saving 5 bytes).\n * This is applicable only for zip (not gzip or zlib).\n * - creating new Huffman trees less frequently may not provide fast\n * adaptation to changes in the input data statistics. (Take for\n * example a binary file with poorly compressible code followed by\n * a highly compressible string table.) Smaller buffer sizes give\n * fast adaptation but have of course the overhead of transmitting\n * trees more frequently.\n * - I can't count above 4\n */\n\n this.last_lit = 0; /* running index in l_buf */\n\n this.d_buf = 0;\n /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n * the same number of elements. To use different lengths, an extra flag\n * array would be necessary.\n */\n\n this.opt_len = 0; /* bit length of current block with optimal trees */\n this.static_len = 0; /* bit length of current block with static trees */\n this.matches = 0; /* number of string matches in current block */\n this.insert = 0; /* bytes at end of window left to insert */\n\n\n this.bi_buf = 0;\n /* Output buffer. bits are inserted starting at the bottom (least\n * significant bits).\n */\n this.bi_valid = 0;\n /* Number of valid bits in bi_buf. All bits above the last valid bit\n * are always zero.\n */\n\n // Used for window memory init. We safely ignore it for JS. That makes\n // sense only for pointers and memory check tools.\n //this.high_water = 0;\n /* High water mark offset in window for initialized bytes -- bytes above\n * this are set to zero in order to avoid memory check warnings when\n * longest match routines access bytes past the input. This is then\n * updated to the new high water mark.\n */\n}\n\n\nfunction deflateResetKeep(strm) {\n var s;\n\n if (!strm || !strm.state) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n\n s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n /* was made negative by deflate(..., Z_FINISH); */\n }\n s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n strm.adler = (s.wrap === 2) ?\n 0 // crc32(0, Z_NULL, 0)\n :\n 1; // adler32(0, Z_NULL, 0)\n s.last_flush = Z_NO_FLUSH;\n trees._tr_init(s);\n return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n var ret = deflateResetKeep(strm);\n if (ret === Z_OK) {\n lm_init(strm.state);\n }\n return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n strm.state.gzhead = head;\n return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n if (!strm) { // === Z_NULL\n return Z_STREAM_ERROR;\n }\n var wrap = 1;\n\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n\n if (windowBits < 0) { /* suppress zlib wrapper */\n wrap = 0;\n windowBits = -windowBits;\n }\n\n else if (windowBits > 15) {\n wrap = 2; /* write gzip wrapper instead */\n windowBits -= 16;\n }\n\n\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n strategy < 0 || strategy > Z_FIXED) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n\n if (windowBits === 8) {\n windowBits = 9;\n }\n /* until 256-byte window bug fixed */\n\n var s = new DeflateState();\n\n strm.state = s;\n s.strm = strm;\n\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n s.window = new utils.Buf8(s.w_size * 2);\n s.head = new utils.Buf16(s.hash_size);\n s.prev = new utils.Buf16(s.w_size);\n\n // Don't need mem init magic for JS.\n //s.high_water = 0; /* nothing written to s->window yet */\n\n s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n s.pending_buf_size = s.lit_bufsize * 4;\n\n //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n //s->pending_buf = (uchf *) overlay;\n s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n s.d_buf = 1 * s.lit_bufsize;\n\n //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n s.l_buf = (1 + 2) * s.lit_bufsize;\n\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n\n return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n var old_flush, s;\n var beg, val; // for gzip header write only\n\n if (!strm || !strm.state ||\n flush > Z_BLOCK || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n }\n\n s = strm.state;\n\n if (!strm.output ||\n (!strm.input && strm.avail_in !== 0) ||\n (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n }\n\n s.strm = strm; /* just in case */\n old_flush = s.last_flush;\n s.last_flush = flush;\n\n /* Write the header */\n if (s.status === INIT_STATE) {\n\n if (s.wrap === 2) { // GZIP header\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) { // s->gzhead == Z_NULL\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n }\n else {\n put_byte(s, (s.gzhead.text ? 1 : 0) +\n (s.gzhead.hcrc ? 2 : 0) +\n (!s.gzhead.extra ? 0 : 4) +\n (!s.gzhead.name ? 0 : 8) +\n (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 0xff);\n put_byte(s, (s.gzhead.time >> 8) & 0xff);\n put_byte(s, (s.gzhead.time >> 16) & 0xff);\n put_byte(s, (s.gzhead.time >> 24) & 0xff);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, s.gzhead.os & 0xff);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 0xff);\n put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n else // DEFLATE header\n {\n var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n var level_flags = -1;\n\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= (level_flags << 6);\n if (s.strstart !== 0) { header |= PRESET_DICT; }\n header += 31 - (header % 31);\n\n s.status = BUSY_STATE;\n putShortMSB(s, header);\n\n /* Save the adler32 of the preset dictionary: */\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n strm.adler = 1; // adler32(0L, Z_NULL, 0);\n }\n }\n\n//#ifdef GZIP\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n\n while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n break;\n }\n }\n put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n s.gzindex++;\n }\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (s.gzindex === s.gzhead.extra.length) {\n s.gzindex = 0;\n s.status = NAME_STATE;\n }\n }\n else {\n s.status = NAME_STATE;\n }\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.gzindex = 0;\n s.status = COMMENT_STATE;\n }\n }\n else {\n s.status = COMMENT_STATE;\n }\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.status = HCRC_STATE;\n }\n }\n else {\n s.status = HCRC_STATE;\n }\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n }\n if (s.pending + 2 <= s.pending_buf_size) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n s.status = BUSY_STATE;\n }\n }\n else {\n s.status = BUSY_STATE;\n }\n }\n//#endif\n\n /* Flush as much pending output as possible */\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n /* Since avail_out is 0, deflate will be called again with\n * more output space, but possibly with both pending and\n * avail_in equal to zero. There won't be anything to do,\n * but this is not an error situation so make sure we\n * return OK instead of BUF_ERROR at next call of deflate:\n */\n s.last_flush = -1;\n return Z_OK;\n }\n\n /* Make sure there is something to do and avoid duplicate consecutive\n * flushes. For repeated and useless calls with Z_FINISH, we keep\n * returning Z_STREAM_END instead of Z_BUF_ERROR.\n */\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n flush !== Z_FINISH) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* User must not provide more input after the first FINISH: */\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* Start a new block or continue the current one.\n */\n if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n configuration_table[s.level].func(s, flush));\n\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n /* avoid BUF_ERROR next call, see above */\n }\n return Z_OK;\n /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n * of deflate should use the same flush parameter to make sure\n * that the flush is complete. So we don't have to output an\n * empty block here, this will be done at next call. This also\n * ensures that for a very small output buffer, we emit at most\n * one empty block.\n */\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n trees._tr_align(s);\n }\n else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n trees._tr_stored_block(s, 0, 0, false);\n /* For a full flush, this empty block will be recognized\n * as a special marker by inflate_sync().\n */\n if (flush === Z_FULL_FLUSH) {\n /*** CLEAR_HASH(s); ***/ /* forget history */\n zero(s.head); // Fill with NIL (= 0);\n\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n return Z_OK;\n }\n }\n }\n //Assert(strm->avail_out > 0, \"bug2\");\n //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n if (flush !== Z_FINISH) { return Z_OK; }\n if (s.wrap <= 0) { return Z_STREAM_END; }\n\n /* Write the trailer */\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n put_byte(s, (strm.adler >> 16) & 0xff);\n put_byte(s, (strm.adler >> 24) & 0xff);\n put_byte(s, strm.total_in & 0xff);\n put_byte(s, (strm.total_in >> 8) & 0xff);\n put_byte(s, (strm.total_in >> 16) & 0xff);\n put_byte(s, (strm.total_in >> 24) & 0xff);\n }\n else\n {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n\n flush_pending(strm);\n /* If avail_out is zero, the application will call deflate again\n * to flush the rest.\n */\n if (s.wrap > 0) { s.wrap = -s.wrap; }\n /* write the trailer only once! */\n return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n var status;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n status = strm.state.status;\n if (status !== INIT_STATE &&\n status !== EXTRA_STATE &&\n status !== NAME_STATE &&\n status !== COMMENT_STATE &&\n status !== HCRC_STATE &&\n status !== BUSY_STATE &&\n status !== FINISH_STATE\n ) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.state = null;\n\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var s;\n var str, n;\n var wrap;\n var avail;\n var next;\n var input;\n var tmpDict;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n s = strm.state;\n wrap = s.wrap;\n\n if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n return Z_STREAM_ERROR;\n }\n\n /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n if (wrap === 1) {\n /* adler32(strm->adler, dictionary, dictLength); */\n strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n }\n\n s.wrap = 0; /* avoid computing Adler-32 in read_buf */\n\n /* if dictionary would fill window, just replace the history */\n if (dictLength >= s.w_size) {\n if (wrap === 0) { /* already empty otherwise */\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n /* use the tail */\n // dictionary = dictionary.slice(dictLength - s.w_size);\n tmpDict = new utils.Buf8(s.w_size);\n utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n /* insert dictionary into window and hash */\n avail = strm.avail_in;\n next = strm.next_in;\n input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n str = s.strstart;\n n = s.lookahead - (MIN_MATCH - 1);\n do {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n","'use strict';\n\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED = 1;\n//var Z_HUFFMAN_ONLY = 2;\n//var Z_RLE = 3;\nvar Z_FIXED = 4;\n//var Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY = 0;\nvar Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES = 30;\n/* number of distance codes */\n\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK = 256;\n/* end of block literal code */\n\nvar REP_3_6 = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10 = 17;\n/* repeat a zero length 3-10 times (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits = /* extra bits for each length code */\n [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];\n\nvar extra_dbits = /* extra bits for each distance code */\n [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];\n\nvar extra_blbits = /* extra bits for each bit length code */\n [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array insdead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n this.static_tree = static_tree; /* static tree or NULL */\n this.extra_bits = extra_bits; /* extra bits for each code or NULL */\n this.extra_base = extra_base; /* base index for extra_bits */\n this.elems = elems; /* max number of elements in the tree */\n this.max_length = max_length; /* max bit length for the codes */\n\n // show if `static_tree` has data or dummy - needed for monomorphic objects\n this.has_stree = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree; /* the dynamic tree */\n this.max_code = 0; /* largest code with non zero frequency */\n this.stat_desc = stat_desc; /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n// put_byte(s, (uch)((w) & 0xff));\n// put_byte(s, (uch)((ush)(w) >> 8));\n s.pending_buf[s.pending++] = (w) & 0xff;\n s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n if (s.bi_valid > (Buf_size - length)) {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> (Buf_size - s.bi_valid);\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n s.bi_valid += length;\n }\n}\n\n\nfunction send_code(s, c, tree) {\n send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n var res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n * above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n * array bl_count contains the frequencies for each bit length.\n * The length opt_len is updated; static_len is also updated if stree is\n * not null.\n */\nfunction gen_bitlen(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var max_code = desc.max_code;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var extra = desc.stat_desc.extra_bits;\n var base = desc.stat_desc.extra_base;\n var max_length = desc.stat_desc.max_length;\n var h; /* heap index */\n var n, m; /* iterate over the tree elements */\n var bits; /* bit length */\n var xbits; /* extra bits */\n var f; /* frequency */\n var overflow = 0; /* number of elements with bit length too large */\n\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n\n /* In a first pass, compute the optimal bit lengths (which may\n * overflow in the case of the bit length tree).\n */\n tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1]/*.Len*/ = bits;\n /* We overwrite tree[n].Dad which is no longer needed */\n\n if (n > max_code) { continue; } /* not a leaf node */\n\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2]/*.Freq*/;\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n }\n }\n if (overflow === 0) { return; }\n\n // Trace((stderr,\"\\nbit length overflow\\n\"));\n /* This happens for example on obj2 and pic of the Calgary corpus */\n\n /* Find the first bit length which could increase: */\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) { bits--; }\n s.bl_count[bits]--; /* move one leaf down the tree */\n s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n s.bl_count[max_length]--;\n /* The brother of the overflow item also moves one step up,\n * but this does not affect bl_count[max_length]\n */\n overflow -= 2;\n } while (overflow > 0);\n\n /* Now recompute all bit lengths, scanning in increasing frequency.\n * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n * lengths instead of fixing only the wrong ones. This idea is taken\n * from 'ar' written by Haruhiko Okumura.)\n */\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) { continue; }\n if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n tree[m * 2 + 1]/*.Len*/ = bits;\n }\n n--;\n }\n }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n * zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n// ct_data *tree; /* the tree to decorate */\n// int max_code; /* largest code with non zero frequency */\n// ushf *bl_count; /* number of codes at each bit length */\n{\n var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n var code = 0; /* running code value */\n var bits; /* bit index */\n var n; /* code index */\n\n /* The distribution counts are first used to generate the code values\n * without bit reversal.\n */\n for (bits = 1; bits <= MAX_BITS; bits++) {\n next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n }\n /* Check that the bit counts in bl_count are consistent. The last code\n * must be all ones.\n */\n //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length[code] = length;\n for (n = 0; n < (1 << extra_lbits[code]); n++) {\n _length_code[length++] = code;\n }\n }\n //Assert (length == 256, \"tr_static_init: length != 256\");\n /* Note that the length 255 (match length 258) can be represented\n * in two different ways: code 284 + 5 bits or code 285, so we\n * overwrite length_code[255] to use the best encoding:\n */\n _length_code[length - 1] = code;\n\n /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist[code] = dist;\n for (n = 0; n < (1 << extra_dbits[code]); n++) {\n _dist_code[dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: dist != 256\");\n dist >>= 7; /* from now on, all distances are divided by 128 */\n for (; code < D_CODES; code++) {\n base_dist[code] = dist << 7;\n for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n _dist_code[256 + dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n /* Construct the codes of the static literal tree */\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n\n n = 0;\n while (n <= 143) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree[n * 2 + 1]/*.Len*/ = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree[n * 2 + 1]/*.Len*/ = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n /* Codes 286 and 287 do not exist, but we must include them in the\n * tree construction to get a canonical Huffman tree (longest code\n * all ones)\n */\n gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n /* The static distance tree is trivial: */\n for (n = 0; n < D_CODES; n++) {\n static_dtree[n * 2 + 1]/*.Len*/ = 5;\n static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n }\n\n // Now data ready and we can init static trees\n static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n\n //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n var n; /* iterates over tree elements */\n\n /* Initialize the trees. */\n for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n s.opt_len = s.static_len = 0;\n s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n //put_byte(s, (Byte)s->bi_buf);\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf *buf; /* the input data */\n//unsigned len; /* its length */\n//int header; /* true if block header must be written */\n{\n bi_windup(s); /* align on byte boundary */\n\n if (header) {\n put_short(s, len);\n put_short(s, ~len);\n }\n// while (len--) {\n// put_byte(s, *buf++);\n// }\n utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n var _n2 = n * 2;\n var _m2 = m * 2;\n return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n// deflate_state *s;\n// ct_data *tree; /* the tree to restore */\n// int k; /* node to move down */\n{\n var v = s.heap[k];\n var j = k << 1; /* left son of k */\n while (j <= s.heap_len) {\n /* Set j to the smallest of the two sons: */\n if (j < s.heap_len &&\n smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n /* Exit if v is smaller than both sons */\n if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n /* Exchange v with the smallest son */\n s.heap[k] = s.heap[j];\n k = j;\n\n /* And continue down the tree, setting j to the left son of k */\n j <<= 1;\n }\n s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n// deflate_state *s;\n// const ct_data *ltree; /* literal tree */\n// const ct_data *dtree; /* distance tree */\n{\n var dist; /* distance of matched string */\n var lc; /* match length or unmatched char (if dist == 0) */\n var lx = 0; /* running index in l_buf */\n var code; /* the code to send */\n var extra; /* number of extra bits to send */\n\n if (s.last_lit !== 0) {\n do {\n dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n lc = s.pending_buf[s.l_buf + lx];\n lx++;\n\n if (dist === 0) {\n send_code(s, lc, ltree); /* send a literal byte */\n //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n } else {\n /* Here, lc is the match length - MIN_MATCH */\n code = _length_code[lc];\n send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length[code];\n send_bits(s, lc, extra); /* send the extra length bits */\n }\n dist--; /* dist is now the match distance - 1 */\n code = d_code(dist);\n //Assert (code < D_CODES, \"bad d_code\");\n\n send_code(s, code, dtree); /* send the distance code */\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist[code];\n send_bits(s, dist, extra); /* send the extra distance bits */\n }\n } /* literal or match pair ? */\n\n /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n // \"pendingBuf overflow\");\n\n } while (lx < s.last_lit);\n }\n\n send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n * and corresponding code. The length opt_len is updated; static_len is\n * also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var elems = desc.stat_desc.elems;\n var n, m; /* iterate over heap elements */\n var max_code = -1; /* largest code with non zero frequency */\n var node; /* new node being created */\n\n /* Construct the initial heap, with least frequent element in\n * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n * heap[0] is not used.\n */\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n\n for (n = 0; n < elems; n++) {\n if (tree[n * 2]/*.Freq*/ !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n\n } else {\n tree[n * 2 + 1]/*.Len*/ = 0;\n }\n }\n\n /* The pkzip format requires that at least one distance code exists,\n * and that at least one bit should be sent even if there is only one\n * possible code. So to avoid special checks later on we force at least\n * two codes of non zero frequency.\n */\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n tree[node * 2]/*.Freq*/ = 1;\n s.depth[node] = 0;\n s.opt_len--;\n\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1]/*.Len*/;\n }\n /* node is 0 or 1 so it does not have extra bits */\n }\n desc.max_code = max_code;\n\n /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n * establish sub-heaps of increasing lengths:\n */\n for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n /* Construct the Huffman tree by repeatedly combining the least two\n * frequent nodes.\n */\n node = elems; /* next internal node of the tree */\n do {\n //pqremove(s, tree, n); /* n = node of least frequency */\n /*** pqremove ***/\n n = s.heap[1/*SMALLEST*/];\n s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n pqdownheap(s, tree, 1/*SMALLEST*/);\n /***/\n\n m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n s.heap[--s.heap_max] = m;\n\n /* Create a new node father of n and m */\n tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n /* and insert the new node in the heap */\n s.heap[1/*SMALLEST*/] = node++;\n pqdownheap(s, tree, 1/*SMALLEST*/);\n\n } while (s.heap_len >= 2);\n\n s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n /* At this point, the fields freq and dad are set. We can now\n * generate the bit lengths.\n */\n gen_bitlen(s, desc);\n\n /* The field len is now set, we can generate the bit codes */\n gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n } else if (curlen !== 0) {\n\n if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n } else {\n s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n }\n\n count = 0;\n prevlen = curlen;\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n /* tree[max_code+1].Len = -1; */ /* guard already set */\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n //Assert(count >= 3 && count <= 6, \" 3_6?\");\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n var max_blindex; /* index of last bit length code of non zero freq */\n\n /* Determine the bit length frequencies for literal and distance trees */\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n /* Build the bit length tree: */\n build_tree(s, s.bl_desc);\n /* opt_len now includes the length of the tree representations, except\n * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n */\n\n /* Determine the number of bit length codes to send. The pkzip format\n * requires that at least 4 bit length codes be sent. (appnote.txt says\n * 3 but the actual value used is 4.)\n */\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n break;\n }\n }\n /* Update opt_len to include the bit length tree and counts */\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n // s->opt_len, s->static_len));\n\n return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n// deflate_state *s;\n// int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n var rank; /* index in bl_order */\n\n //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n // \"too many codes\");\n //Tracev((stderr, \"\\nbl counts: \"));\n send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */\n for (rank = 0; rank < blcodes; rank++) {\n //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n }\n //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n * a) There are no non-portable control characters belonging to the\n * \"black list\" (0..6, 14..25, 28..31).\n * b) There is at least one printable character belonging to the\n * \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n * \"gray list\" that is ignored in this detection algorithm:\n * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n /* black_mask is the bit mask of black-listed bytes\n * set bits 0..6, 14..25, and 28..31\n * 0xf3ffc07f = binary 11110011111111111100000001111111\n */\n var black_mask = 0xf3ffc07f;\n var n;\n\n /* Check for non-textual (\"black-listed\") bytes. */\n for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n return Z_BINARY;\n }\n }\n\n /* Check for textual (\"white-listed\") bytes. */\n if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n }\n\n /* There are no \"black-listed\" or \"white-listed\" bytes:\n * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n */\n return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n /* Initialize the first block of the first file: */\n init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */\n copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree);\n bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block, or NULL if too old */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n var opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n var max_blindex = 0; /* index of last bit length code of non zero freq */\n\n /* Build the Huffman trees unless a stored block is forced */\n if (s.level > 0) {\n\n /* Check if the file is binary or text */\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n\n /* Construct the literal and distance trees */\n build_tree(s, s.l_desc);\n // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n\n build_tree(s, s.d_desc);\n // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n /* At this point, opt_len and static_len are the total bit lengths of\n * the compressed block data, excluding the tree representations.\n */\n\n /* Build the bit length tree for the above two trees, and get the index\n * in bl_order of the last bit length code to send.\n */\n max_blindex = build_bl_tree(s);\n\n /* Determine the best encoding. Compute the block lengths in bytes. */\n opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n // s->last_lit));\n\n if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n } else {\n // Assert(buf != (char*)0, \"lost buf\");\n opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n }\n\n if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n /* 4: two words for the lengths */\n\n /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n * Otherwise we can't have processed more than WSIZE input bytes since\n * the last block flush, because compression would have been\n * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n * transform a block into a stored block.\n */\n _tr_stored_block(s, buf, stored_len, last);\n\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree, static_dtree);\n\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n /* The above check is made mod 2^32, for files larger than 512 MB\n * and uLong implemented on 32 bits.\n */\n init_block(s);\n\n if (last) {\n bi_windup(s);\n }\n // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n // s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n// deflate_state *s;\n// unsigned dist; /* distance of matched string */\n// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n //var out_length, in_length, dcode;\n\n s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;\n s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n s.last_lit++;\n\n if (dist === 0) {\n /* lc is the unmatched char */\n s.dyn_ltree[lc * 2]/*.Freq*/++;\n } else {\n s.matches++;\n /* Here, lc is the match length - MIN_MATCH */\n dist--; /* dist = match distance - 1 */\n //Assert((ush)dist < (ush)MAX_DIST(s) &&\n // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n // (ush)d_code(dist) < (ush)D_CODES, \"_tr_tally: bad match\");\n\n s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n// /* Try to guess if it is profitable to stop the current block here */\n// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n// /* Compute an upper bound for the compressed length */\n// out_length = s.last_lit*8;\n// in_length = s.strstart - s.block_start;\n//\n// for (dcode = 0; dcode < D_CODES; dcode++) {\n// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n// }\n// out_length >>>= 3;\n// //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n// // s->last_lit, in_length, out_length,\n// // 100L - out_length*100L/in_length));\n// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n// return true;\n// }\n// }\n//#endif\n\n return (s.last_lit === s.lit_bufsize - 1);\n /* We avoid equality with lit_bufsize because of wraparound at 64K\n * on 16 bit machines and because stored blocks are restricted to\n * 64K-1 bytes.\n */\n}\n\nexports._tr_init = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n","'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar c = require('./zlib/constants');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\nvar GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = utils.assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n\n this.header = new GZheader();\n\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = strings.binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\n if (status === c.Z_NEED_DICT && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = strings.string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = zlib_inflate.inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === c.Z_BUF_ERROR && allowBufError === true) {\n status = c.Z_OK;\n allowBufError = false;\n }\n\n if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n if (status === c.Z_STREAM_END) {\n _mode = c.Z_FINISH;\n }\n\n // Finalize on the last chunk.\n if (_mode === c.Z_FINISH) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === c.Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === c.Z_SYNC_FLUSH) {\n this.onEnd(c.Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === c.Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip = inflate;\n","'use strict';\n\n\nvar utils = require('../utils/common');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar inflate_fast = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n this.work = new utils.Buf16(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\nfunction inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new utils.Buf32(512);\n distfix = new utils.Buf32(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new utils.Buf8(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n utils.arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n utils.arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n utils.arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n","'use strict';\n\n// See state defs from inflate.js\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n","'use strict';\n\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n","'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\nmodule.exports = GZheader;\n","// This is free and unencumbered software released into the public domain.\n// See LICENSE.md for more information.\n\nvar encoding = require(\"./lib/encoding.js\");\n\nmodule.exports = {\n TextEncoder: encoding.TextEncoder,\n TextDecoder: encoding.TextDecoder,\n};\n","// This is free and unencumbered software released into the public domain.\n// See LICENSE.md for more information.\n\n// If we're in node require encoding-indexes and attach it to the global.\n/**\n * @fileoverview Global |this| required for resolving indexes in node.\n * @suppress {globalThis}\n */\n(function(global) {\n 'use strict';\n\n //\n // Utilities\n //\n\n /**\n * @param {number} a The number to test.\n * @param {number} min The minimum value in the range, inclusive.\n * @param {number} max The maximum value in the range, inclusive.\n * @return {boolean} True if a >= min and a <= max.\n */\n function inRange(a, min, max) {\n return min <= a && a <= max;\n }\n\n /**\n * @param {!Array.<*>} array The array to check.\n * @param {*} item The item to look for in the array.\n * @return {boolean} True if the item appears in the array.\n */\n function includes(array, item) {\n return array.indexOf(item) !== -1;\n }\n\n /**\n * @param {*} o\n * @return {Object}\n */\n function ToDictionary(o) {\n if (o === undefined) return {};\n if (o === Object(o)) return o;\n throw TypeError('Could not convert argument to dictionary');\n }\n\n /**\n * @param {string} string Input string of UTF-16 code units.\n * @return {!Array.} Code points.\n */\n function stringToCodePoints(string) {\n // https://heycam.github.io/webidl/#dfn-obtain-unicode\n\n // 1. Let S be the DOMString value.\n var s = String(string);\n\n // 2. Let n be the length of S.\n var n = s.length;\n\n // 3. Initialize i to 0.\n var i = 0;\n\n // 4. Initialize U to be an empty sequence of Unicode characters.\n var u = [];\n\n // 5. While i < n:\n while (i < n) {\n\n // 1. Let c be the code unit in S at index i.\n var c = s.charCodeAt(i);\n\n // 2. Depending on the value of c:\n\n // c < 0xD800 or c > 0xDFFF\n if (c < 0xD800 || c > 0xDFFF) {\n // Append to U the Unicode character with code point c.\n u.push(c);\n }\n\n // 0xDC00 ≤ c ≤ 0xDFFF\n else if (0xDC00 <= c && c <= 0xDFFF) {\n // Append to U a U+FFFD REPLACEMENT CHARACTER.\n u.push(0xFFFD);\n }\n\n // 0xD800 ≤ c ≤ 0xDBFF\n else if (0xD800 <= c && c <= 0xDBFF) {\n // 1. If i = n−1, then append to U a U+FFFD REPLACEMENT\n // CHARACTER.\n if (i === n - 1) {\n u.push(0xFFFD);\n }\n // 2. Otherwise, i < n−1:\n else {\n // 1. Let d be the code unit in S at index i+1.\n var d = s.charCodeAt(i + 1);\n\n // 2. If 0xDC00 ≤ d ≤ 0xDFFF, then:\n if (0xDC00 <= d && d <= 0xDFFF) {\n // 1. Let a be c & 0x3FF.\n var a = c & 0x3FF;\n\n // 2. Let b be d & 0x3FF.\n var b = d & 0x3FF;\n\n // 3. Append to U the Unicode character with code point\n // 2^16+2^10*a+b.\n u.push(0x10000 + (a << 10) + b);\n\n // 4. Set i to i+1.\n i += 1;\n }\n\n // 3. Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a\n // U+FFFD REPLACEMENT CHARACTER.\n else {\n u.push(0xFFFD);\n }\n }\n }\n\n // 3. Set i to i+1.\n i += 1;\n }\n\n // 6. Return U.\n return u;\n }\n\n /**\n * @param {!Array.} code_points Array of code points.\n * @return {string} string String of UTF-16 code units.\n */\n function codePointsToString(code_points) {\n var s = '';\n for (var i = 0; i < code_points.length; ++i) {\n var cp = code_points[i];\n if (cp <= 0xFFFF) {\n s += String.fromCharCode(cp);\n } else {\n cp -= 0x10000;\n s += String.fromCharCode((cp >> 10) + 0xD800,\n (cp & 0x3FF) + 0xDC00);\n }\n }\n return s;\n }\n\n\n //\n // Implementation of Encoding specification\n // https://encoding.spec.whatwg.org/\n //\n\n //\n // 4. Terminology\n //\n\n /**\n * An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive.\n * @param {number} a The number to test.\n * @return {boolean} True if a is in the range 0x00 to 0x7F, inclusive.\n */\n function isASCIIByte(a) {\n return 0x00 <= a && a <= 0x7F;\n }\n\n /**\n * An ASCII code point is a code point in the range U+0000 to\n * U+007F, inclusive.\n */\n var isASCIICodePoint = isASCIIByte;\n\n\n /**\n * End-of-stream is a special token that signifies no more tokens\n * are in the stream.\n * @const\n */ var end_of_stream = -1;\n\n /**\n * A stream represents an ordered sequence of tokens.\n *\n * @constructor\n * @param {!(Array.|Uint8Array)} tokens Array of tokens that provide\n * the stream.\n */\n function Stream(tokens) {\n /** @type {!Array.} */\n this.tokens = [].slice.call(tokens);\n // Reversed as push/pop is more efficient than shift/unshift.\n this.tokens.reverse();\n }\n\n Stream.prototype = {\n /**\n * @return {boolean} True if end-of-stream has been hit.\n */\n endOfStream: function() {\n return !this.tokens.length;\n },\n\n /**\n * When a token is read from a stream, the first token in the\n * stream must be returned and subsequently removed, and\n * end-of-stream must be returned otherwise.\n *\n * @return {number} Get the next token from the stream, or\n * end_of_stream.\n */\n read: function() {\n if (!this.tokens.length)\n return end_of_stream;\n return this.tokens.pop();\n },\n\n /**\n * When one or more tokens are prepended to a stream, those tokens\n * must be inserted, in given order, before the first token in the\n * stream.\n *\n * @param {(number|!Array.)} token The token(s) to prepend to the\n * stream.\n */\n prepend: function(token) {\n if (Array.isArray(token)) {\n var tokens = /**@type {!Array.}*/(token);\n while (tokens.length)\n this.tokens.push(tokens.pop());\n } else {\n this.tokens.push(token);\n }\n },\n\n /**\n * When one or more tokens are pushed to a stream, those tokens\n * must be inserted, in given order, after the last token in the\n * stream.\n *\n * @param {(number|!Array.)} token The tokens(s) to push to the\n * stream.\n */\n push: function(token) {\n if (Array.isArray(token)) {\n var tokens = /**@type {!Array.}*/(token);\n while (tokens.length)\n this.tokens.unshift(tokens.shift());\n } else {\n this.tokens.unshift(token);\n }\n }\n };\n\n //\n // 5. Encodings\n //\n\n // 5.1 Encoders and decoders\n\n /** @const */\n var finished = -1;\n\n /**\n * @param {boolean} fatal If true, decoding errors raise an exception.\n * @param {number=} opt_code_point Override the standard fallback code point.\n * @return {number} The code point to insert on a decoding error.\n */\n function decoderError(fatal, opt_code_point) {\n if (fatal)\n throw TypeError('Decoder error');\n return opt_code_point || 0xFFFD;\n }\n\n /**\n * @param {number} code_point The code point that could not be encoded.\n * @return {number} Always throws, no value is actually returned.\n */\n function encoderError(code_point) {\n throw TypeError('The code point ' + code_point + ' could not be encoded.');\n }\n\n /** @interface */\n function Decoder() {}\n Decoder.prototype = {\n /**\n * @param {Stream} stream The stream of bytes being decoded.\n * @param {number} bite The next byte read from the stream.\n * @return {?(number|!Array.)} The next code point(s)\n * decoded, or null if not enough data exists in the input\n * stream to decode a complete code point, or |finished|.\n */\n handler: function(stream, bite) {}\n };\n\n /** @interface */\n function Encoder() {}\n Encoder.prototype = {\n /**\n * @param {Stream} stream The stream of code points being encoded.\n * @param {number} code_point Next code point read from the stream.\n * @return {(number|!Array.)} Byte(s) to emit, or |finished|.\n */\n handler: function(stream, code_point) {}\n };\n\n // 5.2 Names and labels\n\n // TODO: Define @typedef for Encoding: {name:string,labels:Array.}\n // https://github.com/google/closure-compiler/issues/247\n\n /**\n * @param {string} label The encoding label.\n * @return {?{name:string,labels:Array.}}\n */\n function getEncoding(label) {\n // 1. Remove any leading and trailing ASCII whitespace from label.\n label = String(label).trim().toLowerCase();\n\n // 2. If label is an ASCII case-insensitive match for any of the\n // labels listed in the table below, return the corresponding\n // encoding, and failure otherwise.\n if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) {\n return label_to_encoding[label];\n }\n return null;\n }\n\n /**\n * Encodings table: https://encoding.spec.whatwg.org/encodings.json\n * @const\n * @type {!Array.<{\n * heading: string,\n * encodings: Array.<{name:string,labels:Array.}>\n * }>}\n */\n var encodings = [\n {\n \"encodings\": [\n {\n \"labels\": [\n \"unicode-1-1-utf-8\",\n \"utf-8\",\n \"utf8\"\n ],\n \"name\": \"UTF-8\"\n }\n ],\n \"heading\": \"The Encoding\"\n }\n ];\n\n // Label to encoding registry.\n /** @type {Object.}>} */\n var label_to_encoding = {};\n encodings.forEach(function(category) {\n category.encodings.forEach(function(encoding) {\n encoding.labels.forEach(function(label) {\n label_to_encoding[label] = encoding;\n });\n });\n });\n\n // Registry of of encoder/decoder factories, by encoding name.\n /** @type {Object.} */\n var encoders = {};\n /** @type {Object.} */\n var decoders = {};\n\n //\n // 8. API\n //\n\n /** @const */ var DEFAULT_ENCODING = 'utf-8';\n\n // 8.1 Interface TextDecoder\n\n /**\n * @constructor\n * @param {string=} label The label of the encoding;\n * defaults to 'utf-8'.\n * @param {Object=} options\n */\n function TextDecoder(label, options) {\n // Web IDL conventions\n if (!(this instanceof TextDecoder))\n throw TypeError('Called as a function. Did you forget \\'new\\'?');\n label = label !== undefined ? String(label) : DEFAULT_ENCODING;\n options = ToDictionary(options);\n\n // A TextDecoder object has an associated encoding, decoder,\n // stream, ignore BOM flag (initially unset), BOM seen flag\n // (initially unset), error mode (initially replacement), and do\n // not flush flag (initially unset).\n\n /** @private */\n this._encoding = null;\n /** @private @type {?Decoder} */\n this._decoder = null;\n /** @private @type {boolean} */\n this._ignoreBOM = false;\n /** @private @type {boolean} */\n this._BOMseen = false;\n /** @private @type {string} */\n this._error_mode = 'replacement';\n /** @private @type {boolean} */\n this._do_not_flush = false;\n\n\n // 1. Let encoding be the result of getting an encoding from\n // label.\n var encoding = getEncoding(label);\n\n // 2. If encoding is failure or replacement, throw a RangeError.\n if (encoding === null || encoding.name === 'replacement')\n throw RangeError('Unknown encoding: ' + label);\n if (!decoders[encoding.name]) {\n throw Error('Decoder not present.' +\n ' Did you forget to include encoding-indexes.js?');\n }\n\n // 3. Let dec be a new TextDecoder object.\n var dec = this;\n\n // 4. Set dec's encoding to encoding.\n dec._encoding = encoding;\n\n // 5. If options's fatal member is true, set dec's error mode to\n // fatal.\n if (Boolean(options['fatal']))\n dec._error_mode = 'fatal';\n\n // 6. If options's ignoreBOM member is true, set dec's ignore BOM\n // flag.\n if (Boolean(options['ignoreBOM']))\n dec._ignoreBOM = true;\n\n // 7. Return dec.\n return dec;\n }\n\n if (Object.defineProperty) {\n // The encoding attribute's getter must return encoding's name.\n Object.defineProperty(TextDecoder.prototype, 'encoding', {\n /** @this {TextDecoder} */\n get: function() { return this._encoding.name.toLowerCase(); }\n });\n\n // The fatal attribute's getter must return true if error mode\n // is fatal, and false otherwise.\n Object.defineProperty(TextDecoder.prototype, 'fatal', {\n /** @this {TextDecoder} */\n get: function() { return this._error_mode === 'fatal'; }\n });\n\n // The ignoreBOM attribute's getter must return true if ignore\n // BOM flag is set, and false otherwise.\n Object.defineProperty(TextDecoder.prototype, 'ignoreBOM', {\n /** @this {TextDecoder} */\n get: function() { return this._ignoreBOM; }\n });\n }\n\n /**\n * @param {BufferSource=} input The buffer of bytes to decode.\n * @param {Object=} options\n * @return {string} The decoded string.\n */\n TextDecoder.prototype.decode = function decode(input, options) {\n var bytes;\n if (typeof input === 'object' && input instanceof ArrayBuffer) {\n bytes = new Uint8Array(input);\n } else if (typeof input === 'object' && 'buffer' in input &&\n input.buffer instanceof ArrayBuffer) {\n bytes = new Uint8Array(input.buffer,\n input.byteOffset,\n input.byteLength);\n } else {\n bytes = new Uint8Array(0);\n }\n\n options = ToDictionary(options);\n\n // 1. If the do not flush flag is unset, set decoder to a new\n // encoding's decoder, set stream to a new stream, and unset the\n // BOM seen flag.\n if (!this._do_not_flush) {\n this._decoder = decoders[this._encoding.name]({\n fatal: this._error_mode === 'fatal'});\n this._BOMseen = false;\n }\n\n // 2. If options's stream is true, set the do not flush flag, and\n // unset the do not flush flag otherwise.\n this._do_not_flush = Boolean(options['stream']);\n\n // 3. If input is given, push a copy of input to stream.\n // TODO: Align with spec algorithm - maintain stream on instance.\n var input_stream = new Stream(bytes);\n\n // 4. Let output be a new stream.\n var output = [];\n\n /** @type {?(number|!Array.)} */\n var result;\n\n // 5. While true:\n while (true) {\n // 1. Let token be the result of reading from stream.\n var token = input_stream.read();\n\n // 2. If token is end-of-stream and the do not flush flag is\n // set, return output, serialized.\n // TODO: Align with spec algorithm.\n if (token === end_of_stream)\n break;\n\n // 3. Otherwise, run these subsubsteps:\n\n // 1. Let result be the result of processing token for decoder,\n // stream, output, and error mode.\n result = this._decoder.handler(input_stream, token);\n\n // 2. If result is finished, return output, serialized.\n if (result === finished)\n break;\n\n if (result !== null) {\n if (Array.isArray(result))\n output.push.apply(output, /**@type {!Array.}*/(result));\n else\n output.push(result);\n }\n\n // 3. Otherwise, if result is error, throw a TypeError.\n // (Thrown in handler)\n\n // 4. Otherwise, do nothing.\n }\n // TODO: Align with spec algorithm.\n if (!this._do_not_flush) {\n do {\n result = this._decoder.handler(input_stream, input_stream.read());\n if (result === finished)\n break;\n if (result === null)\n continue;\n if (Array.isArray(result))\n output.push.apply(output, /**@type {!Array.}*/(result));\n else\n output.push(result);\n } while (!input_stream.endOfStream());\n this._decoder = null;\n }\n\n // A TextDecoder object also has an associated serialize stream\n // algorithm...\n /**\n * @param {!Array.} stream\n * @return {string}\n * @this {TextDecoder}\n */\n function serializeStream(stream) {\n // 1. Let token be the result of reading from stream.\n // (Done in-place on array, rather than as a stream)\n\n // 2. If encoding is UTF-8, UTF-16BE, or UTF-16LE, and ignore\n // BOM flag and BOM seen flag are unset, run these subsubsteps:\n if (includes(['UTF-8', 'UTF-16LE', 'UTF-16BE'], this._encoding.name) &&\n !this._ignoreBOM && !this._BOMseen) {\n if (stream.length > 0 && stream[0] === 0xFEFF) {\n // 1. If token is U+FEFF, set BOM seen flag.\n this._BOMseen = true;\n stream.shift();\n } else if (stream.length > 0) {\n // 2. Otherwise, if token is not end-of-stream, set BOM seen\n // flag and append token to stream.\n this._BOMseen = true;\n } else {\n // 3. Otherwise, if token is not end-of-stream, append token\n // to output.\n // (no-op)\n }\n }\n // 4. Otherwise, return output.\n return codePointsToString(stream);\n }\n\n return serializeStream.call(this, output);\n };\n\n // 8.2 Interface TextEncoder\n\n /**\n * @constructor\n * @param {string=} label The label of the encoding. NONSTANDARD.\n * @param {Object=} options NONSTANDARD.\n */\n function TextEncoder(label, options) {\n // Web IDL conventions\n if (!(this instanceof TextEncoder))\n throw TypeError('Called as a function. Did you forget \\'new\\'?');\n options = ToDictionary(options);\n\n // A TextEncoder object has an associated encoding and encoder.\n\n /** @private */\n this._encoding = null;\n /** @private @type {?Encoder} */\n this._encoder = null;\n\n // Non-standard\n /** @private @type {boolean} */\n this._do_not_flush = false;\n /** @private @type {string} */\n this._fatal = Boolean(options['fatal']) ? 'fatal' : 'replacement';\n\n // 1. Let enc be a new TextEncoder object.\n var enc = this;\n\n // 2. Set enc's encoding to UTF-8's encoder.\n // Standard behavior.\n enc._encoding = getEncoding('utf-8');\n\n if (label !== undefined && 'console' in global) {\n console.warn('TextEncoder constructor called with encoding label, '\n + 'which is ignored.');\n }\n\n // 3. Return enc.\n return enc;\n }\n\n if (Object.defineProperty) {\n // The encoding attribute's getter must return encoding's name.\n Object.defineProperty(TextEncoder.prototype, 'encoding', {\n /** @this {TextEncoder} */\n get: function() { return this._encoding.name.toLowerCase(); }\n });\n }\n\n /**\n * @param {string=} opt_string The string to encode.\n * @param {Object=} options\n * @return {!Uint8Array} Encoded bytes, as a Uint8Array.\n */\n TextEncoder.prototype.encode = function encode(opt_string, options) {\n opt_string = opt_string ? String(opt_string) : '';\n options = ToDictionary(options);\n\n // NOTE: This option is nonstandard. None of the encodings\n // permitted for encoding (i.e. UTF-8, UTF-16) are stateful when\n // the input is a USVString so streaming is not necessary.\n if (!this._do_not_flush)\n this._encoder = encoders[this._encoding.name]({\n fatal: this._fatal === 'fatal'});\n this._do_not_flush = Boolean(options['stream']);\n\n // 1. Convert input to a stream.\n var input = new Stream(stringToCodePoints(opt_string));\n\n // 2. Let output be a new stream\n var output = [];\n\n /** @type {?(number|!Array.)} */\n var result;\n // 3. While true, run these substeps:\n while (true) {\n // 1. Let token be the result of reading from input.\n var token = input.read();\n if (token === end_of_stream)\n break;\n // 2. Let result be the result of processing token for encoder,\n // input, output.\n result = this._encoder.handler(input, token);\n if (result === finished)\n break;\n if (Array.isArray(result))\n output.push.apply(output, /**@type {!Array.}*/(result));\n else\n output.push(result);\n }\n // TODO: Align with spec algorithm.\n if (!this._do_not_flush) {\n while (true) {\n result = this._encoder.handler(input, input.read());\n if (result === finished)\n break;\n if (Array.isArray(result))\n output.push.apply(output, /**@type {!Array.}*/(result));\n else\n output.push(result);\n }\n this._encoder = null;\n }\n // 3. If result is finished, convert output into a byte sequence,\n // and then return a Uint8Array object wrapping an ArrayBuffer\n // containing output.\n return new Uint8Array(output);\n };\n\n\n //\n // 9. The encoding\n //\n\n // 9.1 utf-8\n\n // 9.1.1 utf-8 decoder\n /**\n * @constructor\n * @implements {Decoder}\n * @param {{fatal: boolean}} options\n */\n function UTF8Decoder(options) {\n var fatal = options.fatal;\n\n // utf-8's decoder's has an associated utf-8 code point, utf-8\n // bytes seen, and utf-8 bytes needed (all initially 0), a utf-8\n // lower boundary (initially 0x80), and a utf-8 upper boundary\n // (initially 0xBF).\n var /** @type {number} */ utf8_code_point = 0,\n /** @type {number} */ utf8_bytes_seen = 0,\n /** @type {number} */ utf8_bytes_needed = 0,\n /** @type {number} */ utf8_lower_boundary = 0x80,\n /** @type {number} */ utf8_upper_boundary = 0xBF;\n\n /**\n * @param {Stream} stream The stream of bytes being decoded.\n * @param {number} bite The next byte read from the stream.\n * @return {?(number|!Array.)} The next code point(s)\n * decoded, or null if not enough data exists in the input\n * stream to decode a complete code point.\n */\n this.handler = function(stream, bite) {\n // 1. If byte is end-of-stream and utf-8 bytes needed is not 0,\n // set utf-8 bytes needed to 0 and return error.\n if (bite === end_of_stream && utf8_bytes_needed !== 0) {\n utf8_bytes_needed = 0;\n return decoderError(fatal);\n }\n\n // 2. If byte is end-of-stream, return finished.\n if (bite === end_of_stream)\n return finished;\n\n // 3. If utf-8 bytes needed is 0, based on byte:\n if (utf8_bytes_needed === 0) {\n\n // 0x00 to 0x7F\n if (inRange(bite, 0x00, 0x7F)) {\n // Return a code point whose value is byte.\n return bite;\n }\n\n // 0xC2 to 0xDF\n else if (inRange(bite, 0xC2, 0xDF)) {\n // 1. Set utf-8 bytes needed to 1.\n utf8_bytes_needed = 1;\n\n // 2. Set UTF-8 code point to byte & 0x1F.\n utf8_code_point = bite & 0x1F;\n }\n\n // 0xE0 to 0xEF\n else if (inRange(bite, 0xE0, 0xEF)) {\n // 1. If byte is 0xE0, set utf-8 lower boundary to 0xA0.\n if (bite === 0xE0)\n utf8_lower_boundary = 0xA0;\n // 2. If byte is 0xED, set utf-8 upper boundary to 0x9F.\n if (bite === 0xED)\n utf8_upper_boundary = 0x9F;\n // 3. Set utf-8 bytes needed to 2.\n utf8_bytes_needed = 2;\n // 4. Set UTF-8 code point to byte & 0xF.\n utf8_code_point = bite & 0xF;\n }\n\n // 0xF0 to 0xF4\n else if (inRange(bite, 0xF0, 0xF4)) {\n // 1. If byte is 0xF0, set utf-8 lower boundary to 0x90.\n if (bite === 0xF0)\n utf8_lower_boundary = 0x90;\n // 2. If byte is 0xF4, set utf-8 upper boundary to 0x8F.\n if (bite === 0xF4)\n utf8_upper_boundary = 0x8F;\n // 3. Set utf-8 bytes needed to 3.\n utf8_bytes_needed = 3;\n // 4. Set UTF-8 code point to byte & 0x7.\n utf8_code_point = bite & 0x7;\n }\n\n // Otherwise\n else {\n // Return error.\n return decoderError(fatal);\n }\n\n // Return continue.\n return null;\n }\n\n // 4. If byte is not in the range utf-8 lower boundary to utf-8\n // upper boundary, inclusive, run these substeps:\n if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {\n\n // 1. Set utf-8 code point, utf-8 bytes needed, and utf-8\n // bytes seen to 0, set utf-8 lower boundary to 0x80, and set\n // utf-8 upper boundary to 0xBF.\n utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;\n utf8_lower_boundary = 0x80;\n utf8_upper_boundary = 0xBF;\n\n // 2. Prepend byte to stream.\n stream.prepend(bite);\n\n // 3. Return error.\n return decoderError(fatal);\n }\n\n // 5. Set utf-8 lower boundary to 0x80 and utf-8 upper boundary\n // to 0xBF.\n utf8_lower_boundary = 0x80;\n utf8_upper_boundary = 0xBF;\n\n // 6. Set UTF-8 code point to (UTF-8 code point << 6) | (byte &\n // 0x3F)\n utf8_code_point = (utf8_code_point << 6) | (bite & 0x3F);\n\n // 7. Increase utf-8 bytes seen by one.\n utf8_bytes_seen += 1;\n\n // 8. If utf-8 bytes seen is not equal to utf-8 bytes needed,\n // continue.\n if (utf8_bytes_seen !== utf8_bytes_needed)\n return null;\n\n // 9. Let code point be utf-8 code point.\n var code_point = utf8_code_point;\n\n // 10. Set utf-8 code point, utf-8 bytes needed, and utf-8 bytes\n // seen to 0.\n utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;\n\n // 11. Return a code point whose value is code point.\n return code_point;\n };\n }\n\n // 9.1.2 utf-8 encoder\n /**\n * @constructor\n * @implements {Encoder}\n * @param {{fatal: boolean}} options\n */\n function UTF8Encoder(options) {\n var fatal = options.fatal;\n /**\n * @param {Stream} stream Input stream.\n * @param {number} code_point Next code point read from the stream.\n * @return {(number|!Array.)} Byte(s) to emit.\n */\n this.handler = function(stream, code_point) {\n // 1. If code point is end-of-stream, return finished.\n if (code_point === end_of_stream)\n return finished;\n\n // 2. If code point is in the range U+0000 to U+007F, return a\n // byte whose value is code point.\n if (inRange(code_point, 0x0000, 0x007f))\n return code_point;\n\n // 3. Set count and offset based on the range code point is in:\n var count, offset;\n // U+0080 to U+07FF, inclusive:\n if (inRange(code_point, 0x0080, 0x07FF)) {\n // 1 and 0xC0\n count = 1;\n offset = 0xC0;\n }\n // U+0800 to U+FFFF, inclusive:\n else if (inRange(code_point, 0x0800, 0xFFFF)) {\n // 2 and 0xE0\n count = 2;\n offset = 0xE0;\n }\n // U+10000 to U+10FFFF, inclusive:\n else if (inRange(code_point, 0x10000, 0x10FFFF)) {\n // 3 and 0xF0\n count = 3;\n offset = 0xF0;\n }\n\n // 4.Let bytes be a byte sequence whose first byte is (code\n // point >> (6 × count)) + offset.\n var bytes = [(code_point >> (6 * count)) + offset];\n\n // 5. Run these substeps while count is greater than 0:\n while (count > 0) {\n\n // 1. Set temp to code point >> (6 × (count − 1)).\n var temp = code_point >> (6 * (count - 1));\n\n // 2. Append to bytes 0x80 | (temp & 0x3F).\n bytes.push(0x80 | (temp & 0x3F));\n\n // 3. Decrease count by one.\n count -= 1;\n }\n\n // 6. Return bytes bytes, in order.\n return bytes;\n };\n }\n\n /** @param {{fatal: boolean}} options */\n encoders['UTF-8'] = function(options) {\n return new UTF8Encoder(options);\n };\n /** @param {{fatal: boolean}} options */\n decoders['UTF-8'] = function(options) {\n return new UTF8Decoder(options);\n };\n\n if (!global['TextEncoder'])\n global['TextEncoder'] = TextEncoder;\n if (!global['TextDecoder'])\n global['TextDecoder'] = TextDecoder;\n\n if (typeof module !== \"undefined\" && module.exports) {\n module.exports = {\n TextEncoder: global['TextEncoder'],\n TextDecoder: global['TextDecoder']\n };\n }\n}(this));\n","module.exports = __WEBPACK_EXTERNAL_MODULE__42__;","'use strict';\n\nvar XmlUtils = require('../utils/xml-utils');\n\n/**\n * Context with helper methods for load/save\n * @param {Kdbx} opts.kdbx - kdbx file\n * @param {boolean} [opts.exportXml=false] - whether we are exporting as xml\n * @constructor\n */\nvar KdbxContext = function(opts) {\n this.kdbx = opts.kdbx;\n this.exportXml = opts.exportXml || false;\n};\n\n/**\n * Sets XML date, respecting date saving settings\n * @param {Node} node\n * @param {Date} dt\n */\nKdbxContext.prototype.setXmlDate = function(node, dt) {\n var isBinary = this.kdbx.header.versionMajor >= 4 && !this.exportXml;\n XmlUtils.setDate(node, dt, isBinary);\n};\n\nmodule.exports = KdbxContext;\n","module.exports = __WEBPACK_EXTERNAL_MODULE__44__;","'use strict';\n\nvar\n BinaryStream = require('./../utils/binary-stream'),\n KdbxError = require('./../errors/kdbx-error'),\n Consts = require('./../defs/consts'),\n ByteUtils = require('./../utils/byte-utils'),\n CryptoEngine = require('./crypto-engine');\n\nvar BlockSize = 1024*1024;\n\n/**\n * Decrypt buffer\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction decrypt(data) {\n return Promise.resolve().then(function() {\n var stm = new BinaryStream(data);\n var buffers = [];\n var blockIndex = 0, blockLength = 0, blockHash, totalLength = 0;\n\n var next = function() {\n blockIndex = stm.getUint32(true);\n blockHash = stm.readBytes(32);\n blockLength = stm.getUint32(true);\n if (blockLength > 0) {\n totalLength += blockLength;\n var blockData = stm.readBytes(blockLength);\n return CryptoEngine.sha256(blockData).then(function(calculatedHash) {\n if (!ByteUtils.arrayBufferEquals(calculatedHash, blockHash)) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'invalid hash block');\n } else {\n buffers.push(blockData);\n return next();\n }\n });\n } else {\n var ret = new Uint8Array(totalLength);\n var offset = 0;\n for (var i = 0; i < buffers.length; i++) {\n ret.set(new Uint8Array(buffers[i]), offset);\n offset += buffers[i].byteLength;\n }\n return ret.buffer;\n }\n };\n return next();\n });\n}\n\n/**\n * Encrypt buffer\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction encrypt(data) {\n return Promise.resolve().then(function() {\n var bytesLeft = data.byteLength;\n var currentOffset = 0, blockIndex = 0, totalLength = 0;\n var buffers = [];\n\n var next = function() {\n if (bytesLeft > 0) {\n var blockLength = Math.min(BlockSize, bytesLeft);\n bytesLeft -= blockLength;\n\n var blockData = data.slice(currentOffset, currentOffset + blockLength);\n return CryptoEngine.sha256(blockData).then(function(blockHash) {\n var blockBuffer = new ArrayBuffer(4 + 32 + 4);\n var stm = new BinaryStream(blockBuffer);\n stm.setUint32(blockIndex, true);\n stm.writeBytes(blockHash);\n stm.setUint32(blockLength, true);\n\n buffers.push(blockBuffer);\n totalLength += blockBuffer.byteLength;\n buffers.push(blockData);\n totalLength += blockData.byteLength;\n\n blockIndex++;\n currentOffset += blockLength;\n\n return next();\n });\n } else {\n var endBlockData = new ArrayBuffer(4 + 32 + 4);\n var view = new DataView(endBlockData);\n view.setUint32(0, blockIndex, true);\n buffers.push(endBlockData);\n totalLength += endBlockData.byteLength;\n\n var ret = new Uint8Array(totalLength);\n var offset = 0;\n for (var i = 0; i < buffers.length; i++) {\n ret.set(new Uint8Array(buffers[i]), offset);\n offset += buffers[i].byteLength;\n }\n return ret.buffer;\n }\n };\n return next();\n });\n}\n\nmodule.exports.decrypt = decrypt;\nmodule.exports.encrypt = encrypt;\n","'use strict';\n\nvar\n Int64 = require('../utils/int64'),\n KdbxError = require('../errors/kdbx-error'),\n Consts = require('../defs/consts'),\n ByteUtils = require('../utils/byte-utils'),\n BinaryStream = require('../utils/binary-stream'),\n CryptoEngine = require('./crypto-engine');\n\nvar BlockSize = 1024*1024;\n\n/**\n * Computes HMAC-SHA key\n * @param {ArrayBuffer} key\n * @param {Int64} blockIndex\n * @returns {Promise.}\n */\nfunction getHmacKey(key, blockIndex) {\n var shaSrc = new Uint8Array(8 + key.byteLength);\n shaSrc.set(new Uint8Array(key), 8);\n var view = new DataView(shaSrc.buffer);\n view.setUint32(0, blockIndex.lo, true);\n view.setUint32(4, blockIndex.hi, true);\n return CryptoEngine.sha512(ByteUtils.arrayToBuffer(shaSrc)).then(function(sha) {\n ByteUtils.zeroBuffer(shaSrc);\n return sha;\n });\n}\n\n/**\n * Gets block HMAC\n * @param {ArrayBuffer} key\n * @param {number} blockIndex\n * @param {number} blockLength\n * @param {ArrayBuffer} blockData\n * @returns {Promise.}\n */\nfunction getBlockHmac(key, blockIndex, blockLength, blockData) {\n return getHmacKey(key, new Int64(blockIndex)).then(function(blockKey) {\n var blockDataForHash = new Uint8Array(blockData.byteLength + 4 + 8);\n var blockDataForHashView = new DataView(blockDataForHash.buffer);\n blockDataForHash.set(new Uint8Array(blockData), 4 + 8);\n blockDataForHashView.setInt32(0, blockIndex, true);\n blockDataForHashView.setInt32(8, blockLength, true);\n return CryptoEngine.hmacSha256(blockKey, blockDataForHash.buffer);\n });\n}\n\n/**\n * Decrypt buffer\n * @param {ArrayBuffer} data\n * @param {ArrayBuffer} key\n * @returns {Promise.}\n */\nfunction decrypt(data, key) {\n var stm = new BinaryStream(data);\n return Promise.resolve().then(function() {\n var buffers = [];\n var blockIndex = 0, blockLength = 0, blockHash, totalLength = 0;\n\n var next = function() {\n blockHash = stm.readBytes(32);\n blockLength = stm.getUint32(true);\n if (blockLength > 0) {\n totalLength += blockLength;\n var blockData = stm.readBytes(blockLength);\n return getBlockHmac(key, blockIndex, blockLength, blockData).then(function(calculatedBlockHash) {\n if (!ByteUtils.arrayBufferEquals(calculatedBlockHash, blockHash)) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'invalid hash block');\n } else {\n buffers.push(blockData);\n blockIndex++;\n return next();\n }\n });\n } else {\n var ret = new Uint8Array(totalLength);\n var offset = 0;\n for (var i = 0; i < buffers.length; i++) {\n ret.set(new Uint8Array(buffers[i]), offset);\n offset += buffers[i].byteLength;\n }\n return ret.buffer;\n }\n };\n return next();\n });\n}\n\n/**\n * Encrypt buffer\n * @param {ArrayBuffer} data\n * @param {ArrayBuffer} key\n * @returns {Promise.}\n */\nfunction encrypt(data, key) {\n return Promise.resolve().then(function() {\n var bytesLeft = data.byteLength;\n var currentOffset = 0, blockIndex = 0, totalLength = 0;\n var buffers = [];\n\n var next = function() {\n var blockLength = Math.min(BlockSize, bytesLeft);\n bytesLeft -= blockLength;\n\n var blockData = data.slice(currentOffset, currentOffset + blockLength);\n return getBlockHmac(key, blockIndex, blockLength, blockData).then(function(blockHash) {\n var blockBuffer = new ArrayBuffer(32 + 4);\n var stm = new BinaryStream(blockBuffer);\n stm.writeBytes(blockHash);\n stm.setUint32(blockLength, true);\n\n buffers.push(blockBuffer);\n totalLength += blockBuffer.byteLength;\n\n if (blockData.byteLength > 0) {\n buffers.push(blockData);\n totalLength += blockData.byteLength;\n blockIndex++;\n currentOffset += blockLength;\n return next();\n } else {\n var ret = new Uint8Array(totalLength);\n var offset = 0;\n for (var i = 0; i < buffers.length; i++) {\n ret.set(new Uint8Array(buffers[i]), offset);\n offset += buffers[i].byteLength;\n }\n return ret.buffer;\n }\n });\n };\n return next();\n });\n}\n\nmodule.exports.getHmacKey = getHmacKey;\nmodule.exports.decrypt = decrypt;\nmodule.exports.encrypt = encrypt;\n","'use strict';\n\nvar Salsa20 = require('./salsa20'),\n ChaCha20 = require('./chacha20'),\n Consts = require('../defs/consts'),\n KdbxError = require('../errors/kdbx-error'),\n CryptoEngine = require('./crypto-engine'),\n ByteUtils = require('./../utils/byte-utils');\n\nvar SalsaNonce = [0xE8, 0x30, 0x09, 0x4B, 0x97, 0x20, 0x5D, 0x2A];\n\n/**\n * Protect information used for decrypt and encrypt protected data fields\n * @constructor\n */\nvar ProtectSaltGenerator = function(algo) {\n this.algo = algo;\n};\n\n/**\n * Get salt bytes\n * @param {number} len - bytes count\n * @return {ArrayBuffer} - salt bytes\n */\nProtectSaltGenerator.prototype.getSalt = function(len) {\n return ByteUtils.arrayToBuffer(this.algo.getBytes(len));\n};\n\n/**\n * Creates protected salt generator\n * @param {ArrayBuffer|Uint8Array} key\n * @param {Number} crsAlgorithm\n * @return {Promise.}\n */\nProtectSaltGenerator.create = function(key, crsAlgorithm) {\n switch (crsAlgorithm) {\n case Consts.CrsAlgorithm.Salsa20:\n return CryptoEngine.sha256(ByteUtils.arrayToBuffer(key)).then(function(hash) {\n var key = new Uint8Array(hash);\n var algo = new Salsa20(key, SalsaNonce);\n return new ProtectSaltGenerator(algo);\n });\n case Consts.CrsAlgorithm.ChaCha20:\n return CryptoEngine.sha512(ByteUtils.arrayToBuffer(key)).then(function(hash) {\n var key = new Uint8Array(hash, 0, 32);\n var nonce = new Uint8Array(hash, 32, 12);\n var algo = new ChaCha20(key, nonce);\n return new ProtectSaltGenerator(algo);\n });\n default:\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'crsAlgorithm'));\n }\n};\n\nmodule.exports = ProtectSaltGenerator;\n","'use strict';\n\nvar Consts = require('../defs/consts'),\n ByteUtils = require('../utils/byte-utils'),\n VarDictionary = require('../utils/var-dictionary'),\n Int64 = require('../utils/int64'),\n CryptoEngine = require('../crypto/crypto-engine'),\n KdbxError = require('../errors/kdbx-error'),\n KeyEncryptorAes = require('./key-encryptor-aes');\n\nvar KdfFields = [\n { name: 'salt', field: 'S', type: VarDictionary.ValueType.Bytes },\n { name: 'parallelism', field: 'P', type: VarDictionary.ValueType.UInt32 },\n { name: 'memory', field: 'M', type: VarDictionary.ValueType.UInt64 },\n { name: 'iterations', field: 'I', type: VarDictionary.ValueType.UInt64 },\n { name: 'version', field: 'V', type: VarDictionary.ValueType.UInt32 },\n { name: 'secretKey', field: 'K', type: VarDictionary.ValueType.Bytes },\n { name: 'assocData', field: 'A', type: VarDictionary.ValueType.Bytes },\n { name: 'rounds', field: 'R', type: VarDictionary.ValueType.Int64 }\n];\n\n/**\n * Derives key from seed using KDF parameters\n * @param {ArrayBuffer} key\n * @param {VarDictionary} kdfParams\n */\nfunction encrypt(key, kdfParams) {\n var uuid = kdfParams.get('$UUID');\n if (!uuid || !(uuid instanceof ArrayBuffer)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no kdf uuid'));\n }\n var kdfUuid = ByteUtils.bytesToBase64(uuid);\n switch (kdfUuid) {\n case Consts.KdfId.Argon2:\n return encryptArgon2(key, kdfParams);\n case Consts.KdfId.Aes:\n return encryptAes(key, kdfParams);\n default:\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'bad kdf'));\n }\n}\n\nfunction decodeParams(kdfParams) {\n var params = {};\n KdfFields.forEach(function(fieldDef) {\n var value = kdfParams.get(fieldDef.field);\n if (value) {\n if (value instanceof Int64) {\n value = value.value;\n }\n params[fieldDef.name] = value;\n }\n });\n return params;\n}\n\nfunction encryptArgon2(key, kdfParams) {\n var params = decodeParams(kdfParams);\n if (!(params.salt instanceof ArrayBuffer) || params.salt.byteLength !== 32) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 salt'));\n }\n if (typeof params.parallelism !== 'number' || params.parallelism < 1) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 parallelism'));\n }\n if (typeof params.iterations !== 'number' || params.iterations < 1) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 iterations'));\n }\n if (typeof params.memory !== 'number' || params.memory < 1 || params.memory % 1024 !== 0) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 memory'));\n }\n if (params.version !== 0x13 && params.version !== 0x10) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 version'));\n }\n if (params.secretKey) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'argon2 secret key'));\n }\n if (params.assocData) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'argon2 assoc data'));\n }\n return CryptoEngine.argon2(key, params.salt,\n params.memory / 1024, params.iterations,\n 32, params.parallelism, 0, params.version);\n}\n\nfunction encryptAes(key, kdfParams) {\n var params = decodeParams(kdfParams);\n if (!(params.salt instanceof ArrayBuffer) || params.salt.byteLength !== 32) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad aes salt'));\n }\n if (typeof params.rounds !== 'number' || params.rounds < 1) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad aes rounds'));\n }\n return KeyEncryptorAes.encrypt(new Uint8Array(key), new Uint8Array(params.salt), params.rounds).then(function(key) {\n return CryptoEngine.sha256(key).then(function(hash) {\n ByteUtils.zeroBuffer(key);\n return hash;\n });\n });\n}\n\nmodule.exports.encrypt = encrypt;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n KdbxUuid = require('./kdbx-uuid'),\n KdbxCustomData = require('./kdbx-custom-data'),\n XmlUtils = require('./../utils/xml-utils'),\n Consts = require('./../defs/consts');\n\nvar Constants = {\n Generator: 'KdbxWeb'\n};\n\n/**\n * Db metadata\n * @constructor\n */\nvar KdbxMeta = function() {\n this.generator = undefined;\n this.headerHash = undefined;\n this.settingsChanged = undefined;\n this._name = undefined;\n this.nameChanged = undefined;\n this._desc = undefined;\n this.descChanged = undefined;\n this._defaultUser = undefined;\n this.defaultUserChanged = undefined;\n this._mntncHistoryDays = undefined;\n this._color = undefined;\n this.keyChanged = undefined;\n this._keyChangeRec = undefined;\n this._keyChangeForce = undefined;\n this._recycleBinEnabled = undefined;\n this._recycleBinUuid = undefined;\n this.recycleBinChanged = undefined;\n this._entryTemplatesGroup = undefined;\n this.entryTemplatesGroupChanged = undefined;\n this._historyMaxItems = undefined;\n this._historyMaxSize = undefined;\n this._lastSelectedGroup = undefined;\n this._lastTopVisibleGroup = undefined;\n this._memoryProtection = {\n title: undefined, userName: undefined, password: undefined, url: undefined, notes: undefined\n };\n this.customData = {};\n this.customIcons = {};\n this._editState = undefined;\n Object.preventExtensions(this);\n};\n\nvar props = {\n name: 'nameChanged',\n desc: 'descChanged',\n defaultUser: 'defaultUserChanged',\n mntncHistoryDays: null,\n color: null,\n keyChangeRec: null,\n keyChangeForce: null,\n recycleBinEnabled: 'recycleBinChanged',\n recycleBinUuid: 'recycleBinChanged',\n entryTemplatesGroup: 'entryTemplatesGroupChanged',\n historyMaxItems: null,\n historyMaxSize: null,\n lastSelectedGroup: null,\n lastTopVisibleGroup: null,\n memoryProtection: null\n};\n\nObject.keys(props).forEach(function(prop) {\n createProperty(prop, props[prop]);\n});\n\nfunction createProperty(prop, propChanged) {\n var field = '_' + prop;\n Object.defineProperty(KdbxMeta.prototype, prop, {\n enumerable: true,\n get: function() { return this[field]; },\n set: function(value) {\n if (value !== this[field]) {\n this[field] = value;\n if (propChanged) {\n this[propChanged] = new Date();\n } else {\n this._setPropModDate(prop);\n }\n }\n }\n });\n}\n\nKdbxMeta.prototype._setPropModDate = function(prop) {\n if (!this._editState) {\n this._editState = { };\n }\n this._editState[prop] = new Date().getTime();\n};\n\nKdbxMeta.prototype._readNode = function(node, ctx) {\n switch (node.tagName) {\n case XmlNames.Elem.Generator:\n this.generator = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.HeaderHash:\n this.headerHash = XmlUtils.getBytes(node);\n break;\n case XmlNames.Elem.SettingsChanged:\n this.settingsChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbName:\n this._name = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.DbNameChanged:\n this.nameChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbDesc:\n this._desc = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.DbDescChanged:\n this.descChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbDefaultUser:\n this._defaultUser = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.DbDefaultUserChanged:\n this.defaultUserChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbMntncHistoryDays:\n this._mntncHistoryDays = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.DbColor:\n this._color = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.DbKeyChanged:\n this.keyChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbKeyChangeRec:\n this._keyChangeRec = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.DbKeyChangeForce:\n this._keyChangeForce = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.RecycleBinEnabled:\n this._recycleBinEnabled = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.RecycleBinUuid:\n this._recycleBinUuid = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.RecycleBinChanged:\n this.recycleBinChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.EntryTemplatesGroup:\n this._entryTemplatesGroup = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.EntryTemplatesGroupChanged:\n this.entryTemplatesGroupChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.HistoryMaxItems:\n this._historyMaxItems = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.HistoryMaxSize:\n this._historyMaxSize = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.LastSelectedGroup:\n this._lastSelectedGroup = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.LastTopVisibleGroup:\n this._lastTopVisibleGroup = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.MemoryProt:\n this._readMemoryProtection(node);\n break;\n case XmlNames.Elem.CustomIcons:\n this._readCustomIcons(node);\n break;\n case XmlNames.Elem.Binaries:\n this._readBinaries(node, ctx);\n break;\n case XmlNames.Elem.CustomData:\n this._readCustomData(node);\n break;\n }\n};\n\nKdbxMeta.prototype._readMemoryProtection = function(node) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.ProtTitle:\n this.memoryProtection.title = XmlUtils.getBoolean(childNode);\n break;\n case XmlNames.Elem.ProtUserName:\n this.memoryProtection.userName = XmlUtils.getBoolean(childNode);\n break;\n case XmlNames.Elem.ProtPassword:\n this.memoryProtection.password = XmlUtils.getBoolean(childNode);\n break;\n case XmlNames.Elem.ProtUrl:\n this.memoryProtection.url = XmlUtils.getBoolean(childNode);\n break;\n case XmlNames.Elem.ProtNotes:\n this.memoryProtection.notes = XmlUtils.getBoolean(childNode);\n break;\n }\n }\n};\n\nKdbxMeta.prototype._writeMemoryProtection = function(parentNode) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.MemoryProt);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtTitle), this.memoryProtection.title);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtUserName), this.memoryProtection.userName);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtPassword), this.memoryProtection.password);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtUrl), this.memoryProtection.url);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtNotes), this.memoryProtection.notes);\n};\n\nKdbxMeta.prototype._readCustomIcons = function(node) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName === XmlNames.Elem.CustomIconItem) {\n this._readCustomIcon(childNode);\n }\n }\n};\n\nKdbxMeta.prototype._readCustomIcon = function(node) {\n var uuid, data;\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.CustomIconItemID:\n uuid = XmlUtils.getUuid(childNode);\n break;\n case XmlNames.Elem.CustomIconItemData:\n data = XmlUtils.getBytes(childNode);\n break;\n }\n }\n if (uuid && data) {\n this.customIcons[uuid] = data;\n }\n};\n\nKdbxMeta.prototype._writeCustomIcons = function(parentNode) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.CustomIcons);\n var customIcons = this.customIcons;\n Object.keys(customIcons).forEach(function(uuid) {\n var data = customIcons[uuid];\n if (data) {\n var itemNode = XmlUtils.addChildNode(node, XmlNames.Elem.CustomIconItem);\n XmlUtils.setUuid(XmlUtils.addChildNode(itemNode, XmlNames.Elem.CustomIconItemID), uuid);\n XmlUtils.setBytes(XmlUtils.addChildNode(itemNode, XmlNames.Elem.CustomIconItemData), data);\n }\n });\n};\n\nKdbxMeta.prototype._readBinaries = function(node, ctx) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName === XmlNames.Elem.Binary) {\n this._readBinary(childNode, ctx);\n }\n }\n};\n\nKdbxMeta.prototype._readBinary = function(node, ctx) {\n var id = node.getAttribute(XmlNames.Attr.Id);\n var binary = XmlUtils.getProtectedBinary(node);\n if (id && binary) {\n ctx.kdbx.binaries[id] = binary;\n }\n};\n\nKdbxMeta.prototype._writeBinaries = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Binaries);\n var binaries = ctx.kdbx.binaries;\n binaries.hashOrder.forEach(function(hash, index) {\n var data = binaries[hash];\n if (data) {\n var itemNode = XmlUtils.addChildNode(node, XmlNames.Elem.Binary);\n itemNode.setAttribute(XmlNames.Attr.Id, index.toString());\n XmlUtils.setProtectedBinary(itemNode, data);\n }\n });\n};\n\nKdbxMeta.prototype._readCustomData = function(node) {\n this.customData = KdbxCustomData.read(node);\n};\n\nKdbxMeta.prototype._writeCustomData = function(parentNode) {\n KdbxCustomData.write(parentNode, this.customData);\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxMeta.prototype.write = function(parentNode, ctx) {\n this.generator = Constants.generator;\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Meta);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Generator), Constants.Generator);\n if (ctx.kdbx.header.versionMajor < 4) {\n XmlUtils.setBytes(XmlUtils.addChildNode(node, XmlNames.Elem.HeaderHash), this.headerHash);\n } else if (this.settingsChanged) {\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.SettingsChanged), this.settingsChanged);\n }\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbName), this.name);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DbNameChanged), this.nameChanged);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbDesc), this.desc);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DbDescChanged), this.descChanged);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbDefaultUser), this.defaultUser);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DbDefaultUserChanged), this.defaultUserChanged);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbMntncHistoryDays), this.mntncHistoryDays);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbColor), this.color);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DbKeyChanged), this.keyChanged);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.DbKeyChangeRec), this.keyChangeRec);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.DbKeyChangeForce), this.keyChangeForce);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.RecycleBinEnabled), this.recycleBinEnabled);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.RecycleBinUuid), this.recycleBinUuid);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.RecycleBinChanged), this.recycleBinChanged);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.EntryTemplatesGroup), this.entryTemplatesGroup);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.EntryTemplatesGroupChanged), this.entryTemplatesGroupChanged);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.HistoryMaxItems), this.historyMaxItems);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.HistoryMaxSize), this.historyMaxSize);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.LastSelectedGroup), this.lastSelectedGroup);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.LastTopVisibleGroup), this.lastTopVisibleGroup);\n this._writeMemoryProtection(node);\n this._writeCustomIcons(node);\n if (ctx.exportXml || ctx.kdbx.header.versionMajor < 4) {\n this._writeBinaries(node, ctx);\n }\n this._writeCustomData(node);\n};\n\n/**\n * Merge meta with another db\n * @param {KdbxMeta} remote\n * @param {{objects, remote, deleted}} objectMap\n */\nKdbxMeta.prototype.merge = function(remote, objectMap) {\n if (remote.nameChanged > this.nameChanged) {\n this._name = remote.name;\n this.nameChanged = remote.nameChanged;\n }\n if (remote.descChanged > this.descChanged) {\n this._desc = remote.desc;\n this.descChanged = remote.descChanged;\n }\n if (remote.defaultUserChanged > this.defaultUserChanged) {\n this._defaultUser = remote.defaultUser;\n this.defaultUserChanged = remote.defaultUserChanged;\n }\n if (remote.keyChanged > this.keyChanged) {\n this.keyChanged = remote.keyChanged;\n }\n if (remote.settingsChanged > this.settingsChanged) {\n this.settingsChanged = remote.settingsChanged;\n }\n if (remote.recycleBinChanged > this.recycleBinChanged) {\n this._recycleBinEnabled = remote.recycleBinEnabled;\n this._recycleBinUuid = remote.recycleBinUuid;\n this.recycleBinChanged = remote.recycleBinChanged;\n }\n if (remote.entryTemplatesGroupChanged > this.entryTemplatesGroupChanged) {\n this._entryTemplatesGroup = remote.entryTemplatesGroup;\n this.entryTemplatesGroupChanged = remote.entryTemplatesGroupChanged;\n }\n Object.keys(remote.customData).forEach(function(key) {\n if (!this.customData[key] && !objectMap.deleted[key]) {\n this.customData[key] = remote.customData[key];\n }\n }, this);\n Object.keys(remote.customIcons).forEach(function(key) {\n if (!this.customIcons[key] && !objectMap.deleted[key]) {\n this.customIcons[key] = remote.customIcons[key];\n }\n }, this);\n if (!this._editState || !this._editState.historyMaxItems) { this.historyMaxItems = remote.historyMaxItems; }\n if (!this._editState || !this._editState.historyMaxSize) { this.historyMaxSize = remote.historyMaxSize; }\n if (!this._editState || !this._editState.keyChangeRec) { this.keyChangeRec = remote.keyChangeRec; }\n if (!this._editState || !this._editState.keyChangeForce) { this.keyChangeForce = remote.keyChangeForce; }\n if (!this._editState || !this._editState.mntncHistoryDays) { this.mntncHistoryDays = remote.mntncHistoryDays; }\n if (!this._editState || !this._editState.color) { this.color = remote.color; }\n};\n\n/**\n * Creates new meta\n * @returns {KdbxMeta}\n */\nKdbxMeta.create = function() {\n var now = new Date();\n var meta = new KdbxMeta();\n meta.generator = Constants.Generator;\n meta.settingsChanged = now;\n meta.mntncHistoryDays = Consts.Defaults.MntncHistoryDays;\n meta.recycleBinEnabled = true;\n meta.historyMaxItems = Consts.Defaults.HistoryMaxItems;\n meta.historyMaxSize = Consts.Defaults.HistoryMaxSize;\n meta.nameChanged = now;\n meta.descChanged = now;\n meta.defaultUserChanged = now;\n meta.recycleBinChanged = now;\n meta.keyChangeRec = -1;\n meta.keyChangeForce = -1;\n meta.entryTemplatesGroup = new KdbxUuid();\n meta.entryTemplatesGroupChanged = now;\n meta.memoryProtection = { title: false, userName: false, password: true, url: false, notes: false };\n return meta;\n};\n\n/**\n * Read KdbxMeta from stream\n * @param {Node} xmlNode - xml Meta node\n * @param {KdbxContext} ctx\n * @return {KdbxMeta}\n */\nKdbxMeta.read = function(xmlNode, ctx) {\n var meta = new KdbxMeta();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n meta._readNode(childNode, ctx);\n }\n }\n return meta;\n};\n\nmodule.exports = KdbxMeta;\n","'use strict';\n\nvar ProtectedValue = require('./../crypto/protected-value'),\n CryptoEngine = require('./../crypto/crypto-engine'),\n ByteUtils = require('./../utils/byte-utils');\n\nvar KdbxBinaries = function() {\n Object.defineProperties(this, {\n idToHash: { value: {} },\n hashOrder: { value: null, configurable: true }\n });\n};\n\nKdbxBinaries.prototype.hash = function() {\n var promises = [];\n var that = this;\n Object.keys(that).forEach(function(id) {\n var binary = that[id];\n promises.push(that.getBinaryHash(binary).then(function(hash) {\n that.idToHash[id] = hash;\n that[hash] = that[id];\n delete that[id];\n }));\n });\n return Promise.all(promises);\n};\n\nKdbxBinaries.prototype.getBinaryHash = function(binary) {\n var promise;\n if (binary instanceof ProtectedValue) {\n promise = binary.getHash();\n } else if (binary instanceof ArrayBuffer || binary instanceof Uint8Array) {\n binary = ByteUtils.arrayToBuffer(binary);\n promise = CryptoEngine.sha256(binary);\n }\n return promise.then(function(hash) {\n return ByteUtils.bytesToHex(hash);\n });\n};\n\nKdbxBinaries.prototype.assignIds = function() {\n Object.defineProperty(this, 'hashOrder', { value: Object.keys(this), configurable: true });\n};\n\nKdbxBinaries.prototype.add = function(value) {\n var that = this;\n return this.getBinaryHash(value).then(function(hash) {\n that[hash] = value;\n return { ref: hash, value: value };\n });\n};\n\nmodule.exports = KdbxBinaries;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils'),\n Consts = require('../defs/consts'),\n KdbxCustomData = require('./kdbx-custom-data'),\n KdbxTimes = require('./kdbx-times'),\n KdbxUuid = require('./kdbx-uuid'),\n KdbxEntry = require('./kdbx-entry');\n\n/**\n * Entries group\n * @constructor\n */\nvar KdbxGroup = function() {\n this.uuid = undefined;\n this.name = undefined;\n this.notes = undefined;\n this.icon = undefined;\n this.customIcon = undefined;\n this.times = new KdbxTimes();\n this.expanded = undefined;\n this.defaultAutoTypeSeq = undefined;\n this.enableAutoType = undefined;\n this.enableSearching = undefined;\n this.lastTopVisibleEntry = undefined;\n this.groups = [];\n this.entries = [];\n this.parentGroup = undefined;\n this.customData = undefined;\n Object.preventExtensions(this);\n};\n\nKdbxGroup.prototype._readNode = function(node, ctx) {\n switch (node.tagName) {\n case XmlNames.Elem.Uuid:\n this.uuid = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.Name:\n this.name = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.Notes:\n this.notes = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.Icon:\n this.icon = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.CustomIconID:\n this.customIcon = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.Times:\n this.times = KdbxTimes.read(node);\n break;\n case XmlNames.Elem.IsExpanded:\n this.expanded = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.GroupDefaultAutoTypeSeq:\n this.defaultAutoTypeSeq = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.EnableAutoType:\n this.enableAutoType = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.EnableSearching:\n this.enableSearching = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.LastTopVisibleEntry:\n this.lastTopVisibleEntry = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.Group:\n this.groups.push(KdbxGroup.read(node, ctx, this));\n break;\n case XmlNames.Elem.Entry:\n this.entries.push(KdbxEntry.read(node, ctx, this));\n break;\n case XmlNames.Elem.CustomData:\n this.customData = KdbxCustomData.read(node);\n break;\n }\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxGroup.prototype.write = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Group);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.Uuid), this.uuid);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Name), this.name);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Notes), this.notes);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.Icon), this.icon);\n if (this.customIcon) {\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.CustomIconID), this.customIcon);\n }\n KdbxCustomData.write(node, this.customData);\n this.times.write(node, ctx);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.IsExpanded), this.expanded);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.GroupDefaultAutoTypeSeq), this.defaultAutoTypeSeq);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.EnableAutoType), this.enableAutoType);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.EnableSearching), this.enableSearching);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.LastTopVisibleEntry), this.lastTopVisibleEntry);\n this.groups.forEach(function(g) { g.write(node, ctx); });\n this.entries.forEach(function(e) { e.write(node, ctx); });\n};\n\n/**\n * Invokes callback for each entry in recursive way\n * @param {function} callback - will be invoked with entry or group argument\n * @param {function} [thisArg] - callback context\n */\nKdbxGroup.prototype.forEach = function(callback, thisArg) {\n callback.call(thisArg, undefined, this);\n this.entries.forEach(function(entry) { callback.call(thisArg, entry); });\n this.groups.forEach(function(group) { group.forEach(callback, thisArg); });\n};\n\n/**\n * Merge group with remote group\n * @param {{objects, remote, deleted}} objectMap\n */\nKdbxGroup.prototype.merge = function(objectMap) {\n var remoteGroup = objectMap.remote[this.uuid];\n if (!remoteGroup) {\n return;\n }\n if (remoteGroup.times.lastModTime > this.times.lastModTime) {\n this.copyFrom(remoteGroup);\n }\n this.groups = this._mergeCollection(this.groups, remoteGroup.groups, objectMap);\n this.entries = this._mergeCollection(this.entries, remoteGroup.entries, objectMap);\n this.groups.forEach(function(group) { group.merge(objectMap); });\n this.entries.forEach(function(entry) { entry.merge(objectMap); });\n};\n\n/**\n * Merge object collection with remote collection\n * Implements 2P-set CRDT with tombstones stored in objectMap.deleted\n * Assumes tombstones are already merged\n * @param {object[]} collection - local groups or entries\n * @param {object[]} remoteCollection - remote groups or entries\n * @param {{objects, remote, deleted}} objectMap - local objects hashmap, remote objects hashmap and tombstones\n * @returns {object[]}\n * @private\n */\nKdbxGroup.prototype._mergeCollection = function(collection, remoteCollection, objectMap) {\n var newItems = [];\n collection.forEach(function(item) {\n if (objectMap.deleted[item.uuid]) {\n return; // item deleted\n }\n var remoteItem = objectMap.remote[item.uuid];\n if (!remoteItem) {\n newItems.push(item); // item added locally\n } else if (remoteItem.times.locationChanged <= item.times.locationChanged) {\n newItems.push(item); // item not changed or moved to this group locally later than remote\n }\n }, this);\n remoteCollection.forEach(function(remoteItem, ix) {\n if (objectMap.deleted[remoteItem.uuid]) {\n return; // item already processed as local item or deleted\n }\n var item = objectMap.objects[remoteItem.uuid];\n if (item && remoteItem.times.locationChanged > item.times.locationChanged) {\n item.parentGroup = this; // item moved to this group remotely later than local\n newItems.splice(this._findInsertIx(newItems, remoteCollection, ix), 0, item);\n } else if (!item) {\n var newItem = new remoteItem.constructor(); // item created remotely\n newItem.copyFrom(remoteItem);\n newItem.parentGroup = this;\n newItems.splice(this._findInsertIx(newItems, remoteCollection, ix), 0, newItem);\n }\n }, this);\n return newItems;\n};\n\n/**\n * Finds a best place to insert new item into collection\n * @param {object[]} dst - destination collection\n * @param {object[]} src - source item\n * @param {int} srcIx - source item index in collection\n * @returns {int} - index in collection\n * @private\n */\nKdbxGroup.prototype._findInsertIx = function(dst, src, srcIx) {\n var selectedIx = dst.length, selectedScore = -1;\n for (var dstIx = 0; dstIx <= dst.length; dstIx++) {\n var score = 0;\n var srcPrev = srcIx > 0 ? src[srcIx - 1].uuid.id : undefined,\n srcNext = srcIx + 1 < src.length ? src[srcIx + 1].uuid.id : undefined,\n dstPrev = dstIx > 0 ? dst[dstIx - 1].uuid.id : undefined,\n dstNext = dstIx < dst.length ? dst[dstIx].uuid.id : undefined;\n if (!srcPrev && !dstPrev) {\n score += 1; // start of sequence\n } else if (srcPrev === dstPrev) {\n score += 5; // previous element equals\n }\n if (!srcNext && !dstNext) {\n score += 2; // end of sequence\n } else if (srcNext === dstNext) {\n score += 5; // next element equals\n }\n if (score > selectedScore) {\n selectedIx = dstIx;\n selectedScore = score;\n }\n }\n return selectedIx;\n};\n\n/**\n * Clone group state from another group\n */\nKdbxGroup.prototype.copyFrom = function(group) {\n this.uuid = group.uuid;\n this.name = group.name;\n this.notes = group.notes;\n this.icon = group.icon;\n this.customIcon = group.customIcon;\n this.times = group.times.clone();\n this.expanded = group.expanded;\n this.defaultAutoTypeSeq = group.defaultAutoTypeSeq;\n this.enableAutoType = group.enableAutoType;\n this.enableSearching = group.enableSearching;\n this.lastTopVisibleEntry = group.lastTopVisibleEntry;\n};\n\n/**\n * Creates new group\n * @param {string} name\n * @param {KdbxGroup} [parentGroup]\n * @returns {KdbxGroup}\n */\nKdbxGroup.create = function(name, parentGroup) {\n var group = new KdbxGroup();\n group.uuid = KdbxUuid.random();\n group.icon = Consts.Icons.Folder;\n group.times = KdbxTimes.create();\n group.name = name;\n group.parentGroup = parentGroup;\n group.expanded = true;\n group.enableAutoType = null;\n group.enableSearching = null;\n group.lastTopVisibleEntry = new KdbxUuid();\n return group;\n};\n\n/**\n * Read group from xml\n * @param {Node} xmlNode\n * @param {KdbxContext} ctx\n * @param {KdbxGroup} [parentGroup]\n * @return {KdbxGroup}\n */\nKdbxGroup.read = function(xmlNode, ctx, parentGroup) {\n var grp = new KdbxGroup();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n grp._readNode(childNode, ctx);\n }\n }\n grp.parentGroup = parentGroup;\n return grp;\n};\n\nmodule.exports = KdbxGroup;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils');\n\n/**\n * Deleted object\n * @constructor\n */\nvar KdbxDeletedObject = function() {\n this.uuid = undefined;\n this.deletionTime = undefined;\n Object.preventExtensions(this);\n};\n\nKdbxDeletedObject.prototype._readNode = function(node) {\n switch (node.tagName) {\n case XmlNames.Elem.Uuid:\n this.uuid = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.DeletionTime:\n this.deletionTime = XmlUtils.getDate(node);\n break;\n }\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxDeletedObject.prototype.write = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.DeletedObject);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.Uuid), this.uuid);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DeletionTime), this.deletionTime);\n};\n\n/**\n * Read deleted object from xml\n * @param {Node} xmlNode\n * @return {KdbxTimes}\n */\nKdbxDeletedObject.read = function(xmlNode) {\n var obj = new KdbxDeletedObject();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n obj._readNode(childNode);\n }\n }\n return obj;\n};\n\nmodule.exports = KdbxDeletedObject;\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://kdbxweb/webpack/universalModuleDefinition","webpack://kdbxweb/webpack/bootstrap","webpack://kdbxweb/./utils/byte-utils.js","webpack://kdbxweb/./defs/consts.js","webpack://kdbxweb/./errors/kdbx-error.js","webpack://kdbxweb/./crypto/crypto-engine.js","webpack://kdbxweb/./utils/xml-utils.js","webpack://kdbxweb/../node_modules/pako/lib/utils/common.js","webpack://kdbxweb/./defs/xml-names.js","webpack://kdbxweb/./format/kdbx-uuid.js","webpack://kdbxweb/./utils/int64.js","webpack://kdbxweb/./crypto/protected-value.js","webpack://kdbxweb/./crypto/random.js","webpack://kdbxweb/./utils/binary-stream.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/messages.js","webpack://kdbxweb/../node_modules/webpack/buildin/global.js","webpack://kdbxweb/./utils/var-dictionary.js","webpack://kdbxweb/./format/kdbx-custom-data.js","webpack://kdbxweb/../node_modules/pako/index.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/adler32.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/crc32.js","webpack://kdbxweb/../node_modules/pako/lib/utils/strings.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/zstream.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/constants.js","webpack://kdbxweb/./format/kdbx-header.js","webpack://kdbxweb/./crypto/salsa20.js","webpack://kdbxweb/./crypto/chacha20.js","webpack://kdbxweb/./crypto/key-encryptor-aes.js","webpack://kdbxweb/./format/kdbx-credentials.js","webpack://kdbxweb/./format/kdbx-times.js","webpack://kdbxweb/./format/kdbx-entry.js","webpack://kdbxweb/./index.js","webpack://kdbxweb/./format/kdbx.js","webpack://kdbxweb/./format/kdbx-format.js","webpack://kdbxweb/../node_modules/pako/lib/deflate.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/deflate.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/trees.js","webpack://kdbxweb/../node_modules/pako/lib/inflate.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/inflate.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/inffast.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/inftrees.js","webpack://kdbxweb/../node_modules/pako/lib/zlib/gzheader.js","webpack://kdbxweb/../node_modules/text-encoding/index.js","webpack://kdbxweb/../node_modules/text-encoding/lib/encoding.js","webpack://kdbxweb/external \"crypto\"","webpack://kdbxweb/./format/kdbx-context.js","webpack://kdbxweb/external \"xmldom\"","webpack://kdbxweb/./crypto/hashed-block-transform.js","webpack://kdbxweb/./crypto/hmac-block-transform.js","webpack://kdbxweb/./crypto/protect-salt-generator.js","webpack://kdbxweb/./crypto/key-encryptor-kdf.js","webpack://kdbxweb/./format/kdbx-meta.js","webpack://kdbxweb/./format/kdbx-binaries.js","webpack://kdbxweb/./format/kdbx-group.js","webpack://kdbxweb/./format/kdbx-deleted-object.js"],"names":[],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;AClFA,8CAAa;;AAEb;AACA;;AAEA;AACA,uBAAuB,mBAAO,CAAC,uBAAe;AAC9C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,SAAS;AAC/C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,6BAA6B;AACxC,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,6BAA6B;AACxC,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,6BAA6B;AACxC,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,uBAAuB;AAClC,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,uBAAuB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACnKa;;AAEb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;AC5Ha;;AAEb;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;;;;;;;;ACVA,8CAAa;;AAEb,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,eAAe,mBAAO,CAAC,oBAAY;;AAEnC;AACA;AACA,6FAA6F,mBAAO,CAAC,gBAAQ;;AAE7G;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,kBAAkB;AAChD,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,kBAAkB;AAChD,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA,oBAAoB,sBAAsB,kBAAkB;AAC5D;AACA;AACA;AACA,aAAa;AACb,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,yCAAyC,gBAAgB;AACzD,6BAA6B,gBAAgB,EAAE;AAC/C;;AAEA;AACA,2BAA2B,wBAAwB;AACnD;;AAEA;AACA,2BAA2B,wBAAwB;AACnD,2BAA2B,kEAAkE,EAAE;AAC/F;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,oBAAoB,kEAAkE,EAAE;AAC7F;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,WAAW;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa;AACb;AACA,yFAAyF;AACzF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;;AC7OA,8CAAa;;AAEb,gBAAgB,mBAAO,CAAC,+BAAwB;AAChD,aAAa,mBAAO,CAAC,yBAAkB;AACvC,eAAe,mBAAO,CAAC,0BAAmB;AAC1C,eAAe,mBAAO,CAAC,8BAAuB;AAC9C,qBAAqB,mBAAO,CAAC,oCAA6B;AAC1D,gBAAgB,mBAAO,CAAC,qBAAc;AACtC,YAAY,mBAAO,CAAC,gBAAS;AAC7B,WAAW,mBAAO,CAAC,cAAM;;AAEzB;;AAEA,sCAAsC,mBAAO,CAAC,gBAAQ;AACtD;AACA;AACA,4BAA4B,SAAS,EAAE;AACvC,iCAAiC,SAAS;AAC1C;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,QAAQ;AACnB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,uBAAuB;AAC1C;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,SAAS;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA,8DAA8D,SAAS;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,iBAAiB;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,YAAY;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,wCAAwC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,eAAe;AAC1B,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,iBAAiB;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,iBAAiB;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,kBAAkB;AAC9B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,kBAAkB;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,sBAAsB;AACjC;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY,4BAA4B,aAAa;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,4BAA4B,YAAY,QAAQ;AAC3D;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,SAAS;AACpB;AACA;AACA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,qBAAqB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,qBAAqB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACzea;;;AAGb;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA,kBAAkB,UAAU;;AAE5B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA,4BAA4B,YAAY;AACxC,qBAAqB,8BAA8B;AACnD;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;;AAEA;AACA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACrGa;;AAEb;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;AC9Ga;;AAEb,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,aAAa,mBAAO,CAAC,0BAAkB;;AAEvC;;AAEA;AACA;AACA,WAAW,mBAAmB;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,SAAS;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,gBAAgB;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACpEa;;AAEb;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACrDa;;AAEb,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,mBAAmB,mBAAO,CAAC,wBAAiB;AAC5C,aAAa,mBAAO,CAAC,kBAAU;;AAE/B;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB;AACA;AACA;AACA,2CAA2C,+BAA+B;AAC1E,0CAA0C,8BAA8B;AACxE;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;AACA;;AAEA;AACA,qEAAqE;AACrE,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,oBAAoB;AAC/C,0BAA0B,sBAAsB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,kCAAkC,QAAQ;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;;;;;;;;;;;;;AC5Ia;;AAEb,cAAc,mBAAO,CAAC,mBAAW;AACjC,mBAAmB,mBAAO,CAAC,wBAAiB;;AAE5C;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,WAAW;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,QAAQ;AAChD;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AChCa;;AAEb;AACA;AACA,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;;;;;;;;;;;;;AC9Ga;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACZA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C;;;;;;;;;;;;;;ACnBa;;AAEb,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,YAAY,mBAAO,CAAC,uBAAgB;;AAEpC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA,2CAA2C,iBAAiB,EAAE;AAC9D;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,qBAAqB,2BAA2B;AAChD,CAAC;;AAED;AACA;AACA,WAAW,OAAO;AAClB,WAAW,+BAA+B;AAC1C,WAAW,EAAE;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA,qDAAqD,yBAAyB,EAAE;AAChF;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;;AAEA;AACA;AACA,WAAW,aAAa;AACxB;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC5Ra;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;;AAE7C;AACA;AACA;AACA,eAAe,KAAK;AACpB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,8DAA8D,SAAS;AACvE;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,eAAe,KAAK;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA,8DAA8D,SAAS;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC7DA;AACa;;AAEb,gBAAgB,mBAAO,CAAC,2BAAoB;;AAE5C,gBAAgB,mBAAO,CAAC,uBAAe;AACvC,gBAAgB,mBAAO,CAAC,uBAAe;AACvC,gBAAgB,mBAAO,CAAC,8BAAsB;;AAE9C;;AAEA;;AAEA;;;;;;;;;;;;;;ACba;;AAEb;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;;;AAGA;;;;;;;;;;;;;;AC/Ba;;AAEb;AACA;AACA;;;AAGA;AACA;AACA;;AAEA,iBAAiB,SAAS;AAC1B;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA,mBAAmB,SAAS;AAC5B;AACA;;AAEA,sBAAsB;AACtB;;;AAGA;;;;;;;;;;;;;;ACxCA;AACa;;;AAGb,YAAY,mBAAO,CAAC,iBAAU;;;AAG9B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK,wCAAwC,EAAE,aAAa,sBAAsB;AAClF,KAAK,oDAAoD,EAAE,aAAa,0BAA0B;;;AAGlG;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA,kCAAkC;;;AAGlC;AACA;AACA;;AAEA;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,wBAAwB,aAAa;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,mCAAmC,SAAS;AAC5C;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,sBAAsB,SAAS;AAC/B;AACA;AACA,mBAAmB,qBAAqB,UAAU;;AAElD;AACA;AACA,oBAAoB,0BAA0B,gBAAgB,UAAU;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB,0BAA0B,UAAU;;AAExD;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yBAAyB,kBAAkB;;AAE3C;AACA;AACA,kDAAkD,OAAO;;AAEzD;AACA;AACA,gBAAgB,YAAY;;AAE5B;AACA;AACA,kBAAkB,YAAY;;AAE9B;AACA;;;;;;;;;;;;;;ACxLa;;;AAGb;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC5Ba;;;AAGb;;AAEA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjDa;;AAEb;AACA;AACA;;AAEA,eAAe,mBAAO,CAAC,oBAAa;AACpC,aAAa,mBAAO,CAAC,yBAAkB;AACvC,qBAAqB,mBAAO,CAAC,oCAA6B;AAC1D,gBAAgB,mBAAO,CAAC,+BAAwB;AAChD,mBAAmB,mBAAO,CAAC,kCAA0B;AACrD,gBAAgB,mBAAO,CAAC,8BAAuB;AAC/C,oBAAoB,mBAAO,CAAC,mCAA2B;AACvD,YAAY,mBAAO,CAAC,yBAAkB;AACtC,aAAa,mBAAO,CAAC,0BAAkB;;AAEvC;AACA,KAAK,sBAAsB;;AAE3B,KAAK,kBAAkB;AACvB,KAAK,mBAAmB;AACxB,KAAK,2BAA2B;AAChC,KAAK,qBAAqB;AAC1B,KAAK,kCAAkC;AACvC,KAAK,oCAAoC;AACzC,KAAK,uBAAuB;AAC5B,KAAK,uCAAuC;AAC5C,KAAK,qCAAqC;AAC1C,KAAK,wCAAwC;;AAE7C,KAAK,kCAAkC;AACvC,KAAK;AACL;;AAEA;AACA,KAAK,sBAAsB;;AAE3B,KAAK,8BAA8B;AACnC,KAAK,+BAA+B;AACpC,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,oCAAoC;;AAEpC;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,uBAAuB,6BAA6B;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB;AACA;AACA;AACA;AACA;AACA,oBAAoB,0BAA0B;AAC9C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,YAAY;AACvB;AACA;AACA;AACA,oBAAoB,+BAA+B;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,YAAY;AACvB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;;;;;;;;AC7gBa;;AAEb;;AAEA;AACA;AACA,qBAAqB;AACrB;;AAEA;AACA,uBAAuB;AACvB,6BAA6B;AAC7B,+BAA+B;;AAE/B;AACA,oBAAoB;AACpB,wBAAwB;;AAExB;AACA;AACA;;AAEA;AACA;AACA,0BAA0B,OAAO;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB,kBAAkB;AACpC;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC,yCAAyC;AACzC;;AAEA;;;;;;;;;;;;;;AC/Oa;;AAEb;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;;AAElB;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC7Ha;;AAEb,gBAAgB,mBAAO,CAAC,8BAAuB;AAC/C,mBAAmB,mBAAO,CAAC,wBAAiB;;AAE5C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,6BAA6B,sBAAsB;AACnD;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,+BAA+B,kBAAkB;AACjD;AACA;AACA;AACA,aAAa;AACb;AACA,SAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,sCAAsC,4BAA4B,EAAE;AACpE;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;;;;;;;;;;;;;;ACrEa;;AAEb,qBAAqB,mBAAO,CAAC,kCAA2B;AACxD,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,eAAe,mBAAO,CAAC,2BAAoB;AAC3C,aAAa,mBAAO,CAAC,0BAAkB;AACvC,mBAAmB,mBAAO,CAAC,gCAAyB;;AAEpD;AACA;AACA,WAAW,eAAe;AAC1B,WAAW,8BAA8B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,oBAAoB;AAC/B;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA,WAAW,uBAAuB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,GAAG;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,aAAa;AACb;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,mBAAmB,eAAe;AAClC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AClJa;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACrHa;;AAEb,qBAAqB,mBAAO,CAAC,kCAA2B;AACxD,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;AAC7C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,qBAAqB,mBAAO,CAAC,4BAAoB;AACjD,eAAe,mBAAO,CAAC,oBAAa;AACpC,gBAAgB,mBAAO,CAAC,sBAAc;;AAEtC,2BAA2B;;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,yDAAyD,UAAU,EAAE;AACrE;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,gCAAgC;AACnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,yBAAyB;AAC5C;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA,wBAAwB,oBAAoB;AAC5C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT,mCAAmC;AACnC;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,YAAY,0BAA0B;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA,KAAK;AACL,6BAA6B;AAC7B;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,KAAK;AAChB,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA,sCAAsC,kDAAkD,EAAE;AAC1F,uCAAuC,kDAAkD,EAAE;AAC3F,uBAAuB;AACvB,2CAA2C,yDAAyD,EAAE;AACtG,4CAA4C,+DAA+D,EAAE;AAC7G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,UAAU;AACrB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;ACxdA,sBAAsB,mBAAO,CAAC,uBAAe;AAC7C,0BAA0B,mBAAO,CAAC,2BAAoB;AACtD,2BAA2B,mBAAO,CAAC,4BAAqB;AACxD,6BAA6B,mBAAO,CAAC,mCAA2B;AAChE,wBAAwB,mBAAO,CAAC,sBAAe;AAC/C,gCAAgC,mBAAO,CAAC,iCAA0B;AAClE,2BAA2B,mBAAO,CAAC,2BAAoB;AACvD,+BAA+B,mBAAO,CAAC,gCAAwB;AAC/D,uBAAuB,mBAAO,CAAC,sBAAe;AAC9C,wBAAwB,mBAAO,CAAC,yBAAiB;AACjD,8BAA8B,mBAAO,CAAC,+BAAwB;;;;;;;;;;;;;;ACVjD;;AAEb;AACA,iBAAiB,mBAAO,CAAC,uBAAe;AACxC,gBAAgB,mBAAO,CAAC,+BAAwB;AAChD,sBAAsB,mBAAO,CAAC,4BAAoB;AAClD,iBAAiB,mBAAO,CAAC,uBAAe;AACxC,eAAe,mBAAO,CAAC,qBAAa;AACpC,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,gBAAgB,mBAAO,CAAC,sBAAc;AACtC,gBAAgB,mBAAO,CAAC,sBAAc;AACtC,wBAAwB,mBAAO,CAAC,+BAAuB;AACvD,eAAe,mBAAO,CAAC,oBAAa;AACpC,aAAa,mBAAO,CAAC,yBAAkB;AACvC,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,gBAAgB;AAC3B,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,gBAAgB;AAC3B,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,gBAAgB;AAC3B,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,oBAAoB;AAC/B,WAAW,UAAU;AACrB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,oBAAoB;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,2BAA2B;AACtC,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,UAAU;AACrB,WAAW,UAAU;AACrB,WAAW,KAAK;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,kBAAkB,wDAAwD;AAC1E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL,YAAY;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qCAAqC,wBAAwB,EAAE;AAC/D;AACA,8CAA8C,0BAA0B,EAAE;AAC1E;AACA;;AAEA;;;;;;;;;;;;;;ACljBa;;AAEb,WAAW,mBAAO,CAAC,cAAM;;AAEzB,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,iBAAiB,mBAAO,CAAC,uBAAe;AACxC,kBAAkB,mBAAO,CAAC,wBAAgB;;AAE1C,mBAAmB,mBAAO,CAAC,gCAAyB;AACpD,mBAAmB,mBAAO,CAAC,gCAAwB;AACnD,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,eAAe,mBAAO,CAAC,2BAAoB;AAC3C,YAAY,mBAAO,CAAC,uBAAgB;AACpC,aAAa,mBAAO,CAAC,uBAAgB;AACrC,2BAA2B,mBAAO,CAAC,0CAAkC;AACrE,yBAAyB,mBAAO,CAAC,wCAAgC;AACjE,2BAA2B,mBAAO,CAAC,0CAAkC;AACrE,sBAAsB,mBAAO,CAAC,qCAA6B;AAC3D,sBAAsB,mBAAO,CAAC,qCAA6B;;AAE3D;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,gCAAgC,aAAa;AAC7C;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA,+BAA+B,aAAa;AAC5C;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,gCAAgC,aAAa;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,mCAAmC,8BAA8B;AACjE;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC/Xa;;;AAGb,mBAAmB,mBAAO,CAAC,wBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,uBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,mBAAmB,mBAAO,CAAC,wBAAgB;;AAE3C;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,UAAU;AAC7C;AACA;AACA,8BAA8B;AAC9B;AACA,qBAAqB,8BAA8B;AACnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,eAAe;;AAElB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,kBAAkB;AAClB,mBAAmB;AACnB,sBAAsB;AACtB,mBAAmB;;AAEnB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,cAAc;;AAEjC;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,qBAAqB,oBAAoB;;AAEzC;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;;;;;;;;;;;;AC/Ya;;AAEb,cAAc,mBAAO,CAAC,wBAAiB;AACvC,cAAc,mBAAO,CAAC,iBAAS;AAC/B,cAAc,mBAAO,CAAC,mBAAW;AACjC,cAAc,mBAAO,CAAC,iBAAS;AAC/B,cAAc,mBAAO,CAAC,oBAAY;;AAElC;AACA;;;AAGA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,gCAAgC;AAChC;;;AAGA;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;AAC1B,0BAA0B;AAC1B,0BAA0B;;AAE1B,mBAAmB;;AAEnB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,oBAAoB,sBAAsB,qBAAqB,cAAc,EAAE;;;AAG/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,QAAQ;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,YAAY;AAC/B,kBAAkB,UAAU;;AAE5B;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC;AACxC,wBAAwB;AACxB,YAAY;AACZ,UAAU;AACV,+BAA+B;AAC/B,gCAAgC;AAChC;AACA;;AAEA,sBAAsB;;AAEtB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,0BAA0B;;AAE3D;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,wDAAwD;AACxD;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,sDAAsD;AACtD;AACA;AACA;AACA;AACA;AACA,kEAAkE;AAClE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,aAAa;;AAEb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mEAAmE;;AAEnE;AACA,yDAAyD;AACzD;;AAEA;;AAEA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,2DAA2D;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,0DAA0D;AAC1D;;AAEA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,aAAa;;AAEb;;AAEA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,OAAO,EAAE;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,wDAAwD;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,4DAA4D;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0DAA0D;AAC1D;;AAEA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,WAAW;AACX,mBAAmB;;AAEnB;;AAEA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,OAAO,EAAE;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,oEAAoE;AACpE;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,0DAA0D;AAC1D;;AAEA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa;;AAEb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA,wDAAwD;AACxD;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA,qBAAqB;AACrB,eAAe;;AAEf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA,mBAAmB;AACnB,kBAAkB;AAClB,0BAA0B;AAC1B,4BAA4B;AAC5B,uBAAuB;AACvB,mBAAmB;AACnB,gBAAgB;AAChB,qBAAqB;AACrB,mBAAmB;AACnB,2BAA2B;AAC3B,uBAAuB;;AAEvB,kBAAkB;AAClB,kBAAkB;AAClB,kBAAkB;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB;;AAEnB,iBAAiB;AACjB,qBAAqB;AACrB,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,wBAAwB;AACxB,sBAAsB;AACtB,2BAA2B;AAC3B,oBAAoB;AACpB,uBAAuB;AACvB,qBAAqB;;AAErB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB;AACjB,oBAAoB;;AAEpB;AACA;;AAEA,sBAAsB;;AAEtB;;AAEA;;AAEA,2CAA2C;AAC3C,6CAA6C;AAC7C,4CAA4C;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;;AAEvB;AACA;AACA;;AAEA,0BAA0B;AAC1B,+CAA+C;AAC/C;;AAEA,oBAAoB;AACpB,oBAAoB;AACpB;AACA;AACA;;AAEA,gDAAgD;AAChD;AACA;AACA;;AAEA,iBAAiB;;AAEjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB;;AAEpB;AACA;AACA;AACA;AACA;;AAEA,mBAAmB;AACnB,sBAAsB;AACtB,mBAAmB;AACnB,kBAAkB;;;AAGlB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA,6BAA6B,uBAAuB;AACpD,8BAA8B,uBAAuB;AACrD;AACA;AACA;;;AAGA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;;AAEA,uBAAuB;AACvB;AACA;AACA;;AAEA;AACA,aAAa;AACb;AACA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,qBAAqB;;AAErB,sCAAsC;;AAEtC;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,gBAAgB;AAChB;AACA;;AAEA;AACA;;AAEA,uBAAuB;AACvB,qBAAqB;AACrB;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;AACA,6BAA6B,uBAAuB;AACpD;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;;AAEA;AACA;AACA;AACA,sBAAsB;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;;AAEnC;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B,uBAAuB;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA,8BAA8B;;AAE9B,2BAA2B,aAAa;AACxC,oBAAoB,qBAAqB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,oDAAoD;AACpD;AACA;;AAEA,aAAa;;AAEb;AACA;AACA,qBAAqB;AACrB,yBAAyB;AACzB,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE;AAChE;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;AC9zDa;;;AAGb,YAAY,mBAAO,CAAC,wBAAiB;;AAErC;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,8BAA8B;AAC9B;;AAEA;;;AAGA,oBAAoB,sBAAsB,qBAAqB,cAAc,EAAE;;AAE/E;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,wBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;;AAEA,kCAAkC;AAClC,iCAAiC;AACjC,iCAAiC;AACjC,4BAA4B;AAC5B,iCAAiC;;AAEjC;AACA;AACA;;;AAGA;AACA;AACA;;;AAGA;AACA,2BAA2B;AAC3B,oBAAoB;AACpB,6BAA6B;AAC7B;;;;AAIA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;;AAGA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR,WAAW;AACX,WAAW;AACX,YAAY;AACZ,QAAQ;AACR,mBAAmB;;AAEnB,gBAAgB,kBAAkB;AAClC;AACA;;AAEA;AACA;AACA;AACA,+CAA+C;;AAE/C,0BAA0B,eAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,uBAAuB,UAAU,EAAE;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,QAAQ;;AAE/B;AACA;;AAEA;AACA;AACA;AACA,oCAAoC,QAAQ;AAC5C,uBAAuB;AACvB,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,yBAAyB,YAAY;AACrC;AACA;AACA;AACA,yBAAyB,UAAU;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,mBAAmB;AACnB,qBAAqB;AACrB;AACA,0CAA0C;AAC1C,eAAe;AACf,WAAW;AACX,QAAQ;;AAER;AACA;AACA;AACA,gBAAgB,kBAAkB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,aAAa,gBAAgB;AAC7B;AACA,oBAAoB,UAAU;AAC9B;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA,QAAQ;AACR,WAAW;AACX,aAAa;AACb,WAAW;AACX,WAAW;AACX;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB,yBAAyB;AACzC;AACA,eAAe,8BAA8B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB,WAAW;AAC3B;AACA,eAAe,8BAA8B;AAC7C;AACA;AACA;AACA;AACA,aAAa;AACb,QAAQ,gBAAgB;AACxB;AACA,eAAe,oCAAoC;AACnD;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,kBAAkB;AAClC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,aAAa;AAC1B;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA,QAAQ;;AAER;AACA,aAAa,aAAa,QAAQ,iCAAiC;AACnE,aAAa,aAAa,QAAQ,iCAAiC;AACnE,aAAa,cAAc,OAAO,+BAA+B;;AAEjE;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,eAAe;AACf,kBAAkB;AAClB;AACA,eAAe;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,YAAY;AACZ;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,OAAO;;AAEtD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B,2BAA2B;AAC3B;AACA,WAAW;AACX,SAAS;AACT,aAAa;AACb,WAAW;AACX,YAAY;;AAEZ;AACA;AACA;AACA;AACA;;AAEA;AACA,gCAAgC;AAChC;AACA,OAAO;AACP;AACA;AACA,iDAAiD;AACjD;AACA;AACA;AACA,kCAAkC;AAClC;AACA,eAAe;AACf;AACA;;AAEA,kCAAkC;AAClC;AACA;AACA;AACA,oCAAoC;AACpC;AACA,OAAO;;AAEP;AACA;AACA;;AAEA,KAAK;AACL;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA,6DAA6D;AAC7D;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,oBAAoB;AACpB,WAAW;;AAEX;AACA;AACA;AACA;AACA;AACA;;AAEA,aAAa,WAAW;AACxB;AACA;AACA;;AAEA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uCAAuC,QAAQ,OAAO,wBAAwB;;AAE9E;AACA;AACA;AACA,eAAe;AACf;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;;AAEA,8BAA8B;;AAE9B,6BAA6B;AAC7B;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,GAAG;;AAEH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,mBAAmB;AACnB;AACA,QAAQ;AACR,mBAAmB;AACnB,aAAa;;AAEb,wCAAwC;;AAExC,gBAAgB;AAChB,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;AACA;AACA,gDAAgD;;AAEhD,aAAa,eAAe;AAC5B;AACA;;AAEA;AACA;;AAEA,KAAK;AACL;;AAEA,KAAK;;AAEL,+BAA+B,kCAAkC;AACjE;;AAEA,KAAK;AACL;;AAEA,KAAK;AACL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,KAAK;AACL;AACA;;AAEA,KAAK;AACL;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,mBAAmB;AACnB;AACA,QAAQ;AACR,mBAAmB;AACnB,aAAa;;AAEb,wCAAwC;;AAExC,gBAAgB;AAChB,oBAAoB;AACpB,oBAAoB;;AAEpB,+BAA+B;AAC/B;AACA;AACA;AACA;;AAEA,aAAa,eAAe;AAC5B;AACA;;AAEA;AACA;;AAEA,KAAK;AACL,UAAU,iCAAiC,EAAE;;AAE7C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;AACL;AACA;;AAEA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,KAAK;AACL;AACA;;AAEA,KAAK;AACL;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA,kBAAkB;;AAElB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kCAAkC,kBAAkB;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA,WAAW;;AAEX;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA,gCAAgC;AAChC,gBAAgB,gBAAgB;AAChC;AACA;AACA;AACA;;AAEA,wCAAwC;AACxC;;AAEA,wCAAwC;AACxC;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,IAAI,MAAM,GAAG,MAAM,GAAG;AAChD;AACA;AACA;AACA,SAAS,IAAI,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IAAI,MAAM,IAAI;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc,cAAc;AAC5B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,iBAAiB;AACjB,WAAW;AACX;AACA,wDAAwD;AACxD,uCAAuC;AACvC;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,iBAAiB;AACjB,WAAW;AACX;AACA,4BAA4B;AAC5B,sBAAsB;;AAEtB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,kCAAkC,wBAAwB;;AAE1D,GAAG;AACH;AACA,4CAA4C;AAC5C;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;;AAEH;AACA;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB,kBAAkB;AAClB;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,WAAW;AACX;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjrCa;;;AAGb,mBAAmB,mBAAO,CAAC,wBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,uBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,mBAAmB,mBAAO,CAAC,0BAAkB;AAC7C,mBAAmB,mBAAO,CAAC,yBAAiB;AAC5C,mBAAmB,mBAAO,CAAC,wBAAgB;AAC3C,mBAAmB,mBAAO,CAAC,yBAAiB;;AAE5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,UAAU;AAC7C;AACA;AACA,8BAA8B;AAC9B;AACA,qBAAqB,8BAA8B;AACnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG,eAAe;;AAElB;;AAEA;AACA;AACA;AACA;AACA,+BAA+B,sBAAsB;AACrD;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB,mBAAmB;AACnB,sBAAsB;AACtB,mBAAmB;;AAEnB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,mBAAmB,cAAc;AACjC;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,sDAAsD;;AAEtD;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB,kEAAkE;;AAEvF;;AAEA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,qBAAqB,oBAAoB;;AAEzC;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjaa;;;AAGb,oBAAoB,mBAAO,CAAC,wBAAiB;AAC7C,oBAAoB,mBAAO,CAAC,mBAAW;AACvC,oBAAoB,mBAAO,CAAC,iBAAS;AACrC,oBAAoB,mBAAO,CAAC,mBAAW;AACvC,oBAAoB,mBAAO,CAAC,oBAAY;;AAExC;AACA;AACA;;AAEA;AACA;;;AAGA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;;;AAGA,gBAAgB;AAChB,iBAAiB;AACjB,gBAAgB;AAChB,cAAc;AACd,iBAAiB;AACjB,iBAAiB;AACjB,gBAAgB;AAChB,mBAAmB;AACnB,gBAAgB;AAChB,mBAAmB;AACnB,iBAAiB;AACjB,qBAAqB;AACrB,uBAAuB;AACvB,uBAAuB;AACvB,sBAAsB;AACtB,qBAAqB;AACrB,sBAAsB;AACtB,wBAAwB;AACxB,yBAAyB;AACzB,yBAAyB;AACzB,wBAAwB;AACxB,2BAA2B;AAC3B,yBAAyB;AACzB,4BAA4B;AAC5B,0BAA0B;AAC1B,wBAAwB;AACxB,kBAAkB;AAClB,mBAAmB;AACnB,iBAAiB;AACjB,gBAAgB;AAChB,gBAAgB;AAChB,iBAAiB;;AAEjB;;;;AAIA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA,gBAAgB;AAChB,oBAAoB;AACpB,gBAAgB;AAChB,wBAAwB;AACxB,iBAAiB;AACjB,gBAAgB;AAChB,iBAAiB;AACjB,iBAAiB;AACjB;AACA,mBAAmB;;AAEnB;AACA,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,qBAAqB;;AAErB;AACA,gBAAgB;AAChB,gBAAgB;;AAEhB;AACA,kBAAkB;AAClB,kBAAkB;;AAElB;AACA,iBAAiB;;AAEjB;AACA,sBAAsB;AACtB,uBAAuB;AACvB,mBAAmB;AACnB,oBAAoB;;AAEpB;AACA,iBAAiB;AACjB,gBAAgB;AAChB,iBAAiB;AACjB,gBAAgB;AAChB,mBAAmB;;AAEnB,mCAAmC;AACnC,mCAAmC;;AAEnC;AACA;AACA;AACA;AACA,yCAAyC;AACzC,qBAAqB;AACrB,sBAAsB;AACtB,gBAAgB;AAChB,gBAAgB;AAChB,eAAe;AACf;;AAEA;AACA;;AAEA,6BAA6B,uBAAuB;AACpD;AACA;AACA,gBAAgB;AAChB,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,6BAA6B,uBAAuB;AACpD;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,6BAA6B,uBAAuB;AACpD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,cAAc,uBAAuB;AACrC,sBAAsB;;AAEtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB;;AAEpB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,uBAAuB,uBAAuB;AAC9C,uBAAuB,uBAAuB;AAC9C,uBAAuB,uBAAuB;AAC9C,uBAAuB,uBAAuB;;AAE9C,uEAAuE,UAAU;;AAEjF;AACA;AACA,sBAAsB,uBAAuB;;AAE7C,uEAAuE,UAAU;;AAEjF;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,iBAAiB;AACzD,sCAAsC,qBAAqB;AAC3D;AACA;AACA;AACA;;AAEA;AACA;AACA,oBAAoB;AACpB,WAAW;AACX,UAAU;AACV,iBAAiB;AACjB,WAAW;AACX,WAAW;AACX,gBAAgB;AAChB,WAAW;AACX,WAAW;AACX;AACA,eAAe;AACf,mCAAmC;AACnC,aAAa;AACb,mCAAmC;AACnC,UAAU;AACV,UAAU;AACV,+BAA+B;AAC/B;;AAEA,QAAQ;;AAER;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA,4BAA4B,qBAAqB,EAAE;;;AAGnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,aAAa;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,iBAAiB;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,iBAAiB;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,aAAa;AACvC,0BAA0B,aAAa;AACvC,yBAAyB,iBAAiB;AAC1C,uCAAuC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA,wDAAwD;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf,kEAAkE;AAClE;AACA;AACA;;AAEA,oCAAoC,OAAO;AAC3C;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,+BAA+B,OAAO;;AAEtC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,iBAAiB;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,gEAAgE;AAChE;AACA;AACA;;AAEA,gCAAgC,OAAO;AACvC;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA,gDAAgD,OAAO;AACvD;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,kEAAkE;AAClE;AACA;AACA;;AAEA,kCAAkC,OAAO;AACzC;AACA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA,gDAAgD,OAAO;AACvD;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,qBAAqB;AAC3D,8BAA8B,aAAa;AAC3C;AACA;AACA;AACA;AACA,aAAa;AACb,qCAAqC,kBAAkB;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,qBAAqB;AACvD;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA,wBAAwB,aAAa;AACrC;AACA;AACA;AACA;AACA,OAAO;AACP,+BAA+B,kBAAkB;AACjD;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iFAAiF;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,6BAA6B,uBAAuB;AACpD;AACA,+BAA+B,uBAAuB;;AAEtD;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,6DAA6D,uBAAuB;AACpF;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf,wDAAwD;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjgDa;;AAEb;AACA,aAAa;AACb,cAAc;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,WAAW;AACX,WAAW;AACX,UAAU;AACV,UAAU;AACV;AACA,WAAW;AACX;AACA,YAAY;AACZ,YAAY;AACZ,YAAY;AACZ;AACA,eAAe;AACf,WAAW;AACX,WAAW;AACX,YAAY;AACZ,YAAY;AACZ,YAAY;AACZ,YAAY;AACZ,WAAW;AACX,SAAS;AACT;AACA,UAAU;AACV,WAAW;AACX,WAAW;AACX;;;AAGA,oBAAoB;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,WAAW,GAAG;AACd;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,GAAG;AAClB;AACA;AACA;AACA;;AAEA,wBAAwB;AACxB;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B,4BAA4B;AAC5B,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA,gCAAgC;AAChC;AACA,+BAA+B;AAC/B;AACA;AACA;AACA,mBAAmB;AACnB,qCAAqC;AACrC;AACA;AACA;AACA,oCAAoC;AACpC;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA,mBAAmB;AACnB;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA,qBAAqB;AACrB,uCAAuC;AACvC;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA,+BAA+B;AAC/B;AACA;AACA;AACA,mBAAmB;AACnB,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC,kBAAkB;AAClB;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,gBAAgB;AAChB;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,YAAY;AACZ;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACrUa;;;AAGb,YAAY,mBAAO,CAAC,wBAAiB;;AAErC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,yBAAyB;;AAEzB,cAAc;AACd,cAAc;AACd,uBAAuB;AACvB,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,WAAW;AACX,WAAW;AACX,UAAU;AACV,WAAW;AACX,WAAW;AACX,kBAAkB;AAClB;AACA,iBAAiB;AACjB,UAAU;AACV,2CAA2C,eAAe;AAC1D,0CAA0C,eAAe;AACzD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA,eAAe,aAAa;AAC5B;AACA;;AAEA;AACA;AACA,qBAAqB,UAAU;AAC/B,2BAA2B,OAAO;AAClC;AACA;AACA;AACA;AACA,kBAAkB;AAClB,sCAAsC,2BAA2B;AACjE,uCAAuC;AACvC,wCAAwC;AACxC;;;AAGA;AACA;AACA;AACA;;AAEA;AACA,aAAa;AACb;AACA,eAAe,WAAW;AAC1B,2BAA2B,OAAO;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,cAAc;AACd;;AAEA;AACA;AACA,eAAe,eAAe;AAC9B;AACA;;AAEA;AACA,eAAe,aAAa;AAC5B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA,GAAG,OAAO;AACV;AACA;AACA;AACA;;AAEA;AACA,WAAW;AACX,UAAU;AACV,YAAY;AACZ,qBAAqB;AACrB,cAAc;AACd,WAAW;AACX,WAAW;AACX,mBAAmB;AACnB,kBAAkB;;AAElB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;;AAEA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,wBAAwB,OAAO;AAC/B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kBAAkB;;AAElB;AACA;AACA;AACA;AACA;AACA,wBAAwB,OAAO;AAC/B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACtUa;;;AAGb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;ACvCA;AACA;;AAEA,eAAe,mBAAO,CAAC,2BAAmB;;AAE1C;AACA;AACA;AACA;;;;;;;;;;;;;ACRA;AACA;;AAEA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA,aAAa,WAAW;AACxB,aAAa,EAAE;AACf,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA,aAAa,EAAE;AACf,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,cAAc,gBAAgB;AAC9B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,aAAa,gBAAgB;AAC7B,cAAc,OAAO;AACrB;AACA;AACA;AACA,mBAAmB,wBAAwB;AAC3C;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,6BAA6B;AAC1C;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;;AAEN;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA;AACA;AACA;AACA,+BAA+B,gBAAgB;AAC/C;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA;AACA;AACA;AACA,+BAA+B,gBAAgB;AAC/C;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,cAAc,OAAO;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,0BAA0B;AAC1C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,yBAAyB;AACzC;AACA;AACA;;AAEA;;AAEA,0CAA0C;AAC1C;;AAEA;AACA,aAAa,OAAO;AACpB,cAAc,EAAE;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY;AACZ;AACA,iCAAiC,kCAAkC;AACnE,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,gBAAgB,kCAAkC,EAAE;AACjE;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL,GAAG;;AAEH;AACA,aAAa,0BAA0B,cAAc,YAAY;AACjE;AACA,aAAa,0BAA0B,cAAc,YAAY;AACjE;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,wBAAwB,SAAS;AACjC;AACA,wBAAwB,QAAQ;AAChC;AACA,wBAAwB,QAAQ;AAChC;AACA,wBAAwB,OAAO;AAC/B;AACA,wBAAwB,QAAQ;AAChC;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,uBAAuB,0CAA0C;AACjE,KAAK;;AAEL;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,uBAAuB,qCAAqC;AAC5D,KAAK;;AAEL;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,uBAAuB,wBAAwB;AAC/C,KAAK;AACL;;AAEA;AACA,aAAa,cAAc;AAC3B,aAAa,QAAQ;AACrB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,4CAA4C;AAC5C;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,eAAe,0BAA0B;AACzC;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,8CAA8C,gBAAgB;AAC9D;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,gBAAgB;AAC9D;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,gBAAgB;AAChB,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,wBAAwB,SAAS;AACjC;;AAEA;AACA,wBAAwB,QAAQ;AAChC;AACA,wBAAwB,OAAO;AAC/B;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,uBAAuB,0CAA0C;AACjE,KAAK;AACL;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,cAAc,YAAY;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;;AAEA;AACA;;AAEA;AACA;;AAEA,eAAe,0BAA0B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,gBAAgB;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,gBAAgB;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB,cAAc,gBAAgB;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,OAAO;AAC1B,mBAAmB,OAAO;AAC1B,mBAAmB,OAAO;AAC1B,mBAAmB,OAAO;;AAE1B;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,0BAA0B;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB,cAAc,gBAAgB;AAC9B;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,yBAAyB;AACzC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,eAAe,gBAAgB;AAC/B;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,MAAM,KAA6B;AACnC;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;;;;;ACp6BD,iD;;;;;;;;;;;;;ACAa;;AAEb,eAAe,mBAAO,CAAC,2BAAoB;;AAE3C;AACA;AACA,WAAW,KAAK;AAChB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;ACzBA,iD;;;;;;;;;;;;;ACAa;;AAEb;AACA,mBAAmB,mBAAO,CAAC,kCAA0B;AACrD,gBAAgB,mBAAO,CAAC,+BAAwB;AAChD,aAAa,mBAAO,CAAC,yBAAkB;AACvC,gBAAgB,mBAAO,CAAC,8BAAuB;AAC/C,mBAAmB,mBAAO,CAAC,wBAAiB;;AAE5C;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA,+BAA+B,oBAAoB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,+BAA+B,oBAAoB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;;;;;;;;;;;;;;AC1Ga;;AAEb;AACA,YAAY,mBAAO,CAAC,uBAAgB;AACpC,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,mBAAmB,mBAAO,CAAC,gCAAwB;AACnD,mBAAmB,mBAAO,CAAC,wBAAiB;;AAE5C;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,MAAM;AACjB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA,+BAA+B,oBAAoB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,mCAAmC,oBAAoB;AACvD;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;;;;;;;;;;;;;AC3Ia;;AAEb,cAAc,mBAAO,CAAC,mBAAW;AACjC,eAAe,mBAAO,CAAC,oBAAY;AACnC,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,mBAAmB,mBAAO,CAAC,wBAAiB;AAC5C,gBAAgB,mBAAO,CAAC,8BAAuB;;AAE/C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,YAAY;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,uBAAuB;AAClC,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACtDa;;AAEb,aAAa,mBAAO,CAAC,uBAAgB;AACrC,gBAAgB,mBAAO,CAAC,4BAAqB;AAC7C,oBAAoB,mBAAO,CAAC,iCAAyB;AACrD,YAAY,mBAAO,CAAC,uBAAgB;AACpC,mBAAmB,mBAAO,CAAC,gCAAyB;AACpD,gBAAgB,mBAAO,CAAC,6BAAsB;AAC9C,sBAAsB,mBAAO,CAAC,6BAAqB;;AAEnD;AACA,KAAK,gEAAgE;AACrE,KAAK,wEAAwE;AAC7E,KAAK,mEAAmE;AACxE,KAAK,uEAAuE;AAC5E,KAAK,oEAAoE;AACzE,KAAK,qEAAqE;AAC1E,KAAK,qEAAqE;AAC1E,KAAK;AACL;;AAEA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,cAAc;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;;;;;;;;;;;;;;ACpGa;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,oBAAa;AACpC,qBAAqB,mBAAO,CAAC,4BAAoB;AACjD,eAAe,mBAAO,CAAC,6BAAsB;AAC7C,aAAa,mBAAO,CAAC,yBAAkB;;AAEvC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA,yBAAyB,oBAAoB,EAAE;AAC/C;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,0DAA0D,SAAS;AACnE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,YAAY,0BAA0B;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL,+DAA+D,+CAA+C;AAC9G,8DAA8D,6CAA6C;AAC3G,4DAA4D,yCAAyC;AACrG,8DAA8D,6CAA6C;AAC3G,gEAAgE,iDAAiD;AACjH,qDAAqD,2BAA2B;AAChF;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AC3aa;;AAEb,qBAAqB,mBAAO,CAAC,oCAA6B;AAC1D,mBAAmB,mBAAO,CAAC,kCAA2B;AACtD,gBAAgB,mBAAO,CAAC,8BAAuB;;AAE/C;AACA;AACA,mBAAmB,UAAU,EAAE;AAC/B,oBAAoB;AACpB,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C,+CAA+C;AAC7F;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,KAAK;AACL;;AAEA;;;;;;;;;;;;;;ACpDa;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;AAC7C,aAAa,mBAAO,CAAC,uBAAgB;AACrC,qBAAqB,mBAAO,CAAC,4BAAoB;AACjD,gBAAgB,mBAAO,CAAC,sBAAc;AACtC,eAAe,mBAAO,CAAC,oBAAa;AACpC,gBAAgB,mBAAO,CAAC,sBAAc;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,oBAAoB,EAAE;AAC3D,sCAAsC,oBAAoB,EAAE;AAC5D;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,SAAS;AACpB;AACA;AACA;AACA,0CAA0C,+BAA+B,EAAE;AAC3E,yCAAyC,kCAAkC,EAAE;AAC7E;;AAEA;AACA;AACA,YAAY,0BAA0B;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,wBAAwB,EAAE;AACnE,0CAA0C,wBAAwB,EAAE;AACpE;;AAEA;AACA;AACA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,SAAS;AACpB,YAAY,0BAA0B;AACtC,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA,gCAAgC;AAChC,SAAS;AACT,gCAAgC;AAChC;AACA,KAAK;AACL;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA,oCAAoC;AACpC;AACA,SAAS;AACT,uDAAuD;AACvD;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,SAAS;AACpB,WAAW,IAAI;AACf,aAAa,IAAI;AACjB;AACA;AACA;AACA;AACA,uBAAuB,qBAAqB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB,SAAS;AACT,uBAAuB;AACvB;AACA;AACA,uBAAuB;AACvB,SAAS;AACT,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,UAAU;AACrB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB,WAAW,UAAU;AACrB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;ACzQa;;AAEb,eAAe,mBAAO,CAAC,4BAAqB;AAC5C,eAAe,mBAAO,CAAC,6BAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,YAAY;AACZ;AACA;AACA;AACA,6DAA6D,SAAS;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA","file":"kdbxweb.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"crypto\"), require(\"xmldom\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"crypto\", \"xmldom\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"kdbxweb\"] = factory(require(\"crypto\"), require(\"xmldom\"));\n\telse\n\t\troot[\"kdbxweb\"] = factory(root[\"crypto\"], root[\"xmldom\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE__42__, __WEBPACK_EXTERNAL_MODULE__44__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 29);\n","'use strict';\n\nvar TextEncoder = global.TextEncoder;\nvar TextDecoder = global.TextDecoder;\n\nif (!TextEncoder || !TextDecoder) {\n var textEncoding = require('text-encoding');\n TextEncoder = textEncoding.TextEncoder;\n TextDecoder = textEncoding.TextDecoder;\n}\n\nvar textEncoder = new TextEncoder();\nvar textDecoder = new TextDecoder();\n\n/**\n * Checks if two ArrayBuffers are equal\n * @param {ArrayBuffer} ab1\n * @param {ArrayBuffer} ab2\n * @returns {boolean}\n */\nfunction arrayBufferEquals(ab1, ab2) {\n if (ab1.byteLength !== ab2.byteLength) {\n return false;\n }\n var arr1 = new Uint8Array(ab1);\n var arr2 = new Uint8Array(ab2);\n for (var i = 0, len = arr1.length; i < len; i++) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Converts Array or ArrayBuffer to string\n * @param {Array|Uint8Array|ArrayBuffer} arr\n * @return {string}\n */\nfunction bytesToString(arr) {\n if (arr instanceof ArrayBuffer) {\n arr = new Uint8Array(arr);\n }\n return textDecoder.decode(arr);\n}\n\n/**\n * Converts string to byte array\n * @param {string} str\n * @return {Uint8Array}\n */\nfunction stringToBytes(str) {\n return textEncoder.encode(str);\n}\n\n/**\n * Converts base64 string to array\n * @param {string} str\n * @return {Uint8Array}\n */\nfunction base64ToBytes(str) {\n if (typeof atob === 'undefined' && typeof Buffer === 'function') {\n // node.js doesn't have atob\n var buffer = Buffer.from(str, 'base64');\n return new Uint8Array(buffer);\n }\n var byteStr = atob(str);\n var arr = new Uint8Array(byteStr.length);\n for (var i = 0; i < byteStr.length; i++) {\n arr[i] = byteStr.charCodeAt(i);\n }\n return arr;\n}\n\n/**\n * Converts Array or ArrayBuffer to base64-string\n * @param {Array|Uint8Array|ArrayBuffer} arr\n * @return {string}\n */\nfunction bytesToBase64(arr) {\n if (arr instanceof ArrayBuffer) {\n arr = new Uint8Array(arr);\n }\n if (typeof btoa === 'undefined' && typeof Buffer === 'function') {\n // node.js doesn't have btoa\n var buffer = Buffer.from(arr);\n return buffer.toString('base64');\n }\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n return btoa(str);\n}\n\n/**\n * Convert hex-string to byte array\n * @param {string} hex\n * @return Uint8Array\n */\nfunction hexToBytes(hex) {\n var arr = new Uint8Array(Math.ceil(hex.length / 2));\n for (var i = 0; i < arr.length; i++) {\n arr[i] = parseInt(hex.substr(i * 2, 2), 16);\n }\n return arr;\n}\n\n/**\n * Convert hex-string to byte array\n * @param {Array|Uint8Array|ArrayBuffer} arr\n * @return {string}\n */\nfunction bytesToHex(arr) {\n if (arr instanceof ArrayBuffer) {\n arr = new Uint8Array(arr);\n }\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var byte = arr[i].toString(16);\n if (byte.length === 1) {\n str += '0';\n }\n str += byte;\n }\n return str;\n}\n\n/**\n * Converts byte array to array buffer\n * @param {Uint8Array|ArrayBuffer} arr\n * @returns {ArrayBuffer}\n */\nfunction arrayToBuffer(arr) {\n if (arr instanceof ArrayBuffer) {\n return arr;\n }\n var ab = arr.buffer;\n if (arr.byteOffset === 0 && arr.byteLength === ab.byteLength) {\n return ab;\n }\n return arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength);\n}\n\n/**\n * Fills array or arraybuffer with zeroes\n * @param {Uint8Array|ArrayBuffer} buffer\n */\nfunction zeroBuffer(buffer) {\n if (buffer instanceof ArrayBuffer) {\n buffer = new Uint8Array(buffer);\n }\n buffer.fill(0);\n}\n\nmodule.exports.arrayBufferEquals = arrayBufferEquals;\nmodule.exports.bytesToString = bytesToString;\nmodule.exports.stringToBytes = stringToBytes;\nmodule.exports.base64ToBytes = base64ToBytes;\nmodule.exports.bytesToBase64 = bytesToBase64;\nmodule.exports.hexToBytes = hexToBytes;\nmodule.exports.bytesToHex = bytesToHex;\nmodule.exports.arrayToBuffer = arrayToBuffer;\nmodule.exports.zeroBuffer = zeroBuffer;\n","'use strict';\n\nmodule.exports.Signatures = {\n FileMagic: 0x9AA2D903,\n Sig2Kdbx: 0xB54BFB67,\n Sig2Kdb: 0xB54BFB65\n};\n\nmodule.exports.ErrorCodes = {\n NotImplemented: 'NotImplemented',\n InvalidArg: 'InvalidArg',\n BadSignature: 'BadSignature',\n InvalidVersion: 'InvalidVersion',\n Unsupported: 'Unsupported',\n FileCorrupt: 'FileCorrupt',\n InvalidKey: 'InvalidKey',\n MergeError: 'MergeError'\n};\n\nmodule.exports.CompressionAlgorithm = {\n None: 0,\n GZip: 1\n};\n\nmodule.exports.CrsAlgorithm = {\n Null: 0,\n ArcFourVariant: 1,\n Salsa20: 2,\n ChaCha20: 3\n};\n\nmodule.exports.KdfId = {\n Argon2: '72Nt34wpREuR96mkA+MKDA==',\n Aes: 'ydnzmmKKRGC/dA0IwYpP6g=='\n};\n\nmodule.exports.CipherId = {\n Aes: 'McHy5r9xQ1C+WAUhavxa/w==',\n ChaCha20: '1gOKK4tvTLWlJDOaMdu1mg=='\n};\n\nmodule.exports.AutoTypeObfuscationOptions = {\n None: 0,\n UseClipboard: 1\n};\n\nmodule.exports.Defaults = {\n KeyEncryptionRounds: 300000,\n MntncHistoryDays: 365,\n HistoryMaxItems: 10,\n HistoryMaxSize: 6 * 1024 * 1024,\n RecycleBinName: 'Recycle Bin'\n};\n\nmodule.exports.Icons = {\n Key: 0,\n World: 1,\n Warning: 2,\n NetworkServer: 3,\n MarkedDirectory: 4,\n UserCommunication: 5,\n Parts: 6,\n Notepad: 7,\n WorldSocket: 8,\n Identity: 9,\n PaperReady: 10,\n Digicam: 11,\n IRCommunication: 12,\n MultiKeys: 13,\n Energy: 14,\n Scanner: 15,\n WorldStar: 16,\n CDRom: 17,\n Monitor: 18,\n EMail: 19,\n Configuration: 20,\n ClipboardReady: 21,\n PaperNew: 22,\n Screen: 23,\n EnergyCareful: 24,\n EMailBox: 25,\n Disk: 26,\n Drive: 27,\n PaperQ: 28,\n TerminalEncrypted: 29,\n Console: 30,\n Printer: 31,\n ProgramIcons: 32,\n Run: 33,\n Settings: 34,\n WorldComputer: 35,\n Archive: 36,\n Homebanking: 37,\n DriveWindows: 39,\n Clock: 39,\n EMailSearch: 40,\n PaperFlag: 41,\n Memory: 42,\n TrashBin: 43,\n Note: 44,\n Expired: 45,\n Info: 46,\n Package: 47,\n Folder: 48,\n FolderOpen: 49,\n FolderPackage: 50,\n LockOpen: 51,\n PaperLocked: 52,\n Checked: 53,\n Pen: 54,\n Thumbnail: 55,\n Book: 56,\n List: 57,\n UserKey: 58,\n Tool: 59,\n Home: 60,\n Star: 61,\n Tux: 62,\n Feather: 63,\n Apple: 64,\n Wiki: 65,\n Money: 66,\n Certificate: 67,\n BlackBerry: 68\n};\n","'use strict';\n\nfunction KdbxError(code, message) {\n this.name = 'KdbxError';\n this.code = code;\n this.message = 'Error ' + code + (message ? ': ' + message : '');\n}\n\nKdbxError.prototype = Error.prototype;\n\nmodule.exports = KdbxError;\n","'use strict';\n\nvar ByteUtils = require('../utils/byte-utils'),\n KdbxError = require('../errors/kdbx-error'),\n Consts = require('../defs/consts'),\n ChaCha20 = require('./chacha20');\n\nvar webCrypto = global.crypto;\nvar subtle = webCrypto ? webCrypto.subtle || webCrypto.webkitSubtle : null;\nvar nodeCrypto = global.process && global.process.versions && global.process.versions.node ? require('crypto') : null;\n\nvar EmptySha256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';\nvar EmptySha512 = 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce' +\n '47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e';\n// maxRandomQuota is the max number of random bytes you can asks for from the cryptoEngine\n// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\nvar maxRandomQuota = 65536;\n\n\n/**\n * SHA-256 hash\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction sha256(data) {\n if (!data.byteLength) {\n return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256)));\n }\n if (subtle) {\n return subtle.digest({ name: 'SHA-256' }, data);\n } else if (nodeCrypto) {\n return new Promise(function(resolve) {\n var sha = nodeCrypto.createHash('sha256');\n var hash = sha.update(Buffer.from(data)).digest();\n resolve(hash.buffer);\n });\n } else {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA256 not implemented'));\n }\n}\n\n/**\n * SHA-512 hash\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction sha512(data) {\n if (!data.byteLength) {\n return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha512)));\n }\n if (subtle) {\n return subtle.digest({ name: 'SHA-512' }, data);\n } else if (nodeCrypto) {\n return new Promise(function(resolve) {\n var sha = nodeCrypto.createHash('sha512');\n var hash = sha.update(Buffer.from(data)).digest();\n resolve(hash.buffer);\n });\n } else {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA512 not implemented'));\n }\n}\n\n/**\n * HMAC-SHA-256 hash\n * @param {ArrayBuffer} key\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction hmacSha256(key, data) {\n if (subtle) {\n var algo = { name: 'HMAC', hash: { name: 'SHA-256' } };\n return subtle.importKey('raw', key, algo, false, ['sign'])\n .then(function(subtleKey) {\n return subtle.sign(algo, subtleKey, data);\n });\n } else if (nodeCrypto) {\n return new Promise(function(resolve) {\n var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key));\n var hash = hmac.update(Buffer.from(data)).digest();\n resolve(hash.buffer);\n });\n } else {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'HMAC-SHA256 not implemented'));\n }\n}\n\n/**\n * AES-CBC using WebCrypto\n * @constructor\n */\nfunction AesCbcSubtle() {\n}\n\nAesCbcSubtle.prototype.importKey = function(key) {\n var that = this;\n return subtle.importKey('raw', key, {name: 'AES-CBC'}, false, ['encrypt', 'decrypt'])\n .then(function(key) { that.key = key; });\n};\n\nAesCbcSubtle.prototype.encrypt = function(data, iv) {\n return subtle.encrypt({name: 'AES-CBC', iv: iv}, this.key, data);\n};\n\nAesCbcSubtle.prototype.decrypt = function(data, iv) {\n return subtle.decrypt({name: 'AES-CBC', iv: iv}, this.key, data)\n .catch(function() { throw new KdbxError(Consts.ErrorCodes.InvalidKey, 'invalid key'); });\n};\n\n/**\n * AES-CBC using node crypto\n * @constructor\n */\nfunction AesCbcNode() {\n}\n\nAesCbcNode.prototype.importKey = function(key) {\n this.key = key;\n return Promise.resolve();\n};\n\nAesCbcNode.prototype.encrypt = function(data, iv) {\n var that = this;\n return Promise.resolve().then(function() {\n var cipher = nodeCrypto.createCipheriv('aes-256-cbc', Buffer.from(that.key), Buffer.from(iv));\n var block = cipher.update(Buffer.from(data));\n return ByteUtils.arrayToBuffer(Buffer.concat([block, cipher.final()]));\n });\n};\n\nAesCbcNode.prototype.decrypt = function(data, iv) {\n var that = this;\n return Promise.resolve().then(function() {\n var cipher = nodeCrypto.createDecipheriv('aes-256-cbc', Buffer.from(that.key), Buffer.from(iv));\n var block = cipher.update(Buffer.from(data));\n return ByteUtils.arrayToBuffer(Buffer.concat([block, cipher.final()]));\n }).catch(function() { throw new KdbxError(Consts.ErrorCodes.InvalidKey, 'invalid key'); });\n};\n\n/**\n * Creates AES-CBC implementation\n * @returns AesCbc\n */\nfunction createAesCbc() {\n if (subtle) {\n return new AesCbcSubtle();\n } else if (nodeCrypto) {\n return new AesCbcNode();\n } else {\n throw new KdbxError(Consts.ErrorCodes.NotImplemented, 'AES-CBC not implemented');\n }\n}\n\n/**\n * Gets random bytes from the CryptoEngine\n * @param {number} len - bytes count\n * @return {Uint8Array} - random bytes\n */\nfunction safeRandom(len) {\n var randomBytes = new Uint8Array(len);\n while (len > 0) {\n var segmentSize = len % maxRandomQuota;\n segmentSize = segmentSize > 0 ? segmentSize : maxRandomQuota;\n var randomBytesSegment = new Uint8Array(segmentSize);\n webCrypto.getRandomValues(randomBytesSegment);\n len -= segmentSize;\n randomBytes.set(randomBytesSegment, len);\n }\n return randomBytes;\n}\n\n/**\n * Generates random bytes of specified length\n * @param {Number} len\n * @returns {Uint8Array}\n */\nfunction random(len) {\n if (subtle) {\n return safeRandom(len);\n } else if (nodeCrypto) {\n return new Uint8Array(nodeCrypto.randomBytes(len));\n } else {\n throw new KdbxError(Consts.ErrorCodes.NotImplemented, 'Random not implemented');\n }\n}\n\n/**\n * Encrypts with ChaCha20\n * @param {ArrayBuffer} data\n * @param {ArrayBuffer} key\n * @param {ArrayBuffer} iv\n * @returns {Promise.}\n */\nfunction chacha20(data, key, iv) {\n return Promise.resolve().then(function() {\n var algo = new ChaCha20(new Uint8Array(key), new Uint8Array(iv));\n return ByteUtils.arrayToBuffer(algo.encrypt(new Uint8Array(data)));\n });\n}\n\n/**\n * Argon2 hash\n * @param {ArrayBuffer} password\n * @param {ArrayBuffer} salt\n * @param {Number} memory - memory in KiB\n * @param {Number} iterations - number of iterations\n * @param {Number} length - hash length\n * @param {Number} parallelism - threads count (threads will be emulated if they are not supported)\n * @param {Number} type - 0 = argon2d, 1 = argon2i\n * @param {Number} version - 0x10 or 0x13\n * @returns {Promise.}\n */\nfunction argon2(password, salt, memory, iterations, length, parallelism, type, version) { // jshint ignore:line\n return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'Argon2 not implemented'));\n}\n\n/**\n * Configures globals, for tests\n */\nfunction configure(newSubtle, newWebCrypto, newNodeCrypto) {\n subtle = newSubtle;\n webCrypto = newWebCrypto;\n nodeCrypto = newNodeCrypto;\n}\n\nmodule.exports.subtle = subtle;\nmodule.exports.webCrypto = webCrypto;\nmodule.exports.nodeCrypto = nodeCrypto;\n\nmodule.exports.sha256 = sha256;\nmodule.exports.sha512 = sha512;\nmodule.exports.hmacSha256 = hmacSha256;\nmodule.exports.random = random;\nmodule.exports.createAesCbc = createAesCbc;\nmodule.exports.chacha20 = chacha20;\nmodule.exports.argon2 = argon2;\n\nmodule.exports.configure = configure;\n","'use strict';\n\nvar KdbxError = require('./../errors/kdbx-error'),\n Consts = require('./../defs/consts'),\n XmlNames = require('../defs/xml-names'),\n KdbxUuid = require('./../format/kdbx-uuid'),\n ProtectedValue = require('./../crypto/protected-value'),\n ByteUtils = require('./byte-utils'),\n Int64 = require('./int64'),\n pako = require('pako');\n\nvar dateRegex = /\\.\\d\\d\\d/;\n\nvar dom = global.DOMParser ? global : require('xmldom');\nvar domParserArg = global.DOMParser ? undefined : {\n errorHandler: {\n error: function(e) { throw e; },\n fatalError: function(e) { throw e; }\n }\n};\n\nvar EpochSeconds = 62135596800;\n\n/**\n * Parses XML document\n * Throws an error in case of invalid XML\n * @param {string} xml - xml document\n * @returns {Document}\n */\nfunction parse(xml) {\n var parser = domParserArg ? new dom.DOMParser(domParserArg) : new dom.DOMParser();\n var doc;\n try {\n doc = parser.parseFromString(xml, 'application/xml');\n } catch (e) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + e.message);\n }\n if (!doc.documentElement) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml');\n }\n var parserError = doc.getElementsByTagName('parsererror')[0];\n if (parserError) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + parserError.textContent);\n }\n return doc;\n}\n\n/**\n * Serializes document to XML string\n * @param {Document} doc - source document\n * @param {boolean} [prettyPrint=false] - whether to add whitespace around tags\n * @returns {string} - xml content\n */\nfunction serialize(doc, prettyPrint) {\n if (prettyPrint) {\n prettyPrintXmlNode(doc, 0);\n }\n var xml = new dom.XMLSerializer().serializeToString(doc);\n if (prettyPrint && xml.startsWith(') 0 ? '\\n' + ' '.repeat(indentationLevel - 1) : '';\n var doc = node.ownerDocument || node;\n\n var childNodes = [];\n var childNode;\n\n for (var i = 0; i < numChildNodes; i++) {\n childNode = node.childNodes[i];\n if (childNode.nodeType !== doc.TEXT_NODE && childNode.nodeType !== doc.PROCESSING_INSTRUCTION_NODE) {\n childNodes.push(childNode);\n }\n }\n\n for (var j = 0; j < childNodes.length; j++) {\n childNode = childNodes[j];\n\n var isFirstDocumentNode = indentationLevel === 0 && j === 0;\n if (!isFirstDocumentNode) {\n var textNodeBefore = doc.createTextNode(formatStr);\n node.insertBefore(textNodeBefore, childNode);\n }\n\n if (!childNode.nextSibling && indentationLevel > 0) {\n var textNodeAfter = doc.createTextNode(prevFormatStr);\n node.appendChild(textNodeAfter);\n }\n\n prettyPrintXmlNode(childNode, indentationLevel + 1);\n }\n}\n\n/**\n * Creates a document with specified root node name\n * @param {string} rootNode - root node name\n * @returns {Document} - created XML document\n */\nfunction create(rootNode) {\n return parse('<' + rootNode + '/>');\n}\n\n/**\n * Gets first child node from xml\n * @param {Node} node - parent node for search\n * @param {string} tagName - child node tag name\n * @param {string} [errorMsgIfAbsent] - if set, error will be thrown if node is absent\n * @returns {Node} - first found node, or null, if there's no such node\n */\nfunction getChildNode(node, tagName, errorMsgIfAbsent) {\n if (node && node.childNodes) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n if (cn[i].tagName === tagName) {\n return cn[i];\n }\n }\n }\n if (errorMsgIfAbsent) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, errorMsgIfAbsent);\n } else {\n return null;\n }\n}\n\n/**\n * Adds child node to xml\n * @param {Node} node - parent node\n * @param {string} tagName - child node tag name\n * @returns {Node} - created node\n */\nfunction addChildNode(node, tagName) {\n return node.appendChild((node.ownerDocument || node).createElement(tagName));\n}\n\n/**\n * Gets node inner text\n * @param {Node} node - xml node\n * @return {string|undefined} - node inner text or undefined, if the node is empty\n */\nfunction getText(node) {\n if (!node || !node.childNodes) {\n return undefined;\n }\n return node.protectedValue ? node.protectedValue.text : node.textContent;\n}\n\n/**\n * Sets node inner text\n * @param {Node} node\n * @param {string} text\n */\nfunction setText(node, text) {\n node.textContent = text || '';\n}\n\n/**\n * Parses bytes saved by KeePass from XML\n * @param {Node} node - xml node with bytes saved by KeePass (base64 format)\n * @return {ArrayBuffer} - ArrayBuffer or undefined, if the tag is empty\n */\nfunction getBytes(node) {\n var text = getText(node);\n return text ? ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(text)) : undefined;\n}\n\n/**\n * Sets bytes for node\n * @param {Node} node\n * @param {ArrayBuffer|Uint8Array|string|undefined} bytes\n */\nfunction setBytes(node, bytes) {\n if (typeof bytes === 'string') {\n bytes = ByteUtils.base64ToBytes(bytes);\n }\n setText(node, bytes ? ByteUtils.bytesToBase64(ByteUtils.arrayToBuffer(bytes)) : undefined);\n}\n\n/**\n * Parses date saved by KeePass from XML\n * @param {Node} node - xml node with date saved by KeePass (ISO format or base64-uint64) format\n * @return {Date} - date or undefined, if the tag is empty\n */\nfunction getDate(node) {\n var text = getText(node);\n if (!text) {\n return undefined;\n }\n if (text.indexOf(':') > 0) {\n return new Date(text);\n }\n var bytes = new DataView(ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(text)));\n var secondsFrom00 = new Int64(bytes.getUint32(0, true), bytes.getUint32(4, true)).value;\n var diff = (secondsFrom00 - EpochSeconds) * 1000;\n return new Date(diff);\n}\n\n/**\n * Sets node date as string or binary\n * @param {Node} node\n * @param {Date|undefined} date\n * @param {boolean} [binary=false]\n */\nfunction setDate(node, date, binary) {\n if (date) {\n if (binary) {\n var secondsFrom00 = Math.floor(date.getTime() / 1000) + EpochSeconds;\n var bytes = new DataView(new ArrayBuffer(8));\n var val64 = Int64.from(secondsFrom00);\n bytes.setUint32(0, val64.lo, true);\n bytes.setUint32(4, val64.hi, true);\n setText(node, ByteUtils.bytesToBase64(bytes.buffer));\n } else {\n setText(node, date.toISOString().replace(dateRegex, ''));\n }\n } else {\n setText(node, '');\n }\n}\n\n/**\n * Parses number saved by KeePass from XML\n * @param {Node} node - xml node with number saved by KeePass\n * @return {Number|undefined} - number or undefined, if the tag is empty\n */\nfunction getNumber(node) {\n var text = getText(node);\n return text ? +text : undefined;\n}\n\n/**\n * Sets node number\n * @param {Node} node\n * @return {Number|undefined} number\n */\nfunction setNumber(node, number) {\n setText(node, typeof number === 'number' && !isNaN(number) ? number.toString() : undefined);\n}\n\n/**\n * Parses boolean saved by KeePass from XML\n * @param {Node} node - xml node with boolean saved by KeePass\n * @return {boolean|undefined} - boolean or undefined, if the tag is empty\n */\nfunction getBoolean(node) {\n var text = getText(node);\n return text ? strToBoolean(text) : undefined;\n}\n\n/**\n * Sets node boolean\n * @param {Node} node\n * @param {boolean|undefined} boolean\n */\nfunction setBoolean(node, boolean) {\n setText(node, boolean === undefined ? '' : boolean === null ? 'null' : boolean ? 'True' : 'False');\n}\n\n/**\n * Converts saved string to boolean\n * @param {string} str\n * @returns {boolean}\n */\nfunction strToBoolean(str) {\n switch (str && str.toLowerCase && str.toLowerCase()) {\n case 'true':\n return true;\n case 'false':\n return false;\n case 'null':\n return null;\n }\n return undefined;\n}\n\n/**\n * Parses Uuid saved by KeePass from XML\n * @param {Node} node - xml node with Uuid saved by KeePass\n * @return {KdbxUuid} - Uuid or undefined, if the tag is empty\n */\nfunction getUuid(node) {\n var bytes = getBytes(node);\n return bytes ? new KdbxUuid(bytes) : undefined;\n}\n\n/**\n * Sets node uuid\n * @param {Node} node\n * @param {KdbxUuid} uuid\n */\nfunction setUuid(node, uuid) {\n var uuidBytes = uuid instanceof KdbxUuid ? uuid.toBytes() : uuid;\n setBytes(node, uuidBytes);\n}\n\n/**\n * Gets node protected text from inner text\n * @param {Node} node\n * @return {ProtectedValue|string}\n */\nfunction getProtectedText(node) {\n return node.protectedValue || node.textContent;\n}\n\n/**\n * Sets node protected text\n * @param {Node} node\n * @param {ProtectedValue|string} text\n */\nfunction setProtectedText(node, text) {\n if (text instanceof ProtectedValue) {\n node.protectedValue = text;\n node.setAttribute(XmlNames.Attr.Protected, 'True');\n } else {\n setText(node, text);\n }\n}\n\n/**\n * Gets node protected text from inner text\n * @param {Node} node\n * @return {ProtectedValue|ArrayBuffer|{ref: string}} - protected value, or array buffer, or reference to binary\n */\nfunction getProtectedBinary(node) {\n if (node.protectedValue) {\n return node.protectedValue;\n }\n var text = node.textContent;\n var ref = node.getAttribute(XmlNames.Attr.Ref);\n if (ref) {\n return { ref: ref };\n }\n if (!text) {\n return undefined;\n }\n var compressed = strToBoolean(node.getAttribute(XmlNames.Attr.Compressed));\n var bytes = ByteUtils.base64ToBytes(text);\n if (compressed) {\n bytes = pako.ungzip(bytes);\n }\n return ByteUtils.arrayToBuffer(bytes);\n}\n\n/**\n * Sets node protected binary\n * @param {Node} node\n * @param {ProtectedValue|ArrayBuffer|{ref: string}|string} binary\n */\nfunction setProtectedBinary(node, binary) {\n if (binary instanceof ProtectedValue) {\n node.protectedValue = binary;\n node.setAttribute(XmlNames.Attr.Protected, 'True');\n } else if (binary && binary.ref) {\n node.setAttribute(XmlNames.Attr.Ref, binary.ref);\n } else {\n setBytes(node, binary);\n }\n}\n\n/**\n * Traversed XML tree with depth-first preorder search\n * @param {Node} node\n * @param {function} callback\n */\nfunction traverse(node, callback) {\n callback(node);\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n traverse(childNode, callback);\n }\n }\n}\n\n/**\n * Reads protected values for all nodes in tree\n * @param {Node} node\n * @param {ProtectSaltGenerator} protectSaltGenerator\n */\nfunction setProtectedValues(node, protectSaltGenerator) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected))) {\n try {\n var value = ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(node.textContent));\n if (value.byteLength) {\n var salt = protectSaltGenerator.getSalt(value.byteLength);\n node.protectedValue = new ProtectedValue(value, salt);\n }\n } catch (e) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad protected value at line ' +\n node.lineNumber + ': ' + e);\n }\n }\n });\n}\n\n/**\n * Updates protected values salt for all nodes in tree which have protected values assigned\n * @param {Node} node\n * @param {ProtectSaltGenerator} protectSaltGenerator\n */\nfunction updateProtectedValuesSalt(node, protectSaltGenerator) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected)) && node.protectedValue) {\n var newSalt = protectSaltGenerator.getSalt(node.protectedValue.byteLength);\n node.protectedValue.setSalt(newSalt);\n node.textContent = node.protectedValue.toString();\n }\n });\n}\n\n/**\n * Unprotect protected values for all nodes in tree which have protected values assigned\n * @param {Node} node\n */\nfunction unprotectValues(node) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected)) && node.protectedValue) {\n node.removeAttribute(XmlNames.Attr.Protected);\n node.setAttribute(XmlNames.Attr.ProtectedInMemPlainXml, 'True');\n node.textContent = node.protectedValue.getText();\n }\n });\n}\n\n/**\n * Protect protected values back for all nodes in tree which have been unprotected\n * @param {Node} node\n */\nfunction protectUnprotectedValues(node) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.ProtectedInMemPlainXml)) && node.protectedValue) {\n node.removeAttribute(XmlNames.Attr.ProtectedInMemPlainXml);\n node.setAttribute(XmlNames.Attr.Protected, 'True');\n node.textContent = node.protectedValue.toString();\n }\n });\n}\n\n/**\n * Protect plain values in xml for all nodes in tree which should be protected\n * @param {Node} node\n */\nfunction protectPlainValues(node) {\n traverse(node, function(node) {\n if (strToBoolean(node.getAttribute(XmlNames.Attr.ProtectedInMemPlainXml))) {\n node.protectedValue = ProtectedValue.fromString(node.textContent);\n node.textContent = node.protectedValue.toString();\n node.removeAttribute(XmlNames.Attr.ProtectedInMemPlainXml);\n node.setAttribute(XmlNames.Attr.Protected, 'True');\n }\n });\n}\n\nmodule.exports.parse = parse;\nmodule.exports.serialize = serialize;\nmodule.exports.create = create;\nmodule.exports.getChildNode = getChildNode;\nmodule.exports.addChildNode = addChildNode;\nmodule.exports.getText = getText;\nmodule.exports.setText = setText;\nmodule.exports.getBytes = getBytes;\nmodule.exports.setBytes = setBytes;\nmodule.exports.getDate = getDate;\nmodule.exports.setDate = setDate;\nmodule.exports.getNumber = getNumber;\nmodule.exports.setNumber = setNumber;\nmodule.exports.getBoolean = getBoolean;\nmodule.exports.setBoolean = setBoolean;\nmodule.exports.strToBoolean = strToBoolean;\nmodule.exports.getUuid = getUuid;\nmodule.exports.setUuid = setUuid;\nmodule.exports.getProtectedText = getProtectedText;\nmodule.exports.setProtectedText = setProtectedText;\nmodule.exports.getProtectedBinary = getProtectedBinary;\nmodule.exports.setProtectedBinary = setProtectedBinary;\nmodule.exports.setProtectedValues = setProtectedValues;\nmodule.exports.updateProtectedValuesSalt = updateProtectedValuesSalt;\nmodule.exports.unprotectValues = unprotectValues;\nmodule.exports.protectUnprotectedValues = protectUnprotectedValues;\nmodule.exports.protectPlainValues = protectPlainValues;\n","'use strict';\n\n\nvar TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n (typeof Uint16Array !== 'undefined') &&\n (typeof Int32Array !== 'undefined');\n\n\nexports.assign = function (obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n};\n\n\n// reduce buffer size, avoiding mem copy\nexports.shrinkBuf = function (buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n};\n\n\nvar fnTyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n }\n};\n\nvar fnUntyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n return [].concat.apply([], chunks);\n }\n};\n\n\n// Enable/Disable typed arrays use, for testing\n//\nexports.setTyped = function (on) {\n if (on) {\n exports.Buf8 = Uint8Array;\n exports.Buf16 = Uint16Array;\n exports.Buf32 = Int32Array;\n exports.assign(exports, fnTyped);\n } else {\n exports.Buf8 = Array;\n exports.Buf16 = Array;\n exports.Buf32 = Array;\n exports.assign(exports, fnUntyped);\n }\n};\n\nexports.setTyped(TYPED_OK);\n","'use strict';\n\nmodule.exports = {\n Elem: {\n DocNode: 'KeePassFile',\n\n Meta: 'Meta',\n Root: 'Root',\n Group: 'Group',\n Entry: 'Entry',\n\n Generator: 'Generator',\n HeaderHash: 'HeaderHash',\n SettingsChanged: 'SettingsChanged',\n DbName: 'DatabaseName',\n DbNameChanged: 'DatabaseNameChanged',\n DbDesc: 'DatabaseDescription',\n DbDescChanged: 'DatabaseDescriptionChanged',\n DbDefaultUser: 'DefaultUserName',\n DbDefaultUserChanged: 'DefaultUserNameChanged',\n DbMntncHistoryDays: 'MaintenanceHistoryDays',\n DbColor: 'Color',\n DbKeyChanged: 'MasterKeyChanged',\n DbKeyChangeRec: 'MasterKeyChangeRec',\n DbKeyChangeForce: 'MasterKeyChangeForce',\n RecycleBinEnabled: 'RecycleBinEnabled',\n RecycleBinUuid: 'RecycleBinUUID',\n RecycleBinChanged: 'RecycleBinChanged',\n EntryTemplatesGroup: 'EntryTemplatesGroup',\n EntryTemplatesGroupChanged: 'EntryTemplatesGroupChanged',\n HistoryMaxItems: 'HistoryMaxItems',\n HistoryMaxSize: 'HistoryMaxSize',\n LastSelectedGroup: 'LastSelectedGroup',\n LastTopVisibleGroup: 'LastTopVisibleGroup',\n\n MemoryProt: 'MemoryProtection',\n ProtTitle: 'ProtectTitle',\n ProtUserName: 'ProtectUserName',\n ProtPassword: 'ProtectPassword',\n ProtUrl: 'ProtectURL',\n ProtNotes: 'ProtectNotes',\n\n CustomIcons: 'CustomIcons',\n CustomIconItem: 'Icon',\n CustomIconItemID: 'UUID',\n CustomIconItemData: 'Data',\n\n AutoType: 'AutoType',\n History: 'History',\n\n Name: 'Name',\n Notes: 'Notes',\n Uuid: 'UUID',\n Icon: 'IconID',\n CustomIconID: 'CustomIconUUID',\n FgColor: 'ForegroundColor',\n BgColor: 'BackgroundColor',\n OverrideUrl: 'OverrideURL',\n Times: 'Times',\n Tags: 'Tags',\n\n CreationTime: 'CreationTime',\n LastModTime: 'LastModificationTime',\n LastAccessTime: 'LastAccessTime',\n ExpiryTime: 'ExpiryTime',\n Expires: 'Expires',\n UsageCount: 'UsageCount',\n LocationChanged: 'LocationChanged',\n\n GroupDefaultAutoTypeSeq: 'DefaultAutoTypeSequence',\n EnableAutoType: 'EnableAutoType',\n EnableSearching: 'EnableSearching',\n\n String: 'String',\n Binary: 'Binary',\n Key: 'Key',\n Value: 'Value',\n\n AutoTypeEnabled: 'Enabled',\n AutoTypeObfuscation: 'DataTransferObfuscation',\n AutoTypeDefaultSeq: 'DefaultSequence',\n AutoTypeItem: 'Association',\n Window: 'Window',\n KeystrokeSequence: 'KeystrokeSequence',\n\n Binaries: 'Binaries',\n\n IsExpanded: 'IsExpanded',\n LastTopVisibleEntry: 'LastTopVisibleEntry',\n\n DeletedObjects: 'DeletedObjects',\n DeletedObject: 'DeletedObject',\n DeletionTime: 'DeletionTime',\n\n CustomData: 'CustomData',\n StringDictExItem: 'Item'\n },\n\n Attr: {\n Id: 'ID',\n Ref: 'Ref',\n Protected: 'Protected',\n ProtectedInMemPlainXml: 'ProtectInMemory',\n Compressed: 'Compressed'\n },\n\n Val: {\n False: 'False',\n True: 'True'\n }\n};\n","'use strict';\n\nvar ByteUtils = require('../utils/byte-utils'),\n Random = require('../crypto/random');\n\nvar UuidLength = 16;\n\n/**\n * Uuid for passwords\n * @param {ArrayBuffer|string} ab - ArrayBuffer with data\n * @constructor\n */\nfunction KdbxUuid(ab) {\n if (ab === undefined) {\n ab = new ArrayBuffer(UuidLength);\n }\n if (typeof ab === 'string') {\n ab = ByteUtils.base64ToBytes(ab);\n }\n this.id = ab.byteLength === 16 ? ByteUtils.bytesToBase64(ab) : undefined;\n this.empty = true;\n if (ab) {\n var bytes = new Uint8Array(ab);\n for (var i = 0, len = bytes.length; i < len; i++) {\n if (bytes[i] !== 0) {\n this.empty = false;\n return;\n }\n }\n }\n}\n\n/**\n * Checks whether two uuids are equal\n * @param {KdbxUuid|string} other\n */\nKdbxUuid.prototype.equals = function(other) {\n return other && other.toString() === this.toString() || false;\n};\n\nObject.defineProperty(KdbxUuid.prototype, 'bytes', {\n enumerable: true,\n get: function() {\n return ByteUtils.base64ToBytes(this.id);\n }\n});\n\n/**\n * Generated random uuid\n * @return {KdbxUuid}\n * @static\n */\nKdbxUuid.random = function() {\n return new KdbxUuid(Random.getBytes(UuidLength));\n};\n\nKdbxUuid.prototype.toString = function() {\n return this.id;\n};\n\nKdbxUuid.prototype.valueOf = function() {\n return this.id;\n};\n\nKdbxUuid.prototype.toBytes = function() {\n return this.id ? ByteUtils.base64ToBytes(this.id) : undefined;\n};\n\nmodule.exports = KdbxUuid;\n","'use strict';\n\n/**\n * Represents 64-bit number\n * @param {number} [lo=0]\n * @param {number} [hi=0]\n * @constructor\n */\nfunction Int64(lo, hi) {\n this.lo = lo || 0;\n this.hi = hi || 0;\n}\n\n/**\n * Number value as float\n * @returns {Number}\n */\nObject.defineProperty(Int64.prototype, 'value', {\n enumerable: true,\n get: function() {\n if (this.hi) {\n if (this.hi >= 0x200000) {\n throw new Error('too large number');\n }\n return this.hi * 0x100000000 + this.lo;\n }\n return this.lo;\n }\n});\n\n/**\n * Gets number value\n * @returns {Number}\n */\nInt64.prototype.valueOf = function() {\n return this.value;\n};\n\n/**\n * Creates int64 from number\n * @param {number} value\n * @returns {Int64}\n * @static\n */\nInt64.from = function(value) {\n if (value > 0x1fffffffffffff) {\n throw new Error('too large number');\n }\n var lo = value >>> 0;\n var hi = ((value - lo) / 0x100000000) >>> 0;\n return new Int64(lo, hi);\n};\n\nmodule.exports = Int64;\n","'use strict';\n\nvar ByteUtils = require('../utils/byte-utils'),\n CryptoEngine = require('./crypto-engine'),\n Random = require('./random');\n\n/**\n * Protected value, used for protected entry fields\n * @param {ArrayBuffer} value - encrypted value\n * @param {ArrayBuffer} salt - salt bytes\n * @constructor\n */\nvar ProtectedValue = function(value, salt) {\n Object.defineProperty(this, '_value', { value: new Uint8Array(value) });\n Object.defineProperty(this, '_salt', { value: new Uint8Array(salt) });\n};\n\n/**\n * Returns protected value as base64 string\n * @returns {string}\n */\nProtectedValue.prototype.toString = function() {\n return ByteUtils.bytesToBase64(this._value);\n};\n\n/**\n * Creates protected value from string with new random salt\n * @param {string} str\n */\nProtectedValue.fromString = function(str) {\n var bytes = ByteUtils.stringToBytes(str),\n salt = Random.getBytes(bytes.length);\n for (var i = 0, len = bytes.length; i < len; i++) {\n bytes[i] ^= salt[i];\n }\n return new ProtectedValue(ByteUtils.arrayToBuffer(bytes), ByteUtils.arrayToBuffer(salt));\n};\n\n/**\n * Creates protected value from binary with new random salt\n * @param {ArrayBuffer} binary\n */\nProtectedValue.fromBinary = function(binary) {\n var bytes = new Uint8Array(binary),\n salt = Random.getBytes(bytes.length);\n for (var i = 0, len = bytes.length; i < len; i++) {\n bytes[i] ^= salt[i];\n }\n return new ProtectedValue(ByteUtils.arrayToBuffer(bytes), ByteUtils.arrayToBuffer(salt));\n};\n\n/**\n * Determines whether the value is included as substring (safe check; doesn't decrypt full string)\n * @param {string} str\n * @return {boolean}\n */\nProtectedValue.prototype.includes = function(str) {\n if (str.length === 0) {\n return false;\n }\n var source = this._value,\n salt = this._salt,\n search = ByteUtils.stringToBytes(str),\n sourceLen = source.length, searchLen = search.length, maxPos = sourceLen - searchLen,\n sourceIx, searchIx;\n src: for (sourceIx = 0; sourceIx <= maxPos; sourceIx++) {\n for (searchIx = 0; searchIx < searchLen; searchIx++) {\n if ((source[sourceIx + searchIx] ^ salt[sourceIx + searchIx]) !== search[searchIx]) {\n continue src;\n }\n }\n return true;\n }\n return false;\n};\n\n/**\n * Calculates SHA256 hash of saved value\n * @return {Promise.}\n */\nProtectedValue.prototype.getHash = function() {\n var binary = ByteUtils.arrayToBuffer(this.getBinary());\n return CryptoEngine.sha256(binary).then(function(hash) {\n ByteUtils.zeroBuffer(binary);\n return hash;\n });\n};\n\n/**\n * Decrypted text\n * @returns {string}\n */\nProtectedValue.prototype.getText = function() {\n return ByteUtils.bytesToString(this.getBinary());\n};\n\n/**\n * Decrypted binary. Don't forget to zero it after usage\n * @returns {Uint8Array}\n */\nProtectedValue.prototype.getBinary = function() {\n var value = this._value, salt = this._salt;\n var bytes = new Uint8Array(value.byteLength);\n for (var i = bytes.length - 1; i >= 0; i--) {\n bytes[i] = value[i] ^ salt[i];\n }\n return bytes;\n};\n\n/**\n * Sets new salt\n * @param {ArrayBuffer} newSalt\n */\nProtectedValue.prototype.setSalt = function(newSalt) {\n var newSaltArr = new Uint8Array(newSalt);\n var value = this._value, salt = this._salt;\n for (var i = 0, len = value.length; i < len; i++) {\n value[i] = value[i] ^ salt[i] ^ newSaltArr[i];\n salt[i] = newSaltArr[i];\n }\n};\n\n/**\n * Clones object\n * @return {ProtectedValue}\n */\nProtectedValue.prototype.clone = function() {\n return new ProtectedValue(this._value, this._salt);\n};\n\n/**\n * Value byte length\n */\nObject.defineProperty(ProtectedValue.prototype, 'byteLength', {\n enumerable: true,\n get: function() {\n return this._value.byteLength;\n }\n});\n\nmodule.exports = ProtectedValue;\n","'use strict';\n\nvar Salsa20 = require('./salsa20'),\n CryptoEngine = require('./crypto-engine');\n\nvar key = new Uint8Array(32), nonce = new Uint8Array(8);\nfor (var i = 0; i < key.length; i++) {\n key[i] = Math.random() * 0xff;\n}\nfor (var j = 0; j < nonce.length; j++) {\n nonce[i] = Math.random() * 0xff;\n}\nvar algo = new Salsa20(key, nonce);\n\n/**\n * Gets random bytes\n * @param {number} len - bytes count\n * @return {Uint8Array} - random bytes\n */\nfunction getBytes(len) {\n if (!len) {\n return new Uint8Array(0);\n }\n algo.getBytes(Math.round(Math.random() * len) + 1);\n var result = algo.getBytes(len);\n var cryptoBytes = CryptoEngine.random(len);\n for (var i = cryptoBytes.length - 1; i >= 0; --i) {\n result[i] ^= cryptoBytes[i];\n }\n return result;\n}\n\nmodule.exports.getBytes = getBytes;\n","'use strict';\n\n/**\n * Stream for accessing array buffer with auto-advanced position\n * @param {ArrayBuffer} [arrayBuffer]\n * @constructor\n */\nfunction BinaryStream(arrayBuffer) {\n this._arrayBuffer = arrayBuffer || new ArrayBuffer(1024);\n this._dataView = new DataView(this._arrayBuffer);\n this._pos = 0;\n this._canExpand = !arrayBuffer;\n}\n\n['Int', 'Uint', 'Float'].forEach(function(type) {\n (type === 'Float' ? [4, 8] : [1, 2, 4]).forEach(function(bytes) {\n var getMethod = 'get' + type + bytes * 8;\n BinaryStream.prototype[getMethod] = function(littleEndian) {\n var res = this._dataView[getMethod].call(this._dataView, this._pos, littleEndian);\n this._pos += bytes;\n return res;\n };\n var setMethod = 'set' + type + bytes * 8;\n BinaryStream.prototype[setMethod] = function(value, littleEndian) {\n this._checkCapacity(bytes);\n this._dataView[setMethod].call(this._dataView, this._pos, value, littleEndian);\n this._pos += bytes;\n };\n });\n});\n\nBinaryStream.prototype.getUint64 = function(littleEndian) {\n var part1 = this.getUint32(littleEndian),\n part2 = this.getUint32(littleEndian);\n if (littleEndian) {\n part2 *= 0x100000000;\n } else {\n part1 *= 0x100000000;\n }\n return part1 + part2;\n};\n\nBinaryStream.prototype.setUint64 = function(value, littleEndian) {\n if (littleEndian) {\n this.setUint32(value & 0xffffffff, true);\n this.setUint32(Math.floor(value / 0x100000000), true);\n } else {\n this._checkCapacity(8);\n this.setUint32(Math.floor(value / 0x100000000), false);\n this.setUint32(value & 0xffffffff, false);\n }\n};\n\nBinaryStream.prototype.readBytes = function(size) {\n var buffer = this._arrayBuffer.slice(this._pos, this._pos + size);\n this._pos += size;\n return buffer;\n};\n\nBinaryStream.prototype.readBytesToEnd = function() {\n var size = this._arrayBuffer.byteLength - this._pos;\n return this.readBytes(size);\n};\n\nBinaryStream.prototype.readBytesNoAdvance = function(startPos, endPos) {\n return this._arrayBuffer.slice(startPos, endPos);\n};\n\nBinaryStream.prototype.writeBytes = function(bytes) {\n if (bytes instanceof ArrayBuffer) {\n bytes = new Uint8Array(bytes);\n }\n this._checkCapacity(bytes.length);\n new Uint8Array(this._arrayBuffer).set(bytes, this._pos);\n this._pos += bytes.length;\n};\n\nBinaryStream.prototype.getWrittenBytes = function() {\n return this._arrayBuffer.slice(0, this._pos);\n};\n\nBinaryStream.prototype._checkCapacity = function(addBytes) {\n var available = this._arrayBuffer.byteLength - this._pos;\n if (this._canExpand && available < addBytes) {\n var newLen = this._arrayBuffer.byteLength,\n requestedLen = this._pos + addBytes;\n while (newLen < requestedLen) {\n newLen *= 2;\n }\n var newData = new Uint8Array(newLen);\n newData.set(new Uint8Array(this._arrayBuffer));\n this._arrayBuffer = newData.buffer;\n this._dataView = new DataView(this._arrayBuffer);\n }\n};\n\nObject.defineProperty(BinaryStream.prototype, 'pos', {\n enumerable: true,\n get: function() {\n return this._pos;\n }\n});\n\nObject.defineProperty(BinaryStream.prototype, 'byteLength', {\n enumerable: true,\n get: function() {\n return this._arrayBuffer.byteLength;\n }\n});\n\nmodule.exports = BinaryStream;\n","'use strict';\n\nmodule.exports = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","'use strict';\n\nvar KdbxError = require('../errors/kdbx-error');\nvar Consts = require('../defs/consts');\nvar ByteUtils = require('../utils/byte-utils');\nvar Int64 = require('../utils/int64');\n\nvar MaxSupportedVersion = 1;\nvar DefaultVersion = 0x0100;\n\n/**\n * Value type\n * @enum\n */\nvar ValueType = {\n UInt32: 0x04,\n UInt64: 0x05,\n Bool: 0x08,\n Int32: 0x0C,\n Int64: 0x0D,\n String: 0x18,\n Bytes: 0x42\n};\n\n/**\n * Variant dictionary, capable to store/load different values from byte array\n * @constructor\n */\nfunction VarDictionary() {\n this._items = [];\n this._dict = {};\n Object.preventExtensions(this);\n}\n\n/**\n * Available value types enum\n * @enum\n */\nVarDictionary.ValueType = ValueType;\n\n/**\n * Gets value or undefined\n * @param {string} key\n * @returns {*}\n */\nVarDictionary.prototype.get = function(key) {\n var item = this._dict[key];\n return item ? item.value : undefined;\n};\n\n/**\n * Get all keys\n * @return {string[]} keys array\n */\nVarDictionary.prototype.keys = function() {\n return this._items.map(function(item) { return item.key; });\n};\n\n/**\n * Keys count\n * @returns {Number}\n */\nObject.defineProperty(VarDictionary.prototype, 'length', {\n enumberable: true,\n get: function() { return this._items.length; }\n});\n\n/**\n * Sets or replaces existing item\n * @param {String} key\n * @param {VarDictionary.ValueType|Number} type\n * @param {*} value\n */\nVarDictionary.prototype.set = function(key, type, value) {\n switch (type) {\n case ValueType.UInt32:\n if (typeof value !== 'number' || value < 0) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.UInt64:\n if (!(value instanceof Int64)) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.Bool:\n if (typeof value !== 'boolean') {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.Int32:\n if (typeof value !== 'number') {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.Int64:\n if (!(value instanceof Int64)) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.String:\n if (typeof value !== 'string') {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n case ValueType.Bytes:\n if (value instanceof Uint8Array) {\n value = ByteUtils.arrayToBuffer(value);\n }\n if (!(value instanceof ArrayBuffer)) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n break;\n default:\n throw new KdbxError(Consts.ErrorCodes.InvalidArg);\n }\n var item = { key: key, type: type, value: value };\n if (this._dict[key]) {\n var ix = this._items.indexOf(this._dict[key]);\n this._items.splice(ix, 1, item);\n } else {\n this._items.push(item);\n }\n this._dict[key] = item;\n};\n\n/**\n * Removes key from dictionary\n * @param {string} key\n */\nVarDictionary.prototype.remove = function(key) {\n this._items = this._items.filter(function(item) { return item.key !== key; });\n delete this._dict[key];\n};\n\n/**\n * Reads dictionary from stream\n * @param {BinaryStream} stm\n * @returns {VarDictionary}\n * @static\n */\nVarDictionary.read = function(stm) {\n var dict = new VarDictionary();\n dict._readVersion(stm);\n while (true) {\n var item = dict._readItem(stm);\n if (!item) {\n break;\n }\n dict._items.push(item);\n dict._dict[item.key] = item;\n }\n return dict;\n};\n\nVarDictionary.prototype._readVersion = function(stm) {\n stm.getUint8();\n var versionMajor = stm.getUint8();\n if (versionMajor === 0 || versionMajor > MaxSupportedVersion) {\n throw new KdbxError(Consts.ErrorCodes.InvalidVersion);\n }\n};\n\nVarDictionary.prototype._readItem = function(stm) {\n var type = stm.getUint8();\n if (!type) {\n return false;\n }\n var keyLength = stm.getInt32(true);\n if (keyLength <= 0) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad key length');\n }\n var key = ByteUtils.bytesToString(stm.readBytes(keyLength));\n var valueLength = stm.getInt32(true);\n if (valueLength < 0) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad value length');\n }\n var value;\n switch (type) {\n case ValueType.UInt32:\n if (valueLength !== 4) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad uint32');\n }\n value = stm.getUint32(true);\n break;\n case ValueType.UInt64:\n if (valueLength !== 8) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad uint64');\n }\n var loInt = stm.getUint32(true);\n var hiInt = stm.getUint32(true);\n value = new Int64(loInt, hiInt);\n break;\n case ValueType.Bool:\n if (valueLength !== 1) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad bool');\n }\n value = stm.getUint8() !== 0;\n break;\n case ValueType.Int32:\n if (valueLength !== 4) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad int32');\n }\n value = stm.getInt32(true);\n break;\n case ValueType.Int64:\n if (valueLength !== 8) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad int64');\n }\n var loUint = stm.getUint32(true);\n var hiUint = stm.getUint32(true);\n value = new Int64(loUint, hiUint);\n break;\n case ValueType.String:\n value = ByteUtils.bytesToString(stm.readBytes(valueLength));\n break;\n case ValueType.Bytes:\n value = stm.readBytes(valueLength);\n break;\n default:\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad value type: ' + type);\n }\n return { key: key, type: type, value: value };\n};\n\n/**\n * Writes self to binary stream\n * @param {BinaryStream} stm\n */\nVarDictionary.prototype.write = function(stm) {\n this._writeVersion(stm);\n Object.keys(this._items).forEach(function(key) {\n this._writeItem(stm, this._items[key]);\n }, this);\n stm.setUint8(0);\n};\n\nVarDictionary.prototype._writeVersion = function(stm) {\n stm.setUint16(DefaultVersion, true);\n};\n\nVarDictionary.prototype._writeItem = function(stm, item) {\n stm.setUint8(item.type);\n var keyBytes = ByteUtils.stringToBytes(item.key);\n stm.setInt32(keyBytes.length, true);\n stm.writeBytes(keyBytes);\n switch (item.type) {\n case ValueType.UInt32:\n stm.setInt32(4, true);\n stm.setUint32(item.value, true);\n break;\n case ValueType.UInt64:\n stm.setInt32(8, true);\n stm.setUint32(item.value.lo, true);\n stm.setUint32(item.value.hi, true);\n break;\n case ValueType.Bool:\n stm.setInt32(1, true);\n stm.setUint8(item.value ? 1 : 0);\n break;\n case ValueType.Int32:\n stm.setInt32(4, true);\n stm.setInt32(item.value, true);\n break;\n case ValueType.Int64:\n stm.setInt32(8, true);\n stm.setUint32(item.value.lo, true);\n stm.setUint32(item.value.hi, true);\n break;\n case ValueType.String:\n var strBytes = ByteUtils.stringToBytes(item.value);\n stm.setInt32(strBytes.length, true);\n stm.writeBytes(strBytes);\n break;\n case ValueType.Bytes:\n var bytesBuffer = ByteUtils.arrayToBuffer(item.value);\n stm.setInt32(bytesBuffer.byteLength, true);\n stm.writeBytes(bytesBuffer);\n break;\n default:\n throw new KdbxError(Consts.ErrorCodes.Unsupported);\n }\n};\n\nmodule.exports = VarDictionary;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils');\n\nvar KdbxCustomData = {\n /**\n * Reads custom data from xml\n * @param {Node} node - xml node\n * @returns {object} - custom data dictionary\n */\n read: function(node) {\n var customData = {};\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName === XmlNames.Elem.StringDictExItem) {\n KdbxCustomData._readItem(childNode, customData);\n }\n }\n return customData;\n },\n\n /**\n * Writes custom data to xml\n * @param {Node} parentNode - xml node\n * @param {object} customData - custom data dictionary\n */\n write: function(parentNode, customData) {\n if (!customData) {\n return;\n }\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.CustomData);\n Object.keys(customData).forEach(function(key) {\n var value = customData[key];\n if (value) {\n var itemNode = XmlUtils.addChildNode(node, XmlNames.Elem.StringDictExItem);\n XmlUtils.setText(XmlUtils.addChildNode(itemNode, XmlNames.Elem.Key), key);\n XmlUtils.setText(XmlUtils.addChildNode(itemNode, XmlNames.Elem.Value), value);\n }\n });\n },\n\n _readItem: function(node, customData) {\n var key, value;\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.Key:\n key = XmlUtils.getText(childNode);\n break;\n case XmlNames.Elem.Value:\n value = XmlUtils.getText(childNode);\n break;\n }\n }\n if (key) {\n customData[key] = value;\n }\n }\n};\n\nmodule.exports = KdbxCustomData;\n","// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign = require('./lib/utils/common').assign;\n\nvar deflate = require('./lib/deflate');\nvar inflate = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n","'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n","'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n","// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new utils.Buf8(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n var buf = new utils.Buf8(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n","'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\nmodule.exports = ZStream;\n","'use strict';\n\n\nmodule.exports = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n //Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\n","'use strict';\n\n/* Docs for the KDBX header schema:\n * https://keepass.info/help/kb/kdbx_4.html#innerhdr\n */\n\nvar KdbxUuid = require('./kdbx-uuid'),\n Consts = require('./../defs/consts'),\n ProtectedValue = require('./../crypto/protected-value'),\n KdbxError = require('./../errors/kdbx-error'),\n BinaryStream = require('./../utils/binary-stream'),\n ByteUtils = require('./../utils/byte-utils'),\n VarDictionary = require('./../utils/var-dictionary'),\n Int64 = require('./../utils/int64'),\n Random = require('../crypto/random');\n\nvar HeaderFields = [\n { name: 'EndOfHeader' },\n\n { name: 'Comment' },\n { name: 'CipherID' },\n { name: 'CompressionFlags' },\n { name: 'MasterSeed' },\n { name: 'TransformSeed', ver: [3] },\n { name: 'TransformRounds', ver: [3] },\n { name: 'EncryptionIV' },\n { name: 'ProtectedStreamKey', ver: [3] },\n { name: 'StreamStartBytes', ver: [3] },\n { name: 'InnerRandomStreamID', ver: [3] },\n\n { name: 'KdfParameters', ver: [4] },\n { name: 'PublicCustomData', ver: [4] }\n];\n\nvar InnerHeaderFields = [\n { name: 'EndOfHeader' },\n\n { name: 'InnerRandomStreamID' },\n { name: 'InnerRandomStreamKey' },\n { name: 'Binary', skipHeader: true }\n];\n\nvar HeaderConst = {\n DefaultFileVersionMajor: 3,\n DefaultFileVersionMinor: 1,\n MaxFileVersionMajor: 4,\n MaxFileVersionMinor: 1,\n MaxSupportedVersion: 4,\n FlagBinaryProtected: 0x01,\n InnerHeaderBinaryFieldId: 0x03,\n\n DefaultKdfAlgo: Consts.KdfId.Argon2,\n DefaultKdfSaltLength: 32,\n DefaultKdfParallelism: 1,\n DefaultKdfIterations: 2,\n DefaultKdfMemory: 1024 * 1024,\n DefaultKdfVersion: 0x13\n};\n\nvar LastMinorVersions = {\n 3: 1,\n 4: 1\n};\n\n/**\n * Binary file header reader/writer\n * @constructor\n */\nvar KdbxHeader = function() {\n this.versionMajor = undefined;\n this.versionMinor = undefined;\n this.dataCipherUuid = undefined;\n this.compression = undefined;\n this.masterSeed = undefined;\n this.transformSeed = undefined;\n this.keyEncryptionRounds = undefined;\n this.encryptionIV = undefined;\n this.protectedStreamKey = undefined;\n this.streamStartBytes = undefined;\n this.crsAlgorithm = undefined;\n this.endPos = undefined;\n this.kdfParameters = undefined;\n this.publicCustomData = undefined;\n Object.preventExtensions(this);\n};\n\nKdbxHeader.prototype._readSignature = function(stm) {\n if (stm.byteLength < 8) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'not enough data');\n }\n var sig1 = stm.getUint32(true), sig2 = stm.getUint32(true);\n if (!(sig1 === Consts.Signatures.FileMagic && sig2 === Consts.Signatures.Sig2Kdbx)) {\n throw new KdbxError(Consts.ErrorCodes.BadSignature);\n }\n};\n\nKdbxHeader.prototype._writeSignature = function(stm) {\n stm.setUint32(Consts.Signatures.FileMagic, true);\n stm.setUint32(Consts.Signatures.Sig2Kdbx, true);\n};\n\nKdbxHeader.prototype._readVersion = function(stm) {\n var versionMinor = stm.getUint16(true);\n var versionMajor = stm.getUint16(true);\n if (versionMajor > HeaderConst.MaxSupportedVersion) {\n throw new KdbxError(Consts.ErrorCodes.InvalidVersion);\n }\n this.versionMinor = versionMinor;\n this.versionMajor = versionMajor;\n};\n\nKdbxHeader.prototype._writeVersion = function(stm) {\n stm.setUint16(this.versionMinor, true);\n stm.setUint16(this.versionMajor, true);\n};\n\nKdbxHeader.prototype._readCipherID = function(bytes) {\n if (bytes.byteLength !== 16) {\n throw new KdbxError(Consts.ErrorCodes.Unsupported, 'cipher');\n }\n this.dataCipherUuid = new KdbxUuid(bytes);\n};\n\nKdbxHeader.prototype._writeCipherID = function(stm) {\n this._writeFieldSize(stm, 16);\n stm.writeBytes(this.dataCipherUuid.bytes);\n};\n\nKdbxHeader.prototype._readCompressionFlags = function(bytes) {\n var id = new DataView(bytes).getUint32(bytes, true);\n if (id < 0 || id >= Object.keys(Consts.CompressionAlgorithm).length) {\n throw new KdbxError(Consts.ErrorCodes.Unsupported, 'compression');\n }\n this.compression = id;\n};\n\nKdbxHeader.prototype._writeCompressionFlags = function(stm) {\n this._writeFieldSize(stm, 4);\n stm.setUint32(this.compression, true);\n};\n\nKdbxHeader.prototype._readMasterSeed = function(bytes) {\n this.masterSeed = bytes;\n};\n\nKdbxHeader.prototype._writeMasterSeed = function(stm) {\n this._writeFieldBytes(stm, this.masterSeed);\n};\n\nKdbxHeader.prototype._readTransformSeed = function(bytes) {\n this.transformSeed = bytes;\n};\n\nKdbxHeader.prototype._writeTransformSeed = function(stm) {\n this._writeFieldBytes(stm, this.transformSeed);\n};\n\nKdbxHeader.prototype._readTransformRounds = function(bytes) {\n this.keyEncryptionRounds = new BinaryStream(bytes).getUint64(true);\n};\n\nKdbxHeader.prototype._writeTransformRounds = function(stm) {\n this._writeFieldSize(stm, 8);\n stm.setUint64(this.keyEncryptionRounds, true);\n};\n\nKdbxHeader.prototype._readEncryptionIV = function(bytes) {\n this.encryptionIV = bytes;\n};\n\nKdbxHeader.prototype._writeEncryptionIV = function(stm) {\n this._writeFieldBytes(stm, this.encryptionIV);\n};\n\nKdbxHeader.prototype._readProtectedStreamKey = function(bytes) {\n this.protectedStreamKey = bytes;\n};\n\nKdbxHeader.prototype._writeProtectedStreamKey = function(stm) {\n this._writeFieldBytes(stm, this.protectedStreamKey);\n};\n\nKdbxHeader.prototype._readStreamStartBytes = function(bytes) {\n this.streamStartBytes = bytes;\n};\n\nKdbxHeader.prototype._writeStreamStartBytes = function(stm) {\n this._writeFieldBytes(stm, this.streamStartBytes);\n};\n\nKdbxHeader.prototype._readInnerRandomStreamID = function(bytes) {\n this.crsAlgorithm = new DataView(bytes).getUint32(bytes, true);\n};\n\nKdbxHeader.prototype._writeInnerRandomStreamID = function(stm) {\n this._writeFieldSize(stm, 4);\n stm.setUint32(this.crsAlgorithm, true);\n};\n\nKdbxHeader.prototype._readInnerRandomStreamKey = function(bytes) {\n this.protectedStreamKey = bytes;\n};\n\nKdbxHeader.prototype._writeInnerRandomStreamKey = function(stm) {\n this._writeFieldBytes(stm, this.protectedStreamKey);\n};\n\nKdbxHeader.prototype._readKdfParameters = function(bytes) {\n this.kdfParameters = VarDictionary.read(new BinaryStream(bytes));\n};\n\nKdbxHeader.prototype._writeKdfParameters = function(stm) {\n var innerStream = new BinaryStream();\n this.kdfParameters.write(innerStream);\n this._writeFieldBytes(stm, innerStream.getWrittenBytes());\n};\n\nKdbxHeader.prototype._readPublicCustomData = function(bytes) {\n this.publicCustomData = VarDictionary.read(new BinaryStream(bytes));\n};\n\nKdbxHeader.prototype._hasPublicCustomData = function() {\n return this.publicCustomData;\n};\n\nKdbxHeader.prototype._writePublicCustomData = function(stm) {\n if (this.publicCustomData) {\n var innerStream = new BinaryStream();\n this.publicCustomData.write(innerStream);\n this._writeFieldBytes(stm, innerStream.getWrittenBytes());\n }\n};\n\nKdbxHeader.prototype._readBinary = function(bytes, ctx) {\n var view = new DataView(bytes);\n var flags = view.getUint8(0);\n var isProtected = flags & HeaderConst.FlagBinaryProtected;\n var binaryData = bytes.slice(1); // Actual data comes after the flag byte\n\n var binary = isProtected ? ProtectedValue.fromBinary(binaryData) : binaryData;\n\n var binaryIndex = Object.keys(ctx.kdbx.binaries).length;\n ctx.kdbx.binaries[binaryIndex] = binary;\n};\n\nKdbxHeader.prototype._writeBinary = function(stm, ctx) {\n if (this.versionMajor < 4) {\n return;\n }\n var binaryHashes = ctx.kdbx.binaries.hashOrder;\n for (var index = 0; index < binaryHashes.length; index++) {\n stm.setUint8(HeaderConst.InnerHeaderBinaryFieldId);\n var binary = ctx.kdbx.binaries[binaryHashes[index]];\n if (!binary) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no binary ' + index);\n }\n if (binary instanceof ProtectedValue) {\n var binaryData = binary.getBinary();\n this._writeFieldSize(stm, binaryData.byteLength + 1);\n stm.setUint8(HeaderConst.FlagBinaryProtected);\n stm.writeBytes(binaryData);\n ByteUtils.zeroBuffer(binaryData);\n } else {\n binary = ByteUtils.arrayToBuffer(binary);\n this._writeFieldSize(stm, binary.byteLength + 1);\n stm.setUint8(0);\n stm.writeBytes(binary);\n }\n }\n};\n\nKdbxHeader.prototype._writeEndOfHeader = function(stm) {\n this._writeFieldSize(stm, 4);\n stm.setUint32(0x0d0ad0a);\n};\n\nKdbxHeader.prototype._readField = function(stm, fields, ctx) {\n var headerId = stm.getUint8();\n var size = this._readFieldSize(stm);\n var bytes;\n if (size > 0) {\n bytes = stm.readBytes(size);\n }\n\n var headerField = fields[headerId];\n if (headerField) {\n var method = this['_read' + headerField.name];\n if (method) {\n method.call(this, bytes, ctx);\n }\n }\n return headerId !== 0;\n};\n\nKdbxHeader.prototype._writeField = function(stm, headerId, fields, ctx) {\n var headerField = fields[headerId];\n if (headerField) {\n if (headerField.ver && headerField.ver.indexOf(this.versionMajor) < 0) {\n return;\n }\n var method = this['_write' + headerField.name];\n if (method) {\n var hasMethod = this['_has' + headerField.name];\n if (hasMethod && !hasMethod.call(this)) {\n return;\n }\n if (!headerField.skipHeader) {\n stm.setUint8(headerId);\n }\n method.call(this, stm, ctx);\n }\n }\n};\n\nKdbxHeader.prototype._readFieldSize = function(stm) {\n return this.versionMajor >= 4 ? stm.getUint32(true) : stm.getUint16(true);\n};\n\nKdbxHeader.prototype._writeFieldSize = function(stm, size) {\n if (this.versionMajor >= 4) {\n stm.setUint32(size, true);\n } else {\n stm.setUint16(size, true);\n }\n};\n\nKdbxHeader.prototype._writeFieldBytes = function(stm, bytes) {\n this._writeFieldSize(stm, bytes.byteLength);\n stm.writeBytes(bytes);\n};\n\nKdbxHeader.prototype._validate = function() {\n if (this.dataCipherUuid === undefined) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no cipher in header');\n }\n if (this.compression === undefined) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no compression in header');\n }\n if (!this.masterSeed) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no master seed in header');\n }\n if (this.versionMajor < 4 && !this.transformSeed) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no transform seed in header');\n }\n if (this.versionMajor < 4 && !this.keyEncryptionRounds) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no key encryption rounds in header');\n }\n if (!this.encryptionIV) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no encryption iv in header');\n }\n if (this.versionMajor < 4 && !this.protectedStreamKey) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no protected stream key in header');\n }\n if (this.versionMajor < 4 && !this.streamStartBytes) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no stream start bytes in header');\n }\n if (this.versionMajor < 4 && !this.crsAlgorithm) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no crs algorithm in header');\n }\n if (this.versionMajor >= 4 && !this.kdfParameters) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no kdf parameters in header');\n }\n};\n\nKdbxHeader.prototype._validateInner = function() {\n if (!this.protectedStreamKey) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no protected stream key in header');\n }\n if (!this.crsAlgorithm) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no crs algorithm in header');\n }\n};\n\nKdbxHeader.prototype._createKdfParameters = function(algo) {\n if (!algo) {\n algo = HeaderConst.DefaultKdfAlgo;\n }\n switch (algo) {\n case Consts.KdfId.Argon2:\n this.kdfParameters = new VarDictionary();\n this.kdfParameters.set('$UUID', VarDictionary.ValueType.Bytes, ByteUtils.base64ToBytes(Consts.KdfId.Argon2));\n this.kdfParameters.set('S', VarDictionary.ValueType.Bytes, Random.getBytes(HeaderConst.DefaultKdfSaltLength));\n this.kdfParameters.set('P', VarDictionary.ValueType.UInt32, HeaderConst.DefaultKdfParallelism);\n this.kdfParameters.set('I', VarDictionary.ValueType.UInt64, new Int64(HeaderConst.DefaultKdfIterations));\n this.kdfParameters.set('M', VarDictionary.ValueType.UInt64, new Int64(HeaderConst.DefaultKdfMemory));\n this.kdfParameters.set('V', VarDictionary.ValueType.UInt32, HeaderConst.DefaultKdfVersion);\n break;\n case Consts.KdfId.Aes:\n this.kdfParameters = new VarDictionary();\n this.kdfParameters.set('$UUID', VarDictionary.ValueType.Bytes, ByteUtils.base64ToBytes(Consts.KdfId.Aes));\n this.kdfParameters.set('S', VarDictionary.ValueType.Bytes, Random.getBytes(HeaderConst.DefaultKdfSaltLength));\n this.kdfParameters.set('R', VarDictionary.ValueType.UInt32, Consts.Defaults.KeyEncryptionRounds);\n break;\n default:\n throw new KdbxError(Consts.ErrorCodes.InvalidArg, 'bad KDF algo');\n }\n};\n\n/**\n * Saves header to stream\n * @param {BinaryStream} stm\n */\nKdbxHeader.prototype.write = function(stm) {\n this._validate();\n this._writeSignature(stm);\n this._writeVersion(stm);\n for (var id = 1; id < HeaderFields.length; id++) {\n this._writeField(stm, id, HeaderFields);\n }\n this._writeField(stm, 0, HeaderFields);\n this.endPos = stm.pos;\n};\n\n/**\n * Saves inner header to stream\n * @param {BinaryStream} stm\n * @param {KdbxContext} ctx\n */\nKdbxHeader.prototype.writeInnerHeader = function(stm, ctx) {\n this._validateInner();\n for (var id = 1; id < InnerHeaderFields.length; id++) {\n this._writeField(stm, id, InnerHeaderFields, ctx);\n }\n this._writeField(stm, 0, InnerHeaderFields);\n};\n\n/**\n * Updates header random salts\n */\nKdbxHeader.prototype.generateSalts = function() {\n this.masterSeed = Random.getBytes(32);\n if (this.versionMajor < 4) {\n this.transformSeed = Random.getBytes(32);\n this.streamStartBytes = Random.getBytes(32);\n this.protectedStreamKey = Random.getBytes(32);\n this.encryptionIV = Random.getBytes(16);\n } else {\n this.protectedStreamKey = Random.getBytes(64);\n this.kdfParameters.set('S', VarDictionary.ValueType.Bytes, Random.getBytes(32));\n var ivLength = this.dataCipherUuid.toString() === Consts.CipherId.ChaCha20 ? 12 : 16;\n this.encryptionIV = Random.getBytes(ivLength);\n }\n};\n\n/**\n * Upgrade the header to the specified version\n * @param {Number} version - major file version\n */\nKdbxHeader.prototype.setVersion = function(version) {\n if (version !== 3 && version !== 4) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg, 'bad file version');\n }\n this.versionMajor = version;\n this.versionMinor = LastMinorVersions[version];\n if (this.versionMajor === 4) {\n if (!this.kdfParameters) {\n this._createKdfParameters();\n }\n this.crsAlgorithm = Consts.CrsAlgorithm.ChaCha20;\n this.keyEncryptionRounds = undefined;\n } else {\n this.kdfParameters = undefined;\n this.crsAlgorithm = Consts.CrsAlgorithm.Salsa20;\n this.keyEncryptionRounds = Consts.Defaults.KeyEncryptionRounds;\n }\n};\n\n/**\n * Set file KDF\n * @param kdf - KDF ID, from Consts.KdfId\n */\nKdbxHeader.prototype.setKdf = function(kdf) {\n this._createKdfParameters(kdf);\n};\n\n/**\n * Read header from stream\n * @param {BinaryStream} stm\n * @param {KdbxContext} ctx\n * @return {KdbxHeader}\n * @static\n */\nKdbxHeader.read = function(stm, ctx) {\n var header = new KdbxHeader();\n header._readSignature(stm);\n header._readVersion(stm);\n while (header._readField(stm, HeaderFields, ctx)) {\n continue;\n }\n header.endPos = stm.pos;\n header._validate();\n return header;\n};\n\n/**\n * Reads inner header from stream\n * @param {BinaryStream} stm\n * @param {KdbxContext} ctx\n */\nKdbxHeader.prototype.readInnerHeader = function(stm, ctx) {\n while (this._readField(stm, InnerHeaderFields, ctx)) {\n continue;\n }\n this._validateInner();\n};\n\n/**\n * Creates new header\n * @param {Kdbx} kdbx\n * @return {KdbxHeader}\n * @static\n */\nKdbxHeader.create = function() {\n var header = new KdbxHeader();\n header.versionMajor = HeaderConst.DefaultFileVersionMajor;\n header.versionMinor = HeaderConst.DefaultFileVersionMinor;\n header.dataCipherUuid = new KdbxUuid(Consts.CipherId.Aes);\n header.compression = Consts.CompressionAlgorithm.GZip;\n header.keyEncryptionRounds = Consts.Defaults.KeyEncryptionRounds;\n header.crsAlgorithm = Consts.CrsAlgorithm.Salsa20;\n return header;\n};\n\nKdbxHeader.MaxFileVersion = HeaderConst.MaxFileVersionMajor;\n\nmodule.exports = KdbxHeader;\n","'use strict';\n\n// code from this gist: https://gist.github.com/dchest/4582374 (no license declared)\n\nfunction Salsa20(key, nonce) {\n // Constants.\n this.rounds = 20; // number of Salsa rounds\n this.sigmaWords = [0x61707865, 0x3320646e, 0x79622d32, 0x6b206574];\n\n // State.\n this.keyWords = []; // key words\n this.nonceWords = [0, 0]; // nonce words\n this.counterWords = [0, 0]; // block counter words\n\n // Output buffer.\n this.block = []; // output block of 64 bytes\n this.blockUsed = 64; // number of block bytes used\n\n this.setKey(key);\n this.setNonce(nonce);\n}\n\n// setKey sets the key to the given 32-byte array.\nSalsa20.prototype.setKey = function(key) {\n for (var i = 0, j = 0; i < 8; i++, j += 4) {\n this.keyWords[i] = (key[j] & 0xff) |\n ((key[j+1] & 0xff)<<8) |\n ((key[j+2] & 0xff)<<16) |\n ((key[j+3] & 0xff)<<24);\n }\n this._reset();\n};\n\n// setNonce sets the nonce to the given 8-byte array.\nSalsa20.prototype.setNonce = function(nonce) {\n this.nonceWords[0] = (nonce[0] & 0xff) |\n ((nonce[1] & 0xff)<<8) |\n ((nonce[2] & 0xff)<<16) |\n ((nonce[3] & 0xff)<<24);\n this.nonceWords[1] = (nonce[4] & 0xff) |\n ((nonce[5] & 0xff)<<8) |\n ((nonce[6] & 0xff)<<16) |\n ((nonce[7] & 0xff)<<24);\n this._reset();\n};\n\n// getBytes returns the next numberOfBytes bytes of stream.\nSalsa20.prototype.getBytes = function(numberOfBytes) {\n var out = new Uint8Array(numberOfBytes);\n for (var i = 0; i < numberOfBytes; i++) {\n if (this.blockUsed === 64) {\n this._generateBlock();\n this._incrementCounter();\n this.blockUsed = 0;\n }\n out[i] = this.block[this.blockUsed];\n this.blockUsed++;\n }\n return out;\n};\n\nSalsa20.prototype.getHexString = function(numberOfBytes) {\n var hex=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];\n var out = [];\n var bytes = this.getBytes(numberOfBytes);\n for(var i = 0; i < bytes.length; i++) {\n out.push(hex[(bytes[i] >> 4) & 15]);\n out.push(hex[bytes[i] & 15]);\n }\n return out.join('');\n};\n\n// Private methods.\n\nSalsa20.prototype._reset = function() {\n this.counterWords[0] = 0;\n this.counterWords[1] = 0;\n this.blockUsed = 64;\n};\n\n// _incrementCounter increments block counter.\nSalsa20.prototype._incrementCounter = function() {\n // Note: maximum 2^64 blocks.\n this.counterWords[0] = (this.counterWords[0] + 1) & 0xffffffff;\n if (this.counterWords[0] === 0) {\n this.counterWords[1] = (this.counterWords[1] + 1) & 0xffffffff;\n }\n};\n\n// _generateBlock generates 64 bytes from key, nonce, and counter,\n// and puts the result into this.block.\nSalsa20.prototype._generateBlock = function() {\n var j0 = this.sigmaWords[0],\n j1 = this.keyWords[0],\n j2 = this.keyWords[1],\n j3 = this.keyWords[2],\n j4 = this.keyWords[3],\n j5 = this.sigmaWords[1],\n j6 = this.nonceWords[0],\n j7 = this.nonceWords[1],\n j8 = this.counterWords[0],\n j9 = this.counterWords[1],\n j10 = this.sigmaWords[2],\n j11 = this.keyWords[4],\n j12 = this.keyWords[5],\n j13 = this.keyWords[6],\n j14 = this.keyWords[7],\n j15 = this.sigmaWords[3];\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15;\n\n var u;\n\n for (var i = 0; i < this.rounds; i += 2) {\n u = x0 + x12;\n x4 ^= (u<<7) | (u>>>(32-7));\n u = x4 + x0;\n x8 ^= (u<<9) | (u>>>(32-9));\n u = x8 + x4;\n x12 ^= (u<<13) | (u>>>(32-13));\n u = x12 + x8;\n x0 ^= (u<<18) | (u>>>(32-18));\n\n u = x5 + x1;\n x9 ^= (u<<7) | (u>>>(32-7));\n u = x9 + x5;\n x13 ^= (u<<9) | (u>>>(32-9));\n u = x13 + x9;\n x1 ^= (u<<13) | (u>>>(32-13));\n u = x1 + x13;\n x5 ^= (u<<18) | (u>>>(32-18));\n\n u = x10 + x6;\n x14 ^= (u<<7) | (u>>>(32-7));\n u = x14 + x10;\n x2 ^= (u<<9) | (u>>>(32-9));\n u = x2 + x14;\n x6 ^= (u<<13) | (u>>>(32-13));\n u = x6 + x2;\n x10 ^= (u<<18) | (u>>>(32-18));\n\n u = x15 + x11;\n x3 ^= (u<<7) | (u>>>(32-7));\n u = x3 + x15;\n x7 ^= (u<<9) | (u>>>(32-9));\n u = x7 + x3;\n x11 ^= (u<<13) | (u>>>(32-13));\n u = x11 + x7;\n x15 ^= (u<<18) | (u>>>(32-18));\n\n u = x0 + x3;\n x1 ^= (u<<7) | (u>>>(32-7));\n u = x1 + x0;\n x2 ^= (u<<9) | (u>>>(32-9));\n u = x2 + x1;\n x3 ^= (u<<13) | (u>>>(32-13));\n u = x3 + x2;\n x0 ^= (u<<18) | (u>>>(32-18));\n\n u = x5 + x4;\n x6 ^= (u<<7) | (u>>>(32-7));\n u = x6 + x5;\n x7 ^= (u<<9) | (u>>>(32-9));\n u = x7 + x6;\n x4 ^= (u<<13) | (u>>>(32-13));\n u = x4 + x7;\n x5 ^= (u<<18) | (u>>>(32-18));\n\n u = x10 + x9;\n x11 ^= (u<<7) | (u>>>(32-7));\n u = x11 + x10;\n x8 ^= (u<<9) | (u>>>(32-9));\n u = x8 + x11;\n x9 ^= (u<<13) | (u>>>(32-13));\n u = x9 + x8;\n x10 ^= (u<<18) | (u>>>(32-18));\n\n u = x15 + x14;\n x12 ^= (u<<7) | (u>>>(32-7));\n u = x12 + x15;\n x13 ^= (u<<9) | (u>>>(32-9));\n u = x13 + x12;\n x14 ^= (u<<13) | (u>>>(32-13));\n u = x14 + x13;\n x15 ^= (u<<18) | (u>>>(32-18));\n }\n\n x0 += j0;\n x1 += j1;\n x2 += j2;\n x3 += j3;\n x4 += j4;\n x5 += j5;\n x6 += j6;\n x7 += j7;\n x8 += j8;\n x9 += j9;\n x10 += j10;\n x11 += j11;\n x12 += j12;\n x13 += j13;\n x14 += j14;\n x15 += j15;\n\n this.block[ 0] = ( x0 >>> 0) & 0xff; this.block[ 1] = ( x0 >>> 8) & 0xff;\n this.block[ 2] = ( x0 >>> 16) & 0xff; this.block[ 3] = ( x0 >>> 24) & 0xff;\n this.block[ 4] = ( x1 >>> 0) & 0xff; this.block[ 5] = ( x1 >>> 8) & 0xff;\n this.block[ 6] = ( x1 >>> 16) & 0xff; this.block[ 7] = ( x1 >>> 24) & 0xff;\n this.block[ 8] = ( x2 >>> 0) & 0xff; this.block[ 9] = ( x2 >>> 8) & 0xff;\n this.block[10] = ( x2 >>> 16) & 0xff; this.block[11] = ( x2 >>> 24) & 0xff;\n this.block[12] = ( x3 >>> 0) & 0xff; this.block[13] = ( x3 >>> 8) & 0xff;\n this.block[14] = ( x3 >>> 16) & 0xff; this.block[15] = ( x3 >>> 24) & 0xff;\n this.block[16] = ( x4 >>> 0) & 0xff; this.block[17] = ( x4 >>> 8) & 0xff;\n this.block[18] = ( x4 >>> 16) & 0xff; this.block[19] = ( x4 >>> 24) & 0xff;\n this.block[20] = ( x5 >>> 0) & 0xff; this.block[21] = ( x5 >>> 8) & 0xff;\n this.block[22] = ( x5 >>> 16) & 0xff; this.block[23] = ( x5 >>> 24) & 0xff;\n this.block[24] = ( x6 >>> 0) & 0xff; this.block[25] = ( x6 >>> 8) & 0xff;\n this.block[26] = ( x6 >>> 16) & 0xff; this.block[27] = ( x6 >>> 24) & 0xff;\n this.block[28] = ( x7 >>> 0) & 0xff; this.block[29] = ( x7 >>> 8) & 0xff;\n this.block[30] = ( x7 >>> 16) & 0xff; this.block[31] = ( x7 >>> 24) & 0xff;\n this.block[32] = ( x8 >>> 0) & 0xff; this.block[33] = ( x8 >>> 8) & 0xff;\n this.block[34] = ( x8 >>> 16) & 0xff; this.block[35] = ( x8 >>> 24) & 0xff;\n this.block[36] = ( x9 >>> 0) & 0xff; this.block[37] = ( x9 >>> 8) & 0xff;\n this.block[38] = ( x9 >>> 16) & 0xff; this.block[39] = ( x9 >>> 24) & 0xff;\n this.block[40] = (x10 >>> 0) & 0xff; this.block[41] = (x10 >>> 8) & 0xff;\n this.block[42] = (x10 >>> 16) & 0xff; this.block[43] = (x10 >>> 24) & 0xff;\n this.block[44] = (x11 >>> 0) & 0xff; this.block[45] = (x11 >>> 8) & 0xff;\n this.block[46] = (x11 >>> 16) & 0xff; this.block[47] = (x11 >>> 24) & 0xff;\n this.block[48] = (x12 >>> 0) & 0xff; this.block[49] = (x12 >>> 8) & 0xff;\n this.block[50] = (x12 >>> 16) & 0xff; this.block[51] = (x12 >>> 24) & 0xff;\n this.block[52] = (x13 >>> 0) & 0xff; this.block[53] = (x13 >>> 8) & 0xff;\n this.block[54] = (x13 >>> 16) & 0xff; this.block[55] = (x13 >>> 24) & 0xff;\n this.block[56] = (x14 >>> 0) & 0xff; this.block[57] = (x14 >>> 8) & 0xff;\n this.block[58] = (x14 >>> 16) & 0xff; this.block[59] = (x14 >>> 24) & 0xff;\n this.block[60] = (x15 >>> 0) & 0xff; this.block[61] = (x15 >>> 8) & 0xff;\n this.block[62] = (x15 >>> 16) & 0xff; this.block[63] = (x15 >>> 24) & 0xff;\n};\n\nmodule.exports = Salsa20;\n","'use strict';\n\nfunction ChaCha20(key, nonce) {\n this.sigmaWords = [0x61707865, 0x3320646e, 0x79622d32, 0x6b206574];\n this.block = new Uint8Array(64);\n this.blockUsed = 64;\n this.x = new Uint32Array(16);\n\n var input = new Uint32Array(16);\n\n input[0] = this.sigmaWords[0];\n input[1] = this.sigmaWords[1];\n input[2] = this.sigmaWords[2];\n input[3] = this.sigmaWords[3];\n input[4] = u8to32le(key, 0);\n input[5] = u8to32le(key, 4);\n input[6] = u8to32le(key, 8);\n input[7] = u8to32le(key, 12);\n input[8] = u8to32le(key, 16);\n input[9] = u8to32le(key, 20);\n input[10] = u8to32le(key, 24);\n input[11] = u8to32le(key, 28);\n input[12] = 0; // counter\n\n if (nonce.length === 12) {\n input[13] = u8to32le(nonce, 0);\n input[14] = u8to32le(nonce, 4);\n input[15] = u8to32le(nonce, 8);\n } else {\n input[13] = 0;\n input[14] = u8to32le(nonce, 0);\n input[15] = u8to32le(nonce, 4);\n }\n\n this.input = input;\n}\n\nChaCha20.prototype.getBytes = function(numberOfBytes) {\n var out = new Uint8Array(numberOfBytes);\n for (var i = 0; i < numberOfBytes; i++) {\n if (this.blockUsed === 64) {\n this._generateBlock();\n this.blockUsed = 0;\n }\n out[i] = this.block[this.blockUsed];\n this.blockUsed++;\n }\n return out;\n};\n\nChaCha20.prototype._generateBlock = function() {\n var input = this.input;\n var x = this.x;\n var block = this.block;\n var i;\n\n x.set(input);\n for (i = 20; i > 0; i -= 2) {\n quarterRound(x, 0, 4, 8, 12);\n quarterRound(x, 1, 5, 9, 13);\n quarterRound(x, 2, 6, 10, 14);\n quarterRound(x, 3, 7, 11, 15);\n quarterRound(x, 0, 5, 10, 15);\n quarterRound(x, 1, 6, 11, 12);\n quarterRound(x, 2, 7, 8, 13);\n quarterRound(x, 3, 4, 9, 14);\n }\n for (i = 16; i--;) {\n x[i] += input[i];\n }\n for (i = 16; i--;) {\n u32to8le(block, 4 * i, x[i]);\n }\n\n input[12] += 1;\n if (!input[12]) {\n input[13] += 1;\n }\n};\n\nChaCha20.prototype.encrypt = function(data) {\n var length = data.length;\n var res = new Uint8Array(length);\n var pos = 0;\n var block = this.block;\n while (pos < length) {\n this._generateBlock();\n var blockLength = Math.min(length - pos, 64);\n for (var i = 0; i < blockLength; i++) {\n res[pos] = data[pos] ^ block[i];\n pos++;\n }\n }\n return res;\n};\n\nfunction quarterRound(x, a, b, c, d) {\n x[a] += x[b];\n x[d] = rotate(x[d] ^ x[a], 16);\n x[c] += x[d];\n x[b] = rotate(x[b] ^ x[c], 12);\n x[a] += x[b];\n x[d] = rotate(x[d] ^ x[a], 8);\n x[c] += x[d];\n x[b] = rotate(x[b] ^ x[c], 7);\n}\n\nfunction u8to32le(x, i) {\n return x[i] | (x[i + 1] << 8) | (x[i + 2] << 16) | (x[i + 3] << 24);\n}\n\nfunction u32to8le(x, i, u) {\n x[i] = u;\n u >>>= 8;\n x[i + 1] = u;\n u >>>= 8;\n x[i + 2] = u;\n u >>>= 8;\n x[i + 3] = u;\n}\n\nfunction rotate(v, c) {\n return (v << c) | (v >>> (32 - c));\n}\n\nmodule.exports = ChaCha20;\n","'use strict';\n\nvar ByteUtils = require('./../utils/byte-utils'),\n CryptoEngine = require('./crypto-engine');\n\nvar maxRoundsPreIteration = 10000;\nvar aesBlockSize = 16;\nvar credentialSize = 32;\n\n/*\nIn order to simulate multiple rounds of ECB encryption, we do CBC encryption\nacross a zero buffer of large length with the IV being the desired plaintext.\nThe zero buffer does not contribute to the xor, so xoring the previous block\nwith the next one simulates running ECB multiple times. We limit the maximum\nsize of the zero buffer to prevent enormous memory usage.\n*/\n\nfunction encrypt(credentials, key, rounds) {\n var algo = CryptoEngine.createAesCbc();\n return algo.importKey(ByteUtils.arrayToBuffer(key))\n .then(function() {\n var resolvers = [];\n for (var idx = 0; idx < credentialSize; idx += aesBlockSize) {\n resolvers.push(encryptBlock(algo,\n credentials.subarray(idx, idx + aesBlockSize), rounds));\n }\n return Promise.all(resolvers);\n })\n .then(function(results) {\n var res = new Uint8Array(credentialSize);\n results.forEach(function (result, idx) {\n var base = idx * aesBlockSize;\n for (var i = 0; i < aesBlockSize; ++i) {\n res[i + base] = result[i];\n }\n ByteUtils.zeroBuffer(result);\n });\n return res;\n });\n}\n\nfunction encryptBlock(algo, iv, rounds) {\n var result = Promise.resolve(ByteUtils.arrayToBuffer(iv));\n var buffer = new Uint8Array(aesBlockSize * Math.min(rounds, maxRoundsPreIteration));\n\n while (rounds > 0) {\n var currentRounds = Math.min(rounds, maxRoundsPreIteration);\n rounds -= currentRounds;\n\n var dataLen = aesBlockSize * currentRounds;\n var zeroData = buffer.length === dataLen ? buffer.buffer : ByteUtils.arrayToBuffer(buffer.subarray(0, dataLen));\n result = encryptBlockBuffer(algo, result, zeroData);\n }\n\n return result.then(function(res) { return new Uint8Array(res); });\n}\n\nfunction encryptBlockBuffer(algo, promisedIv, buffer) {\n return promisedIv\n .then(function(iv) {\n return algo.encrypt(buffer, iv);\n })\n .then(function(buf) {\n var res = ByteUtils.arrayToBuffer(new Uint8Array(buf).subarray(-2 * aesBlockSize, -aesBlockSize));\n ByteUtils.zeroBuffer(buf);\n return res;\n });\n}\n\nmodule.exports.encrypt = encrypt;\n","'use strict';\n\nvar ProtectedValue = require('../crypto/protected-value'),\n KdbxError = require('../errors/kdbx-error'),\n Consts = require('../defs/consts'),\n ByteUtils = require('../utils/byte-utils'),\n XmlUtils = require('../utils/xml-utils'),\n Random = require('../crypto/random'),\n CryptoEngine = require('../crypto/crypto-engine');\n\n/**\n * Credentials\n * @param {ProtectedValue} password\n * @param {String|ArrayBuffer|Uint8Array} [keyFile]\n * @constructor\n */\nvar KdbxCredentials = function(password, keyFile) {\n var that = this;\n this.ready = Promise.all([\n this.setPassword(password),\n this.setKeyFile(keyFile)\n ]).then(function() {\n return that;\n });\n};\n\n/**\n * Set password\n * @param {ProtectedValue|null} password\n */\nKdbxCredentials.prototype.setPassword = function(password) {\n if (password === null) {\n this.passwordHash = null;\n } else if (!(password instanceof ProtectedValue)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'password'));\n } else {\n var that = this;\n return password.getHash().then(function(hash) {\n that.passwordHash = ProtectedValue.fromBinary(hash);\n });\n }\n return Promise.resolve();\n};\n\n/**\n * Set keyfile\n * @param {ArrayBuffer|Uint8Array} [keyFile]\n */\nKdbxCredentials.prototype.setKeyFile = function(keyFile) {\n if (keyFile && !(keyFile instanceof ArrayBuffer) && !(keyFile instanceof Uint8Array)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'keyFile'));\n }\n if (keyFile) {\n if (keyFile.byteLength === 32) {\n this.keyFileHash = ProtectedValue.fromBinary(ByteUtils.arrayToBuffer(keyFile));\n return Promise.resolve();\n }\n try {\n var keyFileStr;\n keyFileStr = ByteUtils.bytesToString(ByteUtils.arrayToBuffer(keyFile));\n if (keyFileStr.match(/^[a-f\\d]{64}$/i)) {\n var bytes = ByteUtils.hexToBytes(keyFileStr);\n this.keyFileHash = ProtectedValue.fromBinary(bytes);\n return;\n }\n var xml = XmlUtils.parse(keyFileStr.trim());\n var keyEl = XmlUtils.getChildNode(xml.documentElement, 'Key');\n var dataEl = XmlUtils.getChildNode(keyEl, 'Data');\n this.keyFileHash = ProtectedValue.fromBinary(ByteUtils.base64ToBytes(dataEl.textContent));\n } catch (e) {\n var that = this;\n return CryptoEngine.sha256(keyFile).then(function(hash) {\n that.keyFileHash = ProtectedValue.fromBinary(hash);\n });\n }\n } else {\n this.keyFileHash = null;\n }\n return Promise.resolve();\n};\n\n/**\n * Get credentials hash\n * @returns {Promise.}\n */\nKdbxCredentials.prototype.getHash = function() {\n var that = this;\n return this.ready.then(function() {\n var buffers = [];\n if (that.passwordHash) {\n buffers.push(that.passwordHash.getBinary());\n }\n if (that.keyFileHash) {\n buffers.push(that.keyFileHash.getBinary());\n }\n var totalLength = buffers.reduce(function (acc, buf) {\n return acc + buf.byteLength;\n }, 0);\n var allBytes = new Uint8Array(totalLength);\n var offset = 0;\n buffers.forEach(function (buffer) {\n allBytes.set(buffer, offset);\n ByteUtils.zeroBuffer(buffer);\n offset += buffer.length;\n });\n return CryptoEngine.sha256(ByteUtils.arrayToBuffer(allBytes)).then(function (hash) {\n ByteUtils.zeroBuffer(allBytes);\n return hash;\n });\n });\n};\n\n/**\n * Creates random keyfile\n * @returns {Uint8Array}\n */\nKdbxCredentials.createRandomKeyFile = function() {\n var keyLength = 32;\n var keyBytes = Random.getBytes(keyLength),\n salt = Random.getBytes(keyLength);\n for (var i = 0; i < keyLength; i++) {\n keyBytes[i] ^= salt[i];\n keyBytes[i] ^= (Math.random() * 1000 % 255);\n }\n var key = ByteUtils.bytesToBase64(keyBytes);\n return KdbxCredentials.createKeyFileWithHash(key);\n};\n\n/**\n * Creates keyfile by given hash\n * @param {string} hash base64-encoded hash\n * @returns {Uint8Array}\n */\nKdbxCredentials.createKeyFileWithHash = function(hash) {\n var xml = '\\n' +\n '\\n' +\n ' \\n' +\n ' 1.00\\n' +\n ' \\n' +\n ' \\n' +\n ' ' + hash + '\\n' +\n ' \\n' +\n '';\n return ByteUtils.stringToBytes(xml);\n};\n\nmodule.exports = KdbxCredentials;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils');\n\n/**\n * Kdbx times\n * @constructor\n */\nvar KdbxTimes = function() {\n this.creationTime = undefined;\n this.lastModTime = undefined;\n this.lastAccessTime = undefined;\n this.expiryTime = undefined;\n this.expires = undefined;\n this.usageCount = undefined;\n this.locationChanged = new Date();\n Object.preventExtensions(this);\n};\n\nKdbxTimes.prototype._readNode = function(node) {\n switch (node.tagName) {\n case XmlNames.Elem.CreationTime:\n this.creationTime = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.LastModTime:\n this.lastModTime = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.LastAccessTime:\n this.lastAccessTime = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.ExpiryTime:\n this.expiryTime = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.Expires:\n this.expires = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.UsageCount:\n this.usageCount = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.LocationChanged:\n this.locationChanged = XmlUtils.getDate(node);\n break;\n }\n};\n\n/**\n * Clones object\n * @returns {KdbxTimes}\n */\nKdbxTimes.prototype.clone = function() {\n var clone = new KdbxTimes();\n clone.creationTime = this.creationTime;\n clone.lastModTime = this.lastModTime;\n clone.lastAccessTime = this.lastAccessTime;\n clone.expiryTime = this.expiryTime;\n clone.expires = this.expires;\n clone.usageCount = this.usageCount;\n clone.locationChanged = this.locationChanged;\n return clone;\n};\n\nKdbxTimes.prototype.update = function() {\n var now = new Date();\n this.lastModTime = now;\n this.lastAccessTime = now;\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxTimes.prototype.write = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Times);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.CreationTime), this.creationTime);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.LastModTime), this.lastModTime);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.LastAccessTime), this.lastAccessTime);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.ExpiryTime), this.expiryTime);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.Expires), this.expires);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.UsageCount), this.usageCount);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.LocationChanged), this.locationChanged);\n};\n\n/**\n * Creates new times\n * @return {KdbxTimes}\n */\nKdbxTimes.create = function() {\n var times = new KdbxTimes();\n var now = new Date();\n times.creationTime = now;\n times.lastModTime = now;\n times.lastAccessTime = now;\n times.expiryTime = now;\n times.expires = false;\n times.usageCount = 0;\n times.locationChanged = now;\n return times;\n};\n\n/**\n * Read times from xml\n * @param {Node} xmlNode\n * @return {KdbxTimes}\n */\nKdbxTimes.read = function(xmlNode) {\n var obj = new KdbxTimes();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n obj._readNode(childNode);\n }\n }\n return obj;\n};\n\nmodule.exports = KdbxTimes;\n","'use strict';\n\nvar ProtectedValue = require('../crypto/protected-value'),\n XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils'),\n Consts = require('../defs/consts'),\n KdbxCustomData = require('./kdbx-custom-data'),\n KdbxUuid = require('./kdbx-uuid'),\n KdbxTimes = require('./kdbx-times');\n\nvar tagsSplitRegex = /\\s*[;,:]\\s*/;\n\n/**\n * Entry\n * @constructor\n */\nvar KdbxEntry = function() {\n this.uuid = undefined;\n this.icon = undefined;\n this.customIcon = undefined;\n this.fgColor = undefined;\n this.bgColor = undefined;\n this.overrideUrl = undefined;\n this.tags = [];\n this.times = new KdbxTimes();\n this.fields = {};\n this.binaries = {};\n this.autoType = {\n enabled: true, obfuscation: undefined, defaultSequence: undefined, items: []\n };\n this.history = [];\n this.parentGroup = undefined;\n this.customData = undefined;\n this._editState = undefined;\n Object.preventExtensions(this);\n};\n\nKdbxEntry.prototype._readNode = function(node, ctx) {\n switch (node.tagName) {\n case XmlNames.Elem.Uuid:\n this.uuid = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.Icon:\n this.icon = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.CustomIconID:\n this.customIcon = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.FgColor:\n this.fgColor = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.BgColor:\n this.bgColor = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.OverrideUrl:\n this.overrideUrl = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.Tags:\n this.tags = this._stringToTags(XmlUtils.getText(node));\n break;\n case XmlNames.Elem.Times:\n this.times = KdbxTimes.read(node);\n break;\n case XmlNames.Elem.String:\n this._readField(node);\n break;\n case XmlNames.Elem.Binary:\n this._readBinary(node, ctx);\n break;\n case XmlNames.Elem.AutoType:\n this._readAutoType(node);\n break;\n case XmlNames.Elem.History:\n this._readHistory(node, ctx);\n break;\n case XmlNames.Elem.CustomData:\n this._readCustomData(node);\n break;\n }\n};\n\nKdbxEntry.prototype._readField = function(node) {\n var keyNode = XmlUtils.getChildNode(node, XmlNames.Elem.Key),\n valueNode = XmlUtils.getChildNode(node, XmlNames.Elem.Value),\n key = XmlUtils.getText(keyNode),\n value = XmlUtils.getProtectedText(valueNode);\n if (key) {\n this.fields[key] = value;\n }\n};\n\nKdbxEntry.prototype._writeFields = function(parentNode) {\n var fields = this.fields;\n Object.keys(fields).forEach(function(field) {\n var value = fields[field];\n if (value !== undefined && value !== null) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.String);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Key), field);\n XmlUtils.setProtectedText(XmlUtils.addChildNode(node, XmlNames.Elem.Value), value);\n }\n });\n};\n\nKdbxEntry.prototype._readBinary = function(node, ctx) {\n var keyNode = XmlUtils.getChildNode(node, XmlNames.Elem.Key),\n valueNode = XmlUtils.getChildNode(node, XmlNames.Elem.Value),\n key = XmlUtils.getText(keyNode),\n value = XmlUtils.getProtectedBinary(valueNode);\n if (key && value) {\n if (value.ref) {\n value.ref = ctx.kdbx.binaries.idToHash[value.ref];\n if (value.ref) {\n value.value = ctx.kdbx.binaries[value.ref];\n } else {\n value = null;\n }\n }\n if (value) {\n this.binaries[key] = value;\n }\n }\n};\n\nKdbxEntry.prototype._writeBinaries = function(parentNode, ctx) {\n var binaries = this.binaries;\n Object.keys(binaries).forEach(function(id) {\n var data = binaries[id];\n if (data) {\n if (data.ref) {\n var index = ctx.kdbx.binaries.hashOrder.indexOf(data.ref);\n if (index < 0) {\n return;\n }\n data = { ref: index.toString() };\n }\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Binary);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Key), id);\n XmlUtils.setProtectedBinary(XmlUtils.addChildNode(node, XmlNames.Elem.Value), data);\n }\n });\n};\n\nKdbxEntry.prototype._stringToTags = function(str) {\n if (!str) {\n return [];\n }\n return str.split(tagsSplitRegex).filter(function(s) { return s; });\n};\n\nKdbxEntry.prototype._readAutoType = function(node) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.AutoTypeEnabled:\n this.autoType.enabled = XmlUtils.getBoolean(childNode);\n if (typeof this.autoType.enabled !== 'boolean') {\n this.autoType.enabled = true;\n }\n break;\n case XmlNames.Elem.AutoTypeObfuscation:\n this.autoType.obfuscation = XmlUtils.getNumber(childNode);\n break;\n case XmlNames.Elem.AutoTypeDefaultSeq:\n this.autoType.defaultSequence = XmlUtils.getText(childNode);\n break;\n case XmlNames.Elem.AutoTypeItem:\n this._readAutoTypeItem(childNode);\n break;\n }\n }\n};\n\nKdbxEntry.prototype._readAutoTypeItem = function(node) {\n var item = {};\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.Window:\n item.window = XmlUtils.getText(childNode);\n break;\n case XmlNames.Elem.KeystrokeSequence:\n item.keystrokeSequence = XmlUtils.getText(childNode);\n break;\n }\n }\n this.autoType.items.push(item);\n};\n\nKdbxEntry.prototype._writeAutoType = function(parentNode) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.AutoType);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.AutoTypeEnabled), this.autoType.enabled);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.AutoTypeObfuscation), this.autoType.obfuscation);\n if (this.autoType.defaultSequence) {\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.AutoTypeDefaultSeq), this.autoType.defaultSequence);\n }\n for (var i = 0; i < this.autoType.items.length; i++) {\n var item = this.autoType.items[i];\n var itemNode = XmlUtils.addChildNode(node, XmlNames.Elem.AutoTypeItem);\n XmlUtils.setText(XmlUtils.addChildNode(itemNode, XmlNames.Elem.Window), item.window);\n XmlUtils.setText(XmlUtils.addChildNode(itemNode, XmlNames.Elem.KeystrokeSequence), item.keystrokeSequence);\n }\n};\n\nKdbxEntry.prototype._readHistory = function(node, ctx) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.Entry:\n this.history.push(KdbxEntry.read(childNode, ctx));\n break;\n }\n }\n};\n\nKdbxEntry.prototype._writeHistory = function(parentNode, ctx) {\n var historyNode = XmlUtils.addChildNode(parentNode, XmlNames.Elem.History);\n for (var i = 0; i < this.history.length; i++) {\n this.history[i].write(historyNode, ctx);\n }\n};\n\nKdbxEntry.prototype._readCustomData = function(node) {\n this.customData = KdbxCustomData.read(node);\n};\n\nKdbxEntry.prototype._writeCustomData = function(parentNode) {\n KdbxCustomData.write(parentNode, this.customData);\n};\n\nKdbxEntry.prototype._setField = function(name, str, secure) {\n this.fields[name] = secure ? ProtectedValue.fromString(str) : str;\n};\n\nKdbxEntry.prototype._addHistoryTombstone = function(isAdded, dt) {\n if (!this._editState) {\n this._editState = { added: [], deleted: [] };\n }\n this._editState[isAdded ? 'added' : 'deleted'].push(dt.getTime());\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxEntry.prototype.write = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Entry);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.Uuid), this.uuid);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.Icon), this.icon);\n if (this.customIcon) {\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.CustomIconID), this.customIcon);\n }\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.FgColor), this.fgColor);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.BgColor), this.bgColor);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.OverrideUrl), this.overrideUrl);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Tags), this.tags.join(','));\n this.times.write(node, ctx);\n this._writeFields(node);\n this._writeBinaries(node, ctx);\n this._writeAutoType(node);\n this._writeCustomData(node);\n if (parentNode.tagName !== XmlNames.Elem.History) {\n this._writeHistory(node, ctx);\n }\n};\n\n/**\n * Push current entry state to the top of history\n */\nKdbxEntry.prototype.pushHistory = function() {\n var historyEntry = new KdbxEntry();\n historyEntry.copyFrom(this);\n this.history.push(historyEntry);\n this._addHistoryTombstone(true, historyEntry.times.lastModTime);\n};\n\n/**\n * Remove some entry history states at index\n * @param {number} index - history state start index\n * @param {number} [count=1] - deleted states count\n */\nKdbxEntry.prototype.removeHistory = function(index, count) {\n if (count === undefined) {\n count = 1;\n }\n for (var ix = index; ix < index + count; ix++) {\n if (ix < this.history.length) {\n this._addHistoryTombstone(false, this.history[ix].times.lastModTime);\n }\n }\n this.history.splice(index, count);\n};\n\n/**\n * Clone entry state from another entry, or history entry\n */\nKdbxEntry.prototype.copyFrom = function(entry) {\n this.uuid = entry.uuid;\n this.icon = entry.icon;\n this.customIcon = entry.customIcon;\n this.fgColor = entry.fgColor;\n this.bgColor = entry.bgColor;\n this.overrideUrl = entry.overrideUrl;\n this.tags = entry.tags.slice();\n this.times = entry.times.clone();\n this.fields = {};\n Object.keys(entry.fields).forEach(function(name) {\n if (entry.fields[name] instanceof ProtectedValue) {\n this.fields[name] = entry.fields[name].clone();\n } else {\n this.fields[name] = entry.fields[name];\n }\n }, this);\n this.binaries = {};\n Object.keys(entry.binaries).forEach(function(name) {\n if (entry.binaries[name] instanceof ProtectedValue) {\n this.binaries[name] = entry.binaries[name].clone();\n } else if (entry.binaries[name] && entry.binaries[name].ref) {\n this.binaries[name] = { ref: entry.binaries[name].ref };\n if (entry.binaries[name].value) {\n this.binaries[name].value = entry.binaries[name].value;\n }\n } else {\n this.binaries[name] = entry.binaries[name];\n }\n }, this);\n this.autoType = JSON.parse(JSON.stringify(entry.autoType));\n};\n\n/**\n * Merge entry with remote entry\n * @param {{objects, remote, deleted}} objectMap\n */\nKdbxEntry.prototype.merge = function(objectMap) {\n var remoteEntry = objectMap.remote[this.uuid];\n if (!remoteEntry) {\n return;\n }\n var remoteHistory = remoteEntry.history.slice();\n if (this.times.lastModTime < remoteEntry.times.lastModTime) {\n // remote is more new; push current state to history and update\n this.pushHistory();\n this.copyFrom(remoteEntry);\n } else if (this.times.lastModTime > remoteEntry.times.lastModTime) {\n // local is more new; if remote state is not in history, push it\n var existsInHistory = this.history.some(function(historyEntry) {\n return +historyEntry.times.lastModTime === +remoteEntry.times.lastModTime;\n });\n if (!existsInHistory) {\n var historyEntry = new KdbxEntry();\n historyEntry.copyFrom(remoteEntry);\n remoteHistory.push(historyEntry);\n }\n }\n this.history = this._mergeHistory(remoteHistory, remoteEntry.times.lastModTime);\n};\n\n/**\n * Merge entry history with remote entry history\n * Tombstones are stored locally and must be immediately discarded by replica after successful upstream push.\n * It's client responsibility, to save and load tombstones for local replica, and to clear them after successful upstream push.\n *\n * Implements remove-win OR-set CRDT with local tombstones stored in _editState.\n *\n * Format doesn't allow saving tombstones for history entries, so they are stored locally.\n * Any unmodified state from past or modifications of current state synced with central upstream will be successfully merged.\n * Assumes there's only one central upstream, may produce inconsistencies while merging outdated replica outside main upstream.\n * Phantom entries and phantom deletions will appear if remote replica checked out an old state and has just added a new state.\n * If a client is using central upstream for sync, the remote replica must first sync it state and\n * only after it update the upstream, so this should never happen.\n *\n * References:\n *\n * An Optimized Conflict-free Replicated Set arXiv:1210.3368 [cs.DC]\n * http://arxiv.org/abs/1210.3368\n *\n * Gene T. J. Wuu and Arthur J. Bernstein. Efficient solutions to the replicated log and dictionary\n * problems. In Symp. on Principles of Dist. Comp. (PODC), pages 233–242, Vancouver, BC, Canada, August 1984.\n * https://pages.lip6.fr/Marc.Shapiro/papers/RR-7687.pdf\n *\n * @param {KdbxEntry[]} remoteHistory - history records from remote entry\n * @param {Date} remoteLastModTime - last mod time for remote entry\n * @returns {KdbxEntry[]} - new history\n * @private\n */\nKdbxEntry.prototype._mergeHistory = function(remoteHistory, remoteLastModTime) {\n // we can skip sorting but the history may not have been sorted\n this.history.sort(function(x, y) { return x.times.lastModTime - y.times.lastModTime; });\n remoteHistory.sort(function(x, y) { return x.times.lastModTime - y.times.lastModTime; });\n var historyMap = {}, remoteHistoryMap = {};\n this.history.forEach(function(record) { historyMap[record.times.lastModTime.getTime()] = record; });\n remoteHistory.forEach(function(record) { remoteHistoryMap[record.times.lastModTime.getTime()] = record; });\n var historyIx = 0, remoteHistoryIx = 0;\n var newHistory = [];\n while (historyIx < this.history.length || remoteHistoryIx < remoteHistory.length) {\n var historyEntry = this.history[historyIx],\n remoteHistoryEntry = remoteHistory[remoteHistoryIx],\n entryTime = historyEntry && historyEntry.times.lastModTime.getTime(),\n remoteEntryTime = remoteHistoryEntry && remoteHistoryEntry.times.lastModTime.getTime();\n if (entryTime === remoteEntryTime) {\n // exists in local and remote\n newHistory.push(historyEntry);\n historyIx++;\n remoteHistoryIx++;\n continue;\n }\n if (!historyEntry || entryTime > remoteEntryTime) {\n // local is absent\n if (!this._editState || this._editState.deleted.indexOf(remoteEntryTime) < 0) {\n // added remotely\n var remoteHistoryEntryClone = new KdbxEntry();\n remoteHistoryEntryClone.copyFrom(remoteHistoryEntry);\n newHistory.push(remoteHistoryEntryClone);\n } // else: deleted locally\n remoteHistoryIx++;\n continue;\n }\n // (!remoteHistoryEntry || entryTime < remoteEntryTime) && historyEntry\n // remote is absent\n if (this._editState && this._editState.added.indexOf(entryTime) >= 0) {\n // added locally\n newHistory.push(historyEntry);\n } else if (entryTime > remoteLastModTime) {\n // outdated replica history has ended\n newHistory.push(historyEntry);\n } // else: deleted remotely\n historyIx++;\n }\n return newHistory;\n};\n\n/**\n * Creates new entry\n * @param {KdbxMeta} meta - db metadata\n * @param {KdbxGroup} parentGroup - parent group\n * @returns {KdbxEntry}\n */\nKdbxEntry.create = function(meta, parentGroup) {\n var entry = new KdbxEntry(parentGroup);\n entry.uuid = KdbxUuid.random();\n entry.icon = Consts.Icons.Key;\n entry.times = KdbxTimes.create();\n entry.parentGroup = parentGroup;\n entry._setField('Title', '', meta.memoryProtection.title);\n entry._setField('UserName', meta.defaultUser || '', meta.memoryProtection.userName);\n entry._setField('Password', '', meta.memoryProtection.password);\n entry._setField('URL', '', meta.memoryProtection.url);\n entry._setField('Notes', '', meta.memoryProtection.notes);\n entry.autoType.enabled = typeof parentGroup.enableAutoType === 'boolean' ? parentGroup.enableAutoType : true;\n entry.autoType.obfuscation = Consts.AutoTypeObfuscationOptions.None;\n return entry;\n};\n\n/**\n * Read entry from xml\n * @param {Node} xmlNode\n * @param {KdbxContext} ctx\n * @param {KdbxGroup} [parentGroup]\n * @return {KdbxEntry}\n */\nKdbxEntry.read = function(xmlNode, ctx, parentGroup) {\n var entry = new KdbxEntry();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n entry._readNode(childNode, ctx);\n }\n }\n entry.parentGroup = parentGroup;\n return entry;\n};\n\nmodule.exports = KdbxEntry;\n","module.exports.Kdbx = require('./format/kdbx');\nmodule.exports.KdbxUuid = require('./format/kdbx-uuid');\nmodule.exports.KdbxError = require('./errors/kdbx-error');\nmodule.exports.Credentials = require('./format/kdbx-credentials');\nmodule.exports.Consts = require('./defs/consts');\nmodule.exports.ProtectedValue = require('./crypto/protected-value');\nmodule.exports.ByteUtils = require('./utils/byte-utils');\nmodule.exports.VarDictionary = require('./utils/var-dictionary');\nmodule.exports.Int64 = require('./utils/int64');\nmodule.exports.Random = require('./crypto/random');\nmodule.exports.CryptoEngine = require('./crypto/crypto-engine');\n","'use strict';\n\nvar\n KdbxFormat = require('./kdbx-format'),\n KdbxError = require('./../errors/kdbx-error'),\n KdbxCredentials = require('./kdbx-credentials'),\n KdbxHeader = require('./kdbx-header'),\n KdbxMeta = require('./kdbx-meta'),\n KdbxBinaries = require('./kdbx-binaries'),\n KdbxGroup = require('./kdbx-group'),\n KdbxEntry = require('./kdbx-entry'),\n KdbxDeletedObject = require('./kdbx-deleted-object'),\n KdbxUuid = require('./kdbx-uuid'),\n Consts = require('./../defs/consts'),\n XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils');\n\n/**\n * Kdbx file (KeePass database v2)\n * @constructor\n */\nvar Kdbx = function() {\n this.header = undefined;\n this.credentials = undefined;\n this.meta = undefined;\n this.xml = undefined;\n this.binaries = new KdbxBinaries();\n this.groups = [];\n this.deletedObjects = [];\n Object.preventExtensions(this);\n};\n\n/**\n * Creates new database\n * @return {Kdbx}\n */\nKdbx.create = function(credentials, name) {\n if (!(credentials instanceof KdbxCredentials)) {\n throw new KdbxError(Consts.ErrorCodes.InvalidArg, 'credentials');\n }\n var kdbx = new Kdbx();\n kdbx.credentials = credentials;\n kdbx.header = KdbxHeader.create();\n kdbx.meta = KdbxMeta.create();\n kdbx.meta._name = name;\n kdbx.createDefaultGroup();\n kdbx.createRecycleBin();\n kdbx.meta._lastSelectedGroup = kdbx.getDefaultGroup().id;\n kdbx.meta._lastTopVisibleGroup = kdbx.getDefaultGroup().id;\n return kdbx;\n};\n\n/**\n * Load kdbx file\n * If there was an error loading file, throws an exception\n * @param {ArrayBuffer} data - database file contents\n * @param {KdbxCredentials} credentials\n * @return {Promise.}\n */\nKdbx.load = function(data, credentials) {\n if (!(data instanceof ArrayBuffer)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'data'));\n }\n if (!(credentials instanceof KdbxCredentials)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'credentials'));\n }\n var kdbx = new Kdbx();\n kdbx.credentials = credentials;\n var format = new KdbxFormat(kdbx);\n return format.load(data);\n};\n\n/**\n * Import database from xml file\n * If there was an error loading xml file, throws an exception\n * @param {String} data - xml file contents\n * @param {KdbxCredentials} credentials\n * @return {Promise.}\n */\nKdbx.loadXml = function(data, credentials) {\n if ((typeof data !== 'string')) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'data'));\n }\n if (!(credentials instanceof KdbxCredentials)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.InvalidArg, 'credentials'));\n }\n var kdbx = new Kdbx();\n kdbx.credentials = credentials;\n var format = new KdbxFormat(kdbx);\n return format.loadXml(data);\n};\n\n/**\n * Save db to ArrayBuffer\n * @return {Promise.}\n */\nKdbx.prototype.save = function() {\n var format = new KdbxFormat(this);\n return format.save();\n};\n\n/**\n * Save db to XML\n * @param {boolean} [prettyPrint=false] - pretty print XML\n * @return {Promise.}\n */\nKdbx.prototype.saveXml = function(prettyPrint) {\n var format = new KdbxFormat(this);\n return format.saveXml(prettyPrint);\n};\n\n/**\n * Creates default group, if it's not yet created\n */\nKdbx.prototype.createDefaultGroup = function() {\n if (this.groups.length) {\n return;\n }\n var defaultGroup = KdbxGroup.create(this.meta.name);\n defaultGroup.icon = Consts.Icons.FolderOpen;\n defaultGroup.expanded = true;\n this.groups.push(defaultGroup);\n};\n\n/**\n * Creates recycle bin, if it's not yet created\n */\nKdbx.prototype.createRecycleBin = function() {\n this.meta.recycleBinEnabled = true;\n if (this.meta.recycleBinUuid && this.getGroup(this.meta.recycleBinUuid)) {\n return;\n }\n var defGrp = this.getDefaultGroup();\n var recycleBin = KdbxGroup.create(Consts.Defaults.RecycleBinName, defGrp);\n recycleBin.icon = Consts.Icons.TrashBin;\n recycleBin.enableAutoType = false;\n recycleBin.enableSearching = false;\n this.meta.recycleBinUuid = recycleBin.uuid;\n defGrp.groups.push(recycleBin);\n};\n\n/**\n * Adds new group to group\n * @param {string} name - new group name\n * @param {KdbxGroup} group - parent group\n * @return {KdbxGroup}\n */\nKdbx.prototype.createGroup = function(group, name) {\n var subGroup = KdbxGroup.create(name, group);\n group.groups.push(subGroup);\n return subGroup;\n};\n\n/**\n * Adds new entry to group\n * @param {KdbxGroup} group - parent group\n * @return {KdbxEntry}\n */\nKdbx.prototype.createEntry = function(group) {\n var entry = KdbxEntry.create(this.meta, group);\n group.entries.push(entry);\n return entry;\n};\n\n/**\n * Gets default group\n * @return {KdbxGroup}\n */\nKdbx.prototype.getDefaultGroup = function() {\n return this.groups[0];\n};\n\n/**\n * Get group by uuid\n * @param {KdbxUuid|string} uuid\n * @param {KdbxGroup} [parentGroup]\n * @return {KdbxGroup|undefined}\n */\nKdbx.prototype.getGroup = function(uuid, parentGroup) {\n var groups = parentGroup ? parentGroup.groups : this.groups;\n for (var i = 0; i < groups.length; i++) {\n if (groups[i].uuid.id === uuid.id) {\n return groups[i];\n }\n var res = this.getGroup(uuid, groups[i]);\n if (res) {\n return res;\n }\n }\n};\n\n/**\n * Move object from one group to another\n * @param {KdbxEntry|KdbxGroup} object - object to be moved\n * @param {KdbxGroup} toGroup - target parent group\n * @param {Number} [atIndex] - index in target group (by default, insert to the end of the group)\n */\nKdbx.prototype.move = function(object, toGroup, atIndex) {\n var containerProp = object instanceof KdbxGroup ? 'groups' : 'entries';\n var fromContainer = object.parentGroup[containerProp];\n var ix = fromContainer.indexOf(object);\n if (ix < 0) {\n return;\n }\n fromContainer.splice(ix, 1);\n if (toGroup) {\n if (typeof atIndex === 'number' && atIndex >= 0) {\n toGroup[containerProp].splice(atIndex, 0, object);\n } else {\n toGroup[containerProp].push(object);\n }\n } else {\n var now = new Date();\n if (object instanceof KdbxGroup) {\n object.forEach(function (group, entry) {\n this.addDeletedObject((group || entry).uuid, now);\n }, this);\n } else {\n this.addDeletedObject(object.uuid, now);\n }\n }\n object.parentGroup = toGroup;\n object.times.locationChanged = new Date();\n};\n\n/**\n * Adds deleted object\n * @param {KdbxUuid} uuid - object uuid\n * @param {Date} dt - deletion date\n */\nKdbx.prototype.addDeletedObject = function(uuid, dt) {\n var deletedObject = new KdbxDeletedObject();\n deletedObject.uuid = uuid;\n deletedObject.deletionTime = dt;\n this.deletedObjects.push(deletedObject);\n};\n\n/**\n * Delete entry or group\n * Depending on settings, removes either to trash, or completely\n * @param {KdbxEntry|KdbxGroup} object - object to be deleted\n */\nKdbx.prototype.remove = function(object) {\n var toGroup = null;\n if (this.meta.recycleBinEnabled) {\n this.createRecycleBin();\n toGroup = this.getGroup(this.meta.recycleBinUuid);\n }\n this.move(object, toGroup);\n};\n\n/**\n * Creates a binary in the db and returns a reference to it\n * @param {ProtectedValue|ArrayBuffer} value\n * @return {Promise}\n */\nKdbx.prototype.createBinary = function(value) {\n return this.binaries.add(value);\n};\n\n/**\n * Import entry from another file\n * It's up to caller to decide what should happen to the original entry in the source file\n * @param {KdbxEntry} entry - entry to be imported\n * @param {KdbxGroup} group - target parent group\n * @param {Kdbx} file - the source file containing the group\n */\nKdbx.prototype.importEntry = function(entry, group, file) {\n var newEntry = new KdbxEntry();\n var uuid = KdbxUuid.random();\n\n newEntry.copyFrom(entry);\n newEntry.uuid = uuid;\n entry.history.forEach(function(historyEntry) {\n var newHistoryEntry = new KdbxEntry();\n newHistoryEntry.copyFrom(historyEntry);\n newHistoryEntry.uuid = uuid;\n newEntry.history.push(newHistoryEntry);\n });\n\n var binaries = {};\n var customIcons = {};\n newEntry.history.concat(newEntry).forEach(function(e) {\n if (e.customIcon) {\n customIcons[e.customIcon] = e.customIcon;\n }\n Object.values(e.binaries).forEach(function(binary) {\n if (binary.ref) {\n binaries[binary.ref] = binary;\n }\n });\n });\n\n Object.values(binaries).forEach(function(binary) {\n var fileBinary = file.binaries[binary.ref];\n if (fileBinary && !this.binaries[binary.ref]) {\n this.binaries[binary.ref] = fileBinary;\n }\n }, this);\n\n Object.values(customIcons).forEach(function(customIconId) {\n var customIcon = file.meta.customIcons[customIconId];\n if (customIcon) {\n this.meta.customIcons[customIconId] = customIcon;\n }\n }, this);\n\n group.entries.push(newEntry);\n\n newEntry.parentGroup = group;\n newEntry.times.update();\n\n return newEntry;\n};\n\n/**\n * Perform database cleanup\n * @param {object} settings - cleanup settings\n * @param {boolean} [settings.historyRules=false] - remove extra history, it it doesn't match defined rules, e.g. records number\n * @param {boolean} [settings.customIcons=false] - remove unused custom icons\n * @param {boolean} [settings.binaries=false] - remove unused binaries\n */\nKdbx.prototype.cleanup = function(settings) {\n var now = new Date();\n var historyMaxItems = settings && settings.historyRules && this.meta.historyMaxItems && this.meta.historyMaxItems > 0 ?\n this.meta.historyMaxItems : Infinity;\n var usedCustomIcons = {};\n var usedBinaries = {};\n var processEntry = function(entry) {\n if (entry && entry.customIcon) {\n usedCustomIcons[entry.customIcon] = true;\n }\n if (entry && entry.binaries) {\n Object.keys(entry.binaries).forEach(function(key) {\n if (entry.binaries[key] && entry.binaries[key].ref) {\n usedBinaries[entry.binaries[key].ref] = true;\n }\n });\n }\n };\n this.getDefaultGroup().forEach(function (entry, group) {\n if (entry && entry.history.length > historyMaxItems) {\n entry.removeHistory(0, entry.history.length - historyMaxItems);\n }\n if (entry) {\n processEntry(entry);\n }\n if (entry && entry.history) {\n entry.history.forEach(function(historyEntry) {\n processEntry(historyEntry);\n });\n }\n if (group && group.customIcon) {\n usedCustomIcons[group.customIcon] = true;\n }\n });\n if (settings && settings.customIcons) {\n Object.keys(this.meta.customIcons).forEach(function(customIcon) {\n if (!usedCustomIcons[customIcon]) {\n var uuid = new KdbxUuid(customIcon);\n this.addDeletedObject(uuid, now);\n delete this.meta.customIcons[customIcon];\n }\n }, this);\n }\n if (settings && settings.binaries) {\n Object.keys(this.binaries).forEach(function(bin) {\n if (!usedBinaries[bin]) {\n delete this.binaries[bin];\n }\n }, this);\n }\n};\n\n/**\n * Merge db with another db\n * Some parts of remote DB are copied by reference, so it should NOT be modified after merge\n * Suggested use case:\n * - open local db\n * - get remote db somehow and open in\n * - merge remote into local: local.merge(remote)\n * - close remote db\n * @param {Kdbx} remote - database to merge in\n */\nKdbx.prototype.merge = function(remote) {\n var root = this.getDefaultGroup();\n var remoteRoot = remote.getDefaultGroup();\n if (!root || !remoteRoot) {\n throw new KdbxError(Consts.ErrorCodes.MergeError, 'no default group');\n }\n if (!root.uuid.equals(remoteRoot.uuid)) {\n throw new KdbxError(Consts.ErrorCodes.MergeError, 'default group is different');\n }\n var objectMap = this._getObjectMap();\n remote.deletedObjects.forEach(function(rem) {\n if (!objectMap.deleted[rem.uuid]) {\n this.deletedObjects.push(rem);\n objectMap.deleted[rem.uuid] = rem.deletionTime;\n }\n }, this);\n Object.keys(remote.binaries).forEach(function(key) {\n if (!this.binaries[key] && !objectMap.deleted[key]) {\n this.binaries[key] = remote.binaries[key];\n }\n }, this);\n objectMap.remote = remote._getObjectMap().objects;\n this.meta.merge(remote.meta, objectMap);\n root.merge(objectMap);\n this.cleanup({ historyRules: true, customIcons: true, binaries: true });\n};\n\n/**\n * Gets editing state tombstones (for successful merge)\n * Replica must save this state with the db, assign in on db open and call removeLocalEditState on successful upstream push\n * This state is JSON serializable\n */\nKdbx.prototype.getLocalEditState = function() {\n var editingState = {};\n this.getDefaultGroup().forEach(function(entry) {\n if (entry && entry._editState) {\n editingState[entry.uuid] = entry._editState;\n }\n });\n if (this.meta._editState) {\n editingState.meta = this.meta._editState;\n }\n return editingState;\n};\n\n/**\n * Sets editing state tombstones returned previously by getLocalEditState\n * Replica must call this method on db open with state returned previously on getLocalEditState\n * @param editingState - result of getLocalEditState invoked before db save\n */\nKdbx.prototype.setLocalEditState = function(editingState) {\n this.getDefaultGroup().forEach(function(entry) {\n if (entry && editingState[entry.uuid]) {\n entry._editState = editingState[entry.uuid];\n }\n });\n if (editingState.meta) {\n this.meta._editState = editingState.meta;\n }\n};\n\n/**\n * Removes editing state tombstones\n * Immediately after successful upstream push replica must:\n * - call this method\n * - discard previous state obtained by getLocalEditState call\n */\nKdbx.prototype.removeLocalEditState = function() {\n this.getDefaultGroup().forEach(function(entry) {\n if (entry) {\n entry._editState = undefined;\n }\n });\n this.meta._editState = undefined;\n};\n\n/**\n * Upgrade the file to latest version\n */\nKdbx.prototype.upgrade = function() {\n this.setVersion(KdbxHeader.MaxFileVersion);\n};\n\n/**\n * Set file version to a specified number\n * @param {Number} version - 3 or 4\n */\nKdbx.prototype.setVersion = function(version) {\n this.meta.headerHash = null;\n this.meta.settingsChanged = new Date();\n this.header.setVersion(version);\n};\n\n/**\n * Set file key derivation function\n * @param {String} kdf - KDF id, from Consts.KdfId\n */\nKdbx.prototype.setKdf = function(kdf) {\n this.meta.headerHash = null;\n this.meta.settingsChanged = new Date();\n this.header.setKdf(kdf);\n};\n\nKdbx.prototype._getObjectMap = function() {\n var objects = {}, deleted = {};\n this.getDefaultGroup().forEach(function(entry, group) {\n var object = entry || group;\n if (objects[object.uuid]) {\n throw new KdbxError(Consts.ErrorCodes.MergeError, 'Duplicate: ' + object.uuid);\n }\n objects[object.uuid] = object;\n });\n this.deletedObjects.forEach(function(deletedObject) {\n deleted[deletedObject.uuid] = deletedObject.deletionTime;\n });\n return { objects: objects, deleted: deleted };\n};\n\nKdbx.prototype._loadFromXml = function(ctx) {\n var doc = this.xml.documentElement;\n if (doc.tagName !== XmlNames.Elem.DocNode) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml root');\n }\n this._parseMeta(ctx);\n var that = this;\n return this.binaries.hash().then(function() {\n that._parseRoot(ctx);\n return that;\n });\n};\n\nKdbx.prototype._parseMeta = function(ctx) {\n var node = XmlUtils.getChildNode(this.xml.documentElement, XmlNames.Elem.Meta, 'no meta node');\n this.meta = KdbxMeta.read(node, ctx);\n};\n\nKdbx.prototype._parseRoot = function(ctx) {\n this.groups = [];\n this.deletedObjects = [];\n var node = XmlUtils.getChildNode(this.xml.documentElement, XmlNames.Elem.Root, 'no root node');\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.Group:\n this._readGroup(childNode, ctx);\n break;\n case XmlNames.Elem.DeletedObjects:\n this._readDeletedObjects(childNode);\n break;\n }\n }\n};\n\nKdbx.prototype._readDeletedObjects = function(node) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.DeletedObject:\n this.deletedObjects.push(KdbxDeletedObject.read(childNode));\n break;\n }\n }\n};\n\nKdbx.prototype._readGroup = function(node, ctx) {\n this.groups.push(KdbxGroup.read(node, ctx));\n};\n\nKdbx.prototype._buildXml = function(ctx) {\n var xml = XmlUtils.create(XmlNames.Elem.DocNode);\n this.meta.write(xml.documentElement, ctx);\n var rootNode = XmlUtils.addChildNode(xml.documentElement, XmlNames.Elem.Root);\n this.groups.forEach(function(g) { g.write(rootNode, ctx); }, this);\n var delObjNode = XmlUtils.addChildNode(rootNode, XmlNames.Elem.DeletedObjects);\n this.deletedObjects.forEach(function (d) { d.write(delObjNode, ctx); }, this);\n this.xml = xml;\n};\n\nmodule.exports = Kdbx;\n","'use strict';\r\n\r\nvar pako = require('pako'),\r\n\r\n KdbxError = require('../errors/kdbx-error'),\r\n KdbxHeader = require('./kdbx-header'),\r\n KdbxContext = require('./kdbx-context'),\r\n\r\n CryptoEngine = require('../crypto/crypto-engine'),\r\n BinaryStream = require('../utils/binary-stream'),\r\n ByteUtils = require('../utils/byte-utils'),\r\n XmlUtils = require('../utils/xml-utils'),\r\n Int64 = require('../utils/int64'),\r\n Consts = require('../defs/consts'),\r\n HashedBlockTransform = require('../crypto/hashed-block-transform'),\r\n HmacBlockTransform = require('../crypto/hmac-block-transform'),\r\n ProtectSaltGenerator = require('../crypto/protect-salt-generator'),\r\n KeyEncryptorAes = require('../crypto/key-encryptor-aes'),\r\n KeyEncryptorKdf = require('../crypto/key-encryptor-kdf');\r\n\r\nvar KdbxFormat = function(kdbx) {\r\n this.kdbx = kdbx;\r\n};\r\n\r\n/**\r\n * Load kdbx file\r\n * If there was an error loading file, throws an exception\r\n * @param {ArrayBuffer} data - database file contents\r\n * @returns {Promise.}\r\n */\r\nKdbxFormat.prototype.load = function(data) {\r\n var stm = new BinaryStream(data);\r\n var kdbx = this.kdbx;\r\n var that = this;\r\n that.ctx = new KdbxContext({ kdbx: kdbx });\r\n return kdbx.credentials.ready.then(function() {\r\n kdbx.header = KdbxHeader.read(stm, that.ctx);\r\n if (kdbx.header.versionMajor === 3) {\r\n return that._loadV3(stm);\r\n } else if (kdbx.header.versionMajor === 4) {\r\n return that._loadV4(stm);\r\n } else {\r\n throw new KdbxError(Consts.ErrorCodes.InvalidVersion, 'bad version: ' + kdbx.header.versionMajor);\r\n }\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._loadV3 = function(stm) {\r\n var kdbx = this.kdbx;\r\n var that = this;\r\n return that._decryptXmlV3(kdbx, stm).then(function(xmlStr) {\r\n kdbx.xml = XmlUtils.parse(xmlStr);\r\n return that._setProtectedValues().then(function() {\r\n return kdbx._loadFromXml(that.ctx).then(function() {\r\n return that._checkHeaderHashV3(stm).then(function () {\r\n return kdbx;\r\n });\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._loadV4 = function(stm) {\r\n var that = this;\r\n return that._getHeaderHash(stm).then(function(headerSha) {\r\n var expectedHeaderSha = stm.readBytes(headerSha.byteLength);\r\n if (!ByteUtils.arrayBufferEquals(expectedHeaderSha, headerSha)) {\r\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'header hash mismatch');\r\n }\r\n return that._computeKeysV4().then(function(keys) {\r\n return that._getHeaderHmac(stm, keys.hmacKey).then(function(headerHmac) {\r\n var expectedHeaderHmac = stm.readBytes(headerHmac.byteLength);\r\n if (!ByteUtils.arrayBufferEquals(expectedHeaderHmac, headerHmac)) {\r\n throw new KdbxError(Consts.ErrorCodes.InvalidKey);\r\n }\r\n return HmacBlockTransform.decrypt(stm.readBytesToEnd(), keys.hmacKey).then(function(data) {\r\n ByteUtils.zeroBuffer(keys.hmacKey);\r\n return that._decryptData(data, keys.cipherKey).then(function(data) {\r\n ByteUtils.zeroBuffer(keys.cipherKey);\r\n if (that.kdbx.header.compression === Consts.CompressionAlgorithm.GZip) {\r\n data = pako.ungzip(data);\r\n }\r\n stm = new BinaryStream(ByteUtils.arrayToBuffer(data));\r\n that.kdbx.header.readInnerHeader(stm, that.ctx);\r\n data = stm.readBytesToEnd();\r\n var xmlStr = ByteUtils.bytesToString(data);\r\n that.kdbx.xml = XmlUtils.parse(xmlStr);\r\n return that._setProtectedValues().then(function() {\r\n return that.kdbx._loadFromXml(that.ctx);\r\n });\r\n });\r\n });\r\n });\r\n });\r\n });\r\n};\r\n\r\n/**\r\n * Load XML file\r\n * @param {string} xmlStr\r\n * @returns {Promise.}\r\n */\r\nKdbxFormat.prototype.loadXml = function(xmlStr) {\r\n var kdbx = this.kdbx;\r\n var ctx = new KdbxContext({ kdbx: kdbx });\r\n return kdbx.credentials.ready.then(function() {\r\n kdbx.header = KdbxHeader.create();\r\n kdbx.xml = XmlUtils.parse(xmlStr);\r\n XmlUtils.protectPlainValues(kdbx.xml.documentElement);\r\n return kdbx._loadFromXml(ctx);\r\n });\r\n};\r\n\r\n/**\r\n * Save kdbx file\r\n * @returns {Promise.}\r\n */\r\nKdbxFormat.prototype.save = function() {\r\n var kdbx = this.kdbx;\r\n var that = this;\r\n that.ctx = new KdbxContext({ kdbx: kdbx });\r\n kdbx.binaries.assignIds();\r\n return kdbx.credentials.ready.then(function() {\r\n var stm = new BinaryStream();\r\n kdbx.header.generateSalts();\r\n kdbx.header.write(stm);\r\n if (kdbx.header.versionMajor === 3) {\r\n return that._saveV3(stm);\r\n } else if (kdbx.header.versionMajor === 4) {\r\n return that._saveV4(stm);\r\n } else {\r\n throw new KdbxError(Consts.ErrorCodes.InvalidVersion, 'bad version: ' + kdbx.header.versionMajor);\r\n }\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._saveV3 = function(stm) {\r\n var that = this;\r\n return that._getHeaderHash(stm).then(function(headerHash) {\r\n that.kdbx.meta.headerHash = headerHash;\r\n that.kdbx._buildXml(that.ctx);\r\n return that._getProtectSaltGenerator().then(function(gen) {\r\n XmlUtils.updateProtectedValuesSalt(that.kdbx.xml.documentElement, gen);\r\n return that._encryptXmlV3().then(function(data) {\r\n stm.writeBytes(data);\r\n return stm.getWrittenBytes();\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._saveV4 = function(stm) {\r\n var that = this;\r\n that.kdbx._buildXml(that.ctx);\r\n return that._getHeaderHash(stm).then(function(headerSha) {\r\n stm.writeBytes(headerSha);\r\n return that._computeKeysV4().then(function(keys) {\r\n return that._getHeaderHmac(stm, keys.hmacKey).then(function(headerHmac) {\r\n stm.writeBytes(headerHmac);\r\n return that._getProtectSaltGenerator().then(function(gen) {\r\n XmlUtils.updateProtectedValuesSalt(that.kdbx.xml.documentElement, gen);\r\n var xml = XmlUtils.serialize(that.kdbx.xml);\r\n var innerHeaderStm = new BinaryStream();\r\n that.kdbx.header.writeInnerHeader(innerHeaderStm, that.ctx);\r\n var innerHeaderData = innerHeaderStm.getWrittenBytes();\r\n var xmlData = ByteUtils.arrayToBuffer(ByteUtils.stringToBytes(xml));\r\n var data = new ArrayBuffer(innerHeaderData.byteLength + xmlData.byteLength);\r\n var dataArr = new Uint8Array(data);\r\n dataArr.set(new Uint8Array(innerHeaderData));\r\n dataArr.set(new Uint8Array(xmlData), innerHeaderData.byteLength);\r\n ByteUtils.zeroBuffer(xmlData);\r\n ByteUtils.zeroBuffer(innerHeaderData);\r\n if (that.kdbx.header.compression === Consts.CompressionAlgorithm.GZip) {\r\n data = pako.gzip(data);\r\n }\r\n return that._encryptData(ByteUtils.arrayToBuffer(data), keys.cipherKey).then(function(data) {\r\n ByteUtils.zeroBuffer(keys.cipherKey);\r\n return HmacBlockTransform.encrypt(data, keys.hmacKey).then(function(data) {\r\n ByteUtils.zeroBuffer(keys.hmacKey);\r\n stm.writeBytes(data);\r\n return stm.getWrittenBytes();\r\n });\r\n });\r\n });\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype.saveXml = function(prettyPrint) {\r\n var kdbx = this.kdbx;\r\n return kdbx.credentials.ready.then(function() {\r\n kdbx.header.generateSalts();\r\n var ctx = new KdbxContext({ kdbx: kdbx, exportXml: true });\r\n kdbx.binaries.assignIds();\r\n kdbx._buildXml(ctx);\r\n XmlUtils.unprotectValues(kdbx.xml.documentElement);\r\n var xml = XmlUtils.serialize(kdbx.xml, prettyPrint);\r\n XmlUtils.protectUnprotectedValues(kdbx.xml.documentElement);\r\n return xml;\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._decryptXmlV3 = function(kdbx, stm) {\r\n var data = stm.readBytesToEnd();\r\n var that = this;\r\n return that._getMasterKeyV3().then(function(masterKey) {\r\n return that._decryptData(data, masterKey).then(function(data) {\r\n ByteUtils.zeroBuffer(masterKey);\r\n data = that._trimStartBytesV3(data);\r\n return HashedBlockTransform.decrypt(data).then(function(data) {\r\n if (that.kdbx.header.compression === Consts.CompressionAlgorithm.GZip) {\r\n data = pako.ungzip(data);\r\n }\r\n return ByteUtils.bytesToString(data);\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._encryptXmlV3 = function() {\r\n var kdbx = this.kdbx;\r\n var that = this;\r\n var xml = XmlUtils.serialize(kdbx.xml);\r\n var data = ByteUtils.arrayToBuffer(ByteUtils.stringToBytes(xml));\r\n if (kdbx.header.compression === Consts.CompressionAlgorithm.GZip) {\r\n data = pako.gzip(data);\r\n }\r\n return HashedBlockTransform.encrypt(ByteUtils.arrayToBuffer(data)).then(function(data) {\r\n var ssb = new Uint8Array(kdbx.header.streamStartBytes);\r\n var newData = new Uint8Array(data.byteLength + ssb.length);\r\n newData.set(ssb);\r\n newData.set(new Uint8Array(data), ssb.length);\r\n data = newData;\r\n return that._getMasterKeyV3().then(function(masterKey) {\r\n return that._encryptData(ByteUtils.arrayToBuffer(data), masterKey).then(function(data) {\r\n ByteUtils.zeroBuffer(masterKey);\r\n return data;\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._getMasterKeyV3 = function() {\r\n var kdbx = this.kdbx;\r\n return kdbx.credentials.getHash().then(function(credHash) {\r\n var transformSeed = kdbx.header.transformSeed;\r\n var transformRounds = kdbx.header.keyEncryptionRounds;\r\n var masterSeed = kdbx.header.masterSeed;\r\n\r\n return KeyEncryptorAes.encrypt(new Uint8Array(credHash), transformSeed, transformRounds).then(function(encKey) {\r\n ByteUtils.zeroBuffer(credHash);\r\n return CryptoEngine.sha256(encKey).then(function(keyHash) {\r\n ByteUtils.zeroBuffer(encKey);\r\n var all = new Uint8Array(masterSeed.byteLength + keyHash.byteLength);\r\n all.set(new Uint8Array(masterSeed), 0);\r\n all.set(new Uint8Array(keyHash), masterSeed.byteLength);\r\n ByteUtils.zeroBuffer(keyHash);\r\n ByteUtils.zeroBuffer(masterSeed);\r\n return CryptoEngine.sha256(all.buffer).then(function(masterKey) {\r\n ByteUtils.zeroBuffer(all.buffer);\r\n return masterKey;\r\n });\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._trimStartBytesV3 = function(data) {\r\n var ssb = this.kdbx.header.streamStartBytes;\r\n if (data.byteLength < ssb.byteLength) {\r\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'short start bytes');\r\n }\r\n if (!ByteUtils.arrayBufferEquals(data.slice(0, this.kdbx.header.streamStartBytes.byteLength), ssb)) {\r\n throw new KdbxError(Consts.ErrorCodes.InvalidKey);\r\n }\r\n return data.slice(ssb.byteLength);\r\n};\r\n\r\nKdbxFormat.prototype._setProtectedValues = function() {\r\n var kdbx = this.kdbx;\r\n return this._getProtectSaltGenerator().then(function(gen) {\r\n XmlUtils.setProtectedValues(kdbx.xml.documentElement, gen);\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._getProtectSaltGenerator = function() {\r\n return ProtectSaltGenerator.create(this.kdbx.header.protectedStreamKey, this.kdbx.header.crsAlgorithm);\r\n};\r\n\r\nKdbxFormat.prototype._getHeaderHash = function(stm) {\r\n var src = stm.readBytesNoAdvance(0, this.kdbx.header.endPos);\r\n return CryptoEngine.sha256(src);\r\n};\r\n\r\nKdbxFormat.prototype._getHeaderHmac = function(stm, key) {\r\n var src = stm.readBytesNoAdvance(0, this.kdbx.header.endPos);\r\n return HmacBlockTransform.getHmacKey(key, new Int64(0xffffffff, 0xffffffff)).then(function(keySha) {\r\n return CryptoEngine.hmacSha256(keySha, src);\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._checkHeaderHashV3 = function(stm) {\r\n if (this.kdbx.meta.headerHash) {\r\n var metaHash = this.kdbx.meta.headerHash;\r\n return this._getHeaderHash(stm).then(function(actualHash) {\r\n if (!ByteUtils.arrayBufferEquals(metaHash, actualHash)) {\r\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'header hash mismatch');\r\n }\r\n });\r\n } else {\r\n return Promise.resolve();\r\n }\r\n};\r\n\r\nKdbxFormat.prototype._computeKeysV4 = function() {\r\n var that = this;\r\n var masterSeed = that.kdbx.header.masterSeed;\r\n if (!masterSeed || masterSeed.byteLength !== 32) {\r\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad master seed'));\r\n }\r\n var kdfParams = that.kdbx.header.kdfParameters;\r\n return that.kdbx.credentials.getHash().then(function(credHash) {\r\n return KeyEncryptorKdf.encrypt(credHash, kdfParams).then(function (encKey) {\r\n ByteUtils.zeroBuffer(credHash);\r\n if (!encKey || encKey.byteLength !== 32) {\r\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'bad derived key'));\r\n }\r\n var keyWithSeed = new Uint8Array(65);\r\n keyWithSeed.set(new Uint8Array(masterSeed), 0);\r\n keyWithSeed.set(new Uint8Array(encKey), masterSeed.byteLength);\r\n keyWithSeed[64] = 1;\r\n ByteUtils.zeroBuffer(encKey);\r\n ByteUtils.zeroBuffer(masterSeed);\r\n return Promise.all([\r\n CryptoEngine.sha256(keyWithSeed.buffer.slice(0, 64)),\r\n CryptoEngine.sha512(keyWithSeed.buffer)\r\n ]).then(function (keys) {\r\n ByteUtils.zeroBuffer(keyWithSeed);\r\n return { cipherKey: keys[0], hmacKey: keys[1] };\r\n });\r\n });\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._decryptData = function(data, cipherKey) {\r\n var cipherId = this.kdbx.header.dataCipherUuid;\r\n switch (cipherId.toString()) {\r\n case Consts.CipherId.Aes:\r\n return this._transformDataV4Aes(data, cipherKey, false);\r\n case Consts.CipherId.ChaCha20:\r\n return this._transformDataV4ChaCha20(data, cipherKey);\r\n default:\r\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'unsupported cipher'));\r\n }\r\n};\r\n\r\nKdbxFormat.prototype._encryptData = function(data, cipherKey) {\r\n var cipherId = this.kdbx.header.dataCipherUuid;\r\n switch (cipherId.toString()) {\r\n case Consts.CipherId.Aes:\r\n return this._transformDataV4Aes(data, cipherKey, true);\r\n case Consts.CipherId.ChaCha20:\r\n return this._transformDataV4ChaCha20(data, cipherKey);\r\n default:\r\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'unsupported cipher'));\r\n }\r\n};\r\n\r\nKdbxFormat.prototype._transformDataV4Aes = function(data, cipherKey, encrypt) {\r\n var that = this;\r\n var aesCbc = CryptoEngine.createAesCbc();\r\n return aesCbc.importKey(cipherKey).then(function() {\r\n return encrypt ?\r\n aesCbc.encrypt(data, that.kdbx.header.encryptionIV) :\r\n aesCbc.decrypt(data, that.kdbx.header.encryptionIV);\r\n });\r\n};\r\n\r\nKdbxFormat.prototype._transformDataV4ChaCha20 = function(data, cipherKey) {\r\n return CryptoEngine.chacha20(data, cipherKey, this.kdbx.header.encryptionIV);\r\n};\r\n\r\nmodule.exports = KdbxFormat;\r\n","'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH = 0;\nvar Z_FINISH = 4;\n\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_SYNC_FLUSH = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY = 0;\n\nvar Z_DEFLATED = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overriden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n * - `text` (Boolean) - true if compressed data believed to be text\n * - `time` (Number) - modification time, unix timestamp\n * - `os` (Number) - operation system code\n * - `extra` (Array) - array of bytes with extra data (max 65536)\n * - `name` (String) - file name (binary string)\n * - `comment` (String) - comment (binary string)\n * - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true); // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n if (!(this instanceof Deflate)) return new Deflate(options);\n\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n if (opt.raw && (opt.windowBits > 0)) {\n opt.windowBits = -opt.windowBits;\n }\n\n else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n opt.windowBits += 16;\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n\n if (opt.dictionary) {\n var dict;\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n // If we need to compress text, change encoding to utf8.\n dict = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n this._dict_set = true;\n }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n * converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var status, _mode;\n\n if (this.ended) { return false; }\n\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // If we need to compress text, change encoding to utf8.\n strm.input = strings.string2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_deflate.deflate(strm, _mode); /* no bad return value */\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n if (this.options.to === 'string') {\n this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n var deflator = new Deflate(options);\n\n deflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (deflator.err) { throw deflator.msg; }\n\n return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n","'use strict';\n\nvar utils = require('../utils/common');\nvar trees = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar msg = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\nvar Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\n//var Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\n//var Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\n//var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION = 0;\n//var Z_BEST_SPEED = 1;\n//var Z_BEST_COMPRESSION = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED = 1;\nvar Z_HUFFMAN_ONLY = 2;\nvar Z_RLE = 3;\nvar Z_FIXED = 4;\nvar Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY = 0;\n//var Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES = 30;\n/* number of distance codes */\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n strm.msg = msg[errorCode];\n return errorCode;\n}\n\nfunction rank(f) {\n return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n var s = strm.state;\n\n //_tr_flush_bits(s);\n var len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) { return; }\n\n utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n}\n\n\nfunction flush_block_only(s, last) {\n trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n// put_byte(s, (Byte)(b >> 8));\n// put_byte(s, (Byte)(b & 0xff));\n s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read. All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n var len = strm.avail_in;\n\n if (len > size) { len = size; }\n if (len === 0) { return 0; }\n\n strm.avail_in -= len;\n\n // zmemcpy(buf, strm->next_in, len);\n utils.arraySet(buf, strm.input, strm.next_in, len, start);\n if (strm.state.wrap === 1) {\n strm.adler = adler32(strm.adler, buf, len, start);\n }\n\n else if (strm.state.wrap === 2) {\n strm.adler = crc32(strm.adler, buf, len, start);\n }\n\n strm.next_in += len;\n strm.total_in += len;\n\n return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n var chain_length = s.max_chain_length; /* max hash chain length */\n var scan = s.strstart; /* current string */\n var match; /* matched string */\n var len; /* length of current match */\n var best_len = s.prev_length; /* best match length so far */\n var nice_match = s.nice_match; /* stop if match long enough */\n var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n var _win = s.window; // shortcut\n\n var wmask = s.w_mask;\n var prev = s.prev;\n\n /* Stop when cur_match becomes <= limit. To simplify the code,\n * we prevent matches with the string of window index 0.\n */\n\n var strend = s.strstart + MAX_MATCH;\n var scan_end1 = _win[scan + best_len - 1];\n var scan_end = _win[scan + best_len];\n\n /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n * It is easy to get rid of this optimization if necessary.\n */\n // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n /* Do not waste too much time if we already have a good match: */\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n /* Do not look for matches beyond the end of the input. This is necessary\n * to make deflate deterministic.\n */\n if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n do {\n // Assert(cur_match < s->strstart, \"no future\");\n match = cur_match;\n\n /* Skip to next match if the match length cannot increase\n * or if the match length is less than 2. Note that the checks below\n * for insufficient lookahead only occur occasionally for performance\n * reasons. Therefore uninitialized memory will be accessed, and\n * conditional jumps will be made that depend on those values.\n * However the length of the match is limited to the lookahead, so\n * the output of deflate is not affected by the uninitialized values.\n */\n\n if (_win[match + best_len] !== scan_end ||\n _win[match + best_len - 1] !== scan_end1 ||\n _win[match] !== _win[scan] ||\n _win[++match] !== _win[scan + 1]) {\n continue;\n }\n\n /* The check at best_len-1 can be removed because it will be made\n * again later. (This heuristic is not always a win.)\n * It is not necessary to compare scan[2] and match[2] since they\n * are always equal when the other bytes match, given that\n * the hash keys are equal and that HASH_BITS >= 8.\n */\n scan += 2;\n match++;\n // Assert(*scan == *match, \"match[2]?\");\n\n /* We check for insufficient lookahead only every 8th comparison;\n * the 256th check will be made at strstart+258.\n */\n do {\n /*jshint noempty:false*/\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n scan < strend);\n\n // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n * At least one byte has been read, or avail_in == 0; reads are\n * performed for at least two bytes (required for the zip translate_eol\n * option -- not supported here).\n */\nfunction fill_window(s) {\n var _w_size = s.w_size;\n var p, n, m, more, str;\n\n //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n do {\n more = s.window_size - s.lookahead - s.strstart;\n\n // JS ints have 32 bit, block below not needed\n /* Deal with !@#$% 64K limit: */\n //if (sizeof(int) <= 2) {\n // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n // more = wsize;\n //\n // } else if (more == (unsigned)(-1)) {\n // /* Very unlikely, but possible on 16 bit machine if\n // * strstart == 0 && lookahead == 1 (input done a byte at time)\n // */\n // more--;\n // }\n //}\n\n\n /* If the window is almost full and there is insufficient lookahead,\n * move the upper half to the lower one to make room in the upper half.\n */\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n /* we now have strstart >= MAX_DIST */\n s.block_start -= _w_size;\n\n /* Slide the hash table (could be avoided with 32 bit values\n at the expense of memory usage). We slide even when level == 0\n to keep the hash table consistent if we switch back to level > 0\n later. (Using level 0 permanently is not an optimal usage of\n zlib, so we don't care about this pathological case.)\n */\n\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = (m >= _w_size ? m - _w_size : 0);\n } while (--n);\n\n n = _w_size;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n /* If n is not on any hash chain, prev[n] is garbage but\n * its value will never be used.\n */\n } while (--n);\n\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n\n /* If there was no sliding:\n * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n * more == window_size - lookahead - strstart\n * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n * => more >= window_size - 2*WSIZE + 2\n * In the BIG_MEM or MMAP case (not yet supported),\n * window_size == input_size + MIN_LOOKAHEAD &&\n * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n * Otherwise, window_size == 2*WSIZE so more >= 2.\n * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n */\n //Assert(more >= 2, \"more < 2\");\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n\n /* Initialize the hash value now that we have some input: */\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n\n /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n// Call update_hash() MIN_MATCH-3 more times\n//#endif\n while (s.insert) {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n * but this is not important since only literal bytes will be emitted.\n */\n\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n /* If the WIN_INIT bytes after the end of the current data have never been\n * written, then zero those bytes in order to avoid memory check reports of\n * the use of uninitialized (or uninitialised as Julian writes) bytes by\n * the longest match routines. Update the high water mark for the next\n * time through here. WIN_INIT is set to MAX_MATCH since the longest match\n * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n */\n// if (s.high_water < s.window_size) {\n// var curr = s.strstart + s.lookahead;\n// var init = 0;\n//\n// if (s.high_water < curr) {\n// /* Previous high water mark below current data -- zero WIN_INIT\n// * bytes or up to end of window, whichever is less.\n// */\n// init = s.window_size - curr;\n// if (init > WIN_INIT)\n// init = WIN_INIT;\n// zmemzero(s->window + curr, (unsigned)init);\n// s->high_water = curr + init;\n// }\n// else if (s->high_water < (ulg)curr + WIN_INIT) {\n// /* High water mark at or above current data, but below current data\n// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n// * to end of window, whichever is less.\n// */\n// init = (ulg)curr + WIN_INIT - s->high_water;\n// if (init > s->window_size - s->high_water)\n// init = s->window_size - s->high_water;\n// zmemzero(s->window + s->high_water, (unsigned)init);\n// s->high_water += init;\n// }\n// }\n//\n// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n// \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n * to pending_buf_size, and each stored block has a 5 byte header:\n */\n var max_block_size = 0xffff;\n\n if (max_block_size > s.pending_buf_size - 5) {\n max_block_size = s.pending_buf_size - 5;\n }\n\n /* Copy as much as possible from input to output: */\n for (;;) {\n /* Fill the window as much as possible: */\n if (s.lookahead <= 1) {\n\n //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n // s->block_start >= (long)s->w_size, \"slide too late\");\n// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n// s.block_start >= s.w_size)) {\n// throw new Error(\"slide too late\");\n// }\n\n fill_window(s);\n if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n\n if (s.lookahead === 0) {\n break;\n }\n /* flush the current block */\n }\n //Assert(s->block_start >= 0L, \"block gone\");\n// if (s.block_start < 0) throw new Error(\"block gone\");\n\n s.strstart += s.lookahead;\n s.lookahead = 0;\n\n /* Emit a stored block if pending_buf will be full: */\n var max_start = s.block_start + max_block_size;\n\n if (s.strstart === 0 || s.strstart >= max_start) {\n /* strstart == 0 is possible when wraparound on 16-bit machine */\n s.lookahead = s.strstart - max_start;\n s.strstart = max_start;\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n\n\n }\n /* Flush if we may have to slide, otherwise block_start may become\n * negative and the data will be gone:\n */\n if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n\n s.insert = 0;\n\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n\n if (s.strstart > s.block_start) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n var hash_head; /* head of the hash chain */\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break; /* flush the current block */\n }\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n * At this point we have always match_length < MIN_MATCH\n */\n if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n }\n if (s.match_length >= MIN_MATCH) {\n // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n /*** _tr_tally_dist(s, s.strstart - s.match_start,\n s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n\n /* Insert new strings in the hash table only if the match length\n * is not too large. This saves time but degrades compression.\n */\n if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n s.match_length--; /* string at strstart already in table */\n do {\n s.strstart++;\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n * always MIN_MATCH bytes ahead.\n */\n } while (--s.match_length !== 0);\n s.strstart++;\n } else\n {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n// Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n * matter since it will be recomputed at next deflate call.\n */\n }\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n var hash_head; /* head of hash chain */\n var bflush; /* set if current block must be flushed */\n\n var max_insert;\n\n /* Process the input block. */\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n */\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n\n if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n\n if (s.match_length <= 5 &&\n (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n /* If prev_match is also MIN_MATCH, match_start is garbage\n * but we will ignore the current match anyway.\n */\n s.match_length = MIN_MATCH - 1;\n }\n }\n /* If there was a match at the previous step and the current\n * match is not better, output the previous match:\n */\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n /* Do not insert strings in hash table beyond this. */\n\n //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n s.prev_length - MIN_MATCH, bflush);***/\n bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n /* Insert in hash table all strings up to the end of the match.\n * strstart-1 and strstart are already inserted. If there is not\n * enough lookahead, the last two strings are not inserted in\n * the hash table.\n */\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n } else if (s.match_available) {\n /* If there was no match at the previous position, output a\n * single literal. If there was a match but the current match\n * is longer, truncate the previous match to a single literal.\n */\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n if (bflush) {\n /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n flush_block_only(s, false);\n /***/\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n /* There is no previous match to compare with, wait for\n * the next step to decide.\n */\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n if (s.match_available) {\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one. Do not maintain a hash table. (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n var bflush; /* set if current block must be flushed */\n var prev; /* byte at distance one to match */\n var scan, strend; /* scan goes up to strend for length of run */\n\n var _win = s.window;\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the longest run, plus one for the unrolled loop.\n */\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* See how many times the previous byte repeats */\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n /*jshint noempty:false*/\n } while (prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n }\n\n /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n if (s.match_length >= MIN_MATCH) {\n //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s.match_length = 0;\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast), /* 2 */\n new Config(4, 6, 32, 32, deflate_fast), /* 3 */\n\n new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow), /* 5 */\n new Config(8, 16, 128, 128, deflate_slow), /* 6 */\n new Config(8, 32, 128, 256, deflate_slow), /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow), /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n s.window_size = 2 * s.w_size;\n\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n\n /* Set the default configuration parameters:\n */\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n this.strm = null; /* pointer back to this zlib stream */\n this.status = 0; /* as the name implies */\n this.pending_buf = null; /* output still pending */\n this.pending_buf_size = 0; /* size of pending_buf */\n this.pending_out = 0; /* next pending byte to output to the stream */\n this.pending = 0; /* nb of bytes in the pending buffer */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.gzhead = null; /* gzip header information to write */\n this.gzindex = 0; /* where in extra, name, or comment */\n this.method = Z_DEFLATED; /* can only be DEFLATED */\n this.last_flush = -1; /* value of flush param for previous deflate call */\n\n this.w_size = 0; /* LZ77 window size (32K by default) */\n this.w_bits = 0; /* log2(w_size) (8..16) */\n this.w_mask = 0; /* w_size - 1 */\n\n this.window = null;\n /* Sliding window. Input bytes are read into the second half of the window,\n * and move to the first half later to keep a dictionary of at least wSize\n * bytes. With this organization, matches are limited to a distance of\n * wSize-MAX_MATCH bytes, but this ensures that IO is always\n * performed with a length multiple of the block size.\n */\n\n this.window_size = 0;\n /* Actual size of window: 2*wSize, except when the user input buffer\n * is directly used as sliding window.\n */\n\n this.prev = null;\n /* Link to older string with same hash index. To limit the size of this\n * array to 64K, this link is maintained only for the last 32K strings.\n * An index in this array is thus a window index modulo 32K.\n */\n\n this.head = null; /* Heads of the hash chains or NIL. */\n\n this.ins_h = 0; /* hash index of string to be inserted */\n this.hash_size = 0; /* number of elements in hash table */\n this.hash_bits = 0; /* log2(hash_size) */\n this.hash_mask = 0; /* hash_size-1 */\n\n this.hash_shift = 0;\n /* Number of bits by which ins_h must be shifted at each input\n * step. It must be such that after MIN_MATCH steps, the oldest\n * byte no longer takes part in the hash key, that is:\n * hash_shift * MIN_MATCH >= hash_bits\n */\n\n this.block_start = 0;\n /* Window position at the beginning of the current output block. Gets\n * negative when the window is moved backwards.\n */\n\n this.match_length = 0; /* length of best match */\n this.prev_match = 0; /* previous match */\n this.match_available = 0; /* set if previous match exists */\n this.strstart = 0; /* start of string to insert */\n this.match_start = 0; /* start of matching string */\n this.lookahead = 0; /* number of valid bytes ahead in window */\n\n this.prev_length = 0;\n /* Length of the best match at previous step. Matches not greater than this\n * are discarded. This is used in the lazy match evaluation.\n */\n\n this.max_chain_length = 0;\n /* To speed up deflation, hash chains are never searched beyond this\n * length. A higher limit improves compression ratio but degrades the\n * speed.\n */\n\n this.max_lazy_match = 0;\n /* Attempt to find a better match only when the current match is strictly\n * smaller than this value. This mechanism is used only for compression\n * levels >= 4.\n */\n // That's alias to max_lazy_match, don't use directly\n //this.max_insert_length = 0;\n /* Insert new strings in the hash table only if the match length is not\n * greater than this length. This saves time but degrades compression.\n * max_insert_length is used only for compression levels <= 3.\n */\n\n this.level = 0; /* compression level (1..9) */\n this.strategy = 0; /* favor or force Huffman coding*/\n\n this.good_match = 0;\n /* Use a faster search when the previous match is longer than this */\n\n this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n /* used by trees.c: */\n\n /* Didn't use ct_data typedef below to suppress compiler warning */\n\n // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */\n // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */\n\n // Use flat array of DOUBLE size, with interleaved fata,\n // because JS does not support effective\n this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);\n this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);\n this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n\n this.l_desc = null; /* desc. for literal tree */\n this.d_desc = null; /* desc. for distance tree */\n this.bl_desc = null; /* desc. for bit length tree */\n\n //ush bl_count[MAX_BITS+1];\n this.bl_count = new utils.Buf16(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */\n this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */\n zero(this.heap);\n\n this.heap_len = 0; /* number of elements in the heap */\n this.heap_max = 0; /* element of largest frequency */\n /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n * The same heap array is used to build all trees.\n */\n\n this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n zero(this.depth);\n /* Depth of each subtree used as tie breaker for trees of equal frequency\n */\n\n this.l_buf = 0; /* buffer index for literals or lengths */\n\n this.lit_bufsize = 0;\n /* Size of match buffer for literals/lengths. There are 4 reasons for\n * limiting lit_bufsize to 64K:\n * - frequencies can be kept in 16 bit counters\n * - if compression is not successful for the first block, all input\n * data is still in the window so we can still emit a stored block even\n * when input comes from standard input. (This can also be done for\n * all blocks if lit_bufsize is not greater than 32K.)\n * - if compression is not successful for a file smaller than 64K, we can\n * even emit a stored file instead of a stored block (saving 5 bytes).\n * This is applicable only for zip (not gzip or zlib).\n * - creating new Huffman trees less frequently may not provide fast\n * adaptation to changes in the input data statistics. (Take for\n * example a binary file with poorly compressible code followed by\n * a highly compressible string table.) Smaller buffer sizes give\n * fast adaptation but have of course the overhead of transmitting\n * trees more frequently.\n * - I can't count above 4\n */\n\n this.last_lit = 0; /* running index in l_buf */\n\n this.d_buf = 0;\n /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n * the same number of elements. To use different lengths, an extra flag\n * array would be necessary.\n */\n\n this.opt_len = 0; /* bit length of current block with optimal trees */\n this.static_len = 0; /* bit length of current block with static trees */\n this.matches = 0; /* number of string matches in current block */\n this.insert = 0; /* bytes at end of window left to insert */\n\n\n this.bi_buf = 0;\n /* Output buffer. bits are inserted starting at the bottom (least\n * significant bits).\n */\n this.bi_valid = 0;\n /* Number of valid bits in bi_buf. All bits above the last valid bit\n * are always zero.\n */\n\n // Used for window memory init. We safely ignore it for JS. That makes\n // sense only for pointers and memory check tools.\n //this.high_water = 0;\n /* High water mark offset in window for initialized bytes -- bytes above\n * this are set to zero in order to avoid memory check warnings when\n * longest match routines access bytes past the input. This is then\n * updated to the new high water mark.\n */\n}\n\n\nfunction deflateResetKeep(strm) {\n var s;\n\n if (!strm || !strm.state) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n\n s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n /* was made negative by deflate(..., Z_FINISH); */\n }\n s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n strm.adler = (s.wrap === 2) ?\n 0 // crc32(0, Z_NULL, 0)\n :\n 1; // adler32(0, Z_NULL, 0)\n s.last_flush = Z_NO_FLUSH;\n trees._tr_init(s);\n return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n var ret = deflateResetKeep(strm);\n if (ret === Z_OK) {\n lm_init(strm.state);\n }\n return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n strm.state.gzhead = head;\n return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n if (!strm) { // === Z_NULL\n return Z_STREAM_ERROR;\n }\n var wrap = 1;\n\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n\n if (windowBits < 0) { /* suppress zlib wrapper */\n wrap = 0;\n windowBits = -windowBits;\n }\n\n else if (windowBits > 15) {\n wrap = 2; /* write gzip wrapper instead */\n windowBits -= 16;\n }\n\n\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n strategy < 0 || strategy > Z_FIXED) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n\n if (windowBits === 8) {\n windowBits = 9;\n }\n /* until 256-byte window bug fixed */\n\n var s = new DeflateState();\n\n strm.state = s;\n s.strm = strm;\n\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n s.window = new utils.Buf8(s.w_size * 2);\n s.head = new utils.Buf16(s.hash_size);\n s.prev = new utils.Buf16(s.w_size);\n\n // Don't need mem init magic for JS.\n //s.high_water = 0; /* nothing written to s->window yet */\n\n s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n s.pending_buf_size = s.lit_bufsize * 4;\n\n //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n //s->pending_buf = (uchf *) overlay;\n s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n s.d_buf = 1 * s.lit_bufsize;\n\n //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n s.l_buf = (1 + 2) * s.lit_bufsize;\n\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n\n return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n var old_flush, s;\n var beg, val; // for gzip header write only\n\n if (!strm || !strm.state ||\n flush > Z_BLOCK || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n }\n\n s = strm.state;\n\n if (!strm.output ||\n (!strm.input && strm.avail_in !== 0) ||\n (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n }\n\n s.strm = strm; /* just in case */\n old_flush = s.last_flush;\n s.last_flush = flush;\n\n /* Write the header */\n if (s.status === INIT_STATE) {\n\n if (s.wrap === 2) { // GZIP header\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) { // s->gzhead == Z_NULL\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n }\n else {\n put_byte(s, (s.gzhead.text ? 1 : 0) +\n (s.gzhead.hcrc ? 2 : 0) +\n (!s.gzhead.extra ? 0 : 4) +\n (!s.gzhead.name ? 0 : 8) +\n (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 0xff);\n put_byte(s, (s.gzhead.time >> 8) & 0xff);\n put_byte(s, (s.gzhead.time >> 16) & 0xff);\n put_byte(s, (s.gzhead.time >> 24) & 0xff);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, s.gzhead.os & 0xff);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 0xff);\n put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n else // DEFLATE header\n {\n var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n var level_flags = -1;\n\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= (level_flags << 6);\n if (s.strstart !== 0) { header |= PRESET_DICT; }\n header += 31 - (header % 31);\n\n s.status = BUSY_STATE;\n putShortMSB(s, header);\n\n /* Save the adler32 of the preset dictionary: */\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n strm.adler = 1; // adler32(0L, Z_NULL, 0);\n }\n }\n\n//#ifdef GZIP\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n\n while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n break;\n }\n }\n put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n s.gzindex++;\n }\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (s.gzindex === s.gzhead.extra.length) {\n s.gzindex = 0;\n s.status = NAME_STATE;\n }\n }\n else {\n s.status = NAME_STATE;\n }\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.gzindex = 0;\n s.status = COMMENT_STATE;\n }\n }\n else {\n s.status = COMMENT_STATE;\n }\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.status = HCRC_STATE;\n }\n }\n else {\n s.status = HCRC_STATE;\n }\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n }\n if (s.pending + 2 <= s.pending_buf_size) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n s.status = BUSY_STATE;\n }\n }\n else {\n s.status = BUSY_STATE;\n }\n }\n//#endif\n\n /* Flush as much pending output as possible */\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n /* Since avail_out is 0, deflate will be called again with\n * more output space, but possibly with both pending and\n * avail_in equal to zero. There won't be anything to do,\n * but this is not an error situation so make sure we\n * return OK instead of BUF_ERROR at next call of deflate:\n */\n s.last_flush = -1;\n return Z_OK;\n }\n\n /* Make sure there is something to do and avoid duplicate consecutive\n * flushes. For repeated and useless calls with Z_FINISH, we keep\n * returning Z_STREAM_END instead of Z_BUF_ERROR.\n */\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n flush !== Z_FINISH) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* User must not provide more input after the first FINISH: */\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* Start a new block or continue the current one.\n */\n if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n configuration_table[s.level].func(s, flush));\n\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n /* avoid BUF_ERROR next call, see above */\n }\n return Z_OK;\n /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n * of deflate should use the same flush parameter to make sure\n * that the flush is complete. So we don't have to output an\n * empty block here, this will be done at next call. This also\n * ensures that for a very small output buffer, we emit at most\n * one empty block.\n */\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n trees._tr_align(s);\n }\n else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n trees._tr_stored_block(s, 0, 0, false);\n /* For a full flush, this empty block will be recognized\n * as a special marker by inflate_sync().\n */\n if (flush === Z_FULL_FLUSH) {\n /*** CLEAR_HASH(s); ***/ /* forget history */\n zero(s.head); // Fill with NIL (= 0);\n\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n return Z_OK;\n }\n }\n }\n //Assert(strm->avail_out > 0, \"bug2\");\n //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n if (flush !== Z_FINISH) { return Z_OK; }\n if (s.wrap <= 0) { return Z_STREAM_END; }\n\n /* Write the trailer */\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n put_byte(s, (strm.adler >> 16) & 0xff);\n put_byte(s, (strm.adler >> 24) & 0xff);\n put_byte(s, strm.total_in & 0xff);\n put_byte(s, (strm.total_in >> 8) & 0xff);\n put_byte(s, (strm.total_in >> 16) & 0xff);\n put_byte(s, (strm.total_in >> 24) & 0xff);\n }\n else\n {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n\n flush_pending(strm);\n /* If avail_out is zero, the application will call deflate again\n * to flush the rest.\n */\n if (s.wrap > 0) { s.wrap = -s.wrap; }\n /* write the trailer only once! */\n return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n var status;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n status = strm.state.status;\n if (status !== INIT_STATE &&\n status !== EXTRA_STATE &&\n status !== NAME_STATE &&\n status !== COMMENT_STATE &&\n status !== HCRC_STATE &&\n status !== BUSY_STATE &&\n status !== FINISH_STATE\n ) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.state = null;\n\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var s;\n var str, n;\n var wrap;\n var avail;\n var next;\n var input;\n var tmpDict;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n s = strm.state;\n wrap = s.wrap;\n\n if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n return Z_STREAM_ERROR;\n }\n\n /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n if (wrap === 1) {\n /* adler32(strm->adler, dictionary, dictLength); */\n strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n }\n\n s.wrap = 0; /* avoid computing Adler-32 in read_buf */\n\n /* if dictionary would fill window, just replace the history */\n if (dictLength >= s.w_size) {\n if (wrap === 0) { /* already empty otherwise */\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n /* use the tail */\n // dictionary = dictionary.slice(dictLength - s.w_size);\n tmpDict = new utils.Buf8(s.w_size);\n utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n /* insert dictionary into window and hash */\n avail = strm.avail_in;\n next = strm.next_in;\n input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n str = s.strstart;\n n = s.lookahead - (MIN_MATCH - 1);\n do {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n","'use strict';\n\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED = 1;\n//var Z_HUFFMAN_ONLY = 2;\n//var Z_RLE = 3;\nvar Z_FIXED = 4;\n//var Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY = 0;\nvar Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES = 30;\n/* number of distance codes */\n\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK = 256;\n/* end of block literal code */\n\nvar REP_3_6 = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10 = 17;\n/* repeat a zero length 3-10 times (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits = /* extra bits for each length code */\n [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];\n\nvar extra_dbits = /* extra bits for each distance code */\n [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];\n\nvar extra_blbits = /* extra bits for each bit length code */\n [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array insdead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n this.static_tree = static_tree; /* static tree or NULL */\n this.extra_bits = extra_bits; /* extra bits for each code or NULL */\n this.extra_base = extra_base; /* base index for extra_bits */\n this.elems = elems; /* max number of elements in the tree */\n this.max_length = max_length; /* max bit length for the codes */\n\n // show if `static_tree` has data or dummy - needed for monomorphic objects\n this.has_stree = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree; /* the dynamic tree */\n this.max_code = 0; /* largest code with non zero frequency */\n this.stat_desc = stat_desc; /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n// put_byte(s, (uch)((w) & 0xff));\n// put_byte(s, (uch)((ush)(w) >> 8));\n s.pending_buf[s.pending++] = (w) & 0xff;\n s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n if (s.bi_valid > (Buf_size - length)) {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> (Buf_size - s.bi_valid);\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n s.bi_valid += length;\n }\n}\n\n\nfunction send_code(s, c, tree) {\n send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n var res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n * above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n * array bl_count contains the frequencies for each bit length.\n * The length opt_len is updated; static_len is also updated if stree is\n * not null.\n */\nfunction gen_bitlen(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var max_code = desc.max_code;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var extra = desc.stat_desc.extra_bits;\n var base = desc.stat_desc.extra_base;\n var max_length = desc.stat_desc.max_length;\n var h; /* heap index */\n var n, m; /* iterate over the tree elements */\n var bits; /* bit length */\n var xbits; /* extra bits */\n var f; /* frequency */\n var overflow = 0; /* number of elements with bit length too large */\n\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n\n /* In a first pass, compute the optimal bit lengths (which may\n * overflow in the case of the bit length tree).\n */\n tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1]/*.Len*/ = bits;\n /* We overwrite tree[n].Dad which is no longer needed */\n\n if (n > max_code) { continue; } /* not a leaf node */\n\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2]/*.Freq*/;\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n }\n }\n if (overflow === 0) { return; }\n\n // Trace((stderr,\"\\nbit length overflow\\n\"));\n /* This happens for example on obj2 and pic of the Calgary corpus */\n\n /* Find the first bit length which could increase: */\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) { bits--; }\n s.bl_count[bits]--; /* move one leaf down the tree */\n s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n s.bl_count[max_length]--;\n /* The brother of the overflow item also moves one step up,\n * but this does not affect bl_count[max_length]\n */\n overflow -= 2;\n } while (overflow > 0);\n\n /* Now recompute all bit lengths, scanning in increasing frequency.\n * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n * lengths instead of fixing only the wrong ones. This idea is taken\n * from 'ar' written by Haruhiko Okumura.)\n */\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) { continue; }\n if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n tree[m * 2 + 1]/*.Len*/ = bits;\n }\n n--;\n }\n }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n * zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n// ct_data *tree; /* the tree to decorate */\n// int max_code; /* largest code with non zero frequency */\n// ushf *bl_count; /* number of codes at each bit length */\n{\n var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n var code = 0; /* running code value */\n var bits; /* bit index */\n var n; /* code index */\n\n /* The distribution counts are first used to generate the code values\n * without bit reversal.\n */\n for (bits = 1; bits <= MAX_BITS; bits++) {\n next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n }\n /* Check that the bit counts in bl_count are consistent. The last code\n * must be all ones.\n */\n //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length[code] = length;\n for (n = 0; n < (1 << extra_lbits[code]); n++) {\n _length_code[length++] = code;\n }\n }\n //Assert (length == 256, \"tr_static_init: length != 256\");\n /* Note that the length 255 (match length 258) can be represented\n * in two different ways: code 284 + 5 bits or code 285, so we\n * overwrite length_code[255] to use the best encoding:\n */\n _length_code[length - 1] = code;\n\n /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist[code] = dist;\n for (n = 0; n < (1 << extra_dbits[code]); n++) {\n _dist_code[dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: dist != 256\");\n dist >>= 7; /* from now on, all distances are divided by 128 */\n for (; code < D_CODES; code++) {\n base_dist[code] = dist << 7;\n for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n _dist_code[256 + dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n /* Construct the codes of the static literal tree */\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n\n n = 0;\n while (n <= 143) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree[n * 2 + 1]/*.Len*/ = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree[n * 2 + 1]/*.Len*/ = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n /* Codes 286 and 287 do not exist, but we must include them in the\n * tree construction to get a canonical Huffman tree (longest code\n * all ones)\n */\n gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n /* The static distance tree is trivial: */\n for (n = 0; n < D_CODES; n++) {\n static_dtree[n * 2 + 1]/*.Len*/ = 5;\n static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n }\n\n // Now data ready and we can init static trees\n static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n\n //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n var n; /* iterates over tree elements */\n\n /* Initialize the trees. */\n for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n s.opt_len = s.static_len = 0;\n s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n //put_byte(s, (Byte)s->bi_buf);\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf *buf; /* the input data */\n//unsigned len; /* its length */\n//int header; /* true if block header must be written */\n{\n bi_windup(s); /* align on byte boundary */\n\n if (header) {\n put_short(s, len);\n put_short(s, ~len);\n }\n// while (len--) {\n// put_byte(s, *buf++);\n// }\n utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n var _n2 = n * 2;\n var _m2 = m * 2;\n return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n// deflate_state *s;\n// ct_data *tree; /* the tree to restore */\n// int k; /* node to move down */\n{\n var v = s.heap[k];\n var j = k << 1; /* left son of k */\n while (j <= s.heap_len) {\n /* Set j to the smallest of the two sons: */\n if (j < s.heap_len &&\n smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n /* Exit if v is smaller than both sons */\n if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n /* Exchange v with the smallest son */\n s.heap[k] = s.heap[j];\n k = j;\n\n /* And continue down the tree, setting j to the left son of k */\n j <<= 1;\n }\n s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n// deflate_state *s;\n// const ct_data *ltree; /* literal tree */\n// const ct_data *dtree; /* distance tree */\n{\n var dist; /* distance of matched string */\n var lc; /* match length or unmatched char (if dist == 0) */\n var lx = 0; /* running index in l_buf */\n var code; /* the code to send */\n var extra; /* number of extra bits to send */\n\n if (s.last_lit !== 0) {\n do {\n dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n lc = s.pending_buf[s.l_buf + lx];\n lx++;\n\n if (dist === 0) {\n send_code(s, lc, ltree); /* send a literal byte */\n //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n } else {\n /* Here, lc is the match length - MIN_MATCH */\n code = _length_code[lc];\n send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length[code];\n send_bits(s, lc, extra); /* send the extra length bits */\n }\n dist--; /* dist is now the match distance - 1 */\n code = d_code(dist);\n //Assert (code < D_CODES, \"bad d_code\");\n\n send_code(s, code, dtree); /* send the distance code */\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist[code];\n send_bits(s, dist, extra); /* send the extra distance bits */\n }\n } /* literal or match pair ? */\n\n /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n // \"pendingBuf overflow\");\n\n } while (lx < s.last_lit);\n }\n\n send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n * and corresponding code. The length opt_len is updated; static_len is\n * also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var elems = desc.stat_desc.elems;\n var n, m; /* iterate over heap elements */\n var max_code = -1; /* largest code with non zero frequency */\n var node; /* new node being created */\n\n /* Construct the initial heap, with least frequent element in\n * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n * heap[0] is not used.\n */\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n\n for (n = 0; n < elems; n++) {\n if (tree[n * 2]/*.Freq*/ !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n\n } else {\n tree[n * 2 + 1]/*.Len*/ = 0;\n }\n }\n\n /* The pkzip format requires that at least one distance code exists,\n * and that at least one bit should be sent even if there is only one\n * possible code. So to avoid special checks later on we force at least\n * two codes of non zero frequency.\n */\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n tree[node * 2]/*.Freq*/ = 1;\n s.depth[node] = 0;\n s.opt_len--;\n\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1]/*.Len*/;\n }\n /* node is 0 or 1 so it does not have extra bits */\n }\n desc.max_code = max_code;\n\n /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n * establish sub-heaps of increasing lengths:\n */\n for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n /* Construct the Huffman tree by repeatedly combining the least two\n * frequent nodes.\n */\n node = elems; /* next internal node of the tree */\n do {\n //pqremove(s, tree, n); /* n = node of least frequency */\n /*** pqremove ***/\n n = s.heap[1/*SMALLEST*/];\n s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n pqdownheap(s, tree, 1/*SMALLEST*/);\n /***/\n\n m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n s.heap[--s.heap_max] = m;\n\n /* Create a new node father of n and m */\n tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n /* and insert the new node in the heap */\n s.heap[1/*SMALLEST*/] = node++;\n pqdownheap(s, tree, 1/*SMALLEST*/);\n\n } while (s.heap_len >= 2);\n\n s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n /* At this point, the fields freq and dad are set. We can now\n * generate the bit lengths.\n */\n gen_bitlen(s, desc);\n\n /* The field len is now set, we can generate the bit codes */\n gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n } else if (curlen !== 0) {\n\n if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n } else {\n s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n }\n\n count = 0;\n prevlen = curlen;\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n /* tree[max_code+1].Len = -1; */ /* guard already set */\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n //Assert(count >= 3 && count <= 6, \" 3_6?\");\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n var max_blindex; /* index of last bit length code of non zero freq */\n\n /* Determine the bit length frequencies for literal and distance trees */\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n /* Build the bit length tree: */\n build_tree(s, s.bl_desc);\n /* opt_len now includes the length of the tree representations, except\n * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n */\n\n /* Determine the number of bit length codes to send. The pkzip format\n * requires that at least 4 bit length codes be sent. (appnote.txt says\n * 3 but the actual value used is 4.)\n */\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n break;\n }\n }\n /* Update opt_len to include the bit length tree and counts */\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n // s->opt_len, s->static_len));\n\n return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n// deflate_state *s;\n// int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n var rank; /* index in bl_order */\n\n //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n // \"too many codes\");\n //Tracev((stderr, \"\\nbl counts: \"));\n send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */\n for (rank = 0; rank < blcodes; rank++) {\n //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n }\n //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n * a) There are no non-portable control characters belonging to the\n * \"black list\" (0..6, 14..25, 28..31).\n * b) There is at least one printable character belonging to the\n * \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n * \"gray list\" that is ignored in this detection algorithm:\n * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n /* black_mask is the bit mask of black-listed bytes\n * set bits 0..6, 14..25, and 28..31\n * 0xf3ffc07f = binary 11110011111111111100000001111111\n */\n var black_mask = 0xf3ffc07f;\n var n;\n\n /* Check for non-textual (\"black-listed\") bytes. */\n for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n return Z_BINARY;\n }\n }\n\n /* Check for textual (\"white-listed\") bytes. */\n if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n }\n\n /* There are no \"black-listed\" or \"white-listed\" bytes:\n * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n */\n return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n /* Initialize the first block of the first file: */\n init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */\n copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree);\n bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block, or NULL if too old */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n var opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n var max_blindex = 0; /* index of last bit length code of non zero freq */\n\n /* Build the Huffman trees unless a stored block is forced */\n if (s.level > 0) {\n\n /* Check if the file is binary or text */\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n\n /* Construct the literal and distance trees */\n build_tree(s, s.l_desc);\n // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n\n build_tree(s, s.d_desc);\n // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n /* At this point, opt_len and static_len are the total bit lengths of\n * the compressed block data, excluding the tree representations.\n */\n\n /* Build the bit length tree for the above two trees, and get the index\n * in bl_order of the last bit length code to send.\n */\n max_blindex = build_bl_tree(s);\n\n /* Determine the best encoding. Compute the block lengths in bytes. */\n opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n // s->last_lit));\n\n if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n } else {\n // Assert(buf != (char*)0, \"lost buf\");\n opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n }\n\n if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n /* 4: two words for the lengths */\n\n /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n * Otherwise we can't have processed more than WSIZE input bytes since\n * the last block flush, because compression would have been\n * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n * transform a block into a stored block.\n */\n _tr_stored_block(s, buf, stored_len, last);\n\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree, static_dtree);\n\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n /* The above check is made mod 2^32, for files larger than 512 MB\n * and uLong implemented on 32 bits.\n */\n init_block(s);\n\n if (last) {\n bi_windup(s);\n }\n // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n // s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n// deflate_state *s;\n// unsigned dist; /* distance of matched string */\n// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n //var out_length, in_length, dcode;\n\n s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;\n s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n s.last_lit++;\n\n if (dist === 0) {\n /* lc is the unmatched char */\n s.dyn_ltree[lc * 2]/*.Freq*/++;\n } else {\n s.matches++;\n /* Here, lc is the match length - MIN_MATCH */\n dist--; /* dist = match distance - 1 */\n //Assert((ush)dist < (ush)MAX_DIST(s) &&\n // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n // (ush)d_code(dist) < (ush)D_CODES, \"_tr_tally: bad match\");\n\n s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n// /* Try to guess if it is profitable to stop the current block here */\n// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n// /* Compute an upper bound for the compressed length */\n// out_length = s.last_lit*8;\n// in_length = s.strstart - s.block_start;\n//\n// for (dcode = 0; dcode < D_CODES; dcode++) {\n// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n// }\n// out_length >>>= 3;\n// //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n// // s->last_lit, in_length, out_length,\n// // 100L - out_length*100L/in_length));\n// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n// return true;\n// }\n// }\n//#endif\n\n return (s.last_lit === s.lit_bufsize - 1);\n /* We avoid equality with lit_bufsize because of wraparound at 64K\n * on 16 bit machines and because stored blocks are restricted to\n * 64K-1 bytes.\n */\n}\n\nexports._tr_init = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n","'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar c = require('./zlib/constants');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\nvar GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = utils.assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n\n this.header = new GZheader();\n\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = strings.binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\n if (status === c.Z_NEED_DICT && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = strings.string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = zlib_inflate.inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === c.Z_BUF_ERROR && allowBufError === true) {\n status = c.Z_OK;\n allowBufError = false;\n }\n\n if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n if (status === c.Z_STREAM_END) {\n _mode = c.Z_FINISH;\n }\n\n // Finalize on the last chunk.\n if (_mode === c.Z_FINISH) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === c.Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === c.Z_SYNC_FLUSH) {\n this.onEnd(c.Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === c.Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip = inflate;\n","'use strict';\n\n\nvar utils = require('../utils/common');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar inflate_fast = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n this.work = new utils.Buf16(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\nfunction inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new utils.Buf32(512);\n distfix = new utils.Buf32(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new utils.Buf8(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n utils.arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n utils.arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n utils.arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n","'use strict';\n\n// See state defs from inflate.js\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n","'use strict';\n\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n","'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\nmodule.exports = GZheader;\n","// This is free and unencumbered software released into the public domain.\n// See LICENSE.md for more information.\n\nvar encoding = require(\"./lib/encoding.js\");\n\nmodule.exports = {\n TextEncoder: encoding.TextEncoder,\n TextDecoder: encoding.TextDecoder,\n};\n","// This is free and unencumbered software released into the public domain.\n// See LICENSE.md for more information.\n\n// If we're in node require encoding-indexes and attach it to the global.\n/**\n * @fileoverview Global |this| required for resolving indexes in node.\n * @suppress {globalThis}\n */\n(function(global) {\n 'use strict';\n\n //\n // Utilities\n //\n\n /**\n * @param {number} a The number to test.\n * @param {number} min The minimum value in the range, inclusive.\n * @param {number} max The maximum value in the range, inclusive.\n * @return {boolean} True if a >= min and a <= max.\n */\n function inRange(a, min, max) {\n return min <= a && a <= max;\n }\n\n /**\n * @param {!Array.<*>} array The array to check.\n * @param {*} item The item to look for in the array.\n * @return {boolean} True if the item appears in the array.\n */\n function includes(array, item) {\n return array.indexOf(item) !== -1;\n }\n\n /**\n * @param {*} o\n * @return {Object}\n */\n function ToDictionary(o) {\n if (o === undefined) return {};\n if (o === Object(o)) return o;\n throw TypeError('Could not convert argument to dictionary');\n }\n\n /**\n * @param {string} string Input string of UTF-16 code units.\n * @return {!Array.} Code points.\n */\n function stringToCodePoints(string) {\n // https://heycam.github.io/webidl/#dfn-obtain-unicode\n\n // 1. Let S be the DOMString value.\n var s = String(string);\n\n // 2. Let n be the length of S.\n var n = s.length;\n\n // 3. Initialize i to 0.\n var i = 0;\n\n // 4. Initialize U to be an empty sequence of Unicode characters.\n var u = [];\n\n // 5. While i < n:\n while (i < n) {\n\n // 1. Let c be the code unit in S at index i.\n var c = s.charCodeAt(i);\n\n // 2. Depending on the value of c:\n\n // c < 0xD800 or c > 0xDFFF\n if (c < 0xD800 || c > 0xDFFF) {\n // Append to U the Unicode character with code point c.\n u.push(c);\n }\n\n // 0xDC00 ≤ c ≤ 0xDFFF\n else if (0xDC00 <= c && c <= 0xDFFF) {\n // Append to U a U+FFFD REPLACEMENT CHARACTER.\n u.push(0xFFFD);\n }\n\n // 0xD800 ≤ c ≤ 0xDBFF\n else if (0xD800 <= c && c <= 0xDBFF) {\n // 1. If i = n−1, then append to U a U+FFFD REPLACEMENT\n // CHARACTER.\n if (i === n - 1) {\n u.push(0xFFFD);\n }\n // 2. Otherwise, i < n−1:\n else {\n // 1. Let d be the code unit in S at index i+1.\n var d = s.charCodeAt(i + 1);\n\n // 2. If 0xDC00 ≤ d ≤ 0xDFFF, then:\n if (0xDC00 <= d && d <= 0xDFFF) {\n // 1. Let a be c & 0x3FF.\n var a = c & 0x3FF;\n\n // 2. Let b be d & 0x3FF.\n var b = d & 0x3FF;\n\n // 3. Append to U the Unicode character with code point\n // 2^16+2^10*a+b.\n u.push(0x10000 + (a << 10) + b);\n\n // 4. Set i to i+1.\n i += 1;\n }\n\n // 3. Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a\n // U+FFFD REPLACEMENT CHARACTER.\n else {\n u.push(0xFFFD);\n }\n }\n }\n\n // 3. Set i to i+1.\n i += 1;\n }\n\n // 6. Return U.\n return u;\n }\n\n /**\n * @param {!Array.} code_points Array of code points.\n * @return {string} string String of UTF-16 code units.\n */\n function codePointsToString(code_points) {\n var s = '';\n for (var i = 0; i < code_points.length; ++i) {\n var cp = code_points[i];\n if (cp <= 0xFFFF) {\n s += String.fromCharCode(cp);\n } else {\n cp -= 0x10000;\n s += String.fromCharCode((cp >> 10) + 0xD800,\n (cp & 0x3FF) + 0xDC00);\n }\n }\n return s;\n }\n\n\n //\n // Implementation of Encoding specification\n // https://encoding.spec.whatwg.org/\n //\n\n //\n // 4. Terminology\n //\n\n /**\n * An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive.\n * @param {number} a The number to test.\n * @return {boolean} True if a is in the range 0x00 to 0x7F, inclusive.\n */\n function isASCIIByte(a) {\n return 0x00 <= a && a <= 0x7F;\n }\n\n /**\n * An ASCII code point is a code point in the range U+0000 to\n * U+007F, inclusive.\n */\n var isASCIICodePoint = isASCIIByte;\n\n\n /**\n * End-of-stream is a special token that signifies no more tokens\n * are in the stream.\n * @const\n */ var end_of_stream = -1;\n\n /**\n * A stream represents an ordered sequence of tokens.\n *\n * @constructor\n * @param {!(Array.|Uint8Array)} tokens Array of tokens that provide\n * the stream.\n */\n function Stream(tokens) {\n /** @type {!Array.} */\n this.tokens = [].slice.call(tokens);\n // Reversed as push/pop is more efficient than shift/unshift.\n this.tokens.reverse();\n }\n\n Stream.prototype = {\n /**\n * @return {boolean} True if end-of-stream has been hit.\n */\n endOfStream: function() {\n return !this.tokens.length;\n },\n\n /**\n * When a token is read from a stream, the first token in the\n * stream must be returned and subsequently removed, and\n * end-of-stream must be returned otherwise.\n *\n * @return {number} Get the next token from the stream, or\n * end_of_stream.\n */\n read: function() {\n if (!this.tokens.length)\n return end_of_stream;\n return this.tokens.pop();\n },\n\n /**\n * When one or more tokens are prepended to a stream, those tokens\n * must be inserted, in given order, before the first token in the\n * stream.\n *\n * @param {(number|!Array.)} token The token(s) to prepend to the\n * stream.\n */\n prepend: function(token) {\n if (Array.isArray(token)) {\n var tokens = /**@type {!Array.}*/(token);\n while (tokens.length)\n this.tokens.push(tokens.pop());\n } else {\n this.tokens.push(token);\n }\n },\n\n /**\n * When one or more tokens are pushed to a stream, those tokens\n * must be inserted, in given order, after the last token in the\n * stream.\n *\n * @param {(number|!Array.)} token The tokens(s) to push to the\n * stream.\n */\n push: function(token) {\n if (Array.isArray(token)) {\n var tokens = /**@type {!Array.}*/(token);\n while (tokens.length)\n this.tokens.unshift(tokens.shift());\n } else {\n this.tokens.unshift(token);\n }\n }\n };\n\n //\n // 5. Encodings\n //\n\n // 5.1 Encoders and decoders\n\n /** @const */\n var finished = -1;\n\n /**\n * @param {boolean} fatal If true, decoding errors raise an exception.\n * @param {number=} opt_code_point Override the standard fallback code point.\n * @return {number} The code point to insert on a decoding error.\n */\n function decoderError(fatal, opt_code_point) {\n if (fatal)\n throw TypeError('Decoder error');\n return opt_code_point || 0xFFFD;\n }\n\n /**\n * @param {number} code_point The code point that could not be encoded.\n * @return {number} Always throws, no value is actually returned.\n */\n function encoderError(code_point) {\n throw TypeError('The code point ' + code_point + ' could not be encoded.');\n }\n\n /** @interface */\n function Decoder() {}\n Decoder.prototype = {\n /**\n * @param {Stream} stream The stream of bytes being decoded.\n * @param {number} bite The next byte read from the stream.\n * @return {?(number|!Array.)} The next code point(s)\n * decoded, or null if not enough data exists in the input\n * stream to decode a complete code point, or |finished|.\n */\n handler: function(stream, bite) {}\n };\n\n /** @interface */\n function Encoder() {}\n Encoder.prototype = {\n /**\n * @param {Stream} stream The stream of code points being encoded.\n * @param {number} code_point Next code point read from the stream.\n * @return {(number|!Array.)} Byte(s) to emit, or |finished|.\n */\n handler: function(stream, code_point) {}\n };\n\n // 5.2 Names and labels\n\n // TODO: Define @typedef for Encoding: {name:string,labels:Array.}\n // https://github.com/google/closure-compiler/issues/247\n\n /**\n * @param {string} label The encoding label.\n * @return {?{name:string,labels:Array.}}\n */\n function getEncoding(label) {\n // 1. Remove any leading and trailing ASCII whitespace from label.\n label = String(label).trim().toLowerCase();\n\n // 2. If label is an ASCII case-insensitive match for any of the\n // labels listed in the table below, return the corresponding\n // encoding, and failure otherwise.\n if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) {\n return label_to_encoding[label];\n }\n return null;\n }\n\n /**\n * Encodings table: https://encoding.spec.whatwg.org/encodings.json\n * @const\n * @type {!Array.<{\n * heading: string,\n * encodings: Array.<{name:string,labels:Array.}>\n * }>}\n */\n var encodings = [\n {\n \"encodings\": [\n {\n \"labels\": [\n \"unicode-1-1-utf-8\",\n \"utf-8\",\n \"utf8\"\n ],\n \"name\": \"UTF-8\"\n }\n ],\n \"heading\": \"The Encoding\"\n }\n ];\n\n // Label to encoding registry.\n /** @type {Object.}>} */\n var label_to_encoding = {};\n encodings.forEach(function(category) {\n category.encodings.forEach(function(encoding) {\n encoding.labels.forEach(function(label) {\n label_to_encoding[label] = encoding;\n });\n });\n });\n\n // Registry of of encoder/decoder factories, by encoding name.\n /** @type {Object.} */\n var encoders = {};\n /** @type {Object.} */\n var decoders = {};\n\n //\n // 8. API\n //\n\n /** @const */ var DEFAULT_ENCODING = 'utf-8';\n\n // 8.1 Interface TextDecoder\n\n /**\n * @constructor\n * @param {string=} label The label of the encoding;\n * defaults to 'utf-8'.\n * @param {Object=} options\n */\n function TextDecoder(label, options) {\n // Web IDL conventions\n if (!(this instanceof TextDecoder))\n throw TypeError('Called as a function. Did you forget \\'new\\'?');\n label = label !== undefined ? String(label) : DEFAULT_ENCODING;\n options = ToDictionary(options);\n\n // A TextDecoder object has an associated encoding, decoder,\n // stream, ignore BOM flag (initially unset), BOM seen flag\n // (initially unset), error mode (initially replacement), and do\n // not flush flag (initially unset).\n\n /** @private */\n this._encoding = null;\n /** @private @type {?Decoder} */\n this._decoder = null;\n /** @private @type {boolean} */\n this._ignoreBOM = false;\n /** @private @type {boolean} */\n this._BOMseen = false;\n /** @private @type {string} */\n this._error_mode = 'replacement';\n /** @private @type {boolean} */\n this._do_not_flush = false;\n\n\n // 1. Let encoding be the result of getting an encoding from\n // label.\n var encoding = getEncoding(label);\n\n // 2. If encoding is failure or replacement, throw a RangeError.\n if (encoding === null || encoding.name === 'replacement')\n throw RangeError('Unknown encoding: ' + label);\n if (!decoders[encoding.name]) {\n throw Error('Decoder not present.' +\n ' Did you forget to include encoding-indexes.js?');\n }\n\n // 3. Let dec be a new TextDecoder object.\n var dec = this;\n\n // 4. Set dec's encoding to encoding.\n dec._encoding = encoding;\n\n // 5. If options's fatal member is true, set dec's error mode to\n // fatal.\n if (Boolean(options['fatal']))\n dec._error_mode = 'fatal';\n\n // 6. If options's ignoreBOM member is true, set dec's ignore BOM\n // flag.\n if (Boolean(options['ignoreBOM']))\n dec._ignoreBOM = true;\n\n // 7. Return dec.\n return dec;\n }\n\n if (Object.defineProperty) {\n // The encoding attribute's getter must return encoding's name.\n Object.defineProperty(TextDecoder.prototype, 'encoding', {\n /** @this {TextDecoder} */\n get: function() { return this._encoding.name.toLowerCase(); }\n });\n\n // The fatal attribute's getter must return true if error mode\n // is fatal, and false otherwise.\n Object.defineProperty(TextDecoder.prototype, 'fatal', {\n /** @this {TextDecoder} */\n get: function() { return this._error_mode === 'fatal'; }\n });\n\n // The ignoreBOM attribute's getter must return true if ignore\n // BOM flag is set, and false otherwise.\n Object.defineProperty(TextDecoder.prototype, 'ignoreBOM', {\n /** @this {TextDecoder} */\n get: function() { return this._ignoreBOM; }\n });\n }\n\n /**\n * @param {BufferSource=} input The buffer of bytes to decode.\n * @param {Object=} options\n * @return {string} The decoded string.\n */\n TextDecoder.prototype.decode = function decode(input, options) {\n var bytes;\n if (typeof input === 'object' && input instanceof ArrayBuffer) {\n bytes = new Uint8Array(input);\n } else if (typeof input === 'object' && 'buffer' in input &&\n input.buffer instanceof ArrayBuffer) {\n bytes = new Uint8Array(input.buffer,\n input.byteOffset,\n input.byteLength);\n } else {\n bytes = new Uint8Array(0);\n }\n\n options = ToDictionary(options);\n\n // 1. If the do not flush flag is unset, set decoder to a new\n // encoding's decoder, set stream to a new stream, and unset the\n // BOM seen flag.\n if (!this._do_not_flush) {\n this._decoder = decoders[this._encoding.name]({\n fatal: this._error_mode === 'fatal'});\n this._BOMseen = false;\n }\n\n // 2. If options's stream is true, set the do not flush flag, and\n // unset the do not flush flag otherwise.\n this._do_not_flush = Boolean(options['stream']);\n\n // 3. If input is given, push a copy of input to stream.\n // TODO: Align with spec algorithm - maintain stream on instance.\n var input_stream = new Stream(bytes);\n\n // 4. Let output be a new stream.\n var output = [];\n\n /** @type {?(number|!Array.)} */\n var result;\n\n // 5. While true:\n while (true) {\n // 1. Let token be the result of reading from stream.\n var token = input_stream.read();\n\n // 2. If token is end-of-stream and the do not flush flag is\n // set, return output, serialized.\n // TODO: Align with spec algorithm.\n if (token === end_of_stream)\n break;\n\n // 3. Otherwise, run these subsubsteps:\n\n // 1. Let result be the result of processing token for decoder,\n // stream, output, and error mode.\n result = this._decoder.handler(input_stream, token);\n\n // 2. If result is finished, return output, serialized.\n if (result === finished)\n break;\n\n if (result !== null) {\n if (Array.isArray(result))\n output.push.apply(output, /**@type {!Array.}*/(result));\n else\n output.push(result);\n }\n\n // 3. Otherwise, if result is error, throw a TypeError.\n // (Thrown in handler)\n\n // 4. Otherwise, do nothing.\n }\n // TODO: Align with spec algorithm.\n if (!this._do_not_flush) {\n do {\n result = this._decoder.handler(input_stream, input_stream.read());\n if (result === finished)\n break;\n if (result === null)\n continue;\n if (Array.isArray(result))\n output.push.apply(output, /**@type {!Array.}*/(result));\n else\n output.push(result);\n } while (!input_stream.endOfStream());\n this._decoder = null;\n }\n\n // A TextDecoder object also has an associated serialize stream\n // algorithm...\n /**\n * @param {!Array.} stream\n * @return {string}\n * @this {TextDecoder}\n */\n function serializeStream(stream) {\n // 1. Let token be the result of reading from stream.\n // (Done in-place on array, rather than as a stream)\n\n // 2. If encoding is UTF-8, UTF-16BE, or UTF-16LE, and ignore\n // BOM flag and BOM seen flag are unset, run these subsubsteps:\n if (includes(['UTF-8', 'UTF-16LE', 'UTF-16BE'], this._encoding.name) &&\n !this._ignoreBOM && !this._BOMseen) {\n if (stream.length > 0 && stream[0] === 0xFEFF) {\n // 1. If token is U+FEFF, set BOM seen flag.\n this._BOMseen = true;\n stream.shift();\n } else if (stream.length > 0) {\n // 2. Otherwise, if token is not end-of-stream, set BOM seen\n // flag and append token to stream.\n this._BOMseen = true;\n } else {\n // 3. Otherwise, if token is not end-of-stream, append token\n // to output.\n // (no-op)\n }\n }\n // 4. Otherwise, return output.\n return codePointsToString(stream);\n }\n\n return serializeStream.call(this, output);\n };\n\n // 8.2 Interface TextEncoder\n\n /**\n * @constructor\n * @param {string=} label The label of the encoding. NONSTANDARD.\n * @param {Object=} options NONSTANDARD.\n */\n function TextEncoder(label, options) {\n // Web IDL conventions\n if (!(this instanceof TextEncoder))\n throw TypeError('Called as a function. Did you forget \\'new\\'?');\n options = ToDictionary(options);\n\n // A TextEncoder object has an associated encoding and encoder.\n\n /** @private */\n this._encoding = null;\n /** @private @type {?Encoder} */\n this._encoder = null;\n\n // Non-standard\n /** @private @type {boolean} */\n this._do_not_flush = false;\n /** @private @type {string} */\n this._fatal = Boolean(options['fatal']) ? 'fatal' : 'replacement';\n\n // 1. Let enc be a new TextEncoder object.\n var enc = this;\n\n // 2. Set enc's encoding to UTF-8's encoder.\n // Standard behavior.\n enc._encoding = getEncoding('utf-8');\n\n if (label !== undefined && 'console' in global) {\n console.warn('TextEncoder constructor called with encoding label, '\n + 'which is ignored.');\n }\n\n // 3. Return enc.\n return enc;\n }\n\n if (Object.defineProperty) {\n // The encoding attribute's getter must return encoding's name.\n Object.defineProperty(TextEncoder.prototype, 'encoding', {\n /** @this {TextEncoder} */\n get: function() { return this._encoding.name.toLowerCase(); }\n });\n }\n\n /**\n * @param {string=} opt_string The string to encode.\n * @param {Object=} options\n * @return {!Uint8Array} Encoded bytes, as a Uint8Array.\n */\n TextEncoder.prototype.encode = function encode(opt_string, options) {\n opt_string = opt_string ? String(opt_string) : '';\n options = ToDictionary(options);\n\n // NOTE: This option is nonstandard. None of the encodings\n // permitted for encoding (i.e. UTF-8, UTF-16) are stateful when\n // the input is a USVString so streaming is not necessary.\n if (!this._do_not_flush)\n this._encoder = encoders[this._encoding.name]({\n fatal: this._fatal === 'fatal'});\n this._do_not_flush = Boolean(options['stream']);\n\n // 1. Convert input to a stream.\n var input = new Stream(stringToCodePoints(opt_string));\n\n // 2. Let output be a new stream\n var output = [];\n\n /** @type {?(number|!Array.)} */\n var result;\n // 3. While true, run these substeps:\n while (true) {\n // 1. Let token be the result of reading from input.\n var token = input.read();\n if (token === end_of_stream)\n break;\n // 2. Let result be the result of processing token for encoder,\n // input, output.\n result = this._encoder.handler(input, token);\n if (result === finished)\n break;\n if (Array.isArray(result))\n output.push.apply(output, /**@type {!Array.}*/(result));\n else\n output.push(result);\n }\n // TODO: Align with spec algorithm.\n if (!this._do_not_flush) {\n while (true) {\n result = this._encoder.handler(input, input.read());\n if (result === finished)\n break;\n if (Array.isArray(result))\n output.push.apply(output, /**@type {!Array.}*/(result));\n else\n output.push(result);\n }\n this._encoder = null;\n }\n // 3. If result is finished, convert output into a byte sequence,\n // and then return a Uint8Array object wrapping an ArrayBuffer\n // containing output.\n return new Uint8Array(output);\n };\n\n\n //\n // 9. The encoding\n //\n\n // 9.1 utf-8\n\n // 9.1.1 utf-8 decoder\n /**\n * @constructor\n * @implements {Decoder}\n * @param {{fatal: boolean}} options\n */\n function UTF8Decoder(options) {\n var fatal = options.fatal;\n\n // utf-8's decoder's has an associated utf-8 code point, utf-8\n // bytes seen, and utf-8 bytes needed (all initially 0), a utf-8\n // lower boundary (initially 0x80), and a utf-8 upper boundary\n // (initially 0xBF).\n var /** @type {number} */ utf8_code_point = 0,\n /** @type {number} */ utf8_bytes_seen = 0,\n /** @type {number} */ utf8_bytes_needed = 0,\n /** @type {number} */ utf8_lower_boundary = 0x80,\n /** @type {number} */ utf8_upper_boundary = 0xBF;\n\n /**\n * @param {Stream} stream The stream of bytes being decoded.\n * @param {number} bite The next byte read from the stream.\n * @return {?(number|!Array.)} The next code point(s)\n * decoded, or null if not enough data exists in the input\n * stream to decode a complete code point.\n */\n this.handler = function(stream, bite) {\n // 1. If byte is end-of-stream and utf-8 bytes needed is not 0,\n // set utf-8 bytes needed to 0 and return error.\n if (bite === end_of_stream && utf8_bytes_needed !== 0) {\n utf8_bytes_needed = 0;\n return decoderError(fatal);\n }\n\n // 2. If byte is end-of-stream, return finished.\n if (bite === end_of_stream)\n return finished;\n\n // 3. If utf-8 bytes needed is 0, based on byte:\n if (utf8_bytes_needed === 0) {\n\n // 0x00 to 0x7F\n if (inRange(bite, 0x00, 0x7F)) {\n // Return a code point whose value is byte.\n return bite;\n }\n\n // 0xC2 to 0xDF\n else if (inRange(bite, 0xC2, 0xDF)) {\n // 1. Set utf-8 bytes needed to 1.\n utf8_bytes_needed = 1;\n\n // 2. Set UTF-8 code point to byte & 0x1F.\n utf8_code_point = bite & 0x1F;\n }\n\n // 0xE0 to 0xEF\n else if (inRange(bite, 0xE0, 0xEF)) {\n // 1. If byte is 0xE0, set utf-8 lower boundary to 0xA0.\n if (bite === 0xE0)\n utf8_lower_boundary = 0xA0;\n // 2. If byte is 0xED, set utf-8 upper boundary to 0x9F.\n if (bite === 0xED)\n utf8_upper_boundary = 0x9F;\n // 3. Set utf-8 bytes needed to 2.\n utf8_bytes_needed = 2;\n // 4. Set UTF-8 code point to byte & 0xF.\n utf8_code_point = bite & 0xF;\n }\n\n // 0xF0 to 0xF4\n else if (inRange(bite, 0xF0, 0xF4)) {\n // 1. If byte is 0xF0, set utf-8 lower boundary to 0x90.\n if (bite === 0xF0)\n utf8_lower_boundary = 0x90;\n // 2. If byte is 0xF4, set utf-8 upper boundary to 0x8F.\n if (bite === 0xF4)\n utf8_upper_boundary = 0x8F;\n // 3. Set utf-8 bytes needed to 3.\n utf8_bytes_needed = 3;\n // 4. Set UTF-8 code point to byte & 0x7.\n utf8_code_point = bite & 0x7;\n }\n\n // Otherwise\n else {\n // Return error.\n return decoderError(fatal);\n }\n\n // Return continue.\n return null;\n }\n\n // 4. If byte is not in the range utf-8 lower boundary to utf-8\n // upper boundary, inclusive, run these substeps:\n if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {\n\n // 1. Set utf-8 code point, utf-8 bytes needed, and utf-8\n // bytes seen to 0, set utf-8 lower boundary to 0x80, and set\n // utf-8 upper boundary to 0xBF.\n utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;\n utf8_lower_boundary = 0x80;\n utf8_upper_boundary = 0xBF;\n\n // 2. Prepend byte to stream.\n stream.prepend(bite);\n\n // 3. Return error.\n return decoderError(fatal);\n }\n\n // 5. Set utf-8 lower boundary to 0x80 and utf-8 upper boundary\n // to 0xBF.\n utf8_lower_boundary = 0x80;\n utf8_upper_boundary = 0xBF;\n\n // 6. Set UTF-8 code point to (UTF-8 code point << 6) | (byte &\n // 0x3F)\n utf8_code_point = (utf8_code_point << 6) | (bite & 0x3F);\n\n // 7. Increase utf-8 bytes seen by one.\n utf8_bytes_seen += 1;\n\n // 8. If utf-8 bytes seen is not equal to utf-8 bytes needed,\n // continue.\n if (utf8_bytes_seen !== utf8_bytes_needed)\n return null;\n\n // 9. Let code point be utf-8 code point.\n var code_point = utf8_code_point;\n\n // 10. Set utf-8 code point, utf-8 bytes needed, and utf-8 bytes\n // seen to 0.\n utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;\n\n // 11. Return a code point whose value is code point.\n return code_point;\n };\n }\n\n // 9.1.2 utf-8 encoder\n /**\n * @constructor\n * @implements {Encoder}\n * @param {{fatal: boolean}} options\n */\n function UTF8Encoder(options) {\n var fatal = options.fatal;\n /**\n * @param {Stream} stream Input stream.\n * @param {number} code_point Next code point read from the stream.\n * @return {(number|!Array.)} Byte(s) to emit.\n */\n this.handler = function(stream, code_point) {\n // 1. If code point is end-of-stream, return finished.\n if (code_point === end_of_stream)\n return finished;\n\n // 2. If code point is in the range U+0000 to U+007F, return a\n // byte whose value is code point.\n if (inRange(code_point, 0x0000, 0x007f))\n return code_point;\n\n // 3. Set count and offset based on the range code point is in:\n var count, offset;\n // U+0080 to U+07FF, inclusive:\n if (inRange(code_point, 0x0080, 0x07FF)) {\n // 1 and 0xC0\n count = 1;\n offset = 0xC0;\n }\n // U+0800 to U+FFFF, inclusive:\n else if (inRange(code_point, 0x0800, 0xFFFF)) {\n // 2 and 0xE0\n count = 2;\n offset = 0xE0;\n }\n // U+10000 to U+10FFFF, inclusive:\n else if (inRange(code_point, 0x10000, 0x10FFFF)) {\n // 3 and 0xF0\n count = 3;\n offset = 0xF0;\n }\n\n // 4.Let bytes be a byte sequence whose first byte is (code\n // point >> (6 × count)) + offset.\n var bytes = [(code_point >> (6 * count)) + offset];\n\n // 5. Run these substeps while count is greater than 0:\n while (count > 0) {\n\n // 1. Set temp to code point >> (6 × (count − 1)).\n var temp = code_point >> (6 * (count - 1));\n\n // 2. Append to bytes 0x80 | (temp & 0x3F).\n bytes.push(0x80 | (temp & 0x3F));\n\n // 3. Decrease count by one.\n count -= 1;\n }\n\n // 6. Return bytes bytes, in order.\n return bytes;\n };\n }\n\n /** @param {{fatal: boolean}} options */\n encoders['UTF-8'] = function(options) {\n return new UTF8Encoder(options);\n };\n /** @param {{fatal: boolean}} options */\n decoders['UTF-8'] = function(options) {\n return new UTF8Decoder(options);\n };\n\n if (!global['TextEncoder'])\n global['TextEncoder'] = TextEncoder;\n if (!global['TextDecoder'])\n global['TextDecoder'] = TextDecoder;\n\n if (typeof module !== \"undefined\" && module.exports) {\n module.exports = {\n TextEncoder: global['TextEncoder'],\n TextDecoder: global['TextDecoder']\n };\n }\n}(this));\n","module.exports = __WEBPACK_EXTERNAL_MODULE__42__;","'use strict';\n\nvar XmlUtils = require('../utils/xml-utils');\n\n/**\n * Context with helper methods for load/save\n * @param {Kdbx} opts.kdbx - kdbx file\n * @param {boolean} [opts.exportXml=false] - whether we are exporting as xml\n * @constructor\n */\nvar KdbxContext = function(opts) {\n this.kdbx = opts.kdbx;\n this.exportXml = opts.exportXml || false;\n};\n\n/**\n * Sets XML date, respecting date saving settings\n * @param {Node} node\n * @param {Date} dt\n */\nKdbxContext.prototype.setXmlDate = function(node, dt) {\n var isBinary = this.kdbx.header.versionMajor >= 4 && !this.exportXml;\n XmlUtils.setDate(node, dt, isBinary);\n};\n\nmodule.exports = KdbxContext;\n","module.exports = __WEBPACK_EXTERNAL_MODULE__44__;","'use strict';\n\nvar\n BinaryStream = require('./../utils/binary-stream'),\n KdbxError = require('./../errors/kdbx-error'),\n Consts = require('./../defs/consts'),\n ByteUtils = require('./../utils/byte-utils'),\n CryptoEngine = require('./crypto-engine');\n\nvar BlockSize = 1024*1024;\n\n/**\n * Decrypt buffer\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction decrypt(data) {\n return Promise.resolve().then(function() {\n var stm = new BinaryStream(data);\n var buffers = [];\n var blockIndex = 0, blockLength = 0, blockHash, totalLength = 0;\n\n var next = function() {\n blockIndex = stm.getUint32(true);\n blockHash = stm.readBytes(32);\n blockLength = stm.getUint32(true);\n if (blockLength > 0) {\n totalLength += blockLength;\n var blockData = stm.readBytes(blockLength);\n return CryptoEngine.sha256(blockData).then(function(calculatedHash) {\n if (!ByteUtils.arrayBufferEquals(calculatedHash, blockHash)) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'invalid hash block');\n } else {\n buffers.push(blockData);\n return next();\n }\n });\n } else {\n var ret = new Uint8Array(totalLength);\n var offset = 0;\n for (var i = 0; i < buffers.length; i++) {\n ret.set(new Uint8Array(buffers[i]), offset);\n offset += buffers[i].byteLength;\n }\n return ret.buffer;\n }\n };\n return next();\n });\n}\n\n/**\n * Encrypt buffer\n * @param {ArrayBuffer} data\n * @returns {Promise.}\n */\nfunction encrypt(data) {\n return Promise.resolve().then(function() {\n var bytesLeft = data.byteLength;\n var currentOffset = 0, blockIndex = 0, totalLength = 0;\n var buffers = [];\n\n var next = function() {\n if (bytesLeft > 0) {\n var blockLength = Math.min(BlockSize, bytesLeft);\n bytesLeft -= blockLength;\n\n var blockData = data.slice(currentOffset, currentOffset + blockLength);\n return CryptoEngine.sha256(blockData).then(function(blockHash) {\n var blockBuffer = new ArrayBuffer(4 + 32 + 4);\n var stm = new BinaryStream(blockBuffer);\n stm.setUint32(blockIndex, true);\n stm.writeBytes(blockHash);\n stm.setUint32(blockLength, true);\n\n buffers.push(blockBuffer);\n totalLength += blockBuffer.byteLength;\n buffers.push(blockData);\n totalLength += blockData.byteLength;\n\n blockIndex++;\n currentOffset += blockLength;\n\n return next();\n });\n } else {\n var endBlockData = new ArrayBuffer(4 + 32 + 4);\n var view = new DataView(endBlockData);\n view.setUint32(0, blockIndex, true);\n buffers.push(endBlockData);\n totalLength += endBlockData.byteLength;\n\n var ret = new Uint8Array(totalLength);\n var offset = 0;\n for (var i = 0; i < buffers.length; i++) {\n ret.set(new Uint8Array(buffers[i]), offset);\n offset += buffers[i].byteLength;\n }\n return ret.buffer;\n }\n };\n return next();\n });\n}\n\nmodule.exports.decrypt = decrypt;\nmodule.exports.encrypt = encrypt;\n","'use strict';\n\nvar\n Int64 = require('../utils/int64'),\n KdbxError = require('../errors/kdbx-error'),\n Consts = require('../defs/consts'),\n ByteUtils = require('../utils/byte-utils'),\n BinaryStream = require('../utils/binary-stream'),\n CryptoEngine = require('./crypto-engine');\n\nvar BlockSize = 1024*1024;\n\n/**\n * Computes HMAC-SHA key\n * @param {ArrayBuffer} key\n * @param {Int64} blockIndex\n * @returns {Promise.}\n */\nfunction getHmacKey(key, blockIndex) {\n var shaSrc = new Uint8Array(8 + key.byteLength);\n shaSrc.set(new Uint8Array(key), 8);\n var view = new DataView(shaSrc.buffer);\n view.setUint32(0, blockIndex.lo, true);\n view.setUint32(4, blockIndex.hi, true);\n return CryptoEngine.sha512(ByteUtils.arrayToBuffer(shaSrc)).then(function(sha) {\n ByteUtils.zeroBuffer(shaSrc);\n return sha;\n });\n}\n\n/**\n * Gets block HMAC\n * @param {ArrayBuffer} key\n * @param {number} blockIndex\n * @param {number} blockLength\n * @param {ArrayBuffer} blockData\n * @returns {Promise.}\n */\nfunction getBlockHmac(key, blockIndex, blockLength, blockData) {\n return getHmacKey(key, new Int64(blockIndex)).then(function(blockKey) {\n var blockDataForHash = new Uint8Array(blockData.byteLength + 4 + 8);\n var blockDataForHashView = new DataView(blockDataForHash.buffer);\n blockDataForHash.set(new Uint8Array(blockData), 4 + 8);\n blockDataForHashView.setInt32(0, blockIndex, true);\n blockDataForHashView.setInt32(8, blockLength, true);\n return CryptoEngine.hmacSha256(blockKey, blockDataForHash.buffer);\n });\n}\n\n/**\n * Decrypt buffer\n * @param {ArrayBuffer} data\n * @param {ArrayBuffer} key\n * @returns {Promise.}\n */\nfunction decrypt(data, key) {\n var stm = new BinaryStream(data);\n return Promise.resolve().then(function() {\n var buffers = [];\n var blockIndex = 0, blockLength = 0, blockHash, totalLength = 0;\n\n var next = function() {\n blockHash = stm.readBytes(32);\n blockLength = stm.getUint32(true);\n if (blockLength > 0) {\n totalLength += blockLength;\n var blockData = stm.readBytes(blockLength);\n return getBlockHmac(key, blockIndex, blockLength, blockData).then(function(calculatedBlockHash) {\n if (!ByteUtils.arrayBufferEquals(calculatedBlockHash, blockHash)) {\n throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'invalid hash block');\n } else {\n buffers.push(blockData);\n blockIndex++;\n return next();\n }\n });\n } else {\n var ret = new Uint8Array(totalLength);\n var offset = 0;\n for (var i = 0; i < buffers.length; i++) {\n ret.set(new Uint8Array(buffers[i]), offset);\n offset += buffers[i].byteLength;\n }\n return ret.buffer;\n }\n };\n return next();\n });\n}\n\n/**\n * Encrypt buffer\n * @param {ArrayBuffer} data\n * @param {ArrayBuffer} key\n * @returns {Promise.}\n */\nfunction encrypt(data, key) {\n return Promise.resolve().then(function() {\n var bytesLeft = data.byteLength;\n var currentOffset = 0, blockIndex = 0, totalLength = 0;\n var buffers = [];\n\n var next = function() {\n var blockLength = Math.min(BlockSize, bytesLeft);\n bytesLeft -= blockLength;\n\n var blockData = data.slice(currentOffset, currentOffset + blockLength);\n return getBlockHmac(key, blockIndex, blockLength, blockData).then(function(blockHash) {\n var blockBuffer = new ArrayBuffer(32 + 4);\n var stm = new BinaryStream(blockBuffer);\n stm.writeBytes(blockHash);\n stm.setUint32(blockLength, true);\n\n buffers.push(blockBuffer);\n totalLength += blockBuffer.byteLength;\n\n if (blockData.byteLength > 0) {\n buffers.push(blockData);\n totalLength += blockData.byteLength;\n blockIndex++;\n currentOffset += blockLength;\n return next();\n } else {\n var ret = new Uint8Array(totalLength);\n var offset = 0;\n for (var i = 0; i < buffers.length; i++) {\n ret.set(new Uint8Array(buffers[i]), offset);\n offset += buffers[i].byteLength;\n }\n return ret.buffer;\n }\n });\n };\n return next();\n });\n}\n\nmodule.exports.getHmacKey = getHmacKey;\nmodule.exports.decrypt = decrypt;\nmodule.exports.encrypt = encrypt;\n","'use strict';\n\nvar Salsa20 = require('./salsa20'),\n ChaCha20 = require('./chacha20'),\n Consts = require('../defs/consts'),\n KdbxError = require('../errors/kdbx-error'),\n CryptoEngine = require('./crypto-engine'),\n ByteUtils = require('./../utils/byte-utils');\n\nvar SalsaNonce = [0xE8, 0x30, 0x09, 0x4B, 0x97, 0x20, 0x5D, 0x2A];\n\n/**\n * Protect information used for decrypt and encrypt protected data fields\n * @constructor\n */\nvar ProtectSaltGenerator = function(algo) {\n this.algo = algo;\n};\n\n/**\n * Get salt bytes\n * @param {number} len - bytes count\n * @return {ArrayBuffer} - salt bytes\n */\nProtectSaltGenerator.prototype.getSalt = function(len) {\n return ByteUtils.arrayToBuffer(this.algo.getBytes(len));\n};\n\n/**\n * Creates protected salt generator\n * @param {ArrayBuffer|Uint8Array} key\n * @param {Number} crsAlgorithm\n * @return {Promise.}\n */\nProtectSaltGenerator.create = function(key, crsAlgorithm) {\n switch (crsAlgorithm) {\n case Consts.CrsAlgorithm.Salsa20:\n return CryptoEngine.sha256(ByteUtils.arrayToBuffer(key)).then(function(hash) {\n var key = new Uint8Array(hash);\n var algo = new Salsa20(key, SalsaNonce);\n return new ProtectSaltGenerator(algo);\n });\n case Consts.CrsAlgorithm.ChaCha20:\n return CryptoEngine.sha512(ByteUtils.arrayToBuffer(key)).then(function(hash) {\n var key = new Uint8Array(hash, 0, 32);\n var nonce = new Uint8Array(hash, 32, 12);\n var algo = new ChaCha20(key, nonce);\n return new ProtectSaltGenerator(algo);\n });\n default:\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'crsAlgorithm'));\n }\n};\n\nmodule.exports = ProtectSaltGenerator;\n","'use strict';\n\nvar Consts = require('../defs/consts'),\n ByteUtils = require('../utils/byte-utils'),\n VarDictionary = require('../utils/var-dictionary'),\n Int64 = require('../utils/int64'),\n CryptoEngine = require('../crypto/crypto-engine'),\n KdbxError = require('../errors/kdbx-error'),\n KeyEncryptorAes = require('./key-encryptor-aes');\n\nvar KdfFields = [\n { name: 'salt', field: 'S', type: VarDictionary.ValueType.Bytes },\n { name: 'parallelism', field: 'P', type: VarDictionary.ValueType.UInt32 },\n { name: 'memory', field: 'M', type: VarDictionary.ValueType.UInt64 },\n { name: 'iterations', field: 'I', type: VarDictionary.ValueType.UInt64 },\n { name: 'version', field: 'V', type: VarDictionary.ValueType.UInt32 },\n { name: 'secretKey', field: 'K', type: VarDictionary.ValueType.Bytes },\n { name: 'assocData', field: 'A', type: VarDictionary.ValueType.Bytes },\n { name: 'rounds', field: 'R', type: VarDictionary.ValueType.Int64 }\n];\n\n/**\n * Derives key from seed using KDF parameters\n * @param {ArrayBuffer} key\n * @param {VarDictionary} kdfParams\n */\nfunction encrypt(key, kdfParams) {\n var uuid = kdfParams.get('$UUID');\n if (!uuid || !(uuid instanceof ArrayBuffer)) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no kdf uuid'));\n }\n var kdfUuid = ByteUtils.bytesToBase64(uuid);\n switch (kdfUuid) {\n case Consts.KdfId.Argon2:\n return encryptArgon2(key, kdfParams);\n case Consts.KdfId.Aes:\n return encryptAes(key, kdfParams);\n default:\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'bad kdf'));\n }\n}\n\nfunction decodeParams(kdfParams) {\n var params = {};\n KdfFields.forEach(function(fieldDef) {\n var value = kdfParams.get(fieldDef.field);\n if (value) {\n if (value instanceof Int64) {\n value = value.value;\n }\n params[fieldDef.name] = value;\n }\n });\n return params;\n}\n\nfunction encryptArgon2(key, kdfParams) {\n var params = decodeParams(kdfParams);\n if (!(params.salt instanceof ArrayBuffer) || params.salt.byteLength !== 32) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 salt'));\n }\n if (typeof params.parallelism !== 'number' || params.parallelism < 1) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 parallelism'));\n }\n if (typeof params.iterations !== 'number' || params.iterations < 1) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 iterations'));\n }\n if (typeof params.memory !== 'number' || params.memory < 1 || params.memory % 1024 !== 0) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 memory'));\n }\n if (params.version !== 0x13 && params.version !== 0x10) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad argon2 version'));\n }\n if (params.secretKey) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'argon2 secret key'));\n }\n if (params.assocData) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.Unsupported, 'argon2 assoc data'));\n }\n return CryptoEngine.argon2(key, params.salt,\n params.memory / 1024, params.iterations,\n 32, params.parallelism, 0, params.version);\n}\n\nfunction encryptAes(key, kdfParams) {\n var params = decodeParams(kdfParams);\n if (!(params.salt instanceof ArrayBuffer) || params.salt.byteLength !== 32) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad aes salt'));\n }\n if (typeof params.rounds !== 'number' || params.rounds < 1) {\n return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad aes rounds'));\n }\n return KeyEncryptorAes.encrypt(new Uint8Array(key), new Uint8Array(params.salt), params.rounds).then(function(key) {\n return CryptoEngine.sha256(key).then(function(hash) {\n ByteUtils.zeroBuffer(key);\n return hash;\n });\n });\n}\n\nmodule.exports.encrypt = encrypt;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n KdbxUuid = require('./kdbx-uuid'),\n KdbxCustomData = require('./kdbx-custom-data'),\n XmlUtils = require('./../utils/xml-utils'),\n Consts = require('./../defs/consts');\n\nvar Constants = {\n Generator: 'KdbxWeb'\n};\n\n/**\n * Db metadata\n * @constructor\n */\nvar KdbxMeta = function() {\n this.generator = undefined;\n this.headerHash = undefined;\n this.settingsChanged = undefined;\n this._name = undefined;\n this.nameChanged = undefined;\n this._desc = undefined;\n this.descChanged = undefined;\n this._defaultUser = undefined;\n this.defaultUserChanged = undefined;\n this._mntncHistoryDays = undefined;\n this._color = undefined;\n this.keyChanged = undefined;\n this._keyChangeRec = undefined;\n this._keyChangeForce = undefined;\n this._recycleBinEnabled = undefined;\n this._recycleBinUuid = undefined;\n this.recycleBinChanged = undefined;\n this._entryTemplatesGroup = undefined;\n this.entryTemplatesGroupChanged = undefined;\n this._historyMaxItems = undefined;\n this._historyMaxSize = undefined;\n this._lastSelectedGroup = undefined;\n this._lastTopVisibleGroup = undefined;\n this._memoryProtection = {\n title: undefined, userName: undefined, password: undefined, url: undefined, notes: undefined\n };\n this.customData = {};\n this.customIcons = {};\n this._editState = undefined;\n Object.preventExtensions(this);\n};\n\nvar props = {\n name: 'nameChanged',\n desc: 'descChanged',\n defaultUser: 'defaultUserChanged',\n mntncHistoryDays: null,\n color: null,\n keyChangeRec: null,\n keyChangeForce: null,\n recycleBinEnabled: 'recycleBinChanged',\n recycleBinUuid: 'recycleBinChanged',\n entryTemplatesGroup: 'entryTemplatesGroupChanged',\n historyMaxItems: null,\n historyMaxSize: null,\n lastSelectedGroup: null,\n lastTopVisibleGroup: null,\n memoryProtection: null\n};\n\nObject.keys(props).forEach(function(prop) {\n createProperty(prop, props[prop]);\n});\n\nfunction createProperty(prop, propChanged) {\n var field = '_' + prop;\n Object.defineProperty(KdbxMeta.prototype, prop, {\n enumerable: true,\n get: function() { return this[field]; },\n set: function(value) {\n if (value !== this[field]) {\n this[field] = value;\n if (propChanged) {\n this[propChanged] = new Date();\n } else {\n this._setPropModDate(prop);\n }\n }\n }\n });\n}\n\nKdbxMeta.prototype._setPropModDate = function(prop) {\n if (!this._editState) {\n this._editState = { };\n }\n this._editState[prop] = new Date().getTime();\n};\n\nKdbxMeta.prototype._readNode = function(node, ctx) {\n switch (node.tagName) {\n case XmlNames.Elem.Generator:\n this.generator = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.HeaderHash:\n this.headerHash = XmlUtils.getBytes(node);\n break;\n case XmlNames.Elem.SettingsChanged:\n this.settingsChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbName:\n this._name = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.DbNameChanged:\n this.nameChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbDesc:\n this._desc = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.DbDescChanged:\n this.descChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbDefaultUser:\n this._defaultUser = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.DbDefaultUserChanged:\n this.defaultUserChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbMntncHistoryDays:\n this._mntncHistoryDays = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.DbColor:\n this._color = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.DbKeyChanged:\n this.keyChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.DbKeyChangeRec:\n this._keyChangeRec = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.DbKeyChangeForce:\n this._keyChangeForce = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.RecycleBinEnabled:\n this._recycleBinEnabled = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.RecycleBinUuid:\n this._recycleBinUuid = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.RecycleBinChanged:\n this.recycleBinChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.EntryTemplatesGroup:\n this._entryTemplatesGroup = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.EntryTemplatesGroupChanged:\n this.entryTemplatesGroupChanged = XmlUtils.getDate(node);\n break;\n case XmlNames.Elem.HistoryMaxItems:\n this._historyMaxItems = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.HistoryMaxSize:\n this._historyMaxSize = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.LastSelectedGroup:\n this._lastSelectedGroup = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.LastTopVisibleGroup:\n this._lastTopVisibleGroup = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.MemoryProt:\n this._readMemoryProtection(node);\n break;\n case XmlNames.Elem.CustomIcons:\n this._readCustomIcons(node);\n break;\n case XmlNames.Elem.Binaries:\n this._readBinaries(node, ctx);\n break;\n case XmlNames.Elem.CustomData:\n this._readCustomData(node);\n break;\n }\n};\n\nKdbxMeta.prototype._readMemoryProtection = function(node) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.ProtTitle:\n this.memoryProtection.title = XmlUtils.getBoolean(childNode);\n break;\n case XmlNames.Elem.ProtUserName:\n this.memoryProtection.userName = XmlUtils.getBoolean(childNode);\n break;\n case XmlNames.Elem.ProtPassword:\n this.memoryProtection.password = XmlUtils.getBoolean(childNode);\n break;\n case XmlNames.Elem.ProtUrl:\n this.memoryProtection.url = XmlUtils.getBoolean(childNode);\n break;\n case XmlNames.Elem.ProtNotes:\n this.memoryProtection.notes = XmlUtils.getBoolean(childNode);\n break;\n }\n }\n};\n\nKdbxMeta.prototype._writeMemoryProtection = function(parentNode) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.MemoryProt);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtTitle), this.memoryProtection.title);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtUserName), this.memoryProtection.userName);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtPassword), this.memoryProtection.password);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtUrl), this.memoryProtection.url);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.ProtNotes), this.memoryProtection.notes);\n};\n\nKdbxMeta.prototype._readCustomIcons = function(node) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName === XmlNames.Elem.CustomIconItem) {\n this._readCustomIcon(childNode);\n }\n }\n};\n\nKdbxMeta.prototype._readCustomIcon = function(node) {\n var uuid, data;\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n switch (childNode.tagName) {\n case XmlNames.Elem.CustomIconItemID:\n uuid = XmlUtils.getUuid(childNode);\n break;\n case XmlNames.Elem.CustomIconItemData:\n data = XmlUtils.getBytes(childNode);\n break;\n }\n }\n if (uuid && data) {\n this.customIcons[uuid] = data;\n }\n};\n\nKdbxMeta.prototype._writeCustomIcons = function(parentNode) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.CustomIcons);\n var customIcons = this.customIcons;\n Object.keys(customIcons).forEach(function(uuid) {\n var data = customIcons[uuid];\n if (data) {\n var itemNode = XmlUtils.addChildNode(node, XmlNames.Elem.CustomIconItem);\n XmlUtils.setUuid(XmlUtils.addChildNode(itemNode, XmlNames.Elem.CustomIconItemID), uuid);\n XmlUtils.setBytes(XmlUtils.addChildNode(itemNode, XmlNames.Elem.CustomIconItemData), data);\n }\n });\n};\n\nKdbxMeta.prototype._readBinaries = function(node, ctx) {\n for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName === XmlNames.Elem.Binary) {\n this._readBinary(childNode, ctx);\n }\n }\n};\n\nKdbxMeta.prototype._readBinary = function(node, ctx) {\n var id = node.getAttribute(XmlNames.Attr.Id);\n var binary = XmlUtils.getProtectedBinary(node);\n if (id && binary) {\n ctx.kdbx.binaries[id] = binary;\n }\n};\n\nKdbxMeta.prototype._writeBinaries = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Binaries);\n var binaries = ctx.kdbx.binaries;\n binaries.hashOrder.forEach(function(hash, index) {\n var data = binaries[hash];\n if (data) {\n var itemNode = XmlUtils.addChildNode(node, XmlNames.Elem.Binary);\n itemNode.setAttribute(XmlNames.Attr.Id, index.toString());\n XmlUtils.setProtectedBinary(itemNode, data);\n }\n });\n};\n\nKdbxMeta.prototype._readCustomData = function(node) {\n this.customData = KdbxCustomData.read(node);\n};\n\nKdbxMeta.prototype._writeCustomData = function(parentNode) {\n KdbxCustomData.write(parentNode, this.customData);\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxMeta.prototype.write = function(parentNode, ctx) {\n this.generator = Constants.generator;\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Meta);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Generator), Constants.Generator);\n if (ctx.kdbx.header.versionMajor < 4) {\n XmlUtils.setBytes(XmlUtils.addChildNode(node, XmlNames.Elem.HeaderHash), this.headerHash);\n } else if (this.settingsChanged) {\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.SettingsChanged), this.settingsChanged);\n }\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbName), this.name);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DbNameChanged), this.nameChanged);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbDesc), this.desc);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DbDescChanged), this.descChanged);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbDefaultUser), this.defaultUser);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DbDefaultUserChanged), this.defaultUserChanged);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbMntncHistoryDays), this.mntncHistoryDays);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.DbColor), this.color);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DbKeyChanged), this.keyChanged);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.DbKeyChangeRec), this.keyChangeRec);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.DbKeyChangeForce), this.keyChangeForce);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.RecycleBinEnabled), this.recycleBinEnabled);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.RecycleBinUuid), this.recycleBinUuid);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.RecycleBinChanged), this.recycleBinChanged);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.EntryTemplatesGroup), this.entryTemplatesGroup);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.EntryTemplatesGroupChanged), this.entryTemplatesGroupChanged);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.HistoryMaxItems), this.historyMaxItems);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.HistoryMaxSize), this.historyMaxSize);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.LastSelectedGroup), this.lastSelectedGroup);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.LastTopVisibleGroup), this.lastTopVisibleGroup);\n this._writeMemoryProtection(node);\n this._writeCustomIcons(node);\n if (ctx.exportXml || ctx.kdbx.header.versionMajor < 4) {\n this._writeBinaries(node, ctx);\n }\n this._writeCustomData(node);\n};\n\n/**\n * Merge meta with another db\n * @param {KdbxMeta} remote\n * @param {{objects, remote, deleted}} objectMap\n */\nKdbxMeta.prototype.merge = function(remote, objectMap) {\n if (remote.nameChanged > this.nameChanged) {\n this._name = remote.name;\n this.nameChanged = remote.nameChanged;\n }\n if (remote.descChanged > this.descChanged) {\n this._desc = remote.desc;\n this.descChanged = remote.descChanged;\n }\n if (remote.defaultUserChanged > this.defaultUserChanged) {\n this._defaultUser = remote.defaultUser;\n this.defaultUserChanged = remote.defaultUserChanged;\n }\n if (remote.keyChanged > this.keyChanged) {\n this.keyChanged = remote.keyChanged;\n }\n if (remote.settingsChanged > this.settingsChanged) {\n this.settingsChanged = remote.settingsChanged;\n }\n if (remote.recycleBinChanged > this.recycleBinChanged) {\n this._recycleBinEnabled = remote.recycleBinEnabled;\n this._recycleBinUuid = remote.recycleBinUuid;\n this.recycleBinChanged = remote.recycleBinChanged;\n }\n if (remote.entryTemplatesGroupChanged > this.entryTemplatesGroupChanged) {\n this._entryTemplatesGroup = remote.entryTemplatesGroup;\n this.entryTemplatesGroupChanged = remote.entryTemplatesGroupChanged;\n }\n Object.keys(remote.customData).forEach(function(key) {\n if (!this.customData[key] && !objectMap.deleted[key]) {\n this.customData[key] = remote.customData[key];\n }\n }, this);\n Object.keys(remote.customIcons).forEach(function(key) {\n if (!this.customIcons[key] && !objectMap.deleted[key]) {\n this.customIcons[key] = remote.customIcons[key];\n }\n }, this);\n if (!this._editState || !this._editState.historyMaxItems) { this.historyMaxItems = remote.historyMaxItems; }\n if (!this._editState || !this._editState.historyMaxSize) { this.historyMaxSize = remote.historyMaxSize; }\n if (!this._editState || !this._editState.keyChangeRec) { this.keyChangeRec = remote.keyChangeRec; }\n if (!this._editState || !this._editState.keyChangeForce) { this.keyChangeForce = remote.keyChangeForce; }\n if (!this._editState || !this._editState.mntncHistoryDays) { this.mntncHistoryDays = remote.mntncHistoryDays; }\n if (!this._editState || !this._editState.color) { this.color = remote.color; }\n};\n\n/**\n * Creates new meta\n * @returns {KdbxMeta}\n */\nKdbxMeta.create = function() {\n var now = new Date();\n var meta = new KdbxMeta();\n meta.generator = Constants.Generator;\n meta.settingsChanged = now;\n meta.mntncHistoryDays = Consts.Defaults.MntncHistoryDays;\n meta.recycleBinEnabled = true;\n meta.historyMaxItems = Consts.Defaults.HistoryMaxItems;\n meta.historyMaxSize = Consts.Defaults.HistoryMaxSize;\n meta.nameChanged = now;\n meta.descChanged = now;\n meta.defaultUserChanged = now;\n meta.recycleBinChanged = now;\n meta.keyChangeRec = -1;\n meta.keyChangeForce = -1;\n meta.entryTemplatesGroup = new KdbxUuid();\n meta.entryTemplatesGroupChanged = now;\n meta.memoryProtection = { title: false, userName: false, password: true, url: false, notes: false };\n return meta;\n};\n\n/**\n * Read KdbxMeta from stream\n * @param {Node} xmlNode - xml Meta node\n * @param {KdbxContext} ctx\n * @return {KdbxMeta}\n */\nKdbxMeta.read = function(xmlNode, ctx) {\n var meta = new KdbxMeta();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n meta._readNode(childNode, ctx);\n }\n }\n return meta;\n};\n\nmodule.exports = KdbxMeta;\n","'use strict';\n\nvar ProtectedValue = require('./../crypto/protected-value'),\n CryptoEngine = require('./../crypto/crypto-engine'),\n ByteUtils = require('./../utils/byte-utils');\n\nvar KdbxBinaries = function() {\n Object.defineProperties(this, {\n idToHash: { value: {} },\n hashOrder: { value: null, configurable: true }\n });\n};\n\nKdbxBinaries.prototype.hash = function() {\n var promises = [];\n var that = this;\n Object.keys(that).forEach(function(id) {\n var binary = that[id];\n promises.push(that.getBinaryHash(binary).then(function(hash) {\n that.idToHash[id] = hash;\n that[hash] = that[id];\n delete that[id];\n }));\n });\n return Promise.all(promises);\n};\n\nKdbxBinaries.prototype.getBinaryHash = function(binary) {\n var promise;\n if (binary instanceof ProtectedValue) {\n promise = binary.getHash();\n } else if (binary instanceof ArrayBuffer || binary instanceof Uint8Array) {\n binary = ByteUtils.arrayToBuffer(binary);\n promise = CryptoEngine.sha256(binary);\n }\n return promise.then(function(hash) {\n return ByteUtils.bytesToHex(hash);\n });\n};\n\nKdbxBinaries.prototype.assignIds = function() {\n Object.defineProperty(this, 'hashOrder', { value: Object.keys(this), configurable: true });\n};\n\nKdbxBinaries.prototype.add = function(value) {\n var that = this;\n return this.getBinaryHash(value).then(function(hash) {\n that[hash] = value;\n return { ref: hash, value: value };\n });\n};\n\nmodule.exports = KdbxBinaries;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils'),\n Consts = require('../defs/consts'),\n KdbxCustomData = require('./kdbx-custom-data'),\n KdbxTimes = require('./kdbx-times'),\n KdbxUuid = require('./kdbx-uuid'),\n KdbxEntry = require('./kdbx-entry');\n\n/**\n * Entries group\n * @constructor\n */\nvar KdbxGroup = function() {\n this.uuid = undefined;\n this.name = undefined;\n this.notes = undefined;\n this.icon = undefined;\n this.customIcon = undefined;\n this.times = new KdbxTimes();\n this.expanded = undefined;\n this.defaultAutoTypeSeq = undefined;\n this.enableAutoType = undefined;\n this.enableSearching = undefined;\n this.lastTopVisibleEntry = undefined;\n this.groups = [];\n this.entries = [];\n this.parentGroup = undefined;\n this.customData = undefined;\n Object.preventExtensions(this);\n};\n\nKdbxGroup.prototype._readNode = function(node, ctx) {\n switch (node.tagName) {\n case XmlNames.Elem.Uuid:\n this.uuid = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.Name:\n this.name = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.Notes:\n this.notes = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.Icon:\n this.icon = XmlUtils.getNumber(node);\n break;\n case XmlNames.Elem.CustomIconID:\n this.customIcon = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.Times:\n this.times = KdbxTimes.read(node);\n break;\n case XmlNames.Elem.IsExpanded:\n this.expanded = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.GroupDefaultAutoTypeSeq:\n this.defaultAutoTypeSeq = XmlUtils.getText(node);\n break;\n case XmlNames.Elem.EnableAutoType:\n this.enableAutoType = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.EnableSearching:\n this.enableSearching = XmlUtils.getBoolean(node);\n break;\n case XmlNames.Elem.LastTopVisibleEntry:\n this.lastTopVisibleEntry = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.Group:\n this.groups.push(KdbxGroup.read(node, ctx, this));\n break;\n case XmlNames.Elem.Entry:\n this.entries.push(KdbxEntry.read(node, ctx, this));\n break;\n case XmlNames.Elem.CustomData:\n this.customData = KdbxCustomData.read(node);\n break;\n }\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxGroup.prototype.write = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.Group);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.Uuid), this.uuid);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Name), this.name);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.Notes), this.notes);\n XmlUtils.setNumber(XmlUtils.addChildNode(node, XmlNames.Elem.Icon), this.icon);\n if (this.customIcon) {\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.CustomIconID), this.customIcon);\n }\n KdbxCustomData.write(node, this.customData);\n this.times.write(node, ctx);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.IsExpanded), this.expanded);\n XmlUtils.setText(XmlUtils.addChildNode(node, XmlNames.Elem.GroupDefaultAutoTypeSeq), this.defaultAutoTypeSeq);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.EnableAutoType), this.enableAutoType);\n XmlUtils.setBoolean(XmlUtils.addChildNode(node, XmlNames.Elem.EnableSearching), this.enableSearching);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.LastTopVisibleEntry), this.lastTopVisibleEntry);\n this.groups.forEach(function(g) { g.write(node, ctx); });\n this.entries.forEach(function(e) { e.write(node, ctx); });\n};\n\n/**\n * Invokes callback for each entry in recursive way\n * @param {function} callback - will be invoked with entry or group argument\n * @param {function} [thisArg] - callback context\n */\nKdbxGroup.prototype.forEach = function(callback, thisArg) {\n callback.call(thisArg, undefined, this);\n this.entries.forEach(function(entry) { callback.call(thisArg, entry); });\n this.groups.forEach(function(group) { group.forEach(callback, thisArg); });\n};\n\n/**\n * Merge group with remote group\n * @param {{objects, remote, deleted}} objectMap\n */\nKdbxGroup.prototype.merge = function(objectMap) {\n var remoteGroup = objectMap.remote[this.uuid];\n if (!remoteGroup) {\n return;\n }\n if (remoteGroup.times.lastModTime > this.times.lastModTime) {\n this.copyFrom(remoteGroup);\n }\n this.groups = this._mergeCollection(this.groups, remoteGroup.groups, objectMap);\n this.entries = this._mergeCollection(this.entries, remoteGroup.entries, objectMap);\n this.groups.forEach(function(group) { group.merge(objectMap); });\n this.entries.forEach(function(entry) { entry.merge(objectMap); });\n};\n\n/**\n * Merge object collection with remote collection\n * Implements 2P-set CRDT with tombstones stored in objectMap.deleted\n * Assumes tombstones are already merged\n * @param {object[]} collection - local groups or entries\n * @param {object[]} remoteCollection - remote groups or entries\n * @param {{objects, remote, deleted}} objectMap - local objects hashmap, remote objects hashmap and tombstones\n * @returns {object[]}\n * @private\n */\nKdbxGroup.prototype._mergeCollection = function(collection, remoteCollection, objectMap) {\n var newItems = [];\n collection.forEach(function(item) {\n if (objectMap.deleted[item.uuid]) {\n return; // item deleted\n }\n var remoteItem = objectMap.remote[item.uuid];\n if (!remoteItem) {\n newItems.push(item); // item added locally\n } else if (remoteItem.times.locationChanged <= item.times.locationChanged) {\n newItems.push(item); // item not changed or moved to this group locally later than remote\n }\n }, this);\n remoteCollection.forEach(function(remoteItem, ix) {\n if (objectMap.deleted[remoteItem.uuid]) {\n return; // item already processed as local item or deleted\n }\n var item = objectMap.objects[remoteItem.uuid];\n if (item && remoteItem.times.locationChanged > item.times.locationChanged) {\n item.parentGroup = this; // item moved to this group remotely later than local\n newItems.splice(this._findInsertIx(newItems, remoteCollection, ix), 0, item);\n } else if (!item) {\n var newItem = new remoteItem.constructor(); // item created remotely\n newItem.copyFrom(remoteItem);\n newItem.parentGroup = this;\n newItems.splice(this._findInsertIx(newItems, remoteCollection, ix), 0, newItem);\n }\n }, this);\n return newItems;\n};\n\n/**\n * Finds a best place to insert new item into collection\n * @param {object[]} dst - destination collection\n * @param {object[]} src - source item\n * @param {int} srcIx - source item index in collection\n * @returns {int} - index in collection\n * @private\n */\nKdbxGroup.prototype._findInsertIx = function(dst, src, srcIx) {\n var selectedIx = dst.length, selectedScore = -1;\n for (var dstIx = 0; dstIx <= dst.length; dstIx++) {\n var score = 0;\n var srcPrev = srcIx > 0 ? src[srcIx - 1].uuid.id : undefined,\n srcNext = srcIx + 1 < src.length ? src[srcIx + 1].uuid.id : undefined,\n dstPrev = dstIx > 0 ? dst[dstIx - 1].uuid.id : undefined,\n dstNext = dstIx < dst.length ? dst[dstIx].uuid.id : undefined;\n if (!srcPrev && !dstPrev) {\n score += 1; // start of sequence\n } else if (srcPrev === dstPrev) {\n score += 5; // previous element equals\n }\n if (!srcNext && !dstNext) {\n score += 2; // end of sequence\n } else if (srcNext === dstNext) {\n score += 5; // next element equals\n }\n if (score > selectedScore) {\n selectedIx = dstIx;\n selectedScore = score;\n }\n }\n return selectedIx;\n};\n\n/**\n * Clone group state from another group\n */\nKdbxGroup.prototype.copyFrom = function(group) {\n this.uuid = group.uuid;\n this.name = group.name;\n this.notes = group.notes;\n this.icon = group.icon;\n this.customIcon = group.customIcon;\n this.times = group.times.clone();\n this.expanded = group.expanded;\n this.defaultAutoTypeSeq = group.defaultAutoTypeSeq;\n this.enableAutoType = group.enableAutoType;\n this.enableSearching = group.enableSearching;\n this.lastTopVisibleEntry = group.lastTopVisibleEntry;\n};\n\n/**\n * Creates new group\n * @param {string} name\n * @param {KdbxGroup} [parentGroup]\n * @returns {KdbxGroup}\n */\nKdbxGroup.create = function(name, parentGroup) {\n var group = new KdbxGroup();\n group.uuid = KdbxUuid.random();\n group.icon = Consts.Icons.Folder;\n group.times = KdbxTimes.create();\n group.name = name;\n group.parentGroup = parentGroup;\n group.expanded = true;\n group.enableAutoType = null;\n group.enableSearching = null;\n group.lastTopVisibleEntry = new KdbxUuid();\n return group;\n};\n\n/**\n * Read group from xml\n * @param {Node} xmlNode\n * @param {KdbxContext} ctx\n * @param {KdbxGroup} [parentGroup]\n * @return {KdbxGroup}\n */\nKdbxGroup.read = function(xmlNode, ctx, parentGroup) {\n var grp = new KdbxGroup();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n grp._readNode(childNode, ctx);\n }\n }\n grp.parentGroup = parentGroup;\n return grp;\n};\n\nmodule.exports = KdbxGroup;\n","'use strict';\n\nvar XmlNames = require('./../defs/xml-names'),\n XmlUtils = require('./../utils/xml-utils');\n\n/**\n * Deleted object\n * @constructor\n */\nvar KdbxDeletedObject = function() {\n this.uuid = undefined;\n this.deletionTime = undefined;\n Object.preventExtensions(this);\n};\n\nKdbxDeletedObject.prototype._readNode = function(node) {\n switch (node.tagName) {\n case XmlNames.Elem.Uuid:\n this.uuid = XmlUtils.getUuid(node);\n break;\n case XmlNames.Elem.DeletionTime:\n this.deletionTime = XmlUtils.getDate(node);\n break;\n }\n};\n\n/**\n * Write to stream\n * @param {Node} parentNode - xml document node\n * @param {KdbxContext} ctx\n */\nKdbxDeletedObject.prototype.write = function(parentNode, ctx) {\n var node = XmlUtils.addChildNode(parentNode, XmlNames.Elem.DeletedObject);\n XmlUtils.setUuid(XmlUtils.addChildNode(node, XmlNames.Elem.Uuid), this.uuid);\n ctx.setXmlDate(XmlUtils.addChildNode(node, XmlNames.Elem.DeletionTime), this.deletionTime);\n};\n\n/**\n * Read deleted object from xml\n * @param {Node} xmlNode\n * @return {KdbxTimes}\n */\nKdbxDeletedObject.read = function(xmlNode) {\n var obj = new KdbxDeletedObject();\n for (var i = 0, cn = xmlNode.childNodes, len = cn.length; i < len; i++) {\n var childNode = cn[i];\n if (childNode.tagName) {\n obj._readNode(childNode);\n }\n }\n return obj;\n};\n\nmodule.exports = KdbxDeletedObject;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/kdbxweb.min.js b/dist/kdbxweb.min.js index fecc60f..0450544 100644 --- a/dist/kdbxweb.min.js +++ b/dist/kdbxweb.min.js @@ -1,2 +1,2 @@ -/*! kdbxweb v1.5.4, (c) 2019 Antelle, opensource.org/licenses/MIT */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("crypto"),require("xmldom")):"function"==typeof define&&define.amd?define(["crypto","xmldom"],t):"object"==typeof exports?exports.kdbxweb=t(require("crypto"),require("xmldom")):e.kdbxweb=t(e.crypto,e.xmldom)}(this,(function(e,t){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=29)}([function(e,t,r){"use strict";(function(t){var i=t.TextEncoder,n=t.TextDecoder;if(!i||!n){var o=r(40);i=o.TextEncoder,n=o.TextDecoder}var a=new i,s=new n;e.exports.arrayBufferEquals=function(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=new Uint8Array(e),i=new Uint8Array(t),n=0,o=r.length;n0;){var r=e%c;r=r>0?r:c;var i=new Uint8Array(r);s.getRandomValues(i),e-=r,t.set(i,e)}return t}(e);if(h)return new Uint8Array(h.randomBytes(e));throw new n(o.ErrorCodes.NotImplemented,"Random not implemented")},e.exports.createAesCbc=function(){if(d)return new f;if(h)return new p;throw new n(o.ErrorCodes.NotImplemented,"AES-CBC not implemented")},e.exports.chacha20=function(e,t,r){return Promise.resolve().then((function(){var n=new a(new Uint8Array(t),new Uint8Array(r));return i.arrayToBuffer(n.encrypt(new Uint8Array(e)))}))},e.exports.argon2=function(e,t,r,i,a,s,d,h){return Promise.reject(new n(o.ErrorCodes.NotImplemented,"Argon2 not implemented"))},e.exports.configure=function(e,t,r){d=e,s=t,h=r}}).call(this,r(13))},function(e,t,r){"use strict";(function(t){var i=r(2),n=r(1),o=r(6),a=r(7),s=r(9),d=r(0),h=r(8),u=r(16),l=/\.\d\d\d/,c=t.DOMParser?t:r(44),f=t.DOMParser?void 0:{errorHandler:{error:function(e){throw e},fatalError:function(e){throw e}}},p=62135596800;function m(e){var t,r=f?new c.DOMParser(f):new c.DOMParser;try{t=r.parseFromString(e,"application/xml")}catch(e){throw new i(n.ErrorCodes.FileCorrupt,"bad xml: "+e.message)}if(!t.documentElement)throw new i(n.ErrorCodes.FileCorrupt,"bad xml");var o=t.getElementsByTagName("parsererror")[0];if(o)throw new i(n.ErrorCodes.FileCorrupt,"bad xml: "+o.textContent);return t}function y(e){if(e&&e.childNodes)return e.protectedValue?e.protectedValue.text:e.textContent}function g(e,t){e.textContent=t||""}function _(e){var t=y(e);return t?d.arrayToBuffer(d.base64ToBytes(t)):void 0}function b(e,t){"string"==typeof t&&(t=d.base64ToBytes(t)),g(e,t?d.bytesToBase64(d.arrayToBuffer(t)):void 0)}function v(e){switch(e&&e.toLowerCase&&e.toLowerCase()){case"true":return!0;case"false":return!1;case"null":return null}}function w(e,t){t(e);for(var r=0,i=e.childNodes,n=i.length;r0?"\n"+" ".repeat(r-1):"";var a=t.ownerDocument||t;var s=[];var d;for(var h=0;h0){var c=a.createTextNode(o);t.appendChild(c)}e(d,r+1)}}(e,0);var r=(new c.XMLSerializer).serializeToString(e);return t&&r.startsWith(")<'+e+"/>")},e.exports.getChildNode=function(e,t,r){if(e&&e.childNodes)for(var o=0,a=e.childNodes,s=a.length;o0)return new Date(t);var r=new DataView(d.arrayToBuffer(d.base64ToBytes(t))),i=new h(r.getUint32(0,!0),r.getUint32(4,!0)).value;return new Date(1e3*(i-p))}},e.exports.setDate=function(e,t,r){if(t)if(r){var i=Math.floor(t.getTime()/1e3)+p,n=new DataView(new ArrayBuffer(8)),o=h.from(i);n.setUint32(0,o.lo,!0),n.setUint32(4,o.hi,!0),g(e,d.bytesToBase64(n.buffer))}else g(e,t.toISOString().replace(l,""));else g(e,"")},e.exports.getNumber=function(e){var t=y(e);return t?+t:void 0},e.exports.setNumber=function(e,t){g(e,"number"!=typeof t||isNaN(t)?void 0:t.toString())},e.exports.getBoolean=function(e){var t=y(e);return t?v(t):void 0},e.exports.setBoolean=function(e,t){g(e,void 0===t?"":null===t?"null":t?"True":"False")},e.exports.strToBoolean=v,e.exports.getUuid=function(e){var t=_(e);return t?new a(t):void 0},e.exports.setUuid=function(e,t){b(e,t instanceof a?t.toBytes():t)},e.exports.getProtectedText=function(e){return e.protectedValue||e.textContent},e.exports.setProtectedText=function(e,t){t instanceof s?(e.protectedValue=t,e.setAttribute(o.Attr.Protected,"True")):g(e,t)},e.exports.getProtectedBinary=function(e){if(e.protectedValue)return e.protectedValue;var t=e.textContent,r=e.getAttribute(o.Attr.Ref);if(r)return{ref:r};if(t){var i=v(e.getAttribute(o.Attr.Compressed)),n=d.base64ToBytes(t);return i&&(n=u.ungzip(n)),d.arrayToBuffer(n)}},e.exports.setProtectedBinary=function(e,t){t instanceof s?(e.protectedValue=t,e.setAttribute(o.Attr.Protected,"True")):t&&t.ref?e.setAttribute(o.Attr.Ref,t.ref):b(e,t)},e.exports.setProtectedValues=function(e,t){w(e,(function(e){if(v(e.getAttribute(o.Attr.Protected)))try{var r=d.arrayToBuffer(d.base64ToBytes(e.textContent));if(r.byteLength){var a=t.getSalt(r.byteLength);e.protectedValue=new s(r,a)}}catch(t){throw new i(n.ErrorCodes.FileCorrupt,"bad protected value at line "+e.lineNumber+": "+t)}}))},e.exports.updateProtectedValuesSalt=function(e,t){w(e,(function(e){if(v(e.getAttribute(o.Attr.Protected))&&e.protectedValue){var r=t.getSalt(e.protectedValue.byteLength);e.protectedValue.setSalt(r),e.textContent=e.protectedValue.toString()}}))},e.exports.unprotectValues=function(e){w(e,(function(e){v(e.getAttribute(o.Attr.Protected))&&e.protectedValue&&(e.removeAttribute(o.Attr.Protected),e.setAttribute(o.Attr.ProtectedInMemPlainXml,"True"),e.textContent=e.protectedValue.getText())}))},e.exports.protectUnprotectedValues=function(e){w(e,(function(e){v(e.getAttribute(o.Attr.ProtectedInMemPlainXml))&&e.protectedValue&&(e.removeAttribute(o.Attr.ProtectedInMemPlainXml),e.setAttribute(o.Attr.Protected,"True"),e.textContent=e.protectedValue.toString())}))},e.exports.protectPlainValues=function(e){w(e,(function(e){v(e.getAttribute(o.Attr.ProtectedInMemPlainXml))&&(e.protectedValue=s.fromString(e.textContent),e.textContent=e.protectedValue.toString(),e.removeAttribute(o.Attr.ProtectedInMemPlainXml),e.setAttribute(o.Attr.Protected,"True"))}))}}).call(this,r(13))},function(e,t,r){"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,i,n){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+i),n);else for(var o=0;o=2097152)throw new Error("too large number");return 4294967296*this.hi+this.lo}return this.lo}}),i.prototype.valueOf=function(){return this.value},i.from=function(e){if(e>9007199254740991)throw new Error("too large number");var t=e>>>0;return new i(t,(e-t)/4294967296>>>0)},e.exports=i},function(e,t,r){"use strict";var i=r(0),n=r(3),o=r(10),a=function(e,t){Object.defineProperty(this,"_value",{value:new Uint8Array(e)}),Object.defineProperty(this,"_salt",{value:new Uint8Array(t)})};a.prototype.toString=function(){return i.bytesToBase64(this._value)},a.fromString=function(e){for(var t=i.stringToBytes(e),r=o.getBytes(t.length),n=0,s=t.length;n=0;i--)r[i]=e[i]^t[i];return r},a.prototype.setSalt=function(e){for(var t=new Uint8Array(e),r=this._value,i=this._salt,n=0,o=r.length;n=0;--i)t[i]^=r[i];return t}},function(e,t,r){"use strict";function i(e){this._arrayBuffer=e||new ArrayBuffer(1024),this._dataView=new DataView(this._arrayBuffer),this._pos=0,this._canExpand=!e}["Int","Uint","Float"].forEach((function(e){("Float"===e?[4,8]:[1,2,4]).forEach((function(t){var r="get"+e+8*t;i.prototype[r]=function(e){var i=this._dataView[r].call(this._dataView,this._pos,e);return this._pos+=t,i};var n="set"+e+8*t;i.prototype[n]=function(e,r){this._checkCapacity(t),this._dataView[n].call(this._dataView,this._pos,e,r),this._pos+=t}}))})),i.prototype.getUint64=function(e){var t=this.getUint32(e),r=this.getUint32(e);return e?r*=4294967296:t*=4294967296,t+r},i.prototype.setUint64=function(e,t){t?(this.setUint32(4294967295&e,!0),this.setUint32(Math.floor(e/4294967296),!0)):(this._checkCapacity(8),this.setUint32(Math.floor(e/4294967296),!1),this.setUint32(4294967295&e,!1))},i.prototype.readBytes=function(e){var t=this._arrayBuffer.slice(this._pos,this._pos+e);return this._pos+=e,t},i.prototype.readBytesToEnd=function(){var e=this._arrayBuffer.byteLength-this._pos;return this.readBytes(e)},i.prototype.readBytesNoAdvance=function(e,t){return this._arrayBuffer.slice(e,t)},i.prototype.writeBytes=function(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e)),this._checkCapacity(e.length),new Uint8Array(this._arrayBuffer).set(e,this._pos),this._pos+=e.length},i.prototype.getWrittenBytes=function(){return this._arrayBuffer.slice(0,this._pos)},i.prototype._checkCapacity=function(e){var t=this._arrayBuffer.byteLength-this._pos;if(this._canExpand&&t1)throw new i(n.ErrorCodes.InvalidVersion)},d.prototype._readItem=function(e){var t=e.getUint8();if(!t)return!1;var r=e.getInt32(!0);if(r<=0)throw new i(n.ErrorCodes.FileCorrupt,"bad key length");var d,h=o.bytesToString(e.readBytes(r)),u=e.getInt32(!0);if(u<0)throw new i(n.ErrorCodes.FileCorrupt,"bad value length");switch(t){case s.UInt32:if(4!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad uint32");d=e.getUint32(!0);break;case s.UInt64:if(8!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad uint64");var l=e.getUint32(!0),c=e.getUint32(!0);d=new a(l,c);break;case s.Bool:if(1!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad bool");d=0!==e.getUint8();break;case s.Int32:if(4!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad int32");d=e.getInt32(!0);break;case s.Int64:if(8!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad int64");var f=e.getUint32(!0),p=e.getUint32(!0);d=new a(f,p);break;case s.String:d=o.bytesToString(e.readBytes(u));break;case s.Bytes:d=e.readBytes(u);break;default:throw new i(n.ErrorCodes.FileCorrupt,"bad value type: "+t)}return{key:h,type:t,value:d}},d.prototype.write=function(e){this._writeVersion(e),Object.keys(this._items).forEach((function(t){this._writeItem(e,this._items[t])}),this),e.setUint8(0)},d.prototype._writeVersion=function(e){e.setUint16(256,!0)},d.prototype._writeItem=function(e,t){e.setUint8(t.type);var r=o.stringToBytes(t.key);switch(e.setInt32(r.length,!0),e.writeBytes(r),t.type){case s.UInt32:e.setInt32(4,!0),e.setUint32(t.value,!0);break;case s.UInt64:e.setInt32(8,!0),e.setUint32(t.value.lo,!0),e.setUint32(t.value.hi,!0);break;case s.Bool:e.setInt32(1,!0),e.setUint8(t.value?1:0);break;case s.Int32:e.setInt32(4,!0),e.setInt32(t.value,!0);break;case s.Int64:e.setInt32(8,!0),e.setUint32(t.value.lo,!0),e.setUint32(t.value.hi,!0);break;case s.String:var a=o.stringToBytes(t.value);e.setInt32(a.length,!0),e.writeBytes(a);break;case s.Bytes:var d=o.arrayToBuffer(t.value);e.setInt32(d.byteLength,!0),e.writeBytes(d);break;default:throw new i(n.ErrorCodes.Unsupported)}},e.exports=d},function(e,t,r){"use strict";var i=r(6),n=r(4),o={read:function(e){for(var t={},r=0,n=e.childNodes,a=n.length;r>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(n=n+t[i++]|0)|0}while(--a);n%=65521,o%=65521}return n|o<<16|0}},function(e,t,r){"use strict";var i=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();e.exports=function(e,t,r,n){var o=i,a=n+r;e^=-1;for(var s=n;s>>8^o[255&(e^t[s])];return-1^e}},function(e,t,r){"use strict";var i=r(5),n=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var a=new i.Buf8(256),s=0;s<256;s++)a[s]=s>=252?6:s>=248?5:s>=240?4:s>=224?3:s>=192?2:1;function d(e,t){if(t<65537&&(e.subarray&&o||!e.subarray&&n))return String.fromCharCode.apply(null,i.shrinkBuf(e,t));for(var r="",a=0;a>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},t.buf2binstring=function(e){return d(e,e.length)},t.binstring2buf=function(e){for(var t=new i.Buf8(e.length),r=0,n=t.length;r4)h[i++]=65533,r+=o-1;else{for(n&=2===o?31:3===o?15:7;o>1&&r1?h[i++]=65533:n<65536?h[i++]=n:(n-=65536,h[i++]=55296|n>>10&1023,h[i++]=56320|1023&n)}return d(h,i)},t.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+a[e[r]]>t?r:t}},function(e,t,r){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},function(e,t,r){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(e,t,r){"use strict";var i=r(7),n=r(1),o=r(9),a=r(2),s=r(11),d=r(0),h=r(14),u=r(8),l=r(10),c=[{name:"EndOfHeader"},{name:"Comment"},{name:"CipherID"},{name:"CompressionFlags"},{name:"MasterSeed"},{name:"TransformSeed",ver:[3]},{name:"TransformRounds",ver:[3]},{name:"EncryptionIV"},{name:"ProtectedStreamKey",ver:[3]},{name:"StreamStartBytes",ver:[3]},{name:"InnerRandomStreamID",ver:[3]},{name:"KdfParameters",ver:[4]},{name:"PublicCustomData",ver:[4]}],f=[{name:"EndOfHeader"},{name:"InnerRandomStreamID"},{name:"InnerRandomStreamKey"},{name:"Binary",skipHeader:!0}],p={DefaultFileVersionMajor:3,DefaultFileVersionMinor:1,MaxFileVersionMajor:4,MaxFileVersionMinor:1,MaxSupportedVersion:4,FlagBinaryProtected:1,InnerHeaderBinaryFieldId:3,DefaultKdfAlgo:n.KdfId.Argon2,DefaultKdfSaltLength:32,DefaultKdfParallelism:1,DefaultKdfIterations:2,DefaultKdfMemory:1048576,DefaultKdfVersion:19},m={3:1,4:1},y=function(){this.versionMajor=void 0,this.versionMinor=void 0,this.dataCipherUuid=void 0,this.compression=void 0,this.masterSeed=void 0,this.transformSeed=void 0,this.keyEncryptionRounds=void 0,this.encryptionIV=void 0,this.protectedStreamKey=void 0,this.streamStartBytes=void 0,this.crsAlgorithm=void 0,this.endPos=void 0,this.kdfParameters=void 0,this.publicCustomData=void 0,Object.preventExtensions(this)};y.prototype._readSignature=function(e){if(e.byteLength<8)throw new a(n.ErrorCodes.FileCorrupt,"not enough data");var t=e.getUint32(!0),r=e.getUint32(!0);if(t!==n.Signatures.FileMagic||r!==n.Signatures.Sig2Kdbx)throw new a(n.ErrorCodes.BadSignature)},y.prototype._writeSignature=function(e){e.setUint32(n.Signatures.FileMagic,!0),e.setUint32(n.Signatures.Sig2Kdbx,!0)},y.prototype._readVersion=function(e){var t=e.getUint16(!0),r=e.getUint16(!0);if(r>p.MaxSupportedVersion)throw new a(n.ErrorCodes.InvalidVersion);this.versionMinor=t,this.versionMajor=r},y.prototype._writeVersion=function(e){e.setUint16(this.versionMinor,!0),e.setUint16(this.versionMajor,!0)},y.prototype._readCipherID=function(e){if(16!==e.byteLength)throw new a(n.ErrorCodes.Unsupported,"cipher");this.dataCipherUuid=new i(e)},y.prototype._writeCipherID=function(e){this._writeFieldSize(e,16),e.writeBytes(this.dataCipherUuid.bytes)},y.prototype._readCompressionFlags=function(e){var t=new DataView(e).getUint32(e,!0);if(t<0||t>=Object.keys(n.CompressionAlgorithm).length)throw new a(n.ErrorCodes.Unsupported,"compression");this.compression=t},y.prototype._writeCompressionFlags=function(e){this._writeFieldSize(e,4),e.setUint32(this.compression,!0)},y.prototype._readMasterSeed=function(e){this.masterSeed=e},y.prototype._writeMasterSeed=function(e){this._writeFieldBytes(e,this.masterSeed)},y.prototype._readTransformSeed=function(e){this.transformSeed=e},y.prototype._writeTransformSeed=function(e){this._writeFieldBytes(e,this.transformSeed)},y.prototype._readTransformRounds=function(e){this.keyEncryptionRounds=new s(e).getUint64(!0)},y.prototype._writeTransformRounds=function(e){this._writeFieldSize(e,8),e.setUint64(this.keyEncryptionRounds,!0)},y.prototype._readEncryptionIV=function(e){this.encryptionIV=e},y.prototype._writeEncryptionIV=function(e){this._writeFieldBytes(e,this.encryptionIV)},y.prototype._readProtectedStreamKey=function(e){this.protectedStreamKey=e},y.prototype._writeProtectedStreamKey=function(e){this._writeFieldBytes(e,this.protectedStreamKey)},y.prototype._readStreamStartBytes=function(e){this.streamStartBytes=e},y.prototype._writeStreamStartBytes=function(e){this._writeFieldBytes(e,this.streamStartBytes)},y.prototype._readInnerRandomStreamID=function(e){this.crsAlgorithm=new DataView(e).getUint32(e,!0)},y.prototype._writeInnerRandomStreamID=function(e){this._writeFieldSize(e,4),e.setUint32(this.crsAlgorithm,!0)},y.prototype._readInnerRandomStreamKey=function(e){this.protectedStreamKey=e},y.prototype._writeInnerRandomStreamKey=function(e){this._writeFieldBytes(e,this.protectedStreamKey)},y.prototype._readKdfParameters=function(e){this.kdfParameters=h.read(new s(e))},y.prototype._writeKdfParameters=function(e){var t=new s;this.kdfParameters.write(t),this._writeFieldBytes(e,t.getWrittenBytes())},y.prototype._readPublicCustomData=function(e){this.publicCustomData=h.read(new s(e))},y.prototype._hasPublicCustomData=function(){return this.publicCustomData},y.prototype._writePublicCustomData=function(e){if(this.publicCustomData){var t=new s;this.publicCustomData.write(t),this._writeFieldBytes(e,t.getWrittenBytes())}},y.prototype._readBinary=function(e,t){var r=new DataView(e).getUint8(0)&p.FlagBinaryProtected,i=e.slice(1),n=r?o.fromBinary(i):i,a=Object.keys(t.kdbx.binaries).length;t.kdbx.binaries[a]=n},y.prototype._writeBinary=function(e,t){if(!(this.versionMajor<4))for(var r=t.kdbx.binaries.hashOrder,i=0;i0&&(i=e.readBytes(o));var a=t[n];if(a){var s=this["_read"+a.name];s&&s.call(this,i,r)}return 0!==n},y.prototype._writeField=function(e,t,r,i){var n=r[t];if(n){if(n.ver&&n.ver.indexOf(this.versionMajor)<0)return;var o=this["_write"+n.name];if(o){var a=this["_has"+n.name];if(a&&!a.call(this))return;n.skipHeader||e.setUint8(t),o.call(this,e,i)}}},y.prototype._readFieldSize=function(e){return this.versionMajor>=4?e.getUint32(!0):e.getUint16(!0)},y.prototype._writeFieldSize=function(e,t){this.versionMajor>=4?e.setUint32(t,!0):e.setUint16(t,!0)},y.prototype._writeFieldBytes=function(e,t){this._writeFieldSize(e,t.byteLength),e.writeBytes(t)},y.prototype._validate=function(){if(void 0===this.dataCipherUuid)throw new a(n.ErrorCodes.FileCorrupt,"no cipher in header");if(void 0===this.compression)throw new a(n.ErrorCodes.FileCorrupt,"no compression in header");if(!this.masterSeed)throw new a(n.ErrorCodes.FileCorrupt,"no master seed in header");if(this.versionMajor<4&&!this.transformSeed)throw new a(n.ErrorCodes.FileCorrupt,"no transform seed in header");if(this.versionMajor<4&&!this.keyEncryptionRounds)throw new a(n.ErrorCodes.FileCorrupt,"no key encryption rounds in header");if(!this.encryptionIV)throw new a(n.ErrorCodes.FileCorrupt,"no encryption iv in header");if(this.versionMajor<4&&!this.protectedStreamKey)throw new a(n.ErrorCodes.FileCorrupt,"no protected stream key in header");if(this.versionMajor<4&&!this.streamStartBytes)throw new a(n.ErrorCodes.FileCorrupt,"no stream start bytes in header");if(this.versionMajor<4&&!this.crsAlgorithm)throw new a(n.ErrorCodes.FileCorrupt,"no crs algorithm in header");if(this.versionMajor>=4&&!this.kdfParameters)throw new a(n.ErrorCodes.FileCorrupt,"no kdf parameters in header")},y.prototype._validateInner=function(){if(!this.protectedStreamKey)throw new a(n.ErrorCodes.FileCorrupt,"no protected stream key in header");if(!this.crsAlgorithm)throw new a(n.ErrorCodes.FileCorrupt,"no crs algorithm in header")},y.prototype._createKdfParameters=function(e){switch(e||(e=p.DefaultKdfAlgo),e){case n.KdfId.Argon2:this.kdfParameters=new h,this.kdfParameters.set("$UUID",h.ValueType.Bytes,d.base64ToBytes(n.KdfId.Argon2)),this.kdfParameters.set("S",h.ValueType.Bytes,l.getBytes(p.DefaultKdfSaltLength)),this.kdfParameters.set("P",h.ValueType.UInt32,p.DefaultKdfParallelism),this.kdfParameters.set("I",h.ValueType.UInt64,new u(p.DefaultKdfIterations)),this.kdfParameters.set("M",h.ValueType.UInt64,new u(p.DefaultKdfMemory)),this.kdfParameters.set("V",h.ValueType.UInt32,p.DefaultKdfVersion);break;case n.KdfId.Aes:this.kdfParameters=new h,this.kdfParameters.set("$UUID",h.ValueType.Bytes,d.base64ToBytes(n.KdfId.Aes)),this.kdfParameters.set("S",h.ValueType.Bytes,l.getBytes(p.DefaultKdfSaltLength)),this.kdfParameters.set("R",h.ValueType.UInt32,n.Defaults.KeyEncryptionRounds);break;default:throw new a(n.ErrorCodes.InvalidArg,"bad KDF algo")}},y.prototype.write=function(e){this._validate(),this._writeSignature(e),this._writeVersion(e);for(var t=1;t>4&15]),r.push(t[15&i[n]]);return r.join("")},i.prototype._reset=function(){this.counterWords[0]=0,this.counterWords[1]=0,this.blockUsed=64},i.prototype._incrementCounter=function(){this.counterWords[0]=this.counterWords[0]+1&4294967295,0===this.counterWords[0]&&(this.counterWords[1]=this.counterWords[1]+1&4294967295)},i.prototype._generateBlock=function(){for(var e,t=this.sigmaWords[0],r=this.keyWords[0],i=this.keyWords[1],n=this.keyWords[2],o=this.keyWords[3],a=this.sigmaWords[1],s=this.nonceWords[0],d=this.nonceWords[1],h=this.counterWords[0],u=this.counterWords[1],l=this.sigmaWords[2],c=this.keyWords[4],f=this.keyWords[5],p=this.keyWords[6],m=this.keyWords[7],y=this.sigmaWords[3],g=t,_=r,b=i,v=n,w=o,k=a,C=s,x=d,E=h,B=u,T=l,S=c,A=f,D=p,U=m,I=y,N=0;N>>25)+g)<<9|e>>>23)+w)<<13|e>>>19)+E)<<18|e>>>14,k^=(e=(_^=(e=(D^=(e=(B^=(e=k+_)<<7|e>>>25)+k)<<9|e>>>23)+B)<<13|e>>>19)+D)<<18|e>>>14,T^=(e=(C^=(e=(b^=(e=(U^=(e=T+C)<<7|e>>>25)+T)<<9|e>>>23)+U)<<13|e>>>19)+b)<<18|e>>>14,I^=(e=(S^=(e=(x^=(e=(v^=(e=I+S)<<7|e>>>25)+I)<<9|e>>>23)+v)<<13|e>>>19)+x)<<18|e>>>14,g^=(e=(v^=(e=(b^=(e=(_^=(e=g+v)<<7|e>>>25)+g)<<9|e>>>23)+_)<<13|e>>>19)+b)<<18|e>>>14,k^=(e=(w^=(e=(x^=(e=(C^=(e=k+w)<<7|e>>>25)+k)<<9|e>>>23)+C)<<13|e>>>19)+x)<<18|e>>>14,T^=(e=(B^=(e=(E^=(e=(S^=(e=T+B)<<7|e>>>25)+T)<<9|e>>>23)+S)<<13|e>>>19)+E)<<18|e>>>14,I^=(e=(U^=(e=(D^=(e=(A^=(e=I+U)<<7|e>>>25)+I)<<9|e>>>23)+A)<<13|e>>>19)+D)<<18|e>>>14;g+=t,_+=r,b+=i,v+=n,w+=o,k+=a,C+=s,x+=d,E+=h,B+=u,T+=l,S+=c,A+=f,D+=p,U+=m,I+=y,this.block[0]=g>>>0&255,this.block[1]=g>>>8&255,this.block[2]=g>>>16&255,this.block[3]=g>>>24&255,this.block[4]=_>>>0&255,this.block[5]=_>>>8&255,this.block[6]=_>>>16&255,this.block[7]=_>>>24&255,this.block[8]=b>>>0&255,this.block[9]=b>>>8&255,this.block[10]=b>>>16&255,this.block[11]=b>>>24&255,this.block[12]=v>>>0&255,this.block[13]=v>>>8&255,this.block[14]=v>>>16&255,this.block[15]=v>>>24&255,this.block[16]=w>>>0&255,this.block[17]=w>>>8&255,this.block[18]=w>>>16&255,this.block[19]=w>>>24&255,this.block[20]=k>>>0&255,this.block[21]=k>>>8&255,this.block[22]=k>>>16&255,this.block[23]=k>>>24&255,this.block[24]=C>>>0&255,this.block[25]=C>>>8&255,this.block[26]=C>>>16&255,this.block[27]=C>>>24&255,this.block[28]=x>>>0&255,this.block[29]=x>>>8&255,this.block[30]=x>>>16&255,this.block[31]=x>>>24&255,this.block[32]=E>>>0&255,this.block[33]=E>>>8&255,this.block[34]=E>>>16&255,this.block[35]=E>>>24&255,this.block[36]=B>>>0&255,this.block[37]=B>>>8&255,this.block[38]=B>>>16&255,this.block[39]=B>>>24&255,this.block[40]=T>>>0&255,this.block[41]=T>>>8&255,this.block[42]=T>>>16&255,this.block[43]=T>>>24&255,this.block[44]=S>>>0&255,this.block[45]=S>>>8&255,this.block[46]=S>>>16&255,this.block[47]=S>>>24&255,this.block[48]=A>>>0&255,this.block[49]=A>>>8&255,this.block[50]=A>>>16&255,this.block[51]=A>>>24&255,this.block[52]=D>>>0&255,this.block[53]=D>>>8&255,this.block[54]=D>>>16&255,this.block[55]=D>>>24&255,this.block[56]=U>>>0&255,this.block[57]=U>>>8&255,this.block[58]=U>>>16&255,this.block[59]=U>>>24&255,this.block[60]=I>>>0&255,this.block[61]=I>>>8&255,this.block[62]=I>>>16&255,this.block[63]=I>>>24&255},e.exports=i},function(e,t,r){"use strict";function i(e,t){this.sigmaWords=[1634760805,857760878,2036477234,1797285236],this.block=new Uint8Array(64),this.blockUsed=64,this.x=new Uint32Array(16);var r=new Uint32Array(16);r[0]=this.sigmaWords[0],r[1]=this.sigmaWords[1],r[2]=this.sigmaWords[2],r[3]=this.sigmaWords[3],r[4]=o(e,0),r[5]=o(e,4),r[6]=o(e,8),r[7]=o(e,12),r[8]=o(e,16),r[9]=o(e,20),r[10]=o(e,24),r[11]=o(e,28),r[12]=0,12===t.length?(r[13]=o(t,0),r[14]=o(t,4),r[15]=o(t,8)):(r[13]=0,r[14]=o(t,0),r[15]=o(t,4)),this.input=r}function n(e,t,r,i,n){e[t]+=e[r],e[n]=s(e[n]^e[t],16),e[i]+=e[n],e[r]=s(e[r]^e[i],12),e[t]+=e[r],e[n]=s(e[n]^e[t],8),e[i]+=e[n],e[r]=s(e[r]^e[i],7)}function o(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function a(e,t,r){e[t]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+3]=r}function s(e,t){return e<>>32-t}i.prototype.getBytes=function(e){for(var t=new Uint8Array(e),r=0;r0;e-=2)n(r,0,4,8,12),n(r,1,5,9,13),n(r,2,6,10,14),n(r,3,7,11,15),n(r,0,5,10,15),n(r,1,6,11,12),n(r,2,7,8,13),n(r,3,4,9,14);for(e=16;e--;)r[e]+=t[e];for(e=16;e--;)a(i,4*e,r[e]);t[12]+=1,t[12]||(t[13]+=1)},i.prototype.encrypt=function(e){for(var t=e.length,r=new Uint8Array(t),i=0,n=this.block;i0;){var d=Math.min(r,o);r-=d;var u=a*d;n=h(e,n,s.length===u?s.buffer:i.arrayToBuffer(s.subarray(0,u)))}return n.then((function(e){return new Uint8Array(e)}))}function h(e,t,r){return t.then((function(t){return e.encrypt(r,t)})).then((function(e){var t=i.arrayToBuffer(new Uint8Array(e).subarray(-2*a,-a));return i.zeroBuffer(e),t}))}e.exports.encrypt=function(e,t,r){var o=n.createAesCbc();return o.importKey(i.arrayToBuffer(t)).then((function(){for(var t=[],i=0;i\n \n";return a.stringToBytes(t)},e.exports=u},function(e,t,r){"use strict";var i=r(6),n=r(4),o=function(){this.creationTime=void 0,this.lastModTime=void 0,this.lastAccessTime=void 0,this.expiryTime=void 0,this.expires=void 0,this.usageCount=void 0,this.locationChanged=new Date,Object.preventExtensions(this)};o.prototype._readNode=function(e){switch(e.tagName){case i.Elem.CreationTime:this.creationTime=n.getDate(e);break;case i.Elem.LastModTime:this.lastModTime=n.getDate(e);break;case i.Elem.LastAccessTime:this.lastAccessTime=n.getDate(e);break;case i.Elem.ExpiryTime:this.expiryTime=n.getDate(e);break;case i.Elem.Expires:this.expires=n.getBoolean(e);break;case i.Elem.UsageCount:this.usageCount=n.getNumber(e);break;case i.Elem.LocationChanged:this.locationChanged=n.getDate(e)}},o.prototype.clone=function(){var e=new o;return e.creationTime=this.creationTime,e.lastModTime=this.lastModTime,e.lastAccessTime=this.lastAccessTime,e.expiryTime=this.expiryTime,e.expires=this.expires,e.usageCount=this.usageCount,e.locationChanged=this.locationChanged,e},o.prototype.update=function(){var e=new Date;this.lastModTime=e,this.lastAccessTime=e},o.prototype.write=function(e,t){var r=n.addChildNode(e,i.Elem.Times);t.setXmlDate(n.addChildNode(r,i.Elem.CreationTime),this.creationTime),t.setXmlDate(n.addChildNode(r,i.Elem.LastModTime),this.lastModTime),t.setXmlDate(n.addChildNode(r,i.Elem.LastAccessTime),this.lastAccessTime),t.setXmlDate(n.addChildNode(r,i.Elem.ExpiryTime),this.expiryTime),n.setBoolean(n.addChildNode(r,i.Elem.Expires),this.expires),n.setNumber(n.addChildNode(r,i.Elem.UsageCount),this.usageCount),t.setXmlDate(n.addChildNode(r,i.Elem.LocationChanged),this.locationChanged)},o.create=function(){var e=new o,t=new Date;return e.creationTime=t,e.lastModTime=t,e.lastAccessTime=t,e.expiryTime=t,e.expires=!1,e.usageCount=0,e.locationChanged=t,e},o.read=function(e){for(var t=new o,r=0,i=e.childNodes,n=i.length;rt.times.lastModTime){if(!this.history.some((function(e){return+e.times.lastModTime==+t.times.lastModTime}))){var i=new l;i.copyFrom(t),r.push(i)}}this.history=this._mergeHistory(r,t.times.lastModTime)}},l.prototype._mergeHistory=function(e,t){this.history.sort((function(e,t){return e.times.lastModTime-t.times.lastModTime})),e.sort((function(e,t){return e.times.lastModTime-t.times.lastModTime}));var r={},i={};this.history.forEach((function(e){r[e.times.lastModTime.getTime()]=e})),e.forEach((function(e){i[e.times.lastModTime.getTime()]=e}));for(var n=0,o=0,a=[];nu){if(!this._editState||this._editState.deleted.indexOf(u)<0){var c=new l;c.copyFrom(d),a.push(c)}o++}else this._editState&&this._editState.added.indexOf(h)>=0?a.push(s):h>t&&a.push(s),n++;else a.push(s),n++,o++}return a},l.create=function(e,t){var r=new l(t);return r.uuid=d.random(),r.icon=a.Icons.Key,r.times=h.create(),r.parentGroup=t,r._setField("Title","",e.memoryProtection.title),r._setField("UserName",e.defaultUser||"",e.memoryProtection.userName),r._setField("Password","",e.memoryProtection.password),r._setField("URL","",e.memoryProtection.url),r._setField("Notes","",e.memoryProtection.notes),r.autoType.enabled="boolean"!=typeof t.enableAutoType||t.enableAutoType,r.autoType.obfuscation=a.AutoTypeObfuscationOptions.None,r},l.read=function(e,t,r){for(var i=new l,n=0,o=e.childNodes,a=o.length;n=0?t[i].splice(r,0,e):t[i].push(e);else{var a=new Date;e instanceof h?e.forEach((function(e,t){this.addDeletedObject((e||t).uuid,a)}),this):this.addDeletedObject(e.uuid,a)}e.parentGroup=t,e.times.locationChanged=new Date}},y.prototype.addDeletedObject=function(e,t){var r=new l;r.uuid=e,r.deletionTime=t,this.deletedObjects.push(r)},y.prototype.remove=function(e){var t=null;this.meta.recycleBinEnabled&&(this.createRecycleBin(),t=this.getGroup(this.meta.recycleBinUuid)),this.move(e,t)},y.prototype.createBinary=function(e){return this.binaries.add(e)},y.prototype.importEntry=function(e,t,r){var i=new u,n=c.random();i.copyFrom(e),i.uuid=n,e.history.forEach((function(e){var t=new u;t.copyFrom(e),t.uuid=n,i.history.push(t)}));var o={},a={};return i.history.concat(i).forEach((function(e){e.customIcon&&(a[e.customIcon]=e.customIcon),Object.values(e.binaries).forEach((function(e){e.ref&&(o[e.ref]=e)}))})),Object.values(o).forEach((function(e){var t=r.binaries[e.ref];t&&!this.binaries[e.ref]&&(this.binaries[e.ref]=t)}),this),Object.values(a).forEach((function(e){var t=r.meta.customIcons[e];t&&(this.meta.customIcons[e]=t)}),this),t.entries.push(i),e.parentGroup=t,e.times.update(),i},y.prototype.cleanup=function(e){var t=new Date,r=e&&e.historyRules&&this.meta.historyMaxItems&&this.meta.historyMaxItems>0?this.meta.historyMaxItems:1/0,i={},n={},o=function(e){e&&e.customIcon&&(i[e.customIcon]=!0),e&&e.binaries&&Object.keys(e.binaries).forEach((function(t){e.binaries[t]&&e.binaries[t].ref&&(n[e.binaries[t].ref]=!0)}))};this.getDefaultGroup().forEach((function(e,t){e&&e.history.length>r&&e.removeHistory(0,e.history.length-r),e&&o(e),e&&e.history&&e.history.forEach((function(e){o(e)})),t&&t.customIcon&&(i[t.customIcon]=!0)})),e&&e.customIcons&&Object.keys(this.meta.customIcons).forEach((function(e){if(!i[e]){var r=new c(e);this.addDeletedObject(r,t),delete this.meta.customIcons[e]}}),this),e&&e.binaries&&Object.keys(this.binaries).forEach((function(e){n[e]||delete this.binaries[e]}),this)},y.prototype.merge=function(e){var t=this.getDefaultGroup(),r=e.getDefaultGroup();if(!t||!r)throw new n(f.ErrorCodes.MergeError,"no default group");if(!t.uuid.equals(r.uuid))throw new n(f.ErrorCodes.MergeError,"default group is different");var i=this._getObjectMap();e.deletedObjects.forEach((function(e){i.deleted[e.uuid]||(this.deletedObjects.push(e),i.deleted[e.uuid]=e.deletionTime)}),this),Object.keys(e.binaries).forEach((function(t){this.binaries[t]||i.deleted[t]||(this.binaries[t]=e.binaries[t])}),this),i.remote=e._getObjectMap().objects,this.meta.merge(e.meta,i),t.merge(i),this.cleanup({historyRules:!0,customIcons:!0,binaries:!0})},y.prototype.getLocalEditState=function(){var e={};return this.getDefaultGroup().forEach((function(t){t&&t._editState&&(e[t.uuid]=t._editState)})),this.meta._editState&&(e.meta=this.meta._editState),e},y.prototype.setLocalEditState=function(e){this.getDefaultGroup().forEach((function(t){t&&e[t.uuid]&&(t._editState=e[t.uuid])})),e.meta&&(this.meta._editState=e.meta)},y.prototype.removeLocalEditState=function(){this.getDefaultGroup().forEach((function(e){e&&(e._editState=void 0)})),this.meta._editState=void 0},y.prototype.upgrade=function(){this.setVersion(a.MaxFileVersion)},y.prototype.setVersion=function(e){this.meta.headerHash=null,this.meta.settingsChanged=new Date,this.header.setVersion(e)},y.prototype.setKdf=function(e){this.meta.headerHash=null,this.meta.settingsChanged=new Date,this.header.setKdf(e)},y.prototype._getObjectMap=function(){var e={},t={};return this.getDefaultGroup().forEach((function(t,r){var i=t||r;if(e[i.uuid])throw new n(f.ErrorCodes.MergeError,"Duplicate: "+i.uuid);e[i.uuid]=i})),this.deletedObjects.forEach((function(e){t[e.uuid]=e.deletionTime})),{objects:e,deleted:t}},y.prototype._loadFromXml=function(e){if(this.xml.documentElement.tagName!==p.Elem.DocNode)throw new n(f.ErrorCodes.FileCorrupt,"bad xml root");this._parseMeta(e);var t=this;return this.binaries.hash().then((function(){return t._parseRoot(e),t}))},y.prototype._parseMeta=function(e){var t=m.getChildNode(this.xml.documentElement,p.Elem.Meta,"no meta node");this.meta=s.read(t,e)},y.prototype._parseRoot=function(e){this.groups=[],this.deletedObjects=[];for(var t=0,r=m.getChildNode(this.xml.documentElement,p.Elem.Root,"no root node").childNodes,i=r.length;t0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var r=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==h)throw new Error(a[r]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var p;if(p="string"==typeof t.dictionary?o.string2buf(t.dictionary):"[object ArrayBuffer]"===d.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=i.deflateSetDictionary(this.strm,p))!==h)throw new Error(a[r]);this._dict_set=!0}}function p(e,t){var r=new f(t);if(r.push(e,!0),r.err)throw r.msg;return r.result}f.prototype.push=function(e,t){var r,a,s=this.strm,u=this.options.chunkSize;if(this.ended)return!1;a=t===~~t?t:!0===t?4:0,"string"==typeof e?s.input=o.string2buf(e):"[object ArrayBuffer]"===d.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new n.Buf8(u),s.next_out=0,s.avail_out=u),1!==(r=i.deflate(s,a))&&r!==h)return this.onEnd(r),this.ended=!0,!1;0!==s.avail_out&&(0!==s.avail_in||4!==a&&2!==a)||("string"===this.options.to?this.onData(o.buf2binstring(n.shrinkBuf(s.output,s.next_out))):this.onData(n.shrinkBuf(s.output,s.next_out)))}while((s.avail_in>0||0===s.avail_out)&&1!==r);return 4===a?(r=i.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===h):2!==a||(this.onEnd(h),s.avail_out=0,!0)},f.prototype.onData=function(e){this.chunks.push(e)},f.prototype.onEnd=function(e){e===h&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Deflate=f,t.deflate=p,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,p(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,p(e,t)}},function(e,t,r){"use strict";var i,n=r(5),o=r(34),a=r(17),s=r(18),d=r(12),h=0,u=1,l=3,c=4,f=5,p=0,m=1,y=-2,g=-3,_=-5,b=-1,v=1,w=2,k=3,C=4,x=0,E=2,B=8,T=9,S=15,A=8,D=286,U=30,I=19,N=2*D+1,P=15,M=3,F=258,z=F+M+1,V=32,O=42,j=69,H=73,K=91,L=103,R=113,G=666,W=1,Z=2,X=3,q=4,Y=3;function $(e,t){return e.msg=d[t],t}function J(e){return(e<<1)-(e>4?9:0)}function Q(e){for(var t=e.length;--t>=0;)e[t]=0}function ee(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(n.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function te(e,t){o._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ee(e.strm)}function re(e,t){e.pending_buf[e.pending++]=t}function ie(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function ne(e,t){var r,i,n=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,d=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,h=e.window,u=e.w_mask,l=e.prev,c=e.strstart+F,f=h[o+a-1],p=h[o+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(h[(r=t)+a]===p&&h[r+a-1]===f&&h[r]===h[o]&&h[++r]===h[o+1]){o+=2,r++;do{}while(h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&oa){if(e.match_start=t,a=i,i>=s)break;f=h[o+a-1],p=h[o+a]}}}while((t=l[t&u])>d&&0!=--n);return a<=e.lookahead?a:e.lookahead}function oe(e){var t,r,i,o,d,h,u,l,c,f,p=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=p+(p-z)){n.arraySet(e.window,e.window,p,p,0),e.match_start-=p,e.strstart-=p,e.block_start-=p,t=r=e.hash_size;do{i=e.head[--t],e.head[t]=i>=p?i-p:0}while(--r);t=r=p;do{i=e.prev[--t],e.prev[t]=i>=p?i-p:0}while(--r);o+=p}if(0===e.strm.avail_in)break;if(h=e.strm,u=e.window,l=e.strstart+e.lookahead,c=o,f=void 0,(f=h.avail_in)>c&&(f=c),r=0===f?0:(h.avail_in-=f,n.arraySet(u,h.input,h.next_in,f,l),1===h.state.wrap?h.adler=a(h.adler,u,f,l):2===h.state.wrap&&(h.adler=s(h.adler,u,f,l)),h.next_in+=f,h.total_in+=f,f),e.lookahead+=r,e.lookahead+e.insert>=M)for(d=e.strstart-e.insert,e.ins_h=e.window[d],e.ins_h=(e.ins_h<=M&&(e.ins_h=(e.ins_h<=M)if(i=o._tr_tally(e,e.strstart-e.match_start,e.match_length-M),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=M){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=M&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=M-1)),e.prev_length>=M&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-M,i=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-M),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<15&&(s=2,i-=16),o<1||o>T||r!==B||i<8||i>15||t<0||t>9||a<0||a>C)return $(e,y);8===i&&(i=9);var d=new he;return e.state=d,d.strm=e,d.wrap=s,d.gzhead=null,d.w_bits=i,d.w_size=1<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(oe(e),0===e.lookahead&&t===h)return W;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+r;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,te(e,!1),0===e.strm.avail_out))return W;if(e.strstart-e.block_start>=e.w_size-z&&(te(e,!1),0===e.strm.avail_out))return W}return e.insert=0,t===c?(te(e,!0),0===e.strm.avail_out?X:q):(e.strstart>e.block_start&&(te(e,!1),e.strm.avail_out),W)})),new de(4,4,8,4,ae),new de(4,5,16,8,ae),new de(4,6,32,32,ae),new de(4,4,16,16,se),new de(8,16,32,32,se),new de(8,16,128,128,se),new de(8,32,128,256,se),new de(32,128,258,1024,se),new de(32,258,258,4096,se)],t.deflateInit=function(e,t){return ce(e,t,B,S,A,x)},t.deflateInit2=ce,t.deflateReset=le,t.deflateResetKeep=ue,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?y:(e.state.gzhead=t,p):y},t.deflate=function(e,t){var r,n,a,d;if(!e||!e.state||t>f||t<0)return e?$(e,y):y;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===G&&t!==c)return $(e,0===e.avail_out?_:y);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===O)if(2===n.wrap)e.adler=0,re(n,31),re(n,139),re(n,8),n.gzhead?(re(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),re(n,255&n.gzhead.time),re(n,n.gzhead.time>>8&255),re(n,n.gzhead.time>>16&255),re(n,n.gzhead.time>>24&255),re(n,9===n.level?2:n.strategy>=w||n.level<2?4:0),re(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(re(n,255&n.gzhead.extra.length),re(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=s(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=j):(re(n,0),re(n,0),re(n,0),re(n,0),re(n,0),re(n,9===n.level?2:n.strategy>=w||n.level<2?4:0),re(n,Y),n.status=R);else{var g=B+(n.w_bits-8<<4)<<8;g|=(n.strategy>=w||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(g|=V),g+=31-g%31,n.status=R,ie(n,g),0!==n.strstart&&(ie(n,e.adler>>>16),ie(n,65535&e.adler)),e.adler=1}if(n.status===j)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),ee(e),a=n.pending,n.pending!==n.pending_buf_size));)re(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=H)}else n.status=H;if(n.status===H)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),ee(e),a=n.pending,n.pending===n.pending_buf_size)){d=1;break}d=n.gzindexa&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),0===d&&(n.gzindex=0,n.status=K)}else n.status=K;if(n.status===K)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),ee(e),a=n.pending,n.pending===n.pending_buf_size)){d=1;break}d=n.gzindexa&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),0===d&&(n.status=L)}else n.status=L;if(n.status===L&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&ee(e),n.pending+2<=n.pending_buf_size&&(re(n,255&e.adler),re(n,e.adler>>8&255),e.adler=0,n.status=R)):n.status=R),0!==n.pending){if(ee(e),0===e.avail_out)return n.last_flush=-1,p}else if(0===e.avail_in&&J(t)<=J(r)&&t!==c)return $(e,_);if(n.status===G&&0!==e.avail_in)return $(e,_);if(0!==e.avail_in||0!==n.lookahead||t!==h&&n.status!==G){var b=n.strategy===w?function(e,t){for(var r;;){if(0===e.lookahead&&(oe(e),0===e.lookahead)){if(t===h)return W;break}if(e.match_length=0,r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(te(e,!1),0===e.strm.avail_out))return W}return e.insert=0,t===c?(te(e,!0),0===e.strm.avail_out?X:q):e.last_lit&&(te(e,!1),0===e.strm.avail_out)?W:Z}(n,t):n.strategy===k?function(e,t){for(var r,i,n,a,s=e.window;;){if(e.lookahead<=F){if(oe(e),e.lookahead<=F&&t===h)return W;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=M&&e.strstart>0&&(i=s[n=e.strstart-1])===s[++n]&&i===s[++n]&&i===s[++n]){a=e.strstart+F;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&ne.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=M?(r=o._tr_tally(e,1,e.match_length-M),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(te(e,!1),0===e.strm.avail_out))return W}return e.insert=0,t===c?(te(e,!0),0===e.strm.avail_out?X:q):e.last_lit&&(te(e,!1),0===e.strm.avail_out)?W:Z}(n,t):i[n.level].func(n,t);if(b!==X&&b!==q||(n.status=G),b===W||b===X)return 0===e.avail_out&&(n.last_flush=-1),p;if(b===Z&&(t===u?o._tr_align(n):t!==f&&(o._tr_stored_block(n,0,0,!1),t===l&&(Q(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ee(e),0===e.avail_out))return n.last_flush=-1,p}return t!==c?p:n.wrap<=0?m:(2===n.wrap?(re(n,255&e.adler),re(n,e.adler>>8&255),re(n,e.adler>>16&255),re(n,e.adler>>24&255),re(n,255&e.total_in),re(n,e.total_in>>8&255),re(n,e.total_in>>16&255),re(n,e.total_in>>24&255)):(ie(n,e.adler>>>16),ie(n,65535&e.adler)),ee(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?p:m)},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==O&&t!==j&&t!==H&&t!==K&&t!==L&&t!==R&&t!==G?$(e,y):(e.state=null,t===R?$(e,g):p):y},t.deflateSetDictionary=function(e,t){var r,i,o,s,d,h,u,l,c=t.length;if(!e||!e.state)return y;if(2===(s=(r=e.state).wrap)||1===s&&r.status!==O||r.lookahead)return y;for(1===s&&(e.adler=a(e.adler,t,c,0)),r.wrap=0,c>=r.w_size&&(0===s&&(Q(r.head),r.strstart=0,r.block_start=0,r.insert=0),l=new n.Buf8(r.w_size),n.arraySet(l,t,c-r.w_size,r.w_size,0),t=l,c=r.w_size),d=e.avail_in,h=e.next_in,u=e.input,e.avail_in=c,e.next_in=0,e.input=t,oe(r);r.lookahead>=M;){i=r.strstart,o=r.lookahead-(M-1);do{r.ins_h=(r.ins_h<=0;)e[t]=0}var h=0,u=1,l=2,c=29,f=256,p=f+1+c,m=30,y=19,g=2*p+1,_=15,b=16,v=7,w=256,k=16,C=17,x=18,E=[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],B=[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],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],A=new Array(2*(p+2));d(A);var D=new Array(2*m);d(D);var U=new Array(512);d(U);var I=new Array(256);d(I);var N=new Array(c);d(N);var P,M,F,z=new Array(m);function V(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}function O(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function j(e){return e<256?U[e]:U[256+(e>>>7)]}function H(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function K(e,t,r){e.bi_valid>b-r?(e.bi_buf|=t<>b-e.bi_valid,e.bi_valid+=r-b):(e.bi_buf|=t<>>=1,r<<=1}while(--t>0);return r>>>1}function G(e,t,r){var i,n,o=new Array(_+1),a=0;for(i=1;i<=_;i++)o[i]=a=a+r[i-1]<<1;for(n=0;n<=t;n++){var s=e[2*n+1];0!==s&&(e[2*n]=R(o[s]++,s))}}function W(e){var t;for(t=0;t8?H(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function X(e,t,r,i){var n=2*t,o=2*r;return e[n]>1;r>=1;r--)q(e,o,r);n=d;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],q(e,o,1),i=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=i,o[2*n]=o[2*r]+o[2*i],e.depth[n]=(e.depth[r]>=e.depth[i]?e.depth[r]:e.depth[i])+1,o[2*r+1]=o[2*i+1]=n,e.heap[1]=n++,q(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,i,n,o,a,s,d=t.dyn_tree,h=t.max_code,u=t.stat_desc.static_tree,l=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(o=0;o<=_;o++)e.bl_count[o]=0;for(d[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;rp&&(o=p,m++),d[2*i+1]=o,i>h||(e.bl_count[o]++,a=0,i>=f&&(a=c[i-f]),s=d[2*i],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(u[2*i+1]+a)));if(0!==m){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,m-=2}while(m>0);for(o=p;0!==o;o--)for(i=e.bl_count[o];0!==i;)(n=e.heap[--r])>h||(d[2*n+1]!==o&&(e.opt_len+=(o-d[2*n+1])*d[2*n],d[2*n+1]=o),i--)}}(e,t),G(o,h,e.bl_count)}function J(e,t,r){var i,n,o=-1,a=t[1],s=0,d=7,h=4;for(0===a&&(d=138,h=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=a,a=t[2*(i+1)+1],++s>=7;i0?(e.strm.data_type===s&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return a;for(t=32;t=3&&0===e.bl_tree[2*S[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),d=e.opt_len+3+7>>>3,(h=e.static_len+3+7>>>3)<=d&&(d=h)):d=h=r+5,r+4<=d&&-1!==t?te(e,t,r,i):e.strategy===n||h===d?(K(e,(u<<1)+(i?1:0),3),Y(e,A,D)):(K(e,(l<<1)+(i?1:0),3),function(e,t,r,i){var n;for(K(e,t-257,5),K(e,r-1,5),K(e,i-4,4),n=0;n>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(I[r]+f+1)]++,e.dyn_dtree[2*j(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){K(e,u<<1,3),L(e,w,A),function(e){16===e.bi_valid?(H(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},function(e,t,r){"use strict";var i=r(36),n=r(5),o=r(19),a=r(21),s=r(12),d=r(20),h=r(39),u=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var r=i.inflateInit2(this.strm,t.windowBits);if(r!==a.Z_OK)throw new Error(s[r]);this.header=new h,i.inflateGetHeader(this.strm,this.header)}function c(e,t){var r=new l(t);if(r.push(e,!0),r.err)throw r.msg;return r.result}l.prototype.push=function(e,t){var r,s,d,h,l,c,f=this.strm,p=this.options.chunkSize,m=this.options.dictionary,y=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?a.Z_FINISH:a.Z_NO_FLUSH,"string"==typeof e?f.input=o.binstring2buf(e):"[object ArrayBuffer]"===u.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new n.Buf8(p),f.next_out=0,f.avail_out=p),(r=i.inflate(f,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&m&&(c="string"==typeof m?o.string2buf(m):"[object ArrayBuffer]"===u.call(m)?new Uint8Array(m):m,r=i.inflateSetDictionary(this.strm,c)),r===a.Z_BUF_ERROR&&!0===y&&(r=a.Z_OK,y=!1),r!==a.Z_STREAM_END&&r!==a.Z_OK)return this.onEnd(r),this.ended=!0,!1;f.next_out&&(0!==f.avail_out&&r!==a.Z_STREAM_END&&(0!==f.avail_in||s!==a.Z_FINISH&&s!==a.Z_SYNC_FLUSH)||("string"===this.options.to?(d=o.utf8border(f.output,f.next_out),h=f.next_out-d,l=o.buf2string(f.output,d),f.next_out=h,f.avail_out=p-h,h&&n.arraySet(f.output,f.output,d,h,0),this.onData(l)):this.onData(n.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(y=!0)}while((f.avail_in>0||0===f.avail_out)&&r!==a.Z_STREAM_END);return r===a.Z_STREAM_END&&(s=a.Z_FINISH),s===a.Z_FINISH?(r=i.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===a.Z_OK):s!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),f.avail_out=0,!0)},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){e===a.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Inflate=l,t.inflate=c,t.inflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},t.ungzip=c},function(e,t,r){"use strict";var i=r(5),n=r(17),o=r(18),a=r(37),s=r(38),d=0,h=1,u=2,l=4,c=5,f=6,p=0,m=1,y=2,g=-2,_=-3,b=-4,v=-5,w=8,k=1,C=2,x=3,E=4,B=5,T=6,S=7,A=8,D=9,U=10,I=11,N=12,P=13,M=14,F=15,z=16,V=17,O=18,j=19,H=20,K=21,L=22,R=23,G=24,W=25,Z=26,X=27,q=28,Y=29,$=30,J=31,Q=32,ee=852,te=592,re=15;function ie(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function ne(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function oe(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=k,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new i.Buf32(ee),t.distcode=t.distdyn=new i.Buf32(te),t.sane=1,t.back=-1,p):g}function ae(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,oe(e)):g}function se(e,t){var r,i;return e&&e.state?(i=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?g:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,ae(e))):g}function de(e,t){var r,i;return e?(i=new ne,e.state=i,i.window=null,(r=se(e,t))!==p&&(e.state=null),r):g}var he,ue,le=!0;function ce(e){if(le){var t;for(he=new i.Buf32(512),ue=new i.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(s(h,e.lens,0,288,he,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;s(u,e.lens,0,32,ue,0,e.work,{bits:5}),le=!1}e.lencode=he,e.lenbits=9,e.distcode=ue,e.distbits=5}function fe(e,t,r,n){var o,a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(i.arraySet(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((o=a.wsize-a.wnext)>n&&(o=n),i.arraySet(a.window,t,r-n,o,a.wnext),(n-=o)?(i.arraySet(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=o(r.check,Te,2,0),se=0,de=0,r.mode=C;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&se)<<8)+(se>>8))%31){e.msg="incorrect header check",r.mode=$;break}if((15&se)!==w){e.msg="unknown compression method",r.mode=$;break}if(de-=4,ke=8+(15&(se>>>=4)),0===r.wbits)r.wbits=ke;else if(ke>r.wbits){e.msg="invalid window size",r.mode=$;break}r.dmax=1<>8&1),512&r.flags&&(Te[0]=255&se,Te[1]=se>>>8&255,r.check=o(r.check,Te,2,0)),se=0,de=0,r.mode=x;case x:for(;de<32;){if(0===oe)break e;oe--,se+=ee[re++]<>>8&255,Te[2]=se>>>16&255,Te[3]=se>>>24&255,r.check=o(r.check,Te,4,0)),se=0,de=0,r.mode=E;case E:for(;de<16;){if(0===oe)break e;oe--,se+=ee[re++]<>8),512&r.flags&&(Te[0]=255&se,Te[1]=se>>>8&255,r.check=o(r.check,Te,2,0)),se=0,de=0,r.mode=B;case B:if(1024&r.flags){for(;de<16;){if(0===oe)break e;oe--,se+=ee[re++]<>>8&255,r.check=o(r.check,Te,2,0)),se=0,de=0}else r.head&&(r.head.extra=null);r.mode=T;case T:if(1024&r.flags&&((le=r.length)>oe&&(le=oe),le&&(r.head&&(ke=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),i.arraySet(r.head.extra,ee,re,le,ke)),512&r.flags&&(r.check=o(r.check,ee,le,re)),oe-=le,re+=le,r.length-=le),r.length))break e;r.length=0,r.mode=S;case S:if(2048&r.flags){if(0===oe)break e;le=0;do{ke=ee[re+le++],r.head&&ke&&r.length<65536&&(r.head.name+=String.fromCharCode(ke))}while(ke&&le>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=N;break;case U:for(;de<32;){if(0===oe)break e;oe--,se+=ee[re++]<>>=7&de,de-=7&de,r.mode=X;break}for(;de<3;){if(0===oe)break e;oe--,se+=ee[re++]<>>=1)){case 0:r.mode=M;break;case 1:if(ce(r),r.mode=H,t===f){se>>>=2,de-=2;break e}break;case 2:r.mode=V;break;case 3:e.msg="invalid block type",r.mode=$}se>>>=2,de-=2;break;case M:for(se>>>=7&de,de-=7&de;de<32;){if(0===oe)break e;oe--,se+=ee[re++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=$;break}if(r.length=65535&se,se=0,de=0,r.mode=F,t===f)break e;case F:r.mode=z;case z:if(le=r.length){if(le>oe&&(le=oe),le>ae&&(le=ae),0===le)break e;i.arraySet(te,ee,re,le,ne),oe-=le,re+=le,ae-=le,ne+=le,r.length-=le;break}r.mode=N;break;case V:for(;de<14;){if(0===oe)break e;oe--,se+=ee[re++]<>>=5,de-=5,r.ndist=1+(31&se),se>>>=5,de-=5,r.ncode=4+(15&se),se>>>=4,de-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=$;break}r.have=0,r.mode=O;case O:for(;r.have>>=3,de-=3}for(;r.have<19;)r.lens[Se[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,xe={bits:r.lenbits},Ce=s(d,r.lens,0,19,r.lencode,0,r.work,xe),r.lenbits=xe.bits,Ce){e.msg="invalid code lengths set",r.mode=$;break}r.have=0,r.mode=j;case j:for(;r.have>>16&255,_e=65535&Be,!((ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>>=ye,de-=ye,r.lens[r.have++]=_e;else{if(16===_e){for(Ee=ye+2;de>>=ye,de-=ye,0===r.have){e.msg="invalid bit length repeat",r.mode=$;break}ke=r.lens[r.have-1],le=3+(3&se),se>>>=2,de-=2}else if(17===_e){for(Ee=ye+3;de>>=ye)),se>>>=3,de-=3}else{for(Ee=ye+7;de>>=ye)),se>>>=7,de-=7}if(r.have+le>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=$;break}for(;le--;)r.lens[r.have++]=ke}}if(r.mode===$)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=$;break}if(r.lenbits=9,xe={bits:r.lenbits},Ce=s(h,r.lens,0,r.nlen,r.lencode,0,r.work,xe),r.lenbits=xe.bits,Ce){e.msg="invalid literal/lengths set",r.mode=$;break}if(r.distbits=6,r.distcode=r.distdyn,xe={bits:r.distbits},Ce=s(u,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,xe),r.distbits=xe.bits,Ce){e.msg="invalid distances set",r.mode=$;break}if(r.mode=H,t===f)break e;case H:r.mode=K;case K:if(oe>=6&&ae>=258){e.next_out=ne,e.avail_out=ae,e.next_in=re,e.avail_in=oe,r.hold=se,r.bits=de,a(e,ue),ne=e.next_out,te=e.output,ae=e.avail_out,re=e.next_in,ee=e.input,oe=e.avail_in,se=r.hold,de=r.bits,r.mode===N&&(r.back=-1);break}for(r.back=0;ge=(Be=r.lencode[se&(1<>>16&255,_e=65535&Be,!((ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>be)])>>>16&255,_e=65535&Be,!(be+(ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>>=be,de-=be,r.back+=be}if(se>>>=ye,de-=ye,r.back+=ye,r.length=_e,0===ge){r.mode=Z;break}if(32&ge){r.back=-1,r.mode=N;break}if(64&ge){e.msg="invalid literal/length code",r.mode=$;break}r.extra=15&ge,r.mode=L;case L:if(r.extra){for(Ee=r.extra;de>>=r.extra,de-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=R;case R:for(;ge=(Be=r.distcode[se&(1<>>16&255,_e=65535&Be,!((ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>be)])>>>16&255,_e=65535&Be,!(be+(ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>>=be,de-=be,r.back+=be}if(se>>>=ye,de-=ye,r.back+=ye,64&ge){e.msg="invalid distance code",r.mode=$;break}r.offset=_e,r.extra=15&ge,r.mode=G;case G:if(r.extra){for(Ee=r.extra;de>>=r.extra,de-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=$;break}r.mode=W;case W:if(0===ae)break e;if(le=ue-ae,r.offset>le){if((le=r.offset-le)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=$;break}le>r.wnext?(le-=r.wnext,pe=r.wsize-le):pe=r.wnext-le,le>r.length&&(le=r.length),me=r.window}else me=te,pe=ne-r.offset,le=r.length;le>ae&&(le=ae),ae-=le,r.length-=le;do{te[ne++]=me[pe++]}while(--le);0===r.length&&(r.mode=K);break;case Z:if(0===ae)break e;te[ne++]=r.length,ae--,r.mode=K;break;case X:if(r.wrap){for(;de<32;){if(0===oe)break e;oe--,se|=ee[re++]<>>=v=b>>>24,p-=v,0===(v=b>>>16&255))B[o++]=65535&b;else{if(!(16&v)){if(0==(64&v)){b=m[(65535&b)+(f&(1<>>=v,p-=v),p<15&&(f+=E[i++]<>>=v=b>>>24,p-=v,!(16&(v=b>>>16&255))){if(0==(64&v)){b=y[(65535&b)+(f&(1<d){e.msg="invalid distance too far back",r.mode=30;break e}if(f>>>=v,p-=v,k>(v=o-a)){if((v=k-v)>u&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(C=0,x=c,0===l){if(C+=h-v,v2;)B[o++]=x[C++],B[o++]=x[C++],B[o++]=x[C++],w-=3;w&&(B[o++]=x[C++],w>1&&(B[o++]=x[C++]))}else{C=o-k;do{B[o++]=B[C++],B[o++]=B[C++],B[o++]=B[C++],w-=3}while(w>2);w&&(B[o++]=B[C++],w>1&&(B[o++]=B[C++]))}break}}break}}while(i>3,f&=(1<<(p-=w<<3))-1,e.next_in=i,e.next_out=o,e.avail_in=i=1&&0===M[B];B--);if(T>B&&(T=B),0===B)return h[u++]=20971520,h[u++]=20971520,c.bits=1,0;for(E=1;E0&&(0===e||1!==B))return-1;for(F[1]=0,C=1;C<15;C++)F[C+1]=F[C]+M[C];for(x=0;x852||2===e&&U>592)return 1;for(;;){0,b=C-A,l[x]<_?(v=0,w=l[x]):l[x]>_?(v=z[V+l[x]],w=N[P+l[x]]):(v=96,w=0),f=1<>A)+(p-=f)]=b<<24|v<<16|w|0}while(0!==p);for(f=1<>=1;if(0!==f?(I&=f-1,I+=f):I=0,x++,0==--M[C]){if(C===B)break;C=t[r+l[x]]}if(C>T&&(I&y)!==m){for(0===A&&(A=T),g+=E,D=1<<(S=C-A);S+A852||2===e&&U>592)return 1;h[m=I&y]=T<<24|S<<16|g-u|0}}return 0!==I&&(h[g+I]=C-A<<24|64<<16|0),c.bits=T,0}},function(e,t,r){"use strict";e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},function(e,t,r){var i=r(41);e.exports={TextEncoder:i.TextEncoder,TextDecoder:i.TextDecoder}},function(e,t,r){!function(t){"use strict";function r(e,t,r){return t<=e&&e<=r}function i(e){if(void 0===e)return{};if(e===Object(e))return e;throw TypeError("Could not convert argument to dictionary")}var n=-1;function o(e){this.tokens=[].slice.call(e),this.tokens.reverse()}o.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():n},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.pop());else this.tokens.push(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.shift());else this.tokens.unshift(e)}};var a=-1;function s(e,t){if(e)throw TypeError("Decoder error");return t||65533}function d(e){return e=String(e).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(h,e)?h[e]:null}var h={};[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"}].forEach((function(e){e.encodings.forEach((function(e){e.labels.forEach((function(t){h[t]=e}))}))}));var u={},l={},c="utf-8";function f(e,t){if(!(this instanceof f))throw TypeError("Called as a function. Did you forget 'new'?");e=void 0!==e?String(e):c,t=i(t),this._encoding=null,this._decoder=null,this._ignoreBOM=!1,this._BOMseen=!1,this._error_mode="replacement",this._do_not_flush=!1;var r=d(e);if(null===r||"replacement"===r.name)throw RangeError("Unknown encoding: "+e);if(!l[r.name])throw Error("Decoder not present. Did you forget to include encoding-indexes.js?");return this._encoding=r,Boolean(t.fatal)&&(this._error_mode="fatal"),Boolean(t.ignoreBOM)&&(this._ignoreBOM=!0),this}function p(e,r){if(!(this instanceof p))throw TypeError("Called as a function. Did you forget 'new'?");r=i(r),this._encoding=null,this._encoder=null,this._do_not_flush=!1,this._fatal=Boolean(r.fatal)?"fatal":"replacement";return this._encoding=d("utf-8"),void 0!==e&&"console"in t&&console.warn("TextEncoder constructor called with encoding label, which is ignored."),this}function m(e){var t=e.fatal,i=0,o=0,d=0,h=128,u=191;this.handler=function(e,l){if(l===n&&0!==d)return d=0,s(t);if(l===n)return a;if(0===d){if(r(l,0,127))return l;if(r(l,194,223))d=1,i=31&l;else if(r(l,224,239))224===l&&(h=160),237===l&&(u=159),d=2,i=15&l;else{if(!r(l,240,244))return s(t);240===l&&(h=144),244===l&&(u=143),d=3,i=7&l}return null}if(!r(l,h,u))return i=d=o=0,h=128,u=191,e.prepend(l),s(t);if(h=128,u=191,i=i<<6|63&l,(o+=1)!==d)return null;var c=i;return i=d=o=0,c}}function y(e){e.fatal;this.handler=function(e,t){if(t===n)return a;if(r(t,0,127))return t;var i,o;r(t,128,2047)?(i=1,o=192):r(t,2048,65535)?(i=2,o=224):r(t,65536,1114111)&&(i=3,o=240);for(var s=[(t>>6*i)+o];i>0;){var d=t>>6*(i-1);s.push(128|63&d),i-=1}return s}}Object.defineProperty&&(Object.defineProperty(f.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(f.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(f.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),f.prototype.decode=function(e,t){var r;r="object"==typeof e&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==typeof e&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t=i(t),this._do_not_flush||(this._decoder=l[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=Boolean(t.stream);for(var s,d=new o(r),h=[];;){var u=d.read();if(u===n)break;if((s=this._decoder.handler(d,u))===a)break;null!==s&&(Array.isArray(s)?h.push.apply(h,s):h.push(s))}if(!this._do_not_flush){do{if((s=this._decoder.handler(d,d.read()))===a)break;null!==s&&(Array.isArray(s)?h.push.apply(h,s):h.push(s))}while(!d.endOfStream());this._decoder=null}return function(e){var t,r;return t=["UTF-8","UTF-16LE","UTF-16BE"],r=this._encoding.name,-1===t.indexOf(r)||this._ignoreBOM||this._BOMseen||(e.length>0&&65279===e[0]?(this._BOMseen=!0,e.shift()):e.length>0&&(this._BOMseen=!0)),function(e){for(var t="",r=0;r>10),56320+(1023&i)))}return t}(e)}.call(this,h)},Object.defineProperty&&Object.defineProperty(p.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),p.prototype.encode=function(e,t){e=e?String(e):"",t=i(t),this._do_not_flush||(this._encoder=u[this._encoding.name]({fatal:"fatal"===this._fatal})),this._do_not_flush=Boolean(t.stream);for(var r,s=new o(function(e){for(var t=String(e),r=t.length,i=0,n=[];i57343)n.push(o);else if(56320<=o&&o<=57343)n.push(65533);else if(55296<=o&&o<=56319)if(i===r-1)n.push(65533);else{var a=t.charCodeAt(i+1);if(56320<=a&&a<=57343){var s=1023&o,d=1023&a;n.push(65536+(s<<10)+d),i+=1}else n.push(65533)}i+=1}return n}(e)),d=[];;){var h=s.read();if(h===n)break;if((r=this._encoder.handler(s,h))===a)break;Array.isArray(r)?d.push.apply(d,r):d.push(r)}if(!this._do_not_flush){for(;(r=this._encoder.handler(s,s.read()))!==a;)Array.isArray(r)?d.push.apply(d,r):d.push(r);this._encoder=null}return new Uint8Array(d)},u["UTF-8"]=function(e){return new y(e)},l["UTF-8"]=function(e){return new m(e)},t.TextEncoder||(t.TextEncoder=p),t.TextDecoder||(t.TextDecoder=f),e.exports&&(e.exports={TextEncoder:t.TextEncoder,TextDecoder:t.TextDecoder})}(this)},function(t,r){t.exports=e},function(e,t,r){"use strict";var i=r(4),n=function(e){this.kdbx=e.kdbx,this.exportXml=e.exportXml||!1};n.prototype.setXmlDate=function(e,t){var r=this.kdbx.header.versionMajor>=4&&!this.exportXml;i.setDate(e,t,r)},e.exports=n},function(e,r){e.exports=t},function(e,t,r){"use strict";var i=r(11),n=r(2),o=r(1),a=r(0),s=r(3),d=1048576;e.exports.decrypt=function(e){return Promise.resolve().then((function(){var t,r=new i(e),d=[],h=0,u=0,l=function(){if(r.getUint32(!0),t=r.readBytes(32),(h=r.getUint32(!0))>0){u+=h;var e=r.readBytes(h);return s.sha256(e).then((function(r){if(a.arrayBufferEquals(r,t))return d.push(e),l();throw new n(o.ErrorCodes.FileCorrupt,"invalid hash block")}))}for(var i=new Uint8Array(u),c=0,f=0;f0){var u=Math.min(d,t);t-=u;var l=e.slice(r,r+u);return s.sha256(l).then((function(e){var t=new ArrayBuffer(40),s=new i(t);return s.setUint32(n,!0),s.writeBytes(e),s.setUint32(u,!0),a.push(t),o+=t.byteLength,a.push(l),o+=l.byteLength,n++,r+=u,h()}))}var c=new ArrayBuffer(40);new DataView(c).setUint32(0,n,!0),a.push(c),o+=c.byteLength;for(var f=new Uint8Array(o),p=0,m=0;m0){h+=d;var c=r.readBytes(d);return l(t,s,d,c).then((function(t){if(a.arrayBufferEquals(t,e))return i.push(c),s++,u();throw new n(o.ErrorCodes.FileCorrupt,"invalid hash block")}))}for(var f=new Uint8Array(h),p=0,m=0;m0)return a.push(c),o+=c.byteLength,n++,i+=u,d();for(var h=new Uint8Array(o),l=0,f=0;fthis.nameChanged&&(this._name=e.name,this.nameChanged=e.nameChanged),e.descChanged>this.descChanged&&(this._desc=e.desc,this.descChanged=e.descChanged),e.defaultUserChanged>this.defaultUserChanged&&(this._defaultUser=e.defaultUser,this.defaultUserChanged=e.defaultUserChanged),e.keyChanged>this.keyChanged&&(this.keyChanged=e.keyChanged),e.settingsChanged>this.settingsChanged&&(this.settingsChanged=e.settingsChanged),e.recycleBinChanged>this.recycleBinChanged&&(this._recycleBinEnabled=e.recycleBinEnabled,this._recycleBinUuid=e.recycleBinUuid,this.recycleBinChanged=e.recycleBinChanged),e.entryTemplatesGroupChanged>this.entryTemplatesGroupChanged&&(this._entryTemplatesGroup=e.entryTemplatesGroup,this.entryTemplatesGroupChanged=e.entryTemplatesGroupChanged),Object.keys(e.customData).forEach((function(r){this.customData[r]||t.deleted[r]||(this.customData[r]=e.customData[r])}),this),Object.keys(e.customIcons).forEach((function(r){this.customIcons[r]||t.deleted[r]||(this.customIcons[r]=e.customIcons[r])}),this),this._editState&&this._editState.historyMaxItems||(this.historyMaxItems=e.historyMaxItems),this._editState&&this._editState.historyMaxSize||(this.historyMaxSize=e.historyMaxSize),this._editState&&this._editState.keyChangeRec||(this.keyChangeRec=e.keyChangeRec),this._editState&&this._editState.keyChangeForce||(this.keyChangeForce=e.keyChangeForce),this._editState&&this._editState.mntncHistoryDays||(this.mntncHistoryDays=e.mntncHistoryDays),this._editState&&this._editState.color||(this.color=e.color)},h.create=function(){var e=new Date,t=new h;return t.generator=d.Generator,t.settingsChanged=e,t.mntncHistoryDays=s.Defaults.MntncHistoryDays,t.recycleBinEnabled=!0,t.historyMaxItems=s.Defaults.HistoryMaxItems,t.historyMaxSize=s.Defaults.HistoryMaxSize,t.nameChanged=e,t.descChanged=e,t.defaultUserChanged=e,t.recycleBinChanged=e,t.keyChangeRec=-1,t.keyChangeForce=-1,t.entryTemplatesGroup=new n,t.entryTemplatesGroupChanged=e,t.memoryProtection={title:!1,userName:!1,password:!0,url:!1,notes:!1},t},h.read=function(e,t){for(var r=new h,i=0,n=e.childNodes,o=n.length;ithis.times.lastModTime&&this.copyFrom(t),this.groups=this._mergeCollection(this.groups,t.groups,e),this.entries=this._mergeCollection(this.entries,t.entries,e),this.groups.forEach((function(t){t.merge(e)})),this.entries.forEach((function(t){t.merge(e)})))},u.prototype._mergeCollection=function(e,t,r){var i=[];return e.forEach((function(e){if(!r.deleted[e.uuid]){var t=r.remote[e.uuid];t?t.times.locationChanged<=e.times.locationChanged&&i.push(e):i.push(e)}}),this),t.forEach((function(e,n){if(!r.deleted[e.uuid]){var o=r.objects[e.uuid];if(o&&e.times.locationChanged>o.times.locationChanged)o.parentGroup=this,i.splice(this._findInsertIx(i,t,n),0,o);else if(!o){var a=new e.constructor;a.copyFrom(e),a.parentGroup=this,i.splice(this._findInsertIx(i,t,n),0,a)}}}),this),i},u.prototype._findInsertIx=function(e,t,r){for(var i=e.length,n=-1,o=0;o<=e.length;o++){var a=0,s=r>0?t[r-1].uuid.id:void 0,d=r+10?e[o-1].uuid.id:void 0,u=on&&(i=o,n=a)}return i},u.prototype.copyFrom=function(e){this.uuid=e.uuid,this.name=e.name,this.notes=e.notes,this.icon=e.icon,this.customIcon=e.customIcon,this.times=e.times.clone(),this.expanded=e.expanded,this.defaultAutoTypeSeq=e.defaultAutoTypeSeq,this.enableAutoType=e.enableAutoType,this.enableSearching=e.enableSearching,this.lastTopVisibleEntry=e.lastTopVisibleEntry},u.create=function(e,t){var r=new u;return r.uuid=d.random(),r.icon=o.Icons.Folder,r.times=s.create(),r.name=e,r.parentGroup=t,r.expanded=!0,r.enableAutoType=null,r.enableSearching=null,r.lastTopVisibleEntry=new d,r},u.read=function(e,t,r){for(var i=new u,n=0,o=e.childNodes,a=o.length;n0;){var r=e%c;r=r>0?r:c;var i=new Uint8Array(r);s.getRandomValues(i),e-=r,t.set(i,e)}return t}(e);if(h)return new Uint8Array(h.randomBytes(e));throw new n(o.ErrorCodes.NotImplemented,"Random not implemented")},e.exports.createAesCbc=function(){if(d)return new f;if(h)return new p;throw new n(o.ErrorCodes.NotImplemented,"AES-CBC not implemented")},e.exports.chacha20=function(e,t,r){return Promise.resolve().then((function(){var n=new a(new Uint8Array(t),new Uint8Array(r));return i.arrayToBuffer(n.encrypt(new Uint8Array(e)))}))},e.exports.argon2=function(e,t,r,i,a,s,d,h){return Promise.reject(new n(o.ErrorCodes.NotImplemented,"Argon2 not implemented"))},e.exports.configure=function(e,t,r){d=e,s=t,h=r}}).call(this,r(13))},function(e,t,r){"use strict";(function(t){var i=r(2),n=r(1),o=r(6),a=r(7),s=r(9),d=r(0),h=r(8),u=r(16),l=/\.\d\d\d/,c=t.DOMParser?t:r(44),f=t.DOMParser?void 0:{errorHandler:{error:function(e){throw e},fatalError:function(e){throw e}}},p=62135596800;function m(e){var t,r=f?new c.DOMParser(f):new c.DOMParser;try{t=r.parseFromString(e,"application/xml")}catch(e){throw new i(n.ErrorCodes.FileCorrupt,"bad xml: "+e.message)}if(!t.documentElement)throw new i(n.ErrorCodes.FileCorrupt,"bad xml");var o=t.getElementsByTagName("parsererror")[0];if(o)throw new i(n.ErrorCodes.FileCorrupt,"bad xml: "+o.textContent);return t}function y(e){if(e&&e.childNodes)return e.protectedValue?e.protectedValue.text:e.textContent}function g(e,t){e.textContent=t||""}function _(e){var t=y(e);return t?d.arrayToBuffer(d.base64ToBytes(t)):void 0}function b(e,t){"string"==typeof t&&(t=d.base64ToBytes(t)),g(e,t?d.bytesToBase64(d.arrayToBuffer(t)):void 0)}function v(e){switch(e&&e.toLowerCase&&e.toLowerCase()){case"true":return!0;case"false":return!1;case"null":return null}}function w(e,t){t(e);for(var r=0,i=e.childNodes,n=i.length;r0?"\n"+" ".repeat(r-1):"";var a=t.ownerDocument||t;var s=[];var d;for(var h=0;h0){var c=a.createTextNode(o);t.appendChild(c)}e(d,r+1)}}(e,0);var r=(new c.XMLSerializer).serializeToString(e);return t&&r.startsWith(")<'+e+"/>")},e.exports.getChildNode=function(e,t,r){if(e&&e.childNodes)for(var o=0,a=e.childNodes,s=a.length;o0)return new Date(t);var r=new DataView(d.arrayToBuffer(d.base64ToBytes(t))),i=new h(r.getUint32(0,!0),r.getUint32(4,!0)).value;return new Date(1e3*(i-p))}},e.exports.setDate=function(e,t,r){if(t)if(r){var i=Math.floor(t.getTime()/1e3)+p,n=new DataView(new ArrayBuffer(8)),o=h.from(i);n.setUint32(0,o.lo,!0),n.setUint32(4,o.hi,!0),g(e,d.bytesToBase64(n.buffer))}else g(e,t.toISOString().replace(l,""));else g(e,"")},e.exports.getNumber=function(e){var t=y(e);return t?+t:void 0},e.exports.setNumber=function(e,t){g(e,"number"!=typeof t||isNaN(t)?void 0:t.toString())},e.exports.getBoolean=function(e){var t=y(e);return t?v(t):void 0},e.exports.setBoolean=function(e,t){g(e,void 0===t?"":null===t?"null":t?"True":"False")},e.exports.strToBoolean=v,e.exports.getUuid=function(e){var t=_(e);return t?new a(t):void 0},e.exports.setUuid=function(e,t){b(e,t instanceof a?t.toBytes():t)},e.exports.getProtectedText=function(e){return e.protectedValue||e.textContent},e.exports.setProtectedText=function(e,t){t instanceof s?(e.protectedValue=t,e.setAttribute(o.Attr.Protected,"True")):g(e,t)},e.exports.getProtectedBinary=function(e){if(e.protectedValue)return e.protectedValue;var t=e.textContent,r=e.getAttribute(o.Attr.Ref);if(r)return{ref:r};if(t){var i=v(e.getAttribute(o.Attr.Compressed)),n=d.base64ToBytes(t);return i&&(n=u.ungzip(n)),d.arrayToBuffer(n)}},e.exports.setProtectedBinary=function(e,t){t instanceof s?(e.protectedValue=t,e.setAttribute(o.Attr.Protected,"True")):t&&t.ref?e.setAttribute(o.Attr.Ref,t.ref):b(e,t)},e.exports.setProtectedValues=function(e,t){w(e,(function(e){if(v(e.getAttribute(o.Attr.Protected)))try{var r=d.arrayToBuffer(d.base64ToBytes(e.textContent));if(r.byteLength){var a=t.getSalt(r.byteLength);e.protectedValue=new s(r,a)}}catch(t){throw new i(n.ErrorCodes.FileCorrupt,"bad protected value at line "+e.lineNumber+": "+t)}}))},e.exports.updateProtectedValuesSalt=function(e,t){w(e,(function(e){if(v(e.getAttribute(o.Attr.Protected))&&e.protectedValue){var r=t.getSalt(e.protectedValue.byteLength);e.protectedValue.setSalt(r),e.textContent=e.protectedValue.toString()}}))},e.exports.unprotectValues=function(e){w(e,(function(e){v(e.getAttribute(o.Attr.Protected))&&e.protectedValue&&(e.removeAttribute(o.Attr.Protected),e.setAttribute(o.Attr.ProtectedInMemPlainXml,"True"),e.textContent=e.protectedValue.getText())}))},e.exports.protectUnprotectedValues=function(e){w(e,(function(e){v(e.getAttribute(o.Attr.ProtectedInMemPlainXml))&&e.protectedValue&&(e.removeAttribute(o.Attr.ProtectedInMemPlainXml),e.setAttribute(o.Attr.Protected,"True"),e.textContent=e.protectedValue.toString())}))},e.exports.protectPlainValues=function(e){w(e,(function(e){v(e.getAttribute(o.Attr.ProtectedInMemPlainXml))&&(e.protectedValue=s.fromString(e.textContent),e.textContent=e.protectedValue.toString(),e.removeAttribute(o.Attr.ProtectedInMemPlainXml),e.setAttribute(o.Attr.Protected,"True"))}))}}).call(this,r(13))},function(e,t,r){"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,i,n){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+i),n);else for(var o=0;o=2097152)throw new Error("too large number");return 4294967296*this.hi+this.lo}return this.lo}}),i.prototype.valueOf=function(){return this.value},i.from=function(e){if(e>9007199254740991)throw new Error("too large number");var t=e>>>0;return new i(t,(e-t)/4294967296>>>0)},e.exports=i},function(e,t,r){"use strict";var i=r(0),n=r(3),o=r(10),a=function(e,t){Object.defineProperty(this,"_value",{value:new Uint8Array(e)}),Object.defineProperty(this,"_salt",{value:new Uint8Array(t)})};a.prototype.toString=function(){return i.bytesToBase64(this._value)},a.fromString=function(e){for(var t=i.stringToBytes(e),r=o.getBytes(t.length),n=0,s=t.length;n=0;i--)r[i]=e[i]^t[i];return r},a.prototype.setSalt=function(e){for(var t=new Uint8Array(e),r=this._value,i=this._salt,n=0,o=r.length;n=0;--i)t[i]^=r[i];return t}},function(e,t,r){"use strict";function i(e){this._arrayBuffer=e||new ArrayBuffer(1024),this._dataView=new DataView(this._arrayBuffer),this._pos=0,this._canExpand=!e}["Int","Uint","Float"].forEach((function(e){("Float"===e?[4,8]:[1,2,4]).forEach((function(t){var r="get"+e+8*t;i.prototype[r]=function(e){var i=this._dataView[r].call(this._dataView,this._pos,e);return this._pos+=t,i};var n="set"+e+8*t;i.prototype[n]=function(e,r){this._checkCapacity(t),this._dataView[n].call(this._dataView,this._pos,e,r),this._pos+=t}}))})),i.prototype.getUint64=function(e){var t=this.getUint32(e),r=this.getUint32(e);return e?r*=4294967296:t*=4294967296,t+r},i.prototype.setUint64=function(e,t){t?(this.setUint32(4294967295&e,!0),this.setUint32(Math.floor(e/4294967296),!0)):(this._checkCapacity(8),this.setUint32(Math.floor(e/4294967296),!1),this.setUint32(4294967295&e,!1))},i.prototype.readBytes=function(e){var t=this._arrayBuffer.slice(this._pos,this._pos+e);return this._pos+=e,t},i.prototype.readBytesToEnd=function(){var e=this._arrayBuffer.byteLength-this._pos;return this.readBytes(e)},i.prototype.readBytesNoAdvance=function(e,t){return this._arrayBuffer.slice(e,t)},i.prototype.writeBytes=function(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e)),this._checkCapacity(e.length),new Uint8Array(this._arrayBuffer).set(e,this._pos),this._pos+=e.length},i.prototype.getWrittenBytes=function(){return this._arrayBuffer.slice(0,this._pos)},i.prototype._checkCapacity=function(e){var t=this._arrayBuffer.byteLength-this._pos;if(this._canExpand&&t1)throw new i(n.ErrorCodes.InvalidVersion)},d.prototype._readItem=function(e){var t=e.getUint8();if(!t)return!1;var r=e.getInt32(!0);if(r<=0)throw new i(n.ErrorCodes.FileCorrupt,"bad key length");var d,h=o.bytesToString(e.readBytes(r)),u=e.getInt32(!0);if(u<0)throw new i(n.ErrorCodes.FileCorrupt,"bad value length");switch(t){case s.UInt32:if(4!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad uint32");d=e.getUint32(!0);break;case s.UInt64:if(8!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad uint64");var l=e.getUint32(!0),c=e.getUint32(!0);d=new a(l,c);break;case s.Bool:if(1!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad bool");d=0!==e.getUint8();break;case s.Int32:if(4!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad int32");d=e.getInt32(!0);break;case s.Int64:if(8!==u)throw new i(n.ErrorCodes.FileCorrupt,"bad int64");var f=e.getUint32(!0),p=e.getUint32(!0);d=new a(f,p);break;case s.String:d=o.bytesToString(e.readBytes(u));break;case s.Bytes:d=e.readBytes(u);break;default:throw new i(n.ErrorCodes.FileCorrupt,"bad value type: "+t)}return{key:h,type:t,value:d}},d.prototype.write=function(e){this._writeVersion(e),Object.keys(this._items).forEach((function(t){this._writeItem(e,this._items[t])}),this),e.setUint8(0)},d.prototype._writeVersion=function(e){e.setUint16(256,!0)},d.prototype._writeItem=function(e,t){e.setUint8(t.type);var r=o.stringToBytes(t.key);switch(e.setInt32(r.length,!0),e.writeBytes(r),t.type){case s.UInt32:e.setInt32(4,!0),e.setUint32(t.value,!0);break;case s.UInt64:e.setInt32(8,!0),e.setUint32(t.value.lo,!0),e.setUint32(t.value.hi,!0);break;case s.Bool:e.setInt32(1,!0),e.setUint8(t.value?1:0);break;case s.Int32:e.setInt32(4,!0),e.setInt32(t.value,!0);break;case s.Int64:e.setInt32(8,!0),e.setUint32(t.value.lo,!0),e.setUint32(t.value.hi,!0);break;case s.String:var a=o.stringToBytes(t.value);e.setInt32(a.length,!0),e.writeBytes(a);break;case s.Bytes:var d=o.arrayToBuffer(t.value);e.setInt32(d.byteLength,!0),e.writeBytes(d);break;default:throw new i(n.ErrorCodes.Unsupported)}},e.exports=d},function(e,t,r){"use strict";var i=r(6),n=r(4),o={read:function(e){for(var t={},r=0,n=e.childNodes,a=n.length;r>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(n=n+t[i++]|0)|0}while(--a);n%=65521,o%=65521}return n|o<<16|0}},function(e,t,r){"use strict";var i=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();e.exports=function(e,t,r,n){var o=i,a=n+r;e^=-1;for(var s=n;s>>8^o[255&(e^t[s])];return-1^e}},function(e,t,r){"use strict";var i=r(5),n=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var a=new i.Buf8(256),s=0;s<256;s++)a[s]=s>=252?6:s>=248?5:s>=240?4:s>=224?3:s>=192?2:1;function d(e,t){if(t<65537&&(e.subarray&&o||!e.subarray&&n))return String.fromCharCode.apply(null,i.shrinkBuf(e,t));for(var r="",a=0;a>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},t.buf2binstring=function(e){return d(e,e.length)},t.binstring2buf=function(e){for(var t=new i.Buf8(e.length),r=0,n=t.length;r4)h[i++]=65533,r+=o-1;else{for(n&=2===o?31:3===o?15:7;o>1&&r1?h[i++]=65533:n<65536?h[i++]=n:(n-=65536,h[i++]=55296|n>>10&1023,h[i++]=56320|1023&n)}return d(h,i)},t.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+a[e[r]]>t?r:t}},function(e,t,r){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},function(e,t,r){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(e,t,r){"use strict";var i=r(7),n=r(1),o=r(9),a=r(2),s=r(11),d=r(0),h=r(14),u=r(8),l=r(10),c=[{name:"EndOfHeader"},{name:"Comment"},{name:"CipherID"},{name:"CompressionFlags"},{name:"MasterSeed"},{name:"TransformSeed",ver:[3]},{name:"TransformRounds",ver:[3]},{name:"EncryptionIV"},{name:"ProtectedStreamKey",ver:[3]},{name:"StreamStartBytes",ver:[3]},{name:"InnerRandomStreamID",ver:[3]},{name:"KdfParameters",ver:[4]},{name:"PublicCustomData",ver:[4]}],f=[{name:"EndOfHeader"},{name:"InnerRandomStreamID"},{name:"InnerRandomStreamKey"},{name:"Binary",skipHeader:!0}],p={DefaultFileVersionMajor:3,DefaultFileVersionMinor:1,MaxFileVersionMajor:4,MaxFileVersionMinor:1,MaxSupportedVersion:4,FlagBinaryProtected:1,InnerHeaderBinaryFieldId:3,DefaultKdfAlgo:n.KdfId.Argon2,DefaultKdfSaltLength:32,DefaultKdfParallelism:1,DefaultKdfIterations:2,DefaultKdfMemory:1048576,DefaultKdfVersion:19},m={3:1,4:1},y=function(){this.versionMajor=void 0,this.versionMinor=void 0,this.dataCipherUuid=void 0,this.compression=void 0,this.masterSeed=void 0,this.transformSeed=void 0,this.keyEncryptionRounds=void 0,this.encryptionIV=void 0,this.protectedStreamKey=void 0,this.streamStartBytes=void 0,this.crsAlgorithm=void 0,this.endPos=void 0,this.kdfParameters=void 0,this.publicCustomData=void 0,Object.preventExtensions(this)};y.prototype._readSignature=function(e){if(e.byteLength<8)throw new a(n.ErrorCodes.FileCorrupt,"not enough data");var t=e.getUint32(!0),r=e.getUint32(!0);if(t!==n.Signatures.FileMagic||r!==n.Signatures.Sig2Kdbx)throw new a(n.ErrorCodes.BadSignature)},y.prototype._writeSignature=function(e){e.setUint32(n.Signatures.FileMagic,!0),e.setUint32(n.Signatures.Sig2Kdbx,!0)},y.prototype._readVersion=function(e){var t=e.getUint16(!0),r=e.getUint16(!0);if(r>p.MaxSupportedVersion)throw new a(n.ErrorCodes.InvalidVersion);this.versionMinor=t,this.versionMajor=r},y.prototype._writeVersion=function(e){e.setUint16(this.versionMinor,!0),e.setUint16(this.versionMajor,!0)},y.prototype._readCipherID=function(e){if(16!==e.byteLength)throw new a(n.ErrorCodes.Unsupported,"cipher");this.dataCipherUuid=new i(e)},y.prototype._writeCipherID=function(e){this._writeFieldSize(e,16),e.writeBytes(this.dataCipherUuid.bytes)},y.prototype._readCompressionFlags=function(e){var t=new DataView(e).getUint32(e,!0);if(t<0||t>=Object.keys(n.CompressionAlgorithm).length)throw new a(n.ErrorCodes.Unsupported,"compression");this.compression=t},y.prototype._writeCompressionFlags=function(e){this._writeFieldSize(e,4),e.setUint32(this.compression,!0)},y.prototype._readMasterSeed=function(e){this.masterSeed=e},y.prototype._writeMasterSeed=function(e){this._writeFieldBytes(e,this.masterSeed)},y.prototype._readTransformSeed=function(e){this.transformSeed=e},y.prototype._writeTransformSeed=function(e){this._writeFieldBytes(e,this.transformSeed)},y.prototype._readTransformRounds=function(e){this.keyEncryptionRounds=new s(e).getUint64(!0)},y.prototype._writeTransformRounds=function(e){this._writeFieldSize(e,8),e.setUint64(this.keyEncryptionRounds,!0)},y.prototype._readEncryptionIV=function(e){this.encryptionIV=e},y.prototype._writeEncryptionIV=function(e){this._writeFieldBytes(e,this.encryptionIV)},y.prototype._readProtectedStreamKey=function(e){this.protectedStreamKey=e},y.prototype._writeProtectedStreamKey=function(e){this._writeFieldBytes(e,this.protectedStreamKey)},y.prototype._readStreamStartBytes=function(e){this.streamStartBytes=e},y.prototype._writeStreamStartBytes=function(e){this._writeFieldBytes(e,this.streamStartBytes)},y.prototype._readInnerRandomStreamID=function(e){this.crsAlgorithm=new DataView(e).getUint32(e,!0)},y.prototype._writeInnerRandomStreamID=function(e){this._writeFieldSize(e,4),e.setUint32(this.crsAlgorithm,!0)},y.prototype._readInnerRandomStreamKey=function(e){this.protectedStreamKey=e},y.prototype._writeInnerRandomStreamKey=function(e){this._writeFieldBytes(e,this.protectedStreamKey)},y.prototype._readKdfParameters=function(e){this.kdfParameters=h.read(new s(e))},y.prototype._writeKdfParameters=function(e){var t=new s;this.kdfParameters.write(t),this._writeFieldBytes(e,t.getWrittenBytes())},y.prototype._readPublicCustomData=function(e){this.publicCustomData=h.read(new s(e))},y.prototype._hasPublicCustomData=function(){return this.publicCustomData},y.prototype._writePublicCustomData=function(e){if(this.publicCustomData){var t=new s;this.publicCustomData.write(t),this._writeFieldBytes(e,t.getWrittenBytes())}},y.prototype._readBinary=function(e,t){var r=new DataView(e).getUint8(0)&p.FlagBinaryProtected,i=e.slice(1),n=r?o.fromBinary(i):i,a=Object.keys(t.kdbx.binaries).length;t.kdbx.binaries[a]=n},y.prototype._writeBinary=function(e,t){if(!(this.versionMajor<4))for(var r=t.kdbx.binaries.hashOrder,i=0;i0&&(i=e.readBytes(o));var a=t[n];if(a){var s=this["_read"+a.name];s&&s.call(this,i,r)}return 0!==n},y.prototype._writeField=function(e,t,r,i){var n=r[t];if(n){if(n.ver&&n.ver.indexOf(this.versionMajor)<0)return;var o=this["_write"+n.name];if(o){var a=this["_has"+n.name];if(a&&!a.call(this))return;n.skipHeader||e.setUint8(t),o.call(this,e,i)}}},y.prototype._readFieldSize=function(e){return this.versionMajor>=4?e.getUint32(!0):e.getUint16(!0)},y.prototype._writeFieldSize=function(e,t){this.versionMajor>=4?e.setUint32(t,!0):e.setUint16(t,!0)},y.prototype._writeFieldBytes=function(e,t){this._writeFieldSize(e,t.byteLength),e.writeBytes(t)},y.prototype._validate=function(){if(void 0===this.dataCipherUuid)throw new a(n.ErrorCodes.FileCorrupt,"no cipher in header");if(void 0===this.compression)throw new a(n.ErrorCodes.FileCorrupt,"no compression in header");if(!this.masterSeed)throw new a(n.ErrorCodes.FileCorrupt,"no master seed in header");if(this.versionMajor<4&&!this.transformSeed)throw new a(n.ErrorCodes.FileCorrupt,"no transform seed in header");if(this.versionMajor<4&&!this.keyEncryptionRounds)throw new a(n.ErrorCodes.FileCorrupt,"no key encryption rounds in header");if(!this.encryptionIV)throw new a(n.ErrorCodes.FileCorrupt,"no encryption iv in header");if(this.versionMajor<4&&!this.protectedStreamKey)throw new a(n.ErrorCodes.FileCorrupt,"no protected stream key in header");if(this.versionMajor<4&&!this.streamStartBytes)throw new a(n.ErrorCodes.FileCorrupt,"no stream start bytes in header");if(this.versionMajor<4&&!this.crsAlgorithm)throw new a(n.ErrorCodes.FileCorrupt,"no crs algorithm in header");if(this.versionMajor>=4&&!this.kdfParameters)throw new a(n.ErrorCodes.FileCorrupt,"no kdf parameters in header")},y.prototype._validateInner=function(){if(!this.protectedStreamKey)throw new a(n.ErrorCodes.FileCorrupt,"no protected stream key in header");if(!this.crsAlgorithm)throw new a(n.ErrorCodes.FileCorrupt,"no crs algorithm in header")},y.prototype._createKdfParameters=function(e){switch(e||(e=p.DefaultKdfAlgo),e){case n.KdfId.Argon2:this.kdfParameters=new h,this.kdfParameters.set("$UUID",h.ValueType.Bytes,d.base64ToBytes(n.KdfId.Argon2)),this.kdfParameters.set("S",h.ValueType.Bytes,l.getBytes(p.DefaultKdfSaltLength)),this.kdfParameters.set("P",h.ValueType.UInt32,p.DefaultKdfParallelism),this.kdfParameters.set("I",h.ValueType.UInt64,new u(p.DefaultKdfIterations)),this.kdfParameters.set("M",h.ValueType.UInt64,new u(p.DefaultKdfMemory)),this.kdfParameters.set("V",h.ValueType.UInt32,p.DefaultKdfVersion);break;case n.KdfId.Aes:this.kdfParameters=new h,this.kdfParameters.set("$UUID",h.ValueType.Bytes,d.base64ToBytes(n.KdfId.Aes)),this.kdfParameters.set("S",h.ValueType.Bytes,l.getBytes(p.DefaultKdfSaltLength)),this.kdfParameters.set("R",h.ValueType.UInt32,n.Defaults.KeyEncryptionRounds);break;default:throw new a(n.ErrorCodes.InvalidArg,"bad KDF algo")}},y.prototype.write=function(e){this._validate(),this._writeSignature(e),this._writeVersion(e);for(var t=1;t>4&15]),r.push(t[15&i[n]]);return r.join("")},i.prototype._reset=function(){this.counterWords[0]=0,this.counterWords[1]=0,this.blockUsed=64},i.prototype._incrementCounter=function(){this.counterWords[0]=this.counterWords[0]+1&4294967295,0===this.counterWords[0]&&(this.counterWords[1]=this.counterWords[1]+1&4294967295)},i.prototype._generateBlock=function(){for(var e,t=this.sigmaWords[0],r=this.keyWords[0],i=this.keyWords[1],n=this.keyWords[2],o=this.keyWords[3],a=this.sigmaWords[1],s=this.nonceWords[0],d=this.nonceWords[1],h=this.counterWords[0],u=this.counterWords[1],l=this.sigmaWords[2],c=this.keyWords[4],f=this.keyWords[5],p=this.keyWords[6],m=this.keyWords[7],y=this.sigmaWords[3],g=t,_=r,b=i,v=n,w=o,k=a,C=s,x=d,E=h,B=u,T=l,S=c,A=f,D=p,U=m,I=y,N=0;N>>25)+g)<<9|e>>>23)+w)<<13|e>>>19)+E)<<18|e>>>14,k^=(e=(_^=(e=(D^=(e=(B^=(e=k+_)<<7|e>>>25)+k)<<9|e>>>23)+B)<<13|e>>>19)+D)<<18|e>>>14,T^=(e=(C^=(e=(b^=(e=(U^=(e=T+C)<<7|e>>>25)+T)<<9|e>>>23)+U)<<13|e>>>19)+b)<<18|e>>>14,I^=(e=(S^=(e=(x^=(e=(v^=(e=I+S)<<7|e>>>25)+I)<<9|e>>>23)+v)<<13|e>>>19)+x)<<18|e>>>14,g^=(e=(v^=(e=(b^=(e=(_^=(e=g+v)<<7|e>>>25)+g)<<9|e>>>23)+_)<<13|e>>>19)+b)<<18|e>>>14,k^=(e=(w^=(e=(x^=(e=(C^=(e=k+w)<<7|e>>>25)+k)<<9|e>>>23)+C)<<13|e>>>19)+x)<<18|e>>>14,T^=(e=(B^=(e=(E^=(e=(S^=(e=T+B)<<7|e>>>25)+T)<<9|e>>>23)+S)<<13|e>>>19)+E)<<18|e>>>14,I^=(e=(U^=(e=(D^=(e=(A^=(e=I+U)<<7|e>>>25)+I)<<9|e>>>23)+A)<<13|e>>>19)+D)<<18|e>>>14;g+=t,_+=r,b+=i,v+=n,w+=o,k+=a,C+=s,x+=d,E+=h,B+=u,T+=l,S+=c,A+=f,D+=p,U+=m,I+=y,this.block[0]=g>>>0&255,this.block[1]=g>>>8&255,this.block[2]=g>>>16&255,this.block[3]=g>>>24&255,this.block[4]=_>>>0&255,this.block[5]=_>>>8&255,this.block[6]=_>>>16&255,this.block[7]=_>>>24&255,this.block[8]=b>>>0&255,this.block[9]=b>>>8&255,this.block[10]=b>>>16&255,this.block[11]=b>>>24&255,this.block[12]=v>>>0&255,this.block[13]=v>>>8&255,this.block[14]=v>>>16&255,this.block[15]=v>>>24&255,this.block[16]=w>>>0&255,this.block[17]=w>>>8&255,this.block[18]=w>>>16&255,this.block[19]=w>>>24&255,this.block[20]=k>>>0&255,this.block[21]=k>>>8&255,this.block[22]=k>>>16&255,this.block[23]=k>>>24&255,this.block[24]=C>>>0&255,this.block[25]=C>>>8&255,this.block[26]=C>>>16&255,this.block[27]=C>>>24&255,this.block[28]=x>>>0&255,this.block[29]=x>>>8&255,this.block[30]=x>>>16&255,this.block[31]=x>>>24&255,this.block[32]=E>>>0&255,this.block[33]=E>>>8&255,this.block[34]=E>>>16&255,this.block[35]=E>>>24&255,this.block[36]=B>>>0&255,this.block[37]=B>>>8&255,this.block[38]=B>>>16&255,this.block[39]=B>>>24&255,this.block[40]=T>>>0&255,this.block[41]=T>>>8&255,this.block[42]=T>>>16&255,this.block[43]=T>>>24&255,this.block[44]=S>>>0&255,this.block[45]=S>>>8&255,this.block[46]=S>>>16&255,this.block[47]=S>>>24&255,this.block[48]=A>>>0&255,this.block[49]=A>>>8&255,this.block[50]=A>>>16&255,this.block[51]=A>>>24&255,this.block[52]=D>>>0&255,this.block[53]=D>>>8&255,this.block[54]=D>>>16&255,this.block[55]=D>>>24&255,this.block[56]=U>>>0&255,this.block[57]=U>>>8&255,this.block[58]=U>>>16&255,this.block[59]=U>>>24&255,this.block[60]=I>>>0&255,this.block[61]=I>>>8&255,this.block[62]=I>>>16&255,this.block[63]=I>>>24&255},e.exports=i},function(e,t,r){"use strict";function i(e,t){this.sigmaWords=[1634760805,857760878,2036477234,1797285236],this.block=new Uint8Array(64),this.blockUsed=64,this.x=new Uint32Array(16);var r=new Uint32Array(16);r[0]=this.sigmaWords[0],r[1]=this.sigmaWords[1],r[2]=this.sigmaWords[2],r[3]=this.sigmaWords[3],r[4]=o(e,0),r[5]=o(e,4),r[6]=o(e,8),r[7]=o(e,12),r[8]=o(e,16),r[9]=o(e,20),r[10]=o(e,24),r[11]=o(e,28),r[12]=0,12===t.length?(r[13]=o(t,0),r[14]=o(t,4),r[15]=o(t,8)):(r[13]=0,r[14]=o(t,0),r[15]=o(t,4)),this.input=r}function n(e,t,r,i,n){e[t]+=e[r],e[n]=s(e[n]^e[t],16),e[i]+=e[n],e[r]=s(e[r]^e[i],12),e[t]+=e[r],e[n]=s(e[n]^e[t],8),e[i]+=e[n],e[r]=s(e[r]^e[i],7)}function o(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function a(e,t,r){e[t]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+3]=r}function s(e,t){return e<>>32-t}i.prototype.getBytes=function(e){for(var t=new Uint8Array(e),r=0;r0;e-=2)n(r,0,4,8,12),n(r,1,5,9,13),n(r,2,6,10,14),n(r,3,7,11,15),n(r,0,5,10,15),n(r,1,6,11,12),n(r,2,7,8,13),n(r,3,4,9,14);for(e=16;e--;)r[e]+=t[e];for(e=16;e--;)a(i,4*e,r[e]);t[12]+=1,t[12]||(t[13]+=1)},i.prototype.encrypt=function(e){for(var t=e.length,r=new Uint8Array(t),i=0,n=this.block;i0;){var d=Math.min(r,o);r-=d;var u=a*d;n=h(e,n,s.length===u?s.buffer:i.arrayToBuffer(s.subarray(0,u)))}return n.then((function(e){return new Uint8Array(e)}))}function h(e,t,r){return t.then((function(t){return e.encrypt(r,t)})).then((function(e){var t=i.arrayToBuffer(new Uint8Array(e).subarray(-2*a,-a));return i.zeroBuffer(e),t}))}e.exports.encrypt=function(e,t,r){var o=n.createAesCbc();return o.importKey(i.arrayToBuffer(t)).then((function(){for(var t=[],i=0;i\n \n";return a.stringToBytes(t)},e.exports=u},function(e,t,r){"use strict";var i=r(6),n=r(4),o=function(){this.creationTime=void 0,this.lastModTime=void 0,this.lastAccessTime=void 0,this.expiryTime=void 0,this.expires=void 0,this.usageCount=void 0,this.locationChanged=new Date,Object.preventExtensions(this)};o.prototype._readNode=function(e){switch(e.tagName){case i.Elem.CreationTime:this.creationTime=n.getDate(e);break;case i.Elem.LastModTime:this.lastModTime=n.getDate(e);break;case i.Elem.LastAccessTime:this.lastAccessTime=n.getDate(e);break;case i.Elem.ExpiryTime:this.expiryTime=n.getDate(e);break;case i.Elem.Expires:this.expires=n.getBoolean(e);break;case i.Elem.UsageCount:this.usageCount=n.getNumber(e);break;case i.Elem.LocationChanged:this.locationChanged=n.getDate(e)}},o.prototype.clone=function(){var e=new o;return e.creationTime=this.creationTime,e.lastModTime=this.lastModTime,e.lastAccessTime=this.lastAccessTime,e.expiryTime=this.expiryTime,e.expires=this.expires,e.usageCount=this.usageCount,e.locationChanged=this.locationChanged,e},o.prototype.update=function(){var e=new Date;this.lastModTime=e,this.lastAccessTime=e},o.prototype.write=function(e,t){var r=n.addChildNode(e,i.Elem.Times);t.setXmlDate(n.addChildNode(r,i.Elem.CreationTime),this.creationTime),t.setXmlDate(n.addChildNode(r,i.Elem.LastModTime),this.lastModTime),t.setXmlDate(n.addChildNode(r,i.Elem.LastAccessTime),this.lastAccessTime),t.setXmlDate(n.addChildNode(r,i.Elem.ExpiryTime),this.expiryTime),n.setBoolean(n.addChildNode(r,i.Elem.Expires),this.expires),n.setNumber(n.addChildNode(r,i.Elem.UsageCount),this.usageCount),t.setXmlDate(n.addChildNode(r,i.Elem.LocationChanged),this.locationChanged)},o.create=function(){var e=new o,t=new Date;return e.creationTime=t,e.lastModTime=t,e.lastAccessTime=t,e.expiryTime=t,e.expires=!1,e.usageCount=0,e.locationChanged=t,e},o.read=function(e){for(var t=new o,r=0,i=e.childNodes,n=i.length;rt.times.lastModTime){if(!this.history.some((function(e){return+e.times.lastModTime==+t.times.lastModTime}))){var i=new l;i.copyFrom(t),r.push(i)}}this.history=this._mergeHistory(r,t.times.lastModTime)}},l.prototype._mergeHistory=function(e,t){this.history.sort((function(e,t){return e.times.lastModTime-t.times.lastModTime})),e.sort((function(e,t){return e.times.lastModTime-t.times.lastModTime}));var r={},i={};this.history.forEach((function(e){r[e.times.lastModTime.getTime()]=e})),e.forEach((function(e){i[e.times.lastModTime.getTime()]=e}));for(var n=0,o=0,a=[];nu){if(!this._editState||this._editState.deleted.indexOf(u)<0){var c=new l;c.copyFrom(d),a.push(c)}o++}else this._editState&&this._editState.added.indexOf(h)>=0?a.push(s):h>t&&a.push(s),n++;else a.push(s),n++,o++}return a},l.create=function(e,t){var r=new l(t);return r.uuid=d.random(),r.icon=a.Icons.Key,r.times=h.create(),r.parentGroup=t,r._setField("Title","",e.memoryProtection.title),r._setField("UserName",e.defaultUser||"",e.memoryProtection.userName),r._setField("Password","",e.memoryProtection.password),r._setField("URL","",e.memoryProtection.url),r._setField("Notes","",e.memoryProtection.notes),r.autoType.enabled="boolean"!=typeof t.enableAutoType||t.enableAutoType,r.autoType.obfuscation=a.AutoTypeObfuscationOptions.None,r},l.read=function(e,t,r){for(var i=new l,n=0,o=e.childNodes,a=o.length;n=0?t[i].splice(r,0,e):t[i].push(e);else{var a=new Date;e instanceof h?e.forEach((function(e,t){this.addDeletedObject((e||t).uuid,a)}),this):this.addDeletedObject(e.uuid,a)}e.parentGroup=t,e.times.locationChanged=new Date}},y.prototype.addDeletedObject=function(e,t){var r=new l;r.uuid=e,r.deletionTime=t,this.deletedObjects.push(r)},y.prototype.remove=function(e){var t=null;this.meta.recycleBinEnabled&&(this.createRecycleBin(),t=this.getGroup(this.meta.recycleBinUuid)),this.move(e,t)},y.prototype.createBinary=function(e){return this.binaries.add(e)},y.prototype.importEntry=function(e,t,r){var i=new u,n=c.random();i.copyFrom(e),i.uuid=n,e.history.forEach((function(e){var t=new u;t.copyFrom(e),t.uuid=n,i.history.push(t)}));var o={},a={};return i.history.concat(i).forEach((function(e){e.customIcon&&(a[e.customIcon]=e.customIcon),Object.values(e.binaries).forEach((function(e){e.ref&&(o[e.ref]=e)}))})),Object.values(o).forEach((function(e){var t=r.binaries[e.ref];t&&!this.binaries[e.ref]&&(this.binaries[e.ref]=t)}),this),Object.values(a).forEach((function(e){var t=r.meta.customIcons[e];t&&(this.meta.customIcons[e]=t)}),this),t.entries.push(i),i.parentGroup=t,i.times.update(),i},y.prototype.cleanup=function(e){var t=new Date,r=e&&e.historyRules&&this.meta.historyMaxItems&&this.meta.historyMaxItems>0?this.meta.historyMaxItems:1/0,i={},n={},o=function(e){e&&e.customIcon&&(i[e.customIcon]=!0),e&&e.binaries&&Object.keys(e.binaries).forEach((function(t){e.binaries[t]&&e.binaries[t].ref&&(n[e.binaries[t].ref]=!0)}))};this.getDefaultGroup().forEach((function(e,t){e&&e.history.length>r&&e.removeHistory(0,e.history.length-r),e&&o(e),e&&e.history&&e.history.forEach((function(e){o(e)})),t&&t.customIcon&&(i[t.customIcon]=!0)})),e&&e.customIcons&&Object.keys(this.meta.customIcons).forEach((function(e){if(!i[e]){var r=new c(e);this.addDeletedObject(r,t),delete this.meta.customIcons[e]}}),this),e&&e.binaries&&Object.keys(this.binaries).forEach((function(e){n[e]||delete this.binaries[e]}),this)},y.prototype.merge=function(e){var t=this.getDefaultGroup(),r=e.getDefaultGroup();if(!t||!r)throw new n(f.ErrorCodes.MergeError,"no default group");if(!t.uuid.equals(r.uuid))throw new n(f.ErrorCodes.MergeError,"default group is different");var i=this._getObjectMap();e.deletedObjects.forEach((function(e){i.deleted[e.uuid]||(this.deletedObjects.push(e),i.deleted[e.uuid]=e.deletionTime)}),this),Object.keys(e.binaries).forEach((function(t){this.binaries[t]||i.deleted[t]||(this.binaries[t]=e.binaries[t])}),this),i.remote=e._getObjectMap().objects,this.meta.merge(e.meta,i),t.merge(i),this.cleanup({historyRules:!0,customIcons:!0,binaries:!0})},y.prototype.getLocalEditState=function(){var e={};return this.getDefaultGroup().forEach((function(t){t&&t._editState&&(e[t.uuid]=t._editState)})),this.meta._editState&&(e.meta=this.meta._editState),e},y.prototype.setLocalEditState=function(e){this.getDefaultGroup().forEach((function(t){t&&e[t.uuid]&&(t._editState=e[t.uuid])})),e.meta&&(this.meta._editState=e.meta)},y.prototype.removeLocalEditState=function(){this.getDefaultGroup().forEach((function(e){e&&(e._editState=void 0)})),this.meta._editState=void 0},y.prototype.upgrade=function(){this.setVersion(a.MaxFileVersion)},y.prototype.setVersion=function(e){this.meta.headerHash=null,this.meta.settingsChanged=new Date,this.header.setVersion(e)},y.prototype.setKdf=function(e){this.meta.headerHash=null,this.meta.settingsChanged=new Date,this.header.setKdf(e)},y.prototype._getObjectMap=function(){var e={},t={};return this.getDefaultGroup().forEach((function(t,r){var i=t||r;if(e[i.uuid])throw new n(f.ErrorCodes.MergeError,"Duplicate: "+i.uuid);e[i.uuid]=i})),this.deletedObjects.forEach((function(e){t[e.uuid]=e.deletionTime})),{objects:e,deleted:t}},y.prototype._loadFromXml=function(e){if(this.xml.documentElement.tagName!==p.Elem.DocNode)throw new n(f.ErrorCodes.FileCorrupt,"bad xml root");this._parseMeta(e);var t=this;return this.binaries.hash().then((function(){return t._parseRoot(e),t}))},y.prototype._parseMeta=function(e){var t=m.getChildNode(this.xml.documentElement,p.Elem.Meta,"no meta node");this.meta=s.read(t,e)},y.prototype._parseRoot=function(e){this.groups=[],this.deletedObjects=[];for(var t=0,r=m.getChildNode(this.xml.documentElement,p.Elem.Root,"no root node").childNodes,i=r.length;t0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var r=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==h)throw new Error(a[r]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var p;if(p="string"==typeof t.dictionary?o.string2buf(t.dictionary):"[object ArrayBuffer]"===d.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=i.deflateSetDictionary(this.strm,p))!==h)throw new Error(a[r]);this._dict_set=!0}}function p(e,t){var r=new f(t);if(r.push(e,!0),r.err)throw r.msg;return r.result}f.prototype.push=function(e,t){var r,a,s=this.strm,u=this.options.chunkSize;if(this.ended)return!1;a=t===~~t?t:!0===t?4:0,"string"==typeof e?s.input=o.string2buf(e):"[object ArrayBuffer]"===d.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new n.Buf8(u),s.next_out=0,s.avail_out=u),1!==(r=i.deflate(s,a))&&r!==h)return this.onEnd(r),this.ended=!0,!1;0!==s.avail_out&&(0!==s.avail_in||4!==a&&2!==a)||("string"===this.options.to?this.onData(o.buf2binstring(n.shrinkBuf(s.output,s.next_out))):this.onData(n.shrinkBuf(s.output,s.next_out)))}while((s.avail_in>0||0===s.avail_out)&&1!==r);return 4===a?(r=i.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===h):2!==a||(this.onEnd(h),s.avail_out=0,!0)},f.prototype.onData=function(e){this.chunks.push(e)},f.prototype.onEnd=function(e){e===h&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Deflate=f,t.deflate=p,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,p(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,p(e,t)}},function(e,t,r){"use strict";var i,n=r(5),o=r(34),a=r(17),s=r(18),d=r(12),h=0,u=1,l=3,c=4,f=5,p=0,m=1,y=-2,g=-3,_=-5,b=-1,v=1,w=2,k=3,C=4,x=0,E=2,B=8,T=9,S=15,A=8,D=286,U=30,I=19,N=2*D+1,P=15,M=3,F=258,z=F+M+1,V=32,O=42,j=69,H=73,K=91,L=103,R=113,G=666,W=1,Z=2,X=3,q=4,Y=3;function $(e,t){return e.msg=d[t],t}function J(e){return(e<<1)-(e>4?9:0)}function Q(e){for(var t=e.length;--t>=0;)e[t]=0}function ee(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(n.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function te(e,t){o._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ee(e.strm)}function re(e,t){e.pending_buf[e.pending++]=t}function ie(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function ne(e,t){var r,i,n=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,d=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,h=e.window,u=e.w_mask,l=e.prev,c=e.strstart+F,f=h[o+a-1],p=h[o+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(h[(r=t)+a]===p&&h[r+a-1]===f&&h[r]===h[o]&&h[++r]===h[o+1]){o+=2,r++;do{}while(h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&h[++o]===h[++r]&&oa){if(e.match_start=t,a=i,i>=s)break;f=h[o+a-1],p=h[o+a]}}}while((t=l[t&u])>d&&0!=--n);return a<=e.lookahead?a:e.lookahead}function oe(e){var t,r,i,o,d,h,u,l,c,f,p=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=p+(p-z)){n.arraySet(e.window,e.window,p,p,0),e.match_start-=p,e.strstart-=p,e.block_start-=p,t=r=e.hash_size;do{i=e.head[--t],e.head[t]=i>=p?i-p:0}while(--r);t=r=p;do{i=e.prev[--t],e.prev[t]=i>=p?i-p:0}while(--r);o+=p}if(0===e.strm.avail_in)break;if(h=e.strm,u=e.window,l=e.strstart+e.lookahead,c=o,f=void 0,(f=h.avail_in)>c&&(f=c),r=0===f?0:(h.avail_in-=f,n.arraySet(u,h.input,h.next_in,f,l),1===h.state.wrap?h.adler=a(h.adler,u,f,l):2===h.state.wrap&&(h.adler=s(h.adler,u,f,l)),h.next_in+=f,h.total_in+=f,f),e.lookahead+=r,e.lookahead+e.insert>=M)for(d=e.strstart-e.insert,e.ins_h=e.window[d],e.ins_h=(e.ins_h<=M&&(e.ins_h=(e.ins_h<=M)if(i=o._tr_tally(e,e.strstart-e.match_start,e.match_length-M),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=M){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=M&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=M-1)),e.prev_length>=M&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-M,i=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-M),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<15&&(s=2,i-=16),o<1||o>T||r!==B||i<8||i>15||t<0||t>9||a<0||a>C)return $(e,y);8===i&&(i=9);var d=new he;return e.state=d,d.strm=e,d.wrap=s,d.gzhead=null,d.w_bits=i,d.w_size=1<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(oe(e),0===e.lookahead&&t===h)return W;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+r;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,te(e,!1),0===e.strm.avail_out))return W;if(e.strstart-e.block_start>=e.w_size-z&&(te(e,!1),0===e.strm.avail_out))return W}return e.insert=0,t===c?(te(e,!0),0===e.strm.avail_out?X:q):(e.strstart>e.block_start&&(te(e,!1),e.strm.avail_out),W)})),new de(4,4,8,4,ae),new de(4,5,16,8,ae),new de(4,6,32,32,ae),new de(4,4,16,16,se),new de(8,16,32,32,se),new de(8,16,128,128,se),new de(8,32,128,256,se),new de(32,128,258,1024,se),new de(32,258,258,4096,se)],t.deflateInit=function(e,t){return ce(e,t,B,S,A,x)},t.deflateInit2=ce,t.deflateReset=le,t.deflateResetKeep=ue,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?y:(e.state.gzhead=t,p):y},t.deflate=function(e,t){var r,n,a,d;if(!e||!e.state||t>f||t<0)return e?$(e,y):y;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===G&&t!==c)return $(e,0===e.avail_out?_:y);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===O)if(2===n.wrap)e.adler=0,re(n,31),re(n,139),re(n,8),n.gzhead?(re(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),re(n,255&n.gzhead.time),re(n,n.gzhead.time>>8&255),re(n,n.gzhead.time>>16&255),re(n,n.gzhead.time>>24&255),re(n,9===n.level?2:n.strategy>=w||n.level<2?4:0),re(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(re(n,255&n.gzhead.extra.length),re(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=s(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=j):(re(n,0),re(n,0),re(n,0),re(n,0),re(n,0),re(n,9===n.level?2:n.strategy>=w||n.level<2?4:0),re(n,Y),n.status=R);else{var g=B+(n.w_bits-8<<4)<<8;g|=(n.strategy>=w||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(g|=V),g+=31-g%31,n.status=R,ie(n,g),0!==n.strstart&&(ie(n,e.adler>>>16),ie(n,65535&e.adler)),e.adler=1}if(n.status===j)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),ee(e),a=n.pending,n.pending!==n.pending_buf_size));)re(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=H)}else n.status=H;if(n.status===H)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),ee(e),a=n.pending,n.pending===n.pending_buf_size)){d=1;break}d=n.gzindexa&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),0===d&&(n.gzindex=0,n.status=K)}else n.status=K;if(n.status===K)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),ee(e),a=n.pending,n.pending===n.pending_buf_size)){d=1;break}d=n.gzindexa&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),0===d&&(n.status=L)}else n.status=L;if(n.status===L&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&ee(e),n.pending+2<=n.pending_buf_size&&(re(n,255&e.adler),re(n,e.adler>>8&255),e.adler=0,n.status=R)):n.status=R),0!==n.pending){if(ee(e),0===e.avail_out)return n.last_flush=-1,p}else if(0===e.avail_in&&J(t)<=J(r)&&t!==c)return $(e,_);if(n.status===G&&0!==e.avail_in)return $(e,_);if(0!==e.avail_in||0!==n.lookahead||t!==h&&n.status!==G){var b=n.strategy===w?function(e,t){for(var r;;){if(0===e.lookahead&&(oe(e),0===e.lookahead)){if(t===h)return W;break}if(e.match_length=0,r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(te(e,!1),0===e.strm.avail_out))return W}return e.insert=0,t===c?(te(e,!0),0===e.strm.avail_out?X:q):e.last_lit&&(te(e,!1),0===e.strm.avail_out)?W:Z}(n,t):n.strategy===k?function(e,t){for(var r,i,n,a,s=e.window;;){if(e.lookahead<=F){if(oe(e),e.lookahead<=F&&t===h)return W;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=M&&e.strstart>0&&(i=s[n=e.strstart-1])===s[++n]&&i===s[++n]&&i===s[++n]){a=e.strstart+F;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&ne.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=M?(r=o._tr_tally(e,1,e.match_length-M),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(te(e,!1),0===e.strm.avail_out))return W}return e.insert=0,t===c?(te(e,!0),0===e.strm.avail_out?X:q):e.last_lit&&(te(e,!1),0===e.strm.avail_out)?W:Z}(n,t):i[n.level].func(n,t);if(b!==X&&b!==q||(n.status=G),b===W||b===X)return 0===e.avail_out&&(n.last_flush=-1),p;if(b===Z&&(t===u?o._tr_align(n):t!==f&&(o._tr_stored_block(n,0,0,!1),t===l&&(Q(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ee(e),0===e.avail_out))return n.last_flush=-1,p}return t!==c?p:n.wrap<=0?m:(2===n.wrap?(re(n,255&e.adler),re(n,e.adler>>8&255),re(n,e.adler>>16&255),re(n,e.adler>>24&255),re(n,255&e.total_in),re(n,e.total_in>>8&255),re(n,e.total_in>>16&255),re(n,e.total_in>>24&255)):(ie(n,e.adler>>>16),ie(n,65535&e.adler)),ee(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?p:m)},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==O&&t!==j&&t!==H&&t!==K&&t!==L&&t!==R&&t!==G?$(e,y):(e.state=null,t===R?$(e,g):p):y},t.deflateSetDictionary=function(e,t){var r,i,o,s,d,h,u,l,c=t.length;if(!e||!e.state)return y;if(2===(s=(r=e.state).wrap)||1===s&&r.status!==O||r.lookahead)return y;for(1===s&&(e.adler=a(e.adler,t,c,0)),r.wrap=0,c>=r.w_size&&(0===s&&(Q(r.head),r.strstart=0,r.block_start=0,r.insert=0),l=new n.Buf8(r.w_size),n.arraySet(l,t,c-r.w_size,r.w_size,0),t=l,c=r.w_size),d=e.avail_in,h=e.next_in,u=e.input,e.avail_in=c,e.next_in=0,e.input=t,oe(r);r.lookahead>=M;){i=r.strstart,o=r.lookahead-(M-1);do{r.ins_h=(r.ins_h<=0;)e[t]=0}var h=0,u=1,l=2,c=29,f=256,p=f+1+c,m=30,y=19,g=2*p+1,_=15,b=16,v=7,w=256,k=16,C=17,x=18,E=[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],B=[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],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],A=new Array(2*(p+2));d(A);var D=new Array(2*m);d(D);var U=new Array(512);d(U);var I=new Array(256);d(I);var N=new Array(c);d(N);var P,M,F,z=new Array(m);function V(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}function O(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function j(e){return e<256?U[e]:U[256+(e>>>7)]}function H(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function K(e,t,r){e.bi_valid>b-r?(e.bi_buf|=t<>b-e.bi_valid,e.bi_valid+=r-b):(e.bi_buf|=t<>>=1,r<<=1}while(--t>0);return r>>>1}function G(e,t,r){var i,n,o=new Array(_+1),a=0;for(i=1;i<=_;i++)o[i]=a=a+r[i-1]<<1;for(n=0;n<=t;n++){var s=e[2*n+1];0!==s&&(e[2*n]=R(o[s]++,s))}}function W(e){var t;for(t=0;t8?H(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function X(e,t,r,i){var n=2*t,o=2*r;return e[n]>1;r>=1;r--)q(e,o,r);n=d;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],q(e,o,1),i=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=i,o[2*n]=o[2*r]+o[2*i],e.depth[n]=(e.depth[r]>=e.depth[i]?e.depth[r]:e.depth[i])+1,o[2*r+1]=o[2*i+1]=n,e.heap[1]=n++,q(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,i,n,o,a,s,d=t.dyn_tree,h=t.max_code,u=t.stat_desc.static_tree,l=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(o=0;o<=_;o++)e.bl_count[o]=0;for(d[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;rp&&(o=p,m++),d[2*i+1]=o,i>h||(e.bl_count[o]++,a=0,i>=f&&(a=c[i-f]),s=d[2*i],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(u[2*i+1]+a)));if(0!==m){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,m-=2}while(m>0);for(o=p;0!==o;o--)for(i=e.bl_count[o];0!==i;)(n=e.heap[--r])>h||(d[2*n+1]!==o&&(e.opt_len+=(o-d[2*n+1])*d[2*n],d[2*n+1]=o),i--)}}(e,t),G(o,h,e.bl_count)}function J(e,t,r){var i,n,o=-1,a=t[1],s=0,d=7,h=4;for(0===a&&(d=138,h=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=a,a=t[2*(i+1)+1],++s>=7;i0?(e.strm.data_type===s&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return a;for(t=32;t=3&&0===e.bl_tree[2*S[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),d=e.opt_len+3+7>>>3,(h=e.static_len+3+7>>>3)<=d&&(d=h)):d=h=r+5,r+4<=d&&-1!==t?te(e,t,r,i):e.strategy===n||h===d?(K(e,(u<<1)+(i?1:0),3),Y(e,A,D)):(K(e,(l<<1)+(i?1:0),3),function(e,t,r,i){var n;for(K(e,t-257,5),K(e,r-1,5),K(e,i-4,4),n=0;n>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(I[r]+f+1)]++,e.dyn_dtree[2*j(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){K(e,u<<1,3),L(e,w,A),function(e){16===e.bi_valid?(H(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},function(e,t,r){"use strict";var i=r(36),n=r(5),o=r(19),a=r(21),s=r(12),d=r(20),h=r(39),u=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var r=i.inflateInit2(this.strm,t.windowBits);if(r!==a.Z_OK)throw new Error(s[r]);this.header=new h,i.inflateGetHeader(this.strm,this.header)}function c(e,t){var r=new l(t);if(r.push(e,!0),r.err)throw r.msg;return r.result}l.prototype.push=function(e,t){var r,s,d,h,l,c,f=this.strm,p=this.options.chunkSize,m=this.options.dictionary,y=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?a.Z_FINISH:a.Z_NO_FLUSH,"string"==typeof e?f.input=o.binstring2buf(e):"[object ArrayBuffer]"===u.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new n.Buf8(p),f.next_out=0,f.avail_out=p),(r=i.inflate(f,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&m&&(c="string"==typeof m?o.string2buf(m):"[object ArrayBuffer]"===u.call(m)?new Uint8Array(m):m,r=i.inflateSetDictionary(this.strm,c)),r===a.Z_BUF_ERROR&&!0===y&&(r=a.Z_OK,y=!1),r!==a.Z_STREAM_END&&r!==a.Z_OK)return this.onEnd(r),this.ended=!0,!1;f.next_out&&(0!==f.avail_out&&r!==a.Z_STREAM_END&&(0!==f.avail_in||s!==a.Z_FINISH&&s!==a.Z_SYNC_FLUSH)||("string"===this.options.to?(d=o.utf8border(f.output,f.next_out),h=f.next_out-d,l=o.buf2string(f.output,d),f.next_out=h,f.avail_out=p-h,h&&n.arraySet(f.output,f.output,d,h,0),this.onData(l)):this.onData(n.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(y=!0)}while((f.avail_in>0||0===f.avail_out)&&r!==a.Z_STREAM_END);return r===a.Z_STREAM_END&&(s=a.Z_FINISH),s===a.Z_FINISH?(r=i.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===a.Z_OK):s!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),f.avail_out=0,!0)},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){e===a.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Inflate=l,t.inflate=c,t.inflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},t.ungzip=c},function(e,t,r){"use strict";var i=r(5),n=r(17),o=r(18),a=r(37),s=r(38),d=0,h=1,u=2,l=4,c=5,f=6,p=0,m=1,y=2,g=-2,_=-3,b=-4,v=-5,w=8,k=1,C=2,x=3,E=4,B=5,T=6,S=7,A=8,D=9,U=10,I=11,N=12,P=13,M=14,F=15,z=16,V=17,O=18,j=19,H=20,K=21,L=22,R=23,G=24,W=25,Z=26,X=27,q=28,Y=29,$=30,J=31,Q=32,ee=852,te=592,re=15;function ie(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function ne(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function oe(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=k,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new i.Buf32(ee),t.distcode=t.distdyn=new i.Buf32(te),t.sane=1,t.back=-1,p):g}function ae(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,oe(e)):g}function se(e,t){var r,i;return e&&e.state?(i=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?g:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,ae(e))):g}function de(e,t){var r,i;return e?(i=new ne,e.state=i,i.window=null,(r=se(e,t))!==p&&(e.state=null),r):g}var he,ue,le=!0;function ce(e){if(le){var t;for(he=new i.Buf32(512),ue=new i.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(s(h,e.lens,0,288,he,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;s(u,e.lens,0,32,ue,0,e.work,{bits:5}),le=!1}e.lencode=he,e.lenbits=9,e.distcode=ue,e.distbits=5}function fe(e,t,r,n){var o,a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(i.arraySet(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((o=a.wsize-a.wnext)>n&&(o=n),i.arraySet(a.window,t,r-n,o,a.wnext),(n-=o)?(i.arraySet(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=o(r.check,Te,2,0),se=0,de=0,r.mode=C;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&se)<<8)+(se>>8))%31){e.msg="incorrect header check",r.mode=$;break}if((15&se)!==w){e.msg="unknown compression method",r.mode=$;break}if(de-=4,ke=8+(15&(se>>>=4)),0===r.wbits)r.wbits=ke;else if(ke>r.wbits){e.msg="invalid window size",r.mode=$;break}r.dmax=1<>8&1),512&r.flags&&(Te[0]=255&se,Te[1]=se>>>8&255,r.check=o(r.check,Te,2,0)),se=0,de=0,r.mode=x;case x:for(;de<32;){if(0===oe)break e;oe--,se+=ee[re++]<>>8&255,Te[2]=se>>>16&255,Te[3]=se>>>24&255,r.check=o(r.check,Te,4,0)),se=0,de=0,r.mode=E;case E:for(;de<16;){if(0===oe)break e;oe--,se+=ee[re++]<>8),512&r.flags&&(Te[0]=255&se,Te[1]=se>>>8&255,r.check=o(r.check,Te,2,0)),se=0,de=0,r.mode=B;case B:if(1024&r.flags){for(;de<16;){if(0===oe)break e;oe--,se+=ee[re++]<>>8&255,r.check=o(r.check,Te,2,0)),se=0,de=0}else r.head&&(r.head.extra=null);r.mode=T;case T:if(1024&r.flags&&((le=r.length)>oe&&(le=oe),le&&(r.head&&(ke=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),i.arraySet(r.head.extra,ee,re,le,ke)),512&r.flags&&(r.check=o(r.check,ee,le,re)),oe-=le,re+=le,r.length-=le),r.length))break e;r.length=0,r.mode=S;case S:if(2048&r.flags){if(0===oe)break e;le=0;do{ke=ee[re+le++],r.head&&ke&&r.length<65536&&(r.head.name+=String.fromCharCode(ke))}while(ke&&le>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=N;break;case U:for(;de<32;){if(0===oe)break e;oe--,se+=ee[re++]<>>=7&de,de-=7&de,r.mode=X;break}for(;de<3;){if(0===oe)break e;oe--,se+=ee[re++]<>>=1)){case 0:r.mode=M;break;case 1:if(ce(r),r.mode=H,t===f){se>>>=2,de-=2;break e}break;case 2:r.mode=V;break;case 3:e.msg="invalid block type",r.mode=$}se>>>=2,de-=2;break;case M:for(se>>>=7&de,de-=7&de;de<32;){if(0===oe)break e;oe--,se+=ee[re++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=$;break}if(r.length=65535&se,se=0,de=0,r.mode=F,t===f)break e;case F:r.mode=z;case z:if(le=r.length){if(le>oe&&(le=oe),le>ae&&(le=ae),0===le)break e;i.arraySet(te,ee,re,le,ne),oe-=le,re+=le,ae-=le,ne+=le,r.length-=le;break}r.mode=N;break;case V:for(;de<14;){if(0===oe)break e;oe--,se+=ee[re++]<>>=5,de-=5,r.ndist=1+(31&se),se>>>=5,de-=5,r.ncode=4+(15&se),se>>>=4,de-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=$;break}r.have=0,r.mode=O;case O:for(;r.have>>=3,de-=3}for(;r.have<19;)r.lens[Se[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,xe={bits:r.lenbits},Ce=s(d,r.lens,0,19,r.lencode,0,r.work,xe),r.lenbits=xe.bits,Ce){e.msg="invalid code lengths set",r.mode=$;break}r.have=0,r.mode=j;case j:for(;r.have>>16&255,_e=65535&Be,!((ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>>=ye,de-=ye,r.lens[r.have++]=_e;else{if(16===_e){for(Ee=ye+2;de>>=ye,de-=ye,0===r.have){e.msg="invalid bit length repeat",r.mode=$;break}ke=r.lens[r.have-1],le=3+(3&se),se>>>=2,de-=2}else if(17===_e){for(Ee=ye+3;de>>=ye)),se>>>=3,de-=3}else{for(Ee=ye+7;de>>=ye)),se>>>=7,de-=7}if(r.have+le>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=$;break}for(;le--;)r.lens[r.have++]=ke}}if(r.mode===$)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=$;break}if(r.lenbits=9,xe={bits:r.lenbits},Ce=s(h,r.lens,0,r.nlen,r.lencode,0,r.work,xe),r.lenbits=xe.bits,Ce){e.msg="invalid literal/lengths set",r.mode=$;break}if(r.distbits=6,r.distcode=r.distdyn,xe={bits:r.distbits},Ce=s(u,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,xe),r.distbits=xe.bits,Ce){e.msg="invalid distances set",r.mode=$;break}if(r.mode=H,t===f)break e;case H:r.mode=K;case K:if(oe>=6&&ae>=258){e.next_out=ne,e.avail_out=ae,e.next_in=re,e.avail_in=oe,r.hold=se,r.bits=de,a(e,ue),ne=e.next_out,te=e.output,ae=e.avail_out,re=e.next_in,ee=e.input,oe=e.avail_in,se=r.hold,de=r.bits,r.mode===N&&(r.back=-1);break}for(r.back=0;ge=(Be=r.lencode[se&(1<>>16&255,_e=65535&Be,!((ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>be)])>>>16&255,_e=65535&Be,!(be+(ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>>=be,de-=be,r.back+=be}if(se>>>=ye,de-=ye,r.back+=ye,r.length=_e,0===ge){r.mode=Z;break}if(32&ge){r.back=-1,r.mode=N;break}if(64&ge){e.msg="invalid literal/length code",r.mode=$;break}r.extra=15&ge,r.mode=L;case L:if(r.extra){for(Ee=r.extra;de>>=r.extra,de-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=R;case R:for(;ge=(Be=r.distcode[se&(1<>>16&255,_e=65535&Be,!((ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>be)])>>>16&255,_e=65535&Be,!(be+(ye=Be>>>24)<=de);){if(0===oe)break e;oe--,se+=ee[re++]<>>=be,de-=be,r.back+=be}if(se>>>=ye,de-=ye,r.back+=ye,64&ge){e.msg="invalid distance code",r.mode=$;break}r.offset=_e,r.extra=15&ge,r.mode=G;case G:if(r.extra){for(Ee=r.extra;de>>=r.extra,de-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=$;break}r.mode=W;case W:if(0===ae)break e;if(le=ue-ae,r.offset>le){if((le=r.offset-le)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=$;break}le>r.wnext?(le-=r.wnext,pe=r.wsize-le):pe=r.wnext-le,le>r.length&&(le=r.length),me=r.window}else me=te,pe=ne-r.offset,le=r.length;le>ae&&(le=ae),ae-=le,r.length-=le;do{te[ne++]=me[pe++]}while(--le);0===r.length&&(r.mode=K);break;case Z:if(0===ae)break e;te[ne++]=r.length,ae--,r.mode=K;break;case X:if(r.wrap){for(;de<32;){if(0===oe)break e;oe--,se|=ee[re++]<>>=v=b>>>24,p-=v,0===(v=b>>>16&255))B[o++]=65535&b;else{if(!(16&v)){if(0==(64&v)){b=m[(65535&b)+(f&(1<>>=v,p-=v),p<15&&(f+=E[i++]<>>=v=b>>>24,p-=v,!(16&(v=b>>>16&255))){if(0==(64&v)){b=y[(65535&b)+(f&(1<d){e.msg="invalid distance too far back",r.mode=30;break e}if(f>>>=v,p-=v,k>(v=o-a)){if((v=k-v)>u&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(C=0,x=c,0===l){if(C+=h-v,v2;)B[o++]=x[C++],B[o++]=x[C++],B[o++]=x[C++],w-=3;w&&(B[o++]=x[C++],w>1&&(B[o++]=x[C++]))}else{C=o-k;do{B[o++]=B[C++],B[o++]=B[C++],B[o++]=B[C++],w-=3}while(w>2);w&&(B[o++]=B[C++],w>1&&(B[o++]=B[C++]))}break}}break}}while(i>3,f&=(1<<(p-=w<<3))-1,e.next_in=i,e.next_out=o,e.avail_in=i=1&&0===M[B];B--);if(T>B&&(T=B),0===B)return h[u++]=20971520,h[u++]=20971520,c.bits=1,0;for(E=1;E0&&(0===e||1!==B))return-1;for(F[1]=0,C=1;C<15;C++)F[C+1]=F[C]+M[C];for(x=0;x852||2===e&&U>592)return 1;for(;;){0,b=C-A,l[x]<_?(v=0,w=l[x]):l[x]>_?(v=z[V+l[x]],w=N[P+l[x]]):(v=96,w=0),f=1<>A)+(p-=f)]=b<<24|v<<16|w|0}while(0!==p);for(f=1<>=1;if(0!==f?(I&=f-1,I+=f):I=0,x++,0==--M[C]){if(C===B)break;C=t[r+l[x]]}if(C>T&&(I&y)!==m){for(0===A&&(A=T),g+=E,D=1<<(S=C-A);S+A852||2===e&&U>592)return 1;h[m=I&y]=T<<24|S<<16|g-u|0}}return 0!==I&&(h[g+I]=C-A<<24|64<<16|0),c.bits=T,0}},function(e,t,r){"use strict";e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},function(e,t,r){var i=r(41);e.exports={TextEncoder:i.TextEncoder,TextDecoder:i.TextDecoder}},function(e,t,r){!function(t){"use strict";function r(e,t,r){return t<=e&&e<=r}function i(e){if(void 0===e)return{};if(e===Object(e))return e;throw TypeError("Could not convert argument to dictionary")}var n=-1;function o(e){this.tokens=[].slice.call(e),this.tokens.reverse()}o.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():n},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.pop());else this.tokens.push(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.shift());else this.tokens.unshift(e)}};var a=-1;function s(e,t){if(e)throw TypeError("Decoder error");return t||65533}function d(e){return e=String(e).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(h,e)?h[e]:null}var h={};[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"}].forEach((function(e){e.encodings.forEach((function(e){e.labels.forEach((function(t){h[t]=e}))}))}));var u={},l={},c="utf-8";function f(e,t){if(!(this instanceof f))throw TypeError("Called as a function. Did you forget 'new'?");e=void 0!==e?String(e):c,t=i(t),this._encoding=null,this._decoder=null,this._ignoreBOM=!1,this._BOMseen=!1,this._error_mode="replacement",this._do_not_flush=!1;var r=d(e);if(null===r||"replacement"===r.name)throw RangeError("Unknown encoding: "+e);if(!l[r.name])throw Error("Decoder not present. Did you forget to include encoding-indexes.js?");return this._encoding=r,Boolean(t.fatal)&&(this._error_mode="fatal"),Boolean(t.ignoreBOM)&&(this._ignoreBOM=!0),this}function p(e,r){if(!(this instanceof p))throw TypeError("Called as a function. Did you forget 'new'?");r=i(r),this._encoding=null,this._encoder=null,this._do_not_flush=!1,this._fatal=Boolean(r.fatal)?"fatal":"replacement";return this._encoding=d("utf-8"),void 0!==e&&"console"in t&&console.warn("TextEncoder constructor called with encoding label, which is ignored."),this}function m(e){var t=e.fatal,i=0,o=0,d=0,h=128,u=191;this.handler=function(e,l){if(l===n&&0!==d)return d=0,s(t);if(l===n)return a;if(0===d){if(r(l,0,127))return l;if(r(l,194,223))d=1,i=31&l;else if(r(l,224,239))224===l&&(h=160),237===l&&(u=159),d=2,i=15&l;else{if(!r(l,240,244))return s(t);240===l&&(h=144),244===l&&(u=143),d=3,i=7&l}return null}if(!r(l,h,u))return i=d=o=0,h=128,u=191,e.prepend(l),s(t);if(h=128,u=191,i=i<<6|63&l,(o+=1)!==d)return null;var c=i;return i=d=o=0,c}}function y(e){e.fatal;this.handler=function(e,t){if(t===n)return a;if(r(t,0,127))return t;var i,o;r(t,128,2047)?(i=1,o=192):r(t,2048,65535)?(i=2,o=224):r(t,65536,1114111)&&(i=3,o=240);for(var s=[(t>>6*i)+o];i>0;){var d=t>>6*(i-1);s.push(128|63&d),i-=1}return s}}Object.defineProperty&&(Object.defineProperty(f.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(f.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(f.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),f.prototype.decode=function(e,t){var r;r="object"==typeof e&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==typeof e&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t=i(t),this._do_not_flush||(this._decoder=l[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=Boolean(t.stream);for(var s,d=new o(r),h=[];;){var u=d.read();if(u===n)break;if((s=this._decoder.handler(d,u))===a)break;null!==s&&(Array.isArray(s)?h.push.apply(h,s):h.push(s))}if(!this._do_not_flush){do{if((s=this._decoder.handler(d,d.read()))===a)break;null!==s&&(Array.isArray(s)?h.push.apply(h,s):h.push(s))}while(!d.endOfStream());this._decoder=null}return function(e){var t,r;return t=["UTF-8","UTF-16LE","UTF-16BE"],r=this._encoding.name,-1===t.indexOf(r)||this._ignoreBOM||this._BOMseen||(e.length>0&&65279===e[0]?(this._BOMseen=!0,e.shift()):e.length>0&&(this._BOMseen=!0)),function(e){for(var t="",r=0;r>10),56320+(1023&i)))}return t}(e)}.call(this,h)},Object.defineProperty&&Object.defineProperty(p.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),p.prototype.encode=function(e,t){e=e?String(e):"",t=i(t),this._do_not_flush||(this._encoder=u[this._encoding.name]({fatal:"fatal"===this._fatal})),this._do_not_flush=Boolean(t.stream);for(var r,s=new o(function(e){for(var t=String(e),r=t.length,i=0,n=[];i57343)n.push(o);else if(56320<=o&&o<=57343)n.push(65533);else if(55296<=o&&o<=56319)if(i===r-1)n.push(65533);else{var a=t.charCodeAt(i+1);if(56320<=a&&a<=57343){var s=1023&o,d=1023&a;n.push(65536+(s<<10)+d),i+=1}else n.push(65533)}i+=1}return n}(e)),d=[];;){var h=s.read();if(h===n)break;if((r=this._encoder.handler(s,h))===a)break;Array.isArray(r)?d.push.apply(d,r):d.push(r)}if(!this._do_not_flush){for(;(r=this._encoder.handler(s,s.read()))!==a;)Array.isArray(r)?d.push.apply(d,r):d.push(r);this._encoder=null}return new Uint8Array(d)},u["UTF-8"]=function(e){return new y(e)},l["UTF-8"]=function(e){return new m(e)},t.TextEncoder||(t.TextEncoder=p),t.TextDecoder||(t.TextDecoder=f),e.exports&&(e.exports={TextEncoder:t.TextEncoder,TextDecoder:t.TextDecoder})}(this)},function(t,r){t.exports=e},function(e,t,r){"use strict";var i=r(4),n=function(e){this.kdbx=e.kdbx,this.exportXml=e.exportXml||!1};n.prototype.setXmlDate=function(e,t){var r=this.kdbx.header.versionMajor>=4&&!this.exportXml;i.setDate(e,t,r)},e.exports=n},function(e,r){e.exports=t},function(e,t,r){"use strict";var i=r(11),n=r(2),o=r(1),a=r(0),s=r(3),d=1048576;e.exports.decrypt=function(e){return Promise.resolve().then((function(){var t,r=new i(e),d=[],h=0,u=0,l=function(){if(r.getUint32(!0),t=r.readBytes(32),(h=r.getUint32(!0))>0){u+=h;var e=r.readBytes(h);return s.sha256(e).then((function(r){if(a.arrayBufferEquals(r,t))return d.push(e),l();throw new n(o.ErrorCodes.FileCorrupt,"invalid hash block")}))}for(var i=new Uint8Array(u),c=0,f=0;f0){var u=Math.min(d,t);t-=u;var l=e.slice(r,r+u);return s.sha256(l).then((function(e){var t=new ArrayBuffer(40),s=new i(t);return s.setUint32(n,!0),s.writeBytes(e),s.setUint32(u,!0),a.push(t),o+=t.byteLength,a.push(l),o+=l.byteLength,n++,r+=u,h()}))}var c=new ArrayBuffer(40);new DataView(c).setUint32(0,n,!0),a.push(c),o+=c.byteLength;for(var f=new Uint8Array(o),p=0,m=0;m0){h+=d;var c=r.readBytes(d);return l(t,s,d,c).then((function(t){if(a.arrayBufferEquals(t,e))return i.push(c),s++,u();throw new n(o.ErrorCodes.FileCorrupt,"invalid hash block")}))}for(var f=new Uint8Array(h),p=0,m=0;m0)return a.push(c),o+=c.byteLength,n++,i+=u,d();for(var h=new Uint8Array(o),l=0,f=0;fthis.nameChanged&&(this._name=e.name,this.nameChanged=e.nameChanged),e.descChanged>this.descChanged&&(this._desc=e.desc,this.descChanged=e.descChanged),e.defaultUserChanged>this.defaultUserChanged&&(this._defaultUser=e.defaultUser,this.defaultUserChanged=e.defaultUserChanged),e.keyChanged>this.keyChanged&&(this.keyChanged=e.keyChanged),e.settingsChanged>this.settingsChanged&&(this.settingsChanged=e.settingsChanged),e.recycleBinChanged>this.recycleBinChanged&&(this._recycleBinEnabled=e.recycleBinEnabled,this._recycleBinUuid=e.recycleBinUuid,this.recycleBinChanged=e.recycleBinChanged),e.entryTemplatesGroupChanged>this.entryTemplatesGroupChanged&&(this._entryTemplatesGroup=e.entryTemplatesGroup,this.entryTemplatesGroupChanged=e.entryTemplatesGroupChanged),Object.keys(e.customData).forEach((function(r){this.customData[r]||t.deleted[r]||(this.customData[r]=e.customData[r])}),this),Object.keys(e.customIcons).forEach((function(r){this.customIcons[r]||t.deleted[r]||(this.customIcons[r]=e.customIcons[r])}),this),this._editState&&this._editState.historyMaxItems||(this.historyMaxItems=e.historyMaxItems),this._editState&&this._editState.historyMaxSize||(this.historyMaxSize=e.historyMaxSize),this._editState&&this._editState.keyChangeRec||(this.keyChangeRec=e.keyChangeRec),this._editState&&this._editState.keyChangeForce||(this.keyChangeForce=e.keyChangeForce),this._editState&&this._editState.mntncHistoryDays||(this.mntncHistoryDays=e.mntncHistoryDays),this._editState&&this._editState.color||(this.color=e.color)},h.create=function(){var e=new Date,t=new h;return t.generator=d.Generator,t.settingsChanged=e,t.mntncHistoryDays=s.Defaults.MntncHistoryDays,t.recycleBinEnabled=!0,t.historyMaxItems=s.Defaults.HistoryMaxItems,t.historyMaxSize=s.Defaults.HistoryMaxSize,t.nameChanged=e,t.descChanged=e,t.defaultUserChanged=e,t.recycleBinChanged=e,t.keyChangeRec=-1,t.keyChangeForce=-1,t.entryTemplatesGroup=new n,t.entryTemplatesGroupChanged=e,t.memoryProtection={title:!1,userName:!1,password:!0,url:!1,notes:!1},t},h.read=function(e,t){for(var r=new h,i=0,n=e.childNodes,o=n.length;ithis.times.lastModTime&&this.copyFrom(t),this.groups=this._mergeCollection(this.groups,t.groups,e),this.entries=this._mergeCollection(this.entries,t.entries,e),this.groups.forEach((function(t){t.merge(e)})),this.entries.forEach((function(t){t.merge(e)})))},u.prototype._mergeCollection=function(e,t,r){var i=[];return e.forEach((function(e){if(!r.deleted[e.uuid]){var t=r.remote[e.uuid];t?t.times.locationChanged<=e.times.locationChanged&&i.push(e):i.push(e)}}),this),t.forEach((function(e,n){if(!r.deleted[e.uuid]){var o=r.objects[e.uuid];if(o&&e.times.locationChanged>o.times.locationChanged)o.parentGroup=this,i.splice(this._findInsertIx(i,t,n),0,o);else if(!o){var a=new e.constructor;a.copyFrom(e),a.parentGroup=this,i.splice(this._findInsertIx(i,t,n),0,a)}}}),this),i},u.prototype._findInsertIx=function(e,t,r){for(var i=e.length,n=-1,o=0;o<=e.length;o++){var a=0,s=r>0?t[r-1].uuid.id:void 0,d=r+10?e[o-1].uuid.id:void 0,u=on&&(i=o,n=a)}return i},u.prototype.copyFrom=function(e){this.uuid=e.uuid,this.name=e.name,this.notes=e.notes,this.icon=e.icon,this.customIcon=e.customIcon,this.times=e.times.clone(),this.expanded=e.expanded,this.defaultAutoTypeSeq=e.defaultAutoTypeSeq,this.enableAutoType=e.enableAutoType,this.enableSearching=e.enableSearching,this.lastTopVisibleEntry=e.lastTopVisibleEntry},u.create=function(e,t){var r=new u;return r.uuid=d.random(),r.icon=o.Icons.Folder,r.times=s.create(),r.name=e,r.parentGroup=t,r.expanded=!0,r.enableAutoType=null,r.enableSearching=null,r.lastTopVisibleEntry=new d,r},u.read=function(e,t,r){for(var i=new u,n=0,o=e.childNodes,a=o.length;n