mirror of
https://github.com/bringout/oca-server-auth.git
synced 2026-04-18 11:32:07 +02:00
2 lines
No EOL
138 KiB
JavaScript
2 lines
No EOL
138 KiB
JavaScript
/*! kdbxweb v1.10.0, (c) 2020 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;n<o;n++)if(r[n]!==i[n])return!1;return!0},e.exports.bytesToString=function(e){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),s.decode(e)},e.exports.stringToBytes=function(e){return a.encode(e)},e.exports.base64ToBytes=function(e){if("undefined"==typeof atob&&"function"==typeof Buffer){var t=Buffer.from(e,"base64");return new Uint8Array(t)}for(var r=atob(e),i=new Uint8Array(r.length),n=0;n<r.length;n++)i[n]=r.charCodeAt(n);return i},e.exports.bytesToBase64=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),"undefined"==typeof btoa&&"function"==typeof Buffer)return Buffer.from(e).toString("base64");for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)},e.exports.hexToBytes=function(e){for(var t=new Uint8Array(Math.ceil(e.length/2)),r=0;r<t.length;r++)t[r]=parseInt(e.substr(2*r,2),16);return t},e.exports.bytesToHex=function(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);1===i.length&&(t+="0"),t+=i}return t},e.exports.arrayToBuffer=function(e){if(e instanceof ArrayBuffer)return e;var t=e.buffer;return 0===e.byteOffset&&e.byteLength===t.byteLength?t:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)},e.exports.zeroBuffer=function(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.fill(0)}}).call(this,r(13))},function(e,t,r){"use strict";e.exports.Signatures={FileMagic:2594363651,Sig2Kdbx:3041655655,Sig2Kdb:3041655653},e.exports.ErrorCodes={NotImplemented:"NotImplemented",InvalidArg:"InvalidArg",BadSignature:"BadSignature",InvalidVersion:"InvalidVersion",Unsupported:"Unsupported",FileCorrupt:"FileCorrupt",InvalidKey:"InvalidKey",MergeError:"MergeError"},e.exports.CompressionAlgorithm={None:0,GZip:1},e.exports.CrsAlgorithm={Null:0,ArcFourVariant:1,Salsa20:2,ChaCha20:3},e.exports.KdfId={Argon2:"72Nt34wpREuR96mkA+MKDA==",Aes:"ydnzmmKKRGC/dA0IwYpP6g=="},e.exports.CipherId={Aes:"McHy5r9xQ1C+WAUhavxa/w==",ChaCha20:"1gOKK4tvTLWlJDOaMdu1mg=="},e.exports.AutoTypeObfuscationOptions={None:0,UseClipboard:1},e.exports.Defaults={KeyEncryptionRounds:3e5,MntncHistoryDays:365,HistoryMaxItems:10,HistoryMaxSize:6291456,RecycleBinName:"Recycle Bin"},e.exports.Icons={Key:0,World:1,Warning:2,NetworkServer:3,MarkedDirectory:4,UserCommunication:5,Parts:6,Notepad:7,WorldSocket:8,Identity:9,PaperReady:10,Digicam:11,IRCommunication:12,MultiKeys:13,Energy:14,Scanner:15,WorldStar:16,CDRom:17,Monitor:18,EMail:19,Configuration:20,ClipboardReady:21,PaperNew:22,Screen:23,EnergyCareful:24,EMailBox:25,Disk:26,Drive:27,PaperQ:28,TerminalEncrypted:29,Console:30,Printer:31,ProgramIcons:32,Run:33,Settings:34,WorldComputer:35,Archive:36,Homebanking:37,DriveWindows:39,Clock:39,EMailSearch:40,PaperFlag:41,Memory:42,TrashBin:43,Note:44,Expired:45,Info:46,Package:47,Folder:48,FolderOpen:49,FolderPackage:50,LockOpen:51,PaperLocked:52,Checked:53,Pen:54,Thumbnail:55,Book:56,List:57,UserKey:58,Tool:59,Home:60,Star:61,Tux:62,Feather:63,Apple:64,Wiki:65,Money:66,Certificate:67,BlackBerry:68}},function(e,t,r){"use strict";function i(e,t){this.name="KdbxError",this.code=e,this.message="Error "+e+(t?": "+t:"")}i.prototype=Error.prototype,e.exports=i},function(e,t,r){"use strict";(function(t){var i=r(0),n=r(2),o=r(1),a=r(24),s=t.crypto,d=s?s.subtle||s.webkitSubtle:null,h=t.process&&t.process.versions&&t.process.versions.node?r(42):null;function u(){}function l(){}u.prototype.importKey=function(e){var t=this;return d.importKey("raw",e,{name:"AES-CBC"},!1,["encrypt","decrypt"]).then((function(e){t.key=e}))},u.prototype.encrypt=function(e,t){return d.encrypt({name:"AES-CBC",iv:t},this.key,e)},u.prototype.decrypt=function(e,t){return d.decrypt({name:"AES-CBC",iv:t},this.key,e).catch((function(){throw new n(o.ErrorCodes.InvalidKey,"invalid key")}))},l.prototype.importKey=function(e){return this.key=e,Promise.resolve()},l.prototype.encrypt=function(e,t){var r=this;return Promise.resolve().then((function(){var n=h.createCipheriv("aes-256-cbc",Buffer.from(r.key),Buffer.from(t)),o=n.update(Buffer.from(e));return i.arrayToBuffer(Buffer.concat([o,n.final()]))}))},l.prototype.decrypt=function(e,t){var r=this;return Promise.resolve().then((function(){var n=h.createDecipheriv("aes-256-cbc",Buffer.from(r.key),Buffer.from(t)),o=n.update(Buffer.from(e));return i.arrayToBuffer(Buffer.concat([o,n.final()]))})).catch((function(){throw new n(o.ErrorCodes.InvalidKey,"invalid key")}))},e.exports.subtle=d,e.exports.webCrypto=s,e.exports.nodeCrypto=h,e.exports.sha256=function(e){return e.byteLength?d?d.digest({name:"SHA-256"},e):h?new Promise((function(t){t(h.createHash("sha256").update(Buffer.from(e)).digest().buffer)})):Promise.reject(new n(o.ErrorCodes.NotImplemented,"SHA256 not implemented")):Promise.resolve(i.arrayToBuffer(i.hexToBytes("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")))},e.exports.sha512=function(e){return e.byteLength?d?d.digest({name:"SHA-512"},e):h?new Promise((function(t){t(h.createHash("sha512").update(Buffer.from(e)).digest().buffer)})):Promise.reject(new n(o.ErrorCodes.NotImplemented,"SHA512 not implemented")):Promise.resolve(i.arrayToBuffer(i.hexToBytes("cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e")))},e.exports.hmacSha256=function(e,t){if(d){var r={name:"HMAC",hash:{name:"SHA-256"}};return d.importKey("raw",e,r,!1,["sign"]).then((function(e){return d.sign(r,e,t)}))}return h?new Promise((function(r){r(h.createHmac("sha256",Buffer.from(e)).update(Buffer.from(t)).digest().buffer)})):Promise.reject(new n(o.ErrorCodes.NotImplemented,"HMAC-SHA256 not implemented"))},e.exports.random=function(e){if(d)return function(e){for(var t=new Uint8Array(e);e>0;){var r=e%65536;r=r>0?r:65536;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 u;if(h)return new l;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,t){var r=e.childNodes.length;if(0!==r){for(var i,n="\n"+" ".repeat(t),o=t>0?"\n"+" ".repeat(t-1):"",a=e.ownerDocument||e,s=[],d=0;d<r;d++)(i=e.childNodes[d]).nodeType!==a.TEXT_NODE&&i.nodeType!==a.PROCESSING_INSTRUCTION_NODE&&s.push(i);for(var h=0;h<s.length;h++){if(i=s[h],!(0===t&&0===h)){var u=a.createTextNode(n);e.insertBefore(u,i)}if(!i.nextSibling&&t>0){var l=a.createTextNode(o);e.appendChild(l)}y(i,t+1)}}}function g(e){if(e&&e.childNodes)return e.protectedValue?e.protectedValue.text:e.textContent}function _(e,t){e.textContent=t||""}function b(e){var t=g(e);return t?d.arrayToBuffer(d.base64ToBytes(t)):void 0}function v(e,t){"string"==typeof t&&(t=d.base64ToBytes(t)),_(e,t?d.bytesToBase64(d.arrayToBuffer(t)):void 0)}function w(e){switch(e&&e.toLowerCase&&e.toLowerCase()){case"true":return!0;case"false":return!1;case"null":return null}}function k(e,t){t(e);for(var r=0,i=e.childNodes,n=i.length;r<n;r++){var o=i[r];o.tagName&&k(o,t)}}e.exports.parse=m,e.exports.serialize=function(e,t){t&&y(e,0);var r=(new c.XMLSerializer).serializeToString(e);return t&&r.startsWith("<?")&&(r=r.replace(/^(<\?.*?\?>)</,"$1\n<")),r},e.exports.create=function(e){return m('<?xml version="1.0" encoding="utf-8" standalone="yes"?><'+e+"/>")},e.exports.getChildNode=function(e,t,r){if(e&&e.childNodes)for(var o=0,a=e.childNodes,s=a.length;o<s;o++)if(a[o].tagName===t)return a[o];if(r)throw new i(n.ErrorCodes.FileCorrupt,r);return null},e.exports.addChildNode=function(e,t){return e.appendChild((e.ownerDocument||e).createElement(t))},e.exports.getText=g,e.exports.setText=_,e.exports.getBytes=b,e.exports.setBytes=v,e.exports.getDate=function(e){var t=g(e);if(t){if(t.indexOf(":")>0)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),_(e,d.bytesToBase64(n.buffer))}else _(e,t.toISOString().replace(l,""));else _(e,"")},e.exports.getNumber=function(e){var t=g(e);return t?+t:void 0},e.exports.setNumber=function(e,t){_(e,"number"!=typeof t||isNaN(t)?void 0:t.toString())},e.exports.getBoolean=function(e){var t=g(e);return t?w(t):void 0},e.exports.setBoolean=function(e,t){_(e,void 0===t?"":null===t?"null":t?"True":"False")},e.exports.strToBoolean=w,e.exports.getUuid=function(e){var t=b(e);return t?new a(t):void 0},e.exports.setUuid=function(e,t){v(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")):_(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=w(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):v(e,t)},e.exports.setProtectedValues=function(e,t){k(e,(function(e){if(w(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){k(e,(function(e){if(w(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){k(e,(function(e){w(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){k(e,(function(e){w(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){k(e,(function(e){w(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<i;o++)e[n+o]=t[r+o]},flattenChunks:function(e){var t,r,i,n,o,a;for(i=0,t=0,r=e.length;t<r;t++)i+=e[t].length;for(a=new Uint8Array(i),n=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,n),n+=o.length;return a}},o={arraySet:function(e,t,r,i,n){for(var o=0;o<i;o++)e[n+o]=t[r+o]},flattenChunks:function(e){return[].concat.apply([],e)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,n)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,o))},t.setTyped(i)},function(e,t,r){"use strict";e.exports={Elem:{DocNode:"KeePassFile",Meta:"Meta",Root:"Root",Group:"Group",Entry:"Entry",Generator:"Generator",HeaderHash:"HeaderHash",SettingsChanged:"SettingsChanged",DbName:"DatabaseName",DbNameChanged:"DatabaseNameChanged",DbDesc:"DatabaseDescription",DbDescChanged:"DatabaseDescriptionChanged",DbDefaultUser:"DefaultUserName",DbDefaultUserChanged:"DefaultUserNameChanged",DbMntncHistoryDays:"MaintenanceHistoryDays",DbColor:"Color",DbKeyChanged:"MasterKeyChanged",DbKeyChangeRec:"MasterKeyChangeRec",DbKeyChangeForce:"MasterKeyChangeForce",RecycleBinEnabled:"RecycleBinEnabled",RecycleBinUuid:"RecycleBinUUID",RecycleBinChanged:"RecycleBinChanged",EntryTemplatesGroup:"EntryTemplatesGroup",EntryTemplatesGroupChanged:"EntryTemplatesGroupChanged",HistoryMaxItems:"HistoryMaxItems",HistoryMaxSize:"HistoryMaxSize",LastSelectedGroup:"LastSelectedGroup",LastTopVisibleGroup:"LastTopVisibleGroup",MemoryProt:"MemoryProtection",ProtTitle:"ProtectTitle",ProtUserName:"ProtectUserName",ProtPassword:"ProtectPassword",ProtUrl:"ProtectURL",ProtNotes:"ProtectNotes",CustomIcons:"CustomIcons",CustomIconItem:"Icon",CustomIconItemID:"UUID",CustomIconItemData:"Data",AutoType:"AutoType",History:"History",Name:"Name",Notes:"Notes",Uuid:"UUID",Icon:"IconID",CustomIconID:"CustomIconUUID",FgColor:"ForegroundColor",BgColor:"BackgroundColor",OverrideUrl:"OverrideURL",Times:"Times",Tags:"Tags",CreationTime:"CreationTime",LastModTime:"LastModificationTime",LastAccessTime:"LastAccessTime",ExpiryTime:"ExpiryTime",Expires:"Expires",UsageCount:"UsageCount",LocationChanged:"LocationChanged",GroupDefaultAutoTypeSeq:"DefaultAutoTypeSequence",EnableAutoType:"EnableAutoType",EnableSearching:"EnableSearching",String:"String",Binary:"Binary",Key:"Key",Value:"Value",AutoTypeEnabled:"Enabled",AutoTypeObfuscation:"DataTransferObfuscation",AutoTypeDefaultSeq:"DefaultSequence",AutoTypeItem:"Association",Window:"Window",KeystrokeSequence:"KeystrokeSequence",Binaries:"Binaries",IsExpanded:"IsExpanded",LastTopVisibleEntry:"LastTopVisibleEntry",DeletedObjects:"DeletedObjects",DeletedObject:"DeletedObject",DeletionTime:"DeletionTime",CustomData:"CustomData",StringDictExItem:"Item"},Attr:{Id:"ID",Ref:"Ref",Protected:"Protected",ProtectedInMemPlainXml:"ProtectInMemory",Compressed:"Compressed"},Val:{False:"False",True:"True"}}},function(e,t,r){"use strict";var i=r(0),n=r(10);function o(e){if(void 0===e&&(e=new ArrayBuffer(16)),"string"==typeof e&&(e=i.base64ToBytes(e)),this.id=16===e.byteLength?i.bytesToBase64(e):void 0,this.empty=!0,e)for(var t=new Uint8Array(e),r=0,n=t.length;r<n;r++)if(0!==t[r])return void(this.empty=!1)}o.prototype.equals=function(e){return e&&e.toString()===this.toString()||!1},Object.defineProperty(o.prototype,"bytes",{enumerable:!0,get:function(){return i.base64ToBytes(this.id)}}),o.random=function(){return new o(n.getBytes(16))},o.prototype.toString=function(){return this.id},o.prototype.valueOf=function(){return this.id},o.prototype.toBytes=function(){return this.id?i.base64ToBytes(this.id):void 0},e.exports=o},function(e,t,r){"use strict";function i(e,t){this.lo=e||0,this.hi=t||0}Object.defineProperty(i.prototype,"value",{enumerable:!0,get:function(){if(this.hi){if(this.hi>=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<s;n++)t[n]^=r[n];return new a(i.arrayToBuffer(t),i.arrayToBuffer(r))},a.fromBinary=function(e){for(var t=new Uint8Array(e),r=o.getBytes(t.length),n=0,s=t.length;n<s;n++)t[n]^=r[n];return new a(i.arrayToBuffer(t),i.arrayToBuffer(r))},a.prototype.includes=function(e){if(0===e.length)return!1;var t,r,n=this._value,o=this._salt,a=i.stringToBytes(e),s=n.length,d=a.length,h=s-d;e:for(t=0;t<=h;t++){for(r=0;r<d;r++)if((n[t+r]^o[t+r])!==a[r])continue e;return!0}return!1},a.prototype.getHash=function(){var e=i.arrayToBuffer(this.getBinary());return n.sha256(e).then((function(t){return i.zeroBuffer(e),t}))},a.prototype.getText=function(){return i.bytesToString(this.getBinary())},a.prototype.getBinary=function(){for(var e=this._value,t=this._salt,r=new Uint8Array(e.byteLength),i=r.length-1;i>=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<o;n++)r[n]=r[n]^i[n]^t[n],i[n]=t[n]},a.prototype.clone=function(){return new a(this._value,this._salt)},Object.defineProperty(a.prototype,"byteLength",{enumerable:!0,get:function(){return this._value.byteLength}}),e.exports=a},function(e,t,r){"use strict";for(var i=r(23),n=r(3),o=new Uint8Array(32),a=new Uint8Array(8),s=0;s<o.length;s++)o[s]=255*Math.random();for(var d=0;d<a.length;d++)a[s]=255*Math.random();var h=new i(o,a);e.exports.getBytes=function(e){if(!e)return new Uint8Array(0);h.getBytes(Math.round(Math.random()*e)+1);for(var t=h.getBytes(e),r=n.random(e),i=r.length-1;i>=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&&t<e){for(var r=this._arrayBuffer.byteLength,i=this._pos+e;r<i;)r*=2;var n=new Uint8Array(r);n.set(new Uint8Array(this._arrayBuffer)),this._arrayBuffer=n.buffer,this._dataView=new DataView(this._arrayBuffer)}},Object.defineProperty(i.prototype,"pos",{enumerable:!0,get:function(){return this._pos}}),Object.defineProperty(i.prototype,"byteLength",{enumerable:!0,get:function(){return this._arrayBuffer.byteLength}}),e.exports=i},function(e,t,r){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var i=r(2),n=r(1),o=r(0),a=r(8),s={UInt32:4,UInt64:5,Bool:8,Int32:12,Int64:13,String:24,Bytes:66};function d(){this._items=[],this._dict={},Object.preventExtensions(this)}d.ValueType=s,d.prototype.get=function(e){var t=this._dict[e];return t?t.value:void 0},d.prototype.keys=function(){return this._items.map((function(e){return e.key}))},Object.defineProperty(d.prototype,"length",{enumberable:!0,get:function(){return this._items.length}}),d.prototype.set=function(e,t,r){switch(t){case s.UInt32:if("number"!=typeof r||r<0)throw new i(n.ErrorCodes.InvalidArg);break;case s.UInt64:if(!(r instanceof a))throw new i(n.ErrorCodes.InvalidArg);break;case s.Bool:if("boolean"!=typeof r)throw new i(n.ErrorCodes.InvalidArg);break;case s.Int32:if("number"!=typeof r)throw new i(n.ErrorCodes.InvalidArg);break;case s.Int64:if(!(r instanceof a))throw new i(n.ErrorCodes.InvalidArg);break;case s.String:if("string"!=typeof r)throw new i(n.ErrorCodes.InvalidArg);break;case s.Bytes:if(r instanceof Uint8Array&&(r=o.arrayToBuffer(r)),!(r instanceof ArrayBuffer))throw new i(n.ErrorCodes.InvalidArg);break;default:throw new i(n.ErrorCodes.InvalidArg)}var d={key:e,type:t,value:r};if(this._dict[e]){var h=this._items.indexOf(this._dict[e]);this._items.splice(h,1,d)}else this._items.push(d);this._dict[e]=d},d.prototype.remove=function(e){this._items=this._items.filter((function(t){return t.key!==e})),delete this._dict[e]},d.read=function(e){var t=new d;for(t._readVersion(e);;){var r=t._readItem(e);if(!r)break;t._items.push(r),t._dict[r.key]=r}return t},d.prototype._readVersion=function(e){e.getUint8();var t=e.getUint8();if(0===t||t>1)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<a;r++){var s=n[r];s.tagName===i.Elem.StringDictExItem&&o._readItem(s,t)}return t},write:function(e,t){if(t){var r=n.addChildNode(e,i.Elem.CustomData);Object.keys(t).forEach((function(e){var o=t[e];if(o){var a=n.addChildNode(r,i.Elem.StringDictExItem);n.setText(n.addChildNode(a,i.Elem.Key),e),n.setText(n.addChildNode(a,i.Elem.Value),o)}}))}},_readItem:function(e,t){for(var r,o,a=0,s=e.childNodes,d=s.length;a<d;a++){var h=s[a];switch(h.tagName){case i.Elem.Key:r=n.getText(h);break;case i.Elem.Value:o=n.getText(h)}}r&&(t[r]=o)}};e.exports=o},function(e,t,r){"use strict";var i={};(0,r(5).assign)(i,r(32),r(35),r(21)),e.exports=i},function(e,t,r){"use strict";e.exports=function(e,t,r,i){for(var n=65535&e|0,o=e>>>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<a;s++)e=e>>>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<t;a++)r+=String.fromCharCode(e[a]);return r}a[254]=a[254]=1,t.string2buf=function(e){var t,r,n,o,a,s=e.length,d=0;for(o=0;o<s;o++)55296==(64512&(r=e.charCodeAt(o)))&&o+1<s&&56320==(64512&(n=e.charCodeAt(o+1)))&&(r=65536+(r-55296<<10)+(n-56320),o++),d+=r<128?1:r<2048?2:r<65536?3:4;for(t=new i.Buf8(d),a=0,o=0;a<d;o++)55296==(64512&(r=e.charCodeAt(o)))&&o+1<s&&56320==(64512&(n=e.charCodeAt(o+1)))&&(r=65536+(r-55296<<10)+(n-56320),o++),r<128?t[a++]=r:r<2048?(t[a++]=192|r>>>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;r<n;r++)t[r]=e.charCodeAt(r);return t},t.buf2string=function(e,t){var r,i,n,o,s=t||e.length,h=new Array(2*s);for(i=0,r=0;r<s;)if((n=e[r++])<128)h[i++]=n;else if((o=a[n])>4)h[i++]=65533,r+=o-1;else{for(n&=2===o?31:3===o?15:7;o>1&&r<s;)n=n<<6|63&e[r++],o--;o>1?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||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:4,DefaultFileVersionMinor:0,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:0},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;i<r.length;i++){e.setUint8(p.InnerHeaderBinaryFieldId);var s=t.kdbx.binaries[r[i]];if(!s)throw new a(n.ErrorCodes.FileCorrupt,"no binary "+i);if(s instanceof o){var h=s.getBinary();this._writeFieldSize(e,h.byteLength+1),e.setUint8(p.FlagBinaryProtected),e.writeBytes(h),d.zeroBuffer(h)}else s=d.arrayToBuffer(s),this._writeFieldSize(e,s.byteLength+1),e.setUint8(0),e.writeBytes(s)}},y.prototype._writeEndOfHeader=function(e){this._writeFieldSize(e,4),e.setUint32(13675786)},y.prototype._readField=function(e,t,r){var i,n=e.getUint8(),o=this._readFieldSize(e);o>0&&(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.UInt64,new u(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<c.length;t++)this._writeField(e,t,c);this._writeField(e,0,c),this.endPos=e.pos},y.prototype.writeInnerHeader=function(e,t){this._validateInner();for(var r=1;r<f.length;r++)this._writeField(e,r,f,t);this._writeField(e,0,f)},y.prototype.generateSalts=function(){if(this.masterSeed=l.getBytes(32),this.versionMajor<4)this.transformSeed=l.getBytes(32),this.streamStartBytes=l.getBytes(32),this.protectedStreamKey=l.getBytes(32),this.encryptionIV=l.getBytes(16);else{this.protectedStreamKey=l.getBytes(64),this.kdfParameters.set("S",h.ValueType.Bytes,l.getBytes(32));var e=this.dataCipherUuid.toString()===n.CipherId.ChaCha20?12:16;this.encryptionIV=l.getBytes(e)}},y.prototype.setVersion=function(e){if(3!==e&&4!==e)throw new a(n.ErrorCodes.InvalidArg,"bad file version");this.versionMajor=e,this.versionMinor=m[e],4===this.versionMajor?(this.kdfParameters||this._createKdfParameters(),this.crsAlgorithm=n.CrsAlgorithm.ChaCha20,this.keyEncryptionRounds=void 0):(this.kdfParameters=void 0,this.crsAlgorithm=n.CrsAlgorithm.Salsa20,this.keyEncryptionRounds=n.Defaults.KeyEncryptionRounds)},y.prototype.setKdf=function(e){this._createKdfParameters(e)},y.read=function(e,t){var r=new y;for(r._readSignature(e),r._readVersion(e);r._readField(e,c,t););return r.endPos=e.pos,r._validate(),r},y.prototype.readInnerHeader=function(e,t){for(;this._readField(e,f,t););this._validateInner()},y.create=function(){var e=new y;return e.versionMajor=p.DefaultFileVersionMajor,e.versionMinor=p.DefaultFileVersionMinor,e.dataCipherUuid=new i(n.CipherId.Aes),e.compression=n.CompressionAlgorithm.GZip,e.crsAlgorithm=n.CrsAlgorithm.ChaCha20,e._createKdfParameters(),e},y.MaxFileVersion=p.MaxFileVersionMajor,e.exports=y},function(e,t,r){"use strict";function i(e,t){this.rounds=20,this.sigmaWords=[1634760805,857760878,2036477234,1797285236],this.keyWords=[],this.nonceWords=[0,0],this.counterWords=[0,0],this.block=[],this.blockUsed=64,this.setKey(e),this.setNonce(t)}i.prototype.setKey=function(e){for(var t=0,r=0;t<8;t++,r+=4)this.keyWords[t]=255&e[r]|(255&e[r+1])<<8|(255&e[r+2])<<16|(255&e[r+3])<<24;this._reset()},i.prototype.setNonce=function(e){this.nonceWords[0]=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,this.nonceWords[1]=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,this._reset()},i.prototype.getBytes=function(e){for(var t=new Uint8Array(e),r=0;r<e;r++)64===this.blockUsed&&(this._generateBlock(),this._incrementCounter(),this.blockUsed=0),t[r]=this.block[this.blockUsed],this.blockUsed++;return t},i.prototype.getHexString=function(e){for(var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],r=[],i=this.getBytes(e),n=0;n<i.length;n++)r.push(t[i[n]>>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,A=c,S=f,U=p,D=m,I=y,N=0;N<this.rounds;N+=2)g^=(e=(S^=(e=(E^=(e=(w^=(e=g+S)<<7|e>>>25)+g)<<9|e>>>23)+w)<<13|e>>>19)+E)<<18|e>>>14,k^=(e=(_^=(e=(U^=(e=(B^=(e=k+_)<<7|e>>>25)+k)<<9|e>>>23)+B)<<13|e>>>19)+U)<<18|e>>>14,T^=(e=(C^=(e=(b^=(e=(D^=(e=T+C)<<7|e>>>25)+T)<<9|e>>>23)+D)<<13|e>>>19)+b)<<18|e>>>14,I^=(e=(A^=(e=(x^=(e=(v^=(e=I+A)<<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=(A^=(e=T+B)<<7|e>>>25)+T)<<9|e>>>23)+A)<<13|e>>>19)+E)<<18|e>>>14,I^=(e=(D^=(e=(U^=(e=(S^=(e=I+D)<<7|e>>>25)+I)<<9|e>>>23)+S)<<13|e>>>19)+U)<<18|e>>>14;g+=t,_+=r,b+=i,v+=n,w+=o,k+=a,C+=s,x+=d,E+=h,B+=u,T+=l,A+=c,S+=f,U+=p,D+=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]=A>>>0&255,this.block[45]=A>>>8&255,this.block[46]=A>>>16&255,this.block[47]=A>>>24&255,this.block[48]=S>>>0&255,this.block[49]=S>>>8&255,this.block[50]=S>>>16&255,this.block[51]=S>>>24&255,this.block[52]=U>>>0&255,this.block[53]=U>>>8&255,this.block[54]=U>>>16&255,this.block[55]=U>>>24&255,this.block[56]=D>>>0&255,this.block[57]=D>>>8&255,this.block[58]=D>>>16&255,this.block[59]=D>>>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<<t|e>>>32-t}i.prototype.getBytes=function(e){for(var t=new Uint8Array(e),r=0;r<e;r++)64===this.blockUsed&&(this._generateBlock(),this.blockUsed=0),t[r]=this.block[this.blockUsed],this.blockUsed++;return t},i.prototype._generateBlock=function(){var e,t=this.input,r=this.x,i=this.block;for(r.set(t),e=20;e>0;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;i<t;){this._generateBlock();for(var o=Math.min(t-i,64),a=0;a<o;a++)r[i]=e[i]^n[a],i++}return r},e.exports=i},function(e,t,r){"use strict";var i=r(0),n=r(3),o=16;function a(e,t,r){for(var n=Promise.resolve(i.arrayToBuffer(t)),a=new Uint8Array(o*Math.min(r,1e4));r>0;){var d=Math.min(r,1e4);r-=d;var h=o*d;n=s(e,n,a.length===h?a.buffer:i.arrayToBuffer(a.subarray(0,h)))}return n.then((function(e){return new Uint8Array(e)}))}function s(e,t,r){return t.then((function(t){return e.encrypt(r,t)})).then((function(e){var t=i.arrayToBuffer(new Uint8Array(e).subarray(-32,-16));return i.zeroBuffer(e),t}))}e.exports.encrypt=function(e,t,r){var s=n.createAesCbc();return s.importKey(i.arrayToBuffer(t)).then((function(){for(var t=[],i=0;i<32;i+=o)t.push(a(s,e.subarray(i,i+o),r));return Promise.all(t)})).then((function(e){var t=new Uint8Array(32);return e.forEach((function(e,r){for(var n=r*o,a=0;a<o;++a)t[a+n]=e[a];i.zeroBuffer(e)})),t}))}},function(e,t,r){"use strict";var i=r(9),n=r(2),o=r(1),a=r(0),s=r(4),d=r(10),h=r(3),u=function(e,t,r){var i=this;this.ready=Promise.all([this.setPassword(e),this.setKeyFile(t),this.setChallengeResponse(r)]).then((function(){return i}))};u.prototype.setPassword=function(e){if(null!==e){if(e instanceof i){var t=this;return e.getHash().then((function(e){t.passwordHash=i.fromBinary(e)}))}return Promise.reject(new n(o.ErrorCodes.InvalidArg,"password"))}return this.passwordHash=null,Promise.resolve()},u.prototype.setKeyFile=function(e){if(e&&!(e instanceof ArrayBuffer)&&!(e instanceof Uint8Array))return Promise.reject(new n(o.ErrorCodes.InvalidArg,"keyFile"));if(e){if(32===e.byteLength)return this.keyFileHash=i.fromBinary(a.arrayToBuffer(e)),Promise.resolve();try{var t;if((t=a.bytesToString(a.arrayToBuffer(e))).match(/^[a-f\d]{64}$/i)){var r=a.hexToBytes(t);return void(this.keyFileHash=i.fromBinary(r))}var d=s.parse(t.trim()),u=s.getChildNode(d.documentElement,"Key"),l=s.getChildNode(u,"Data");this.keyFileHash=i.fromBinary(a.base64ToBytes(l.textContent))}catch(t){var c=this;return h.sha256(e).then((function(e){c.keyFileHash=i.fromBinary(e)}))}}else this.keyFileHash=null;return Promise.resolve()},u.prototype.setChallengeResponse=function(e){return this.challengeResponse=e,Promise.resolve()},u.prototype.getHash=function(e){var t=this;return this.ready.then((function(){return t.getChallengeResponse(e).then((function(e){var r=[];t.passwordHash&&r.push(t.passwordHash.getBinary()),t.keyFileHash&&r.push(t.keyFileHash.getBinary()),e&&r.push(new Uint8Array(e));var i=r.reduce((function(e,t){return e+t.byteLength}),0),n=new Uint8Array(i),o=0;return r.forEach((function(e){n.set(e,o),a.zeroBuffer(e),o+=e.length})),h.sha256(a.arrayToBuffer(n)).then((function(e){return a.zeroBuffer(n),e}))}))}))},u.prototype.getChallengeResponse=function(e){var t=this.challengeResponse;return Promise.resolve().then((function(){return t&&e?t(e).then((function(e){return h.sha256(a.arrayToBuffer(e)).then((function(t){return a.zeroBuffer(e),t}))})):null}))},u.createRandomKeyFile=function(){for(var e=d.getBytes(32),t=d.getBytes(32),r=0;r<32;r++)e[r]^=t[r],e[r]^=1e3*Math.random()%255;var i=a.bytesToBase64(e);return u.createKeyFileWithHash(i)},u.createKeyFileWithHash=function(e){var t='<?xml version="1.0" encoding="utf-8"?>\n<KeyFile>\n <Meta>\n <Version>1.00</Version>\n </Meta>\n <Key>\n <Data>'+e+"</Data>\n </Key>\n</KeyFile>";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;r<n;r++){var a=i[r];a.tagName&&t._readNode(a)}return t},e.exports=o},function(e,t,r){"use strict";var i=r(9),n=r(6),o=r(4),a=r(1),s=r(15),d=r(7),h=r(27),u=/\s*[;,:]\s*/,l=function(){this.uuid=void 0,this.icon=void 0,this.customIcon=void 0,this.fgColor=void 0,this.bgColor=void 0,this.overrideUrl=void 0,this.tags=[],this.times=new h,this.fields={},this.binaries={},this.autoType={enabled:!0,obfuscation:a.AutoTypeObfuscationOptions.None,defaultSequence:void 0,items:[]},this.history=[],this.parentGroup=void 0,this.customData=void 0,this._editState=void 0,Object.preventExtensions(this)};l.prototype._readNode=function(e,t){switch(e.tagName){case n.Elem.Uuid:this.uuid=o.getUuid(e);break;case n.Elem.Icon:this.icon=o.getNumber(e)||a.Icons.Key;break;case n.Elem.CustomIconID:this.customIcon=o.getUuid(e);break;case n.Elem.FgColor:this.fgColor=o.getText(e);break;case n.Elem.BgColor:this.bgColor=o.getText(e);break;case n.Elem.OverrideUrl:this.overrideUrl=o.getText(e);break;case n.Elem.Tags:this.tags=this._stringToTags(o.getText(e));break;case n.Elem.Times:this.times=h.read(e);break;case n.Elem.String:this._readField(e);break;case n.Elem.Binary:this._readBinary(e,t);break;case n.Elem.AutoType:this._readAutoType(e);break;case n.Elem.History:this._readHistory(e,t);break;case n.Elem.CustomData:this._readCustomData(e)}},l.prototype._readField=function(e){var t=o.getChildNode(e,n.Elem.Key),r=o.getChildNode(e,n.Elem.Value),i=o.getText(t),a=o.getProtectedText(r);i&&(this.fields[i]=a)},l.prototype._writeFields=function(e){var t=this.fields;Object.keys(t).forEach((function(r){var i=t[r];if(null!=i){var a=o.addChildNode(e,n.Elem.String);o.setText(o.addChildNode(a,n.Elem.Key),r),o.setProtectedText(o.addChildNode(a,n.Elem.Value),i)}}))},l.prototype._readBinary=function(e,t){var r=o.getChildNode(e,n.Elem.Key),i=o.getChildNode(e,n.Elem.Value),a=o.getText(r),s=o.getProtectedBinary(i);a&&s&&(s.ref&&(s.ref=t.kdbx.binaries.idToHash[s.ref],s.ref?s.value=t.kdbx.binaries[s.ref]:s=null),s&&(this.binaries[a]=s))},l.prototype._writeBinaries=function(e,t){var r=this.binaries;Object.keys(r).forEach((function(i){var a=r[i];if(a){if(a.ref){var s=t.kdbx.binaries.hashOrder.indexOf(a.ref);if(s<0)return;a={ref:s.toString()}}var d=o.addChildNode(e,n.Elem.Binary);o.setText(o.addChildNode(d,n.Elem.Key),i),o.setProtectedBinary(o.addChildNode(d,n.Elem.Value),a)}}))},l.prototype._stringToTags=function(e){return e?e.split(u).filter((function(e){return e})):[]},l.prototype._readAutoType=function(e){for(var t=0,r=e.childNodes,i=r.length;t<i;t++){var s=r[t];switch(s.tagName){case n.Elem.AutoTypeEnabled:this.autoType.enabled=o.getBoolean(s),"boolean"!=typeof this.autoType.enabled&&(this.autoType.enabled=!0);break;case n.Elem.AutoTypeObfuscation:this.autoType.obfuscation=o.getNumber(s)||a.AutoTypeObfuscationOptions.None;break;case n.Elem.AutoTypeDefaultSeq:this.autoType.defaultSequence=o.getText(s);break;case n.Elem.AutoTypeItem:this._readAutoTypeItem(s)}}},l.prototype._readAutoTypeItem=function(e){for(var t={},r=0,i=e.childNodes,a=i.length;r<a;r++){var s=i[r];switch(s.tagName){case n.Elem.Window:t.window=o.getText(s);break;case n.Elem.KeystrokeSequence:t.keystrokeSequence=o.getText(s)}}this.autoType.items.push(t)},l.prototype._writeAutoType=function(e){var t=o.addChildNode(e,n.Elem.AutoType);o.setBoolean(o.addChildNode(t,n.Elem.AutoTypeEnabled),this.autoType.enabled),o.setNumber(o.addChildNode(t,n.Elem.AutoTypeObfuscation),this.autoType.obfuscation||a.AutoTypeObfuscationOptions.None),this.autoType.defaultSequence&&o.setText(o.addChildNode(t,n.Elem.AutoTypeDefaultSeq),this.autoType.defaultSequence);for(var r=0;r<this.autoType.items.length;r++){var i=this.autoType.items[r],s=o.addChildNode(t,n.Elem.AutoTypeItem);o.setText(o.addChildNode(s,n.Elem.Window),i.window),o.setText(o.addChildNode(s,n.Elem.KeystrokeSequence),i.keystrokeSequence)}},l.prototype._readHistory=function(e,t){for(var r=0,i=e.childNodes,o=i.length;r<o;r++){var a=i[r];switch(a.tagName){case n.Elem.Entry:this.history.push(l.read(a,t))}}},l.prototype._writeHistory=function(e,t){for(var r=o.addChildNode(e,n.Elem.History),i=0;i<this.history.length;i++)this.history[i].write(r,t)},l.prototype._readCustomData=function(e){this.customData=s.read(e)},l.prototype._writeCustomData=function(e){s.write(e,this.customData)},l.prototype._setField=function(e,t,r){this.fields[e]=r?i.fromString(t):t},l.prototype._addHistoryTombstone=function(e,t){this._editState||(this._editState={added:[],deleted:[]}),this._editState[e?"added":"deleted"].push(t.getTime())},l.prototype.write=function(e,t){var r=o.addChildNode(e,n.Elem.Entry);o.setUuid(o.addChildNode(r,n.Elem.Uuid),this.uuid),o.setNumber(o.addChildNode(r,n.Elem.Icon),this.icon||a.Icons.Key),this.customIcon&&o.setUuid(o.addChildNode(r,n.Elem.CustomIconID),this.customIcon),o.setText(o.addChildNode(r,n.Elem.FgColor),this.fgColor),o.setText(o.addChildNode(r,n.Elem.BgColor),this.bgColor),o.setText(o.addChildNode(r,n.Elem.OverrideUrl),this.overrideUrl),o.setText(o.addChildNode(r,n.Elem.Tags),this.tags.join(",")),this.times.write(r,t),this._writeFields(r),this._writeBinaries(r,t),this._writeAutoType(r),this._writeCustomData(r),e.tagName!==n.Elem.History&&this._writeHistory(r,t)},l.prototype.pushHistory=function(){var e=new l;e.copyFrom(this),this.history.push(e),this._addHistoryTombstone(!0,e.times.lastModTime)},l.prototype.removeHistory=function(e,t){void 0===t&&(t=1);for(var r=e;r<e+t;r++)r<this.history.length&&this._addHistoryTombstone(!1,this.history[r].times.lastModTime);this.history.splice(e,t)},l.prototype.copyFrom=function(e){this.uuid=e.uuid,this.icon=e.icon,this.customIcon=e.customIcon,this.fgColor=e.fgColor,this.bgColor=e.bgColor,this.overrideUrl=e.overrideUrl,this.tags=e.tags.slice(),this.times=e.times.clone(),this.fields={},Object.keys(e.fields).forEach((function(t){e.fields[t]instanceof i?this.fields[t]=e.fields[t].clone():this.fields[t]=e.fields[t]}),this),this.binaries={},Object.keys(e.binaries).forEach((function(t){e.binaries[t]instanceof i?this.binaries[t]=e.binaries[t].clone():e.binaries[t]&&e.binaries[t].ref?(this.binaries[t]={ref:e.binaries[t].ref},e.binaries[t].value&&(this.binaries[t].value=e.binaries[t].value)):this.binaries[t]=e.binaries[t]}),this),this.autoType=JSON.parse(JSON.stringify(e.autoType))},l.prototype.merge=function(e){var t=e.remote[this.uuid];if(t){var r=t.history.slice();if(this.times.lastModTime<t.times.lastModTime)this.pushHistory(),this.copyFrom(t);else if(this.times.lastModTime>t.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=[];n<this.history.length||o<e.length;){var s=this.history[n],d=e[o],h=s&&s.times.lastModTime.getTime(),u=d&&d.times.lastModTime.getTime();if(h!==u)if(!s||h>u){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||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<a;n++){var s=o[n];s.tagName&&i._readNode(s,t)}if(!i.uuid){i.uuid=d.random();for(var h=0;h<i.history.length;h++)i.history[h].uuid=i.uuid}return i.parentGroup=r,i},e.exports=l},function(e,t,r){e.exports.Kdbx=r(30),e.exports.KdbxUuid=r(7),e.exports.KdbxError=r(2),e.exports.Credentials=r(26),e.exports.Consts=r(1),e.exports.ProtectedValue=r(9),e.exports.ByteUtils=r(0),e.exports.VarDictionary=r(14),e.exports.Int64=r(8),e.exports.Random=r(10),e.exports.CryptoEngine=r(3)},function(e,t,r){"use strict";var i=r(31),n=r(2),o=r(26),a=r(22),s=r(49),d=r(50),h=r(51),u=r(28),l=r(52),c=r(7),f=r(1),p=r(6),m=r(4),y=function(){this.header=void 0,this.credentials=void 0,this.meta=void 0,this.xml=void 0,this.binaries=new d,this.groups=[],this.deletedObjects=[],Object.preventExtensions(this)};y.create=function(e,t){if(!(e instanceof o))throw new n(f.ErrorCodes.InvalidArg,"credentials");var r=new y;return r.credentials=e,r.header=a.create(),r.meta=s.create(),r.meta._name=t,r.createDefaultGroup(),r.createRecycleBin(),r.meta._lastSelectedGroup=r.getDefaultGroup().id,r.meta._lastTopVisibleGroup=r.getDefaultGroup().id,r},y.load=function(e,t){if(!(e instanceof ArrayBuffer))return Promise.reject(new n(f.ErrorCodes.InvalidArg,"data"));if(!(t instanceof o))return Promise.reject(new n(f.ErrorCodes.InvalidArg,"credentials"));var r=new y;return r.credentials=t,new i(r).load(e)},y.loadXml=function(e,t){if("string"!=typeof e)return Promise.reject(new n(f.ErrorCodes.InvalidArg,"data"));if(!(t instanceof o))return Promise.reject(new n(f.ErrorCodes.InvalidArg,"credentials"));var r=new y;return r.credentials=t,new i(r).loadXml(e)},y.prototype.save=function(){return new i(this).save()},y.prototype.saveXml=function(e){return new i(this).saveXml(e)},y.prototype.createDefaultGroup=function(){if(!this.groups.length){var e=h.create(this.meta.name);e.icon=f.Icons.FolderOpen,e.expanded=!0,this.groups.push(e)}},y.prototype.createRecycleBin=function(){if(this.meta.recycleBinEnabled=!0,!this.meta.recycleBinUuid||!this.getGroup(this.meta.recycleBinUuid)){var e=this.getDefaultGroup(),t=h.create(f.Defaults.RecycleBinName,e);t.icon=f.Icons.TrashBin,t.enableAutoType=!1,t.enableSearching=!1,this.meta.recycleBinUuid=t.uuid,e.groups.push(t)}},y.prototype.createGroup=function(e,t){var r=h.create(t,e);return e.groups.push(r),r},y.prototype.createEntry=function(e){var t=u.create(this.meta,e);return e.entries.push(t),t},y.prototype.getDefaultGroup=function(){return this.groups[0]},y.prototype.getGroup=function(e,t){for(var r=t?t.groups:this.groups,i=0;i<r.length;i++){if(r[i].uuid.id===e.id)return r[i];var n=this.getGroup(e,r[i]);if(n)return n}},y.prototype.move=function(e,t,r){var i=e instanceof h?"groups":"entries",n=e.parentGroup[i],o=n.indexOf(e);if(!(o<0)){if(n.splice(o,1),t)"number"==typeof r&&r>=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&&"number"==typeof 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;t<i;t++){var n=r[t];switch(n.tagName){case p.Elem.Group:this._readGroup(n,e);break;case p.Elem.DeletedObjects:this._readDeletedObjects(n)}}},y.prototype._readDeletedObjects=function(e){for(var t=0,r=e.childNodes,i=r.length;t<i;t++){var n=r[t];switch(n.tagName){case p.Elem.DeletedObject:this.deletedObjects.push(l.read(n))}}},y.prototype._readGroup=function(e,t){this.groups.push(h.read(e,t))},y.prototype._buildXml=function(e){var t=m.create(p.Elem.DocNode);this.meta.write(t.documentElement,e);var r=m.addChildNode(t.documentElement,p.Elem.Root);this.groups.forEach((function(t){t.write(r,e)}),this);var i=m.addChildNode(r,p.Elem.DeletedObjects);this.deletedObjects.forEach((function(t){t.write(i,e)}),this),this.xml=t},e.exports=y},function(e,t,r){"use strict";var i=r(16),n=r(2),o=r(22),a=r(43),s=r(3),d=r(11),h=r(0),u=r(4),l=r(8),c=r(1),f=r(45),p=r(46),m=r(47),y=r(25),g=r(48),_=function(e){this.kdbx=e};_.prototype.load=function(e){var t=new d(e),r=this.kdbx,i=this;return i.ctx=new a({kdbx:r}),r.credentials.ready.then((function(){if(r.header=o.read(t,i.ctx),3===r.header.versionMajor)return i._loadV3(t);if(4===r.header.versionMajor)return i._loadV4(t);throw new n(c.ErrorCodes.InvalidVersion,"bad version: "+r.header.versionMajor)}))},_.prototype._loadV3=function(e){var t=this.kdbx,r=this;return r._decryptXmlV3(t,e).then((function(i){return t.xml=u.parse(i),r._setProtectedValues().then((function(){return t._loadFromXml(r.ctx).then((function(){return r._checkHeaderHashV3(e).then((function(){return t}))}))}))}))},_.prototype._loadV4=function(e){var t=this;return t._getHeaderHash(e).then((function(r){var o=e.readBytes(r.byteLength);if(!h.arrayBufferEquals(o,r))throw new n(c.ErrorCodes.FileCorrupt,"header hash mismatch");return t._computeKeysV4().then((function(r){return t._getHeaderHmac(e,r.hmacKey).then((function(o){var a=e.readBytes(o.byteLength);if(!h.arrayBufferEquals(a,o))throw new n(c.ErrorCodes.InvalidKey);return p.decrypt(e.readBytesToEnd(),r.hmacKey).then((function(n){return h.zeroBuffer(r.hmacKey),t._decryptData(n,r.cipherKey).then((function(n){h.zeroBuffer(r.cipherKey),t.kdbx.header.compression===c.CompressionAlgorithm.GZip&&(n=i.ungzip(n)),e=new d(h.arrayToBuffer(n)),t.kdbx.header.readInnerHeader(e,t.ctx),n=e.readBytesToEnd();var o=h.bytesToString(n);return t.kdbx.xml=u.parse(o),t._setProtectedValues().then((function(){return t.kdbx._loadFromXml(t.ctx)}))}))}))}))}))}))},_.prototype.loadXml=function(e){var t=this.kdbx,r=new a({kdbx:t});return t.credentials.ready.then((function(){return t.header=o.create(),t.xml=u.parse(e),u.protectPlainValues(t.xml.documentElement),t._loadFromXml(r)}))},_.prototype.save=function(){var e=this.kdbx,t=this;return t.ctx=new a({kdbx:e}),e.binaries.assignIds(),e.credentials.ready.then((function(){var r=new d;if(e.header.generateSalts(),e.header.write(r),3===e.header.versionMajor)return t._saveV3(r);if(4===e.header.versionMajor)return t._saveV4(r);throw new n(c.ErrorCodes.InvalidVersion,"bad version: "+e.header.versionMajor)}))},_.prototype._saveV3=function(e){var t=this;return t._getHeaderHash(e).then((function(r){return t.kdbx.meta.headerHash=r,t.kdbx._buildXml(t.ctx),t._getProtectSaltGenerator().then((function(r){return u.updateProtectedValuesSalt(t.kdbx.xml.documentElement,r),t._encryptXmlV3().then((function(t){return e.writeBytes(t),e.getWrittenBytes()}))}))}))},_.prototype._saveV4=function(e){var t=this;return t.kdbx._buildXml(t.ctx),t._getHeaderHash(e).then((function(r){return e.writeBytes(r),t._computeKeysV4().then((function(r){return t._getHeaderHmac(e,r.hmacKey).then((function(n){return e.writeBytes(n),t._getProtectSaltGenerator().then((function(n){u.updateProtectedValuesSalt(t.kdbx.xml.documentElement,n);var o=u.serialize(t.kdbx.xml),a=new d;t.kdbx.header.writeInnerHeader(a,t.ctx);var s=a.getWrittenBytes(),l=h.arrayToBuffer(h.stringToBytes(o)),f=new ArrayBuffer(s.byteLength+l.byteLength),m=new Uint8Array(f);return m.set(new Uint8Array(s)),m.set(new Uint8Array(l),s.byteLength),h.zeroBuffer(l),h.zeroBuffer(s),t.kdbx.header.compression===c.CompressionAlgorithm.GZip&&(f=i.gzip(f)),t._encryptData(h.arrayToBuffer(f),r.cipherKey).then((function(t){return h.zeroBuffer(r.cipherKey),p.encrypt(t,r.hmacKey).then((function(t){return h.zeroBuffer(r.hmacKey),e.writeBytes(t),e.getWrittenBytes()}))}))}))}))}))}))},_.prototype.saveXml=function(e){var t=this.kdbx;return t.credentials.ready.then((function(){t.header.generateSalts();var r=new a({kdbx:t,exportXml:!0});t.binaries.assignIds(),t._buildXml(r),u.unprotectValues(t.xml.documentElement);var i=u.serialize(t.xml,e);return u.protectUnprotectedValues(t.xml.documentElement),i}))},_.prototype._decryptXmlV3=function(e,t){var r=t.readBytesToEnd(),n=this;return n._getMasterKeyV3().then((function(e){return n._decryptData(r,e).then((function(t){return h.zeroBuffer(e),t=n._trimStartBytesV3(t),f.decrypt(t).then((function(e){return n.kdbx.header.compression===c.CompressionAlgorithm.GZip&&(e=i.ungzip(e)),h.bytesToString(e)}))}))}))},_.prototype._encryptXmlV3=function(){var e=this.kdbx,t=this,r=u.serialize(e.xml),n=h.arrayToBuffer(h.stringToBytes(r));return e.header.compression===c.CompressionAlgorithm.GZip&&(n=i.gzip(n)),f.encrypt(h.arrayToBuffer(n)).then((function(r){var i=new Uint8Array(e.header.streamStartBytes),n=new Uint8Array(r.byteLength+i.length);return n.set(i),n.set(new Uint8Array(r),i.length),r=n,t._getMasterKeyV3().then((function(e){return t._encryptData(h.arrayToBuffer(r),e).then((function(t){return h.zeroBuffer(e),t}))}))}))},_.prototype._getMasterKeyV3=function(){var e=this.kdbx;return e.credentials.getHash().then((function(t){var r=e.header.transformSeed,i=e.header.keyEncryptionRounds,n=e.header.masterSeed;return e.credentials.getChallengeResponse(n).then((function(e){return y.encrypt(new Uint8Array(t),r,i).then((function(r){return h.zeroBuffer(t),s.sha256(r).then((function(t){h.zeroBuffer(r);var i=e?e.byteLength:0,o=new Uint8Array(n.byteLength+t.byteLength+i);return o.set(new Uint8Array(n),0),e&&o.set(new Uint8Array(e),n.byteLength),o.set(new Uint8Array(t),n.byteLength+i),h.zeroBuffer(t),h.zeroBuffer(n),e&&h.zeroBuffer(e),s.sha256(o.buffer).then((function(e){return h.zeroBuffer(o.buffer),e}))}))}))}))}))},_.prototype._trimStartBytesV3=function(e){var t=this.kdbx.header.streamStartBytes;if(e.byteLength<t.byteLength)throw new n(c.ErrorCodes.FileCorrupt,"short start bytes");if(!h.arrayBufferEquals(e.slice(0,this.kdbx.header.streamStartBytes.byteLength),t))throw new n(c.ErrorCodes.InvalidKey);return e.slice(t.byteLength)},_.prototype._setProtectedValues=function(){var e=this.kdbx;return this._getProtectSaltGenerator().then((function(t){u.setProtectedValues(e.xml.documentElement,t)}))},_.prototype._getProtectSaltGenerator=function(){return m.create(this.kdbx.header.protectedStreamKey,this.kdbx.header.crsAlgorithm)},_.prototype._getHeaderHash=function(e){var t=e.readBytesNoAdvance(0,this.kdbx.header.endPos);return s.sha256(t)},_.prototype._getHeaderHmac=function(e,t){var r=e.readBytesNoAdvance(0,this.kdbx.header.endPos);return p.getHmacKey(t,new l(4294967295,4294967295)).then((function(e){return s.hmacSha256(e,r)}))},_.prototype._checkHeaderHashV3=function(e){if(this.kdbx.meta.headerHash){var t=this.kdbx.meta.headerHash;return this._getHeaderHash(e).then((function(e){if(!h.arrayBufferEquals(t,e))throw new n(c.ErrorCodes.FileCorrupt,"header hash mismatch")}))}return Promise.resolve()},_.prototype._computeKeysV4=function(){var e=this,t=e.kdbx.header.masterSeed;if(!t||32!==t.byteLength)return Promise.reject(new n(c.ErrorCodes.FileCorrupt,"bad master seed"));var r=e.kdbx.header.kdfParameters,i=r.get("S");return e.kdbx.credentials.getHash(i).then((function(e){return g.encrypt(e,r).then((function(r){if(h.zeroBuffer(e),!r||32!==r.byteLength)return Promise.reject(new n(c.ErrorCodes.Unsupported,"bad derived key"));var i=new Uint8Array(65);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(r),t.byteLength),i[64]=1,h.zeroBuffer(r),h.zeroBuffer(t),Promise.all([s.sha256(i.buffer.slice(0,64)),s.sha512(i.buffer)]).then((function(e){return h.zeroBuffer(i),{cipherKey:e[0],hmacKey:e[1]}}))}))}))},_.prototype._decryptData=function(e,t){switch(this.kdbx.header.dataCipherUuid.toString()){case c.CipherId.Aes:return this._transformDataV4Aes(e,t,!1);case c.CipherId.ChaCha20:return this._transformDataV4ChaCha20(e,t);default:return Promise.reject(new n(c.ErrorCodes.Unsupported,"unsupported cipher"))}},_.prototype._encryptData=function(e,t){switch(this.kdbx.header.dataCipherUuid.toString()){case c.CipherId.Aes:return this._transformDataV4Aes(e,t,!0);case c.CipherId.ChaCha20:return this._transformDataV4ChaCha20(e,t);default:return Promise.reject(new n(c.ErrorCodes.Unsupported,"unsupported cipher"))}},_.prototype._transformDataV4Aes=function(e,t,r){var i=this,n=s.createAesCbc();return n.importKey(t).then((function(){return r?n.encrypt(e,i.kdbx.header.encryptionIV):n.decrypt(e,i.kdbx.header.encryptionIV)}))},_.prototype._transformDataV4ChaCha20=function(e,t){return s.chacha20(e,t,this.kdbx.header.encryptionIV)},e.exports=_},function(e,t,r){"use strict";var i=r(33),n=r(5),o=r(19),a=r(12),s=r(20),d=Object.prototype.toString;function h(e){if(!(this instanceof h))return new h(e);this.options=n.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?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(0!==r)throw new Error(a[r]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var u;if(u="string"==typeof t.dictionary?o.string2buf(t.dictionary):"[object ArrayBuffer]"===d.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=i.deflateSetDictionary(this.strm,u)))throw new Error(a[r]);this._dict_set=!0}}function u(e,t){var r=new h(t);if(r.push(e,!0),r.err)throw r.msg;return r.result}h.prototype.push=function(e,t){var r,a,s=this.strm,h=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(h),s.next_out=0,s.avail_out=h),1!==(r=i.deflate(s,a))&&0!==r)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,0===r):2!==a||(this.onEnd(0),s.avail_out=0,!0)},h.prototype.onData=function(e){this.chunks.push(e)},h.prototype.onEnd=function(e){0===e&&("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=h,t.deflate=u,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,u(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=-2,u=258,l=262,c=103,f=113,p=666;function m(e,t){return e.msg=d[t],t}function y(e){return(e<<1)-(e>4?9:0)}function g(e){for(var t=e.length;--t>=0;)e[t]=0}function _(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 b(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,_(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function w(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function k(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-l?e.strstart-(e.w_size-l):0,h=e.window,c=e.w_mask,f=e.prev,p=e.strstart+u,m=h[o+a-1],y=h[o+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(h[(r=t)+a]===y&&h[r+a-1]===m&&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]&&o<p);if(i=u-(p-o),o=p-u,i>a){if(e.match_start=t,a=i,i>=s)break;m=h[o+a-1],y=h[o+a]}}}while((t=f[t&c])>d&&0!=--n);return a<=e.lookahead?a:e.lookahead}function C(e){var t,r,i,o,d,h,u,c,f,p,m=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-l)){n.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=r=e.hash_size;do{i=e.head[--t],e.head[t]=i>=m?i-m:0}while(--r);t=r=m;do{i=e.prev[--t],e.prev[t]=i>=m?i-m:0}while(--r);o+=m}if(0===e.strm.avail_in)break;if(h=e.strm,u=e.window,c=e.strstart+e.lookahead,f=o,p=void 0,(p=h.avail_in)>f&&(p=f),r=0===p?0:(h.avail_in-=p,n.arraySet(u,h.input,h.next_in,p,c),1===h.state.wrap?h.adler=a(h.adler,u,p,c):2===h.state.wrap&&(h.adler=s(h.adler,u,p,c)),h.next_in+=p,h.total_in+=p,p),e.lookahead+=r,e.lookahead+e.insert>=3)for(d=e.strstart-e.insert,e.ins_h=e.window[d],e.ins_h=(e.ins_h<<e.hash_shift^e.window[d+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[d+3-1])&e.hash_mask,e.prev[d&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=d,d++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<l&&0!==e.strm.avail_in)}function x(e,t){for(var r,i;;){if(e.lookahead<l){if(C(e),e.lookahead<l&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-l&&(e.match_length=k(e,r)),e.match_length>=3)if(i=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(b(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(b(e,!1),0===e.strm.avail_out)?1:2}function E(e,t){for(var r,i,n;;){if(e.lookahead<l){if(C(e),e.lookahead<l&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-l&&(e.match_length=k(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,i=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(b(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((i=o._tr_tally(e,0,e.window[e.strstart-1]))&&b(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=o._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(b(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(b(e,!1),0===e.strm.avail_out)?1:2}function B(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}function T(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new n.Buf16(1146),this.dyn_dtree=new n.Buf16(122),this.bl_tree=new n.Buf16(78),g(this.dyn_ltree),g(this.dyn_dtree),g(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(16),this.heap=new n.Buf16(573),g(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(573),g(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function A(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:f,e.adler=2===t.wrap?0:1,t.last_flush=0,o._tr_init(t),0):m(e,h)}function S(e){var t,r=A(e);return 0===r&&((t=e.state).window_size=2*t.w_size,g(t.head),t.max_lazy_match=i[t.level].max_lazy,t.good_match=i[t.level].good_length,t.nice_match=i[t.level].nice_length,t.max_chain_length=i[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function U(e,t,r,i,o,a){if(!e)return h;var s=1;if(-1===t&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),o<1||o>9||8!==r||i<8||i>15||t<0||t>9||a<0||a>4)return m(e,h);8===i&&(i=9);var d=new T;return e.state=d,d.strm=e,d.wrap=s,d.gzhead=null,d.w_bits=i,d.w_size=1<<d.w_bits,d.w_mask=d.w_size-1,d.hash_bits=o+7,d.hash_size=1<<d.hash_bits,d.hash_mask=d.hash_size-1,d.hash_shift=~~((d.hash_bits+3-1)/3),d.window=new n.Buf8(2*d.w_size),d.head=new n.Buf16(d.hash_size),d.prev=new n.Buf16(d.w_size),d.lit_bufsize=1<<o+6,d.pending_buf_size=4*d.lit_bufsize,d.pending_buf=new n.Buf8(d.pending_buf_size),d.d_buf=1*d.lit_bufsize,d.l_buf=3*d.lit_bufsize,d.level=t,d.strategy=a,d.method=r,S(e)}i=[new B(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(C(e),0===e.lookahead&&0===t)return 1;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,b(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-l&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(b(e,!1),e.strm.avail_out),1)})),new B(4,4,8,4,x),new B(4,5,16,8,x),new B(4,6,32,32,x),new B(4,4,16,16,E),new B(8,16,32,32,E),new B(8,16,128,128,E),new B(8,32,128,256,E),new B(32,128,258,1024,E),new B(32,258,258,4096,E)],t.deflateInit=function(e,t){return U(e,t,8,15,8,0)},t.deflateInit2=U,t.deflateReset=S,t.deflateResetKeep=A,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?h:(e.state.gzhead=t,0):h},t.deflate=function(e,t){var r,n,a,d;if(!e||!e.state||t>5||t<0)return e?m(e,h):h;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===p&&4!==t)return m(e,0===e.avail_out?-5:h);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,v(n,31),v(n,139),v(n,8),n.gzhead?(v(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)),v(n,255&n.gzhead.time),v(n,n.gzhead.time>>8&255),v(n,n.gzhead.time>>16&255),v(n,n.gzhead.time>>24&255),v(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),v(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(v(n,255&n.gzhead.extra.length),v(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=69):(v(n,0),v(n,0),v(n,0),v(n,0),v(n,0),v(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),v(n,3),n.status=f);else{var l=8+(n.w_bits-8<<4)<<8;l|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(l|=32),l+=31-l%31,n.status=f,w(n,l),0!==n.strstart&&(w(n,e.adler>>>16),w(n,65535&e.adler)),e.adler=1}if(69===n.status)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)),_(e),a=n.pending,n.pending!==n.pending_buf_size));)v(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=73)}else n.status=73;if(73===n.status)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)),_(e),a=n.pending,n.pending===n.pending_buf_size)){d=1;break}d=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,v(n,d)}while(0!==d);n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),0===d&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)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)),_(e),a=n.pending,n.pending===n.pending_buf_size)){d=1;break}d=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,v(n,d)}while(0!==d);n.gzhead.hcrc&&n.pending>a&&(e.adler=s(e.adler,n.pending_buf,n.pending-a,a)),0===d&&(n.status=c)}else n.status=c;if(n.status===c&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&_(e),n.pending+2<=n.pending_buf_size&&(v(n,255&e.adler),v(n,e.adler>>8&255),e.adler=0,n.status=f)):n.status=f),0!==n.pending){if(_(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&y(t)<=y(r)&&4!==t)return m(e,-5);if(n.status===p&&0!==e.avail_in)return m(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==p){var k=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(C(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(b(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,i,n,a,s=e.window;;){if(e.lookahead<=u){if(C(e),e.lookahead<=u&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=s[n=e.strstart-1])===s[++n]&&i===s[++n]&&i===s[++n]){a=e.strstart+u;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]&&n<a);e.match_length=u-(a-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=o._tr_tally(e,1,e.match_length-3),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&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(b(e,!1),0===e.strm.avail_out)?1:2}(n,t):i[n.level].func(n,t);if(3!==k&&4!==k||(n.status=p),1===k||3===k)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===k&&(1===t?o._tr_align(n):5!==t&&(o._tr_stored_block(n,0,0,!1),3===t&&(g(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),_(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(v(n,255&e.adler),v(n,e.adler>>8&255),v(n,e.adler>>16&255),v(n,e.adler>>24&255),v(n,255&e.total_in),v(n,e.total_in>>8&255),v(n,e.total_in>>16&255),v(n,e.total_in>>24&255)):(w(n,e.adler>>>16),w(n,65535&e.adler)),_(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},t.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==c&&t!==f&&t!==p?m(e,h):(e.state=null,t===f?m(e,-3):0):h},t.deflateSetDictionary=function(e,t){var r,i,o,s,d,u,l,c,f=t.length;if(!e||!e.state)return h;if(2===(s=(r=e.state).wrap)||1===s&&42!==r.status||r.lookahead)return h;for(1===s&&(e.adler=a(e.adler,t,f,0)),r.wrap=0,f>=r.w_size&&(0===s&&(g(r.head),r.strstart=0,r.block_start=0,r.insert=0),c=new n.Buf8(r.w_size),n.arraySet(c,t,f-r.w_size,r.w_size,0),t=c,f=r.w_size),d=e.avail_in,u=e.next_in,l=e.input,e.avail_in=f,e.next_in=0,e.input=t,C(r);r.lookahead>=3;){i=r.strstart,o=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[i+3-1])&r.hash_mask,r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++}while(--o);r.strstart=i,r.lookahead=2,C(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=u,e.input=l,e.avail_in=d,r.wrap=s,0},t.deflateInfo="pako deflate (from Nodeca project)"},function(e,t,r){"use strict";var i=r(5);function n(e){for(var t=e.length;--t>=0;)e[t]=0}var o=256,a=286,s=30,d=15,h=[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],u=[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],l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],c=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],f=new Array(576);n(f);var p=new Array(60);n(p);var m=new Array(512);n(m);var y=new Array(256);n(y);var g=new Array(29);n(g);var _,b,v,w=new Array(s);function k(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 C(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function x(e){return e<256?m[e]:m[256+(e>>>7)]}function E(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function B(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,E(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function T(e,t,r){B(e,r[2*t],r[2*t+1])}function A(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function S(e,t,r){var i,n,o=new Array(16),a=0;for(i=1;i<=d;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]=A(o[s]++,s))}}function U(e){var t;for(t=0;t<a;t++)e.dyn_ltree[2*t]=0;for(t=0;t<s;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function D(e){e.bi_valid>8?E(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 I(e,t,r,i){var n=2*t,o=2*r;return e[n]<e[o]||e[n]===e[o]&&i[t]<=i[r]}function N(e,t,r){for(var i=e.heap[r],n=r<<1;n<=e.heap_len&&(n<e.heap_len&&I(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!I(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i}function P(e,t,r){var i,n,a,s,d=0;if(0!==e.last_lit)do{i=e.pending_buf[e.d_buf+2*d]<<8|e.pending_buf[e.d_buf+2*d+1],n=e.pending_buf[e.l_buf+d],d++,0===i?T(e,n,t):(T(e,(a=y[n])+o+1,t),0!==(s=h[a])&&B(e,n-=g[a],s),T(e,a=x(--i),r),0!==(s=u[a])&&B(e,i-=w[a],s))}while(d<e.last_lit);T(e,256,t)}function M(e,t){var r,i,n,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,h=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<h;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(n=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[n]=0,e.opt_len--,s&&(e.static_len-=a[2*n+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)N(e,o,r);n=h;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],N(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++,N(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,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,c=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,m=t.stat_desc.max_length,y=0;for(o=0;o<=d;o++)e.bl_count[o]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=h[2*h[2*(i=e.heap[r])+1]+1]+1)>m&&(o=m,y++),h[2*i+1]=o,i>u||(e.bl_count[o]++,a=0,i>=p&&(a=f[i-p]),s=h[2*i],e.opt_len+=s*(o+a),c&&(e.static_len+=s*(l[2*i+1]+a)));if(0!==y){do{for(o=m-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[m]--,y-=2}while(y>0);for(o=m;0!==o;o--)for(i=e.bl_count[o];0!==i;)(n=e.heap[--r])>u||(h[2*n+1]!==o&&(e.opt_len+=(o-h[2*n+1])*h[2*n],h[2*n+1]=o),i--)}}(e,t),S(o,u,e.bl_count)}function F(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<d&&n===a||(s<h?e.bl_tree[2*n]+=s:0!==n?(n!==o&&e.bl_tree[2*n]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=n,0===a?(d=138,h=3):n===a?(d=6,h=3):(d=7,h=4))}function z(e,t,r){var i,n,o=-1,a=t[1],s=0,d=7,h=4;for(0===a&&(d=138,h=3),i=0;i<=r;i++)if(n=a,a=t[2*(i+1)+1],!(++s<d&&n===a)){if(s<h)do{T(e,n,e.bl_tree)}while(0!=--s);else 0!==n?(n!==o&&(T(e,n,e.bl_tree),s--),T(e,16,e.bl_tree),B(e,s-3,2)):s<=10?(T(e,17,e.bl_tree),B(e,s-3,3)):(T(e,18,e.bl_tree),B(e,s-11,7));s=0,o=n,0===a?(d=138,h=3):n===a?(d=6,h=3):(d=7,h=4)}}n(w);var O=!1;function V(e,t,r,n){B(e,0+(n?1:0),3),function(e,t,r,n){D(e),n&&(E(e,r),E(e,~r)),i.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}t._tr_init=function(e){O||(!function(){var e,t,r,i,n,o=new Array(16);for(r=0,i=0;i<28;i++)for(g[i]=r,e=0;e<1<<h[i];e++)y[r++]=i;for(y[r-1]=i,n=0,i=0;i<16;i++)for(w[i]=n,e=0;e<1<<u[i];e++)m[n++]=i;for(n>>=7;i<s;i++)for(w[i]=n<<7,e=0;e<1<<u[i]-7;e++)m[256+n++]=i;for(t=0;t<=d;t++)o[t]=0;for(e=0;e<=143;)f[2*e+1]=8,e++,o[8]++;for(;e<=255;)f[2*e+1]=9,e++,o[9]++;for(;e<=279;)f[2*e+1]=7,e++,o[7]++;for(;e<=287;)f[2*e+1]=8,e++,o[8]++;for(S(f,287,o),e=0;e<s;e++)p[2*e+1]=5,p[2*e]=A(e,5);_=new k(f,h,257,a,d),b=new k(p,u,0,s,d),v=new k(new Array(0),l,0,19,7)}(),O=!0),e.l_desc=new C(e.dyn_ltree,_),e.d_desc=new C(e.dyn_dtree,b),e.bl_desc=new C(e.bl_tree,v),e.bi_buf=0,e.bi_valid=0,U(e)},t._tr_stored_block=V,t._tr_flush_block=function(e,t,r,i){var n,a,s=0;e.level>0?(2===e.strm.data_type&&(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 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<o;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),M(e,e.l_desc),M(e,e.d_desc),s=function(e){var t;for(F(e,e.dyn_ltree,e.l_desc.max_code),F(e,e.dyn_dtree,e.d_desc.max_code),M(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*c[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),n=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=n&&(n=a)):n=a=r+5,r+4<=n&&-1!==t?V(e,t,r,i):4===e.strategy||a===n?(B(e,2+(i?1:0),3),P(e,f,p)):(B(e,4+(i?1:0),3),function(e,t,r,i){var n;for(B(e,t-257,5),B(e,r-1,5),B(e,i-4,4),n=0;n<i;n++)B(e,e.bl_tree[2*c[n]+1],3);z(e,e.dyn_ltree,t-1),z(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),P(e,e.dyn_ltree,e.dyn_dtree)),U(e),i&&D(e)},t._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>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*(y[r]+o+1)]++,e.dyn_dtree[2*x(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){B(e,2,3),T(e,256,f),function(e){16===e.bi_valid?(E(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=-2,h=12,u=30;function l(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function c(){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 f(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=1,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(852),t.distcode=t.distdyn=new i.Buf32(592),t.sane=1,t.back=-1,0):d}function p(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,f(e)):d}function m(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)?d:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,p(e))):d}function y(e,t){var r,i;return e?(i=new c,e.state=i,i.window=null,0!==(r=m(e,t))&&(e.state=null),r):d}var g,_,b=!0;function v(e){if(b){var t;for(g=new i.Buf32(512),_=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(1,e.lens,0,288,g,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;s(2,e.lens,0,32,_,0,e.work,{bits:5}),b=!1}e.lencode=g,e.lenbits=9,e.distcode=_,e.distbits=5}function w(e,t,r,n){var o,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new i.Buf8(a.wsize)),n>=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<a.wsize&&(a.whave+=o))),0}t.inflateReset=p,t.inflateReset2=m,t.inflateResetKeep=f,t.inflateInit=function(e){return y(e,15)},t.inflateInit2=y,t.inflate=function(e,t){var r,c,f,p,m,y,g,_,b,k,C,x,E,B,T,A,S,U,D,I,N,P,M,F,z=0,O=new i.Buf8(4),V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return d;(r=e.state).mode===h&&(r.mode=13),m=e.next_out,f=e.output,g=e.avail_out,p=e.next_in,c=e.input,y=e.avail_in,_=r.hold,b=r.bits,k=y,C=g,P=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;b<16;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(2&r.wrap&&35615===_){r.check=0,O[0]=255&_,O[1]=_>>>8&255,r.check=o(r.check,O,2,0),_=0,b=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&_)<<8)+(_>>8))%31){e.msg="incorrect header check",r.mode=u;break}if(8!=(15&_)){e.msg="unknown compression method",r.mode=u;break}if(b-=4,N=8+(15&(_>>>=4)),0===r.wbits)r.wbits=N;else if(N>r.wbits){e.msg="invalid window size",r.mode=u;break}r.dmax=1<<N,e.adler=r.check=1,r.mode=512&_?10:h,_=0,b=0;break;case 2:for(;b<16;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(r.flags=_,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=u;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=u;break}r.head&&(r.head.text=_>>8&1),512&r.flags&&(O[0]=255&_,O[1]=_>>>8&255,r.check=o(r.check,O,2,0)),_=0,b=0,r.mode=3;case 3:for(;b<32;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}r.head&&(r.head.time=_),512&r.flags&&(O[0]=255&_,O[1]=_>>>8&255,O[2]=_>>>16&255,O[3]=_>>>24&255,r.check=o(r.check,O,4,0)),_=0,b=0,r.mode=4;case 4:for(;b<16;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}r.head&&(r.head.xflags=255&_,r.head.os=_>>8),512&r.flags&&(O[0]=255&_,O[1]=_>>>8&255,r.check=o(r.check,O,2,0)),_=0,b=0,r.mode=5;case 5:if(1024&r.flags){for(;b<16;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}r.length=_,r.head&&(r.head.extra_len=_),512&r.flags&&(O[0]=255&_,O[1]=_>>>8&255,r.check=o(r.check,O,2,0)),_=0,b=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((x=r.length)>y&&(x=y),x&&(r.head&&(N=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),i.arraySet(r.head.extra,c,p,x,N)),512&r.flags&&(r.check=o(r.check,c,x,p)),y-=x,p+=x,r.length-=x),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===y)break e;x=0;do{N=c[p+x++],r.head&&N&&r.length<65536&&(r.head.name+=String.fromCharCode(N))}while(N&&x<y);if(512&r.flags&&(r.check=o(r.check,c,x,p)),y-=x,p+=x,N)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===y)break e;x=0;do{N=c[p+x++],r.head&&N&&r.length<65536&&(r.head.comment+=String.fromCharCode(N))}while(N&&x<y);if(512&r.flags&&(r.check=o(r.check,c,x,p)),y-=x,p+=x,N)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;b<16;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(_!==(65535&r.check)){e.msg="header crc mismatch",r.mode=u;break}_=0,b=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=h;break;case 10:for(;b<32;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}e.adler=r.check=l(_),_=0,b=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=m,e.avail_out=g,e.next_in=p,e.avail_in=y,r.hold=_,r.bits=b,2;e.adler=r.check=1,r.mode=h;case h:if(5===t||6===t)break e;case 13:if(r.last){_>>>=7&b,b-=7&b,r.mode=27;break}for(;b<3;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}switch(r.last=1&_,b-=1,3&(_>>>=1)){case 0:r.mode=14;break;case 1:if(v(r),r.mode=20,6===t){_>>>=2,b-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=u}_>>>=2,b-=2;break;case 14:for(_>>>=7&b,b-=7&b;b<32;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if((65535&_)!=(_>>>16^65535)){e.msg="invalid stored block lengths",r.mode=u;break}if(r.length=65535&_,_=0,b=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(x=r.length){if(x>y&&(x=y),x>g&&(x=g),0===x)break e;i.arraySet(f,c,p,x,m),y-=x,p+=x,g-=x,m+=x,r.length-=x;break}r.mode=h;break;case 17:for(;b<14;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(r.nlen=257+(31&_),_>>>=5,b-=5,r.ndist=1+(31&_),_>>>=5,b-=5,r.ncode=4+(15&_),_>>>=4,b-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=u;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;b<3;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}r.lens[V[r.have++]]=7&_,_>>>=3,b-=3}for(;r.have<19;)r.lens[V[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,M={bits:r.lenbits},P=s(0,r.lens,0,19,r.lencode,0,r.work,M),r.lenbits=M.bits,P){e.msg="invalid code lengths set",r.mode=u;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;A=(z=r.lencode[_&(1<<r.lenbits)-1])>>>16&255,S=65535&z,!((T=z>>>24)<=b);){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(S<16)_>>>=T,b-=T,r.lens[r.have++]=S;else{if(16===S){for(F=T+2;b<F;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(_>>>=T,b-=T,0===r.have){e.msg="invalid bit length repeat",r.mode=u;break}N=r.lens[r.have-1],x=3+(3&_),_>>>=2,b-=2}else if(17===S){for(F=T+3;b<F;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}b-=T,N=0,x=3+(7&(_>>>=T)),_>>>=3,b-=3}else{for(F=T+7;b<F;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}b-=T,N=0,x=11+(127&(_>>>=T)),_>>>=7,b-=7}if(r.have+x>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=u;break}for(;x--;)r.lens[r.have++]=N}}if(r.mode===u)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=u;break}if(r.lenbits=9,M={bits:r.lenbits},P=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,M),r.lenbits=M.bits,P){e.msg="invalid literal/lengths set",r.mode=u;break}if(r.distbits=6,r.distcode=r.distdyn,M={bits:r.distbits},P=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,M),r.distbits=M.bits,P){e.msg="invalid distances set",r.mode=u;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(y>=6&&g>=258){e.next_out=m,e.avail_out=g,e.next_in=p,e.avail_in=y,r.hold=_,r.bits=b,a(e,C),m=e.next_out,f=e.output,g=e.avail_out,p=e.next_in,c=e.input,y=e.avail_in,_=r.hold,b=r.bits,r.mode===h&&(r.back=-1);break}for(r.back=0;A=(z=r.lencode[_&(1<<r.lenbits)-1])>>>16&255,S=65535&z,!((T=z>>>24)<=b);){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(A&&0==(240&A)){for(U=T,D=A,I=S;A=(z=r.lencode[I+((_&(1<<U+D)-1)>>U)])>>>16&255,S=65535&z,!(U+(T=z>>>24)<=b);){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}_>>>=U,b-=U,r.back+=U}if(_>>>=T,b-=T,r.back+=T,r.length=S,0===A){r.mode=26;break}if(32&A){r.back=-1,r.mode=h;break}if(64&A){e.msg="invalid literal/length code",r.mode=u;break}r.extra=15&A,r.mode=22;case 22:if(r.extra){for(F=r.extra;b<F;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}r.length+=_&(1<<r.extra)-1,_>>>=r.extra,b-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;A=(z=r.distcode[_&(1<<r.distbits)-1])>>>16&255,S=65535&z,!((T=z>>>24)<=b);){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(0==(240&A)){for(U=T,D=A,I=S;A=(z=r.distcode[I+((_&(1<<U+D)-1)>>U)])>>>16&255,S=65535&z,!(U+(T=z>>>24)<=b);){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}_>>>=U,b-=U,r.back+=U}if(_>>>=T,b-=T,r.back+=T,64&A){e.msg="invalid distance code",r.mode=u;break}r.offset=S,r.extra=15&A,r.mode=24;case 24:if(r.extra){for(F=r.extra;b<F;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}r.offset+=_&(1<<r.extra)-1,_>>>=r.extra,b-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=u;break}r.mode=25;case 25:if(0===g)break e;if(x=C-g,r.offset>x){if((x=r.offset-x)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=u;break}x>r.wnext?(x-=r.wnext,E=r.wsize-x):E=r.wnext-x,x>r.length&&(x=r.length),B=r.window}else B=f,E=m-r.offset,x=r.length;x>g&&(x=g),g-=x,r.length-=x;do{f[m++]=B[E++]}while(--x);0===r.length&&(r.mode=21);break;case 26:if(0===g)break e;f[m++]=r.length,g--,r.mode=21;break;case 27:if(r.wrap){for(;b<32;){if(0===y)break e;y--,_|=c[p++]<<b,b+=8}if(C-=g,e.total_out+=C,r.total+=C,C&&(e.adler=r.check=r.flags?o(r.check,f,C,m-C):n(r.check,f,C,m-C)),C=g,(r.flags?_:l(_))!==r.check){e.msg="incorrect data check",r.mode=u;break}_=0,b=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;b<32;){if(0===y)break e;y--,_+=c[p++]<<b,b+=8}if(_!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=u;break}_=0,b=0}r.mode=29;case 29:P=1;break e;case u:P=-3;break e;case 31:return-4;case 32:default:return d}return e.next_out=m,e.avail_out=g,e.next_in=p,e.avail_in=y,r.hold=_,r.bits=b,(r.wsize||C!==e.avail_out&&r.mode<u&&(r.mode<27||4!==t))&&w(e,e.output,e.next_out,C-e.avail_out)?(r.mode=31,-4):(k-=e.avail_in,C-=e.avail_out,e.total_in+=k,e.total_out+=C,r.total+=C,r.wrap&&C&&(e.adler=r.check=r.flags?o(r.check,f,C,e.next_out-C):n(r.check,f,C,e.next_out-C)),e.data_type=r.bits+(r.last?64:0)+(r.mode===h?128:0)+(20===r.mode||15===r.mode?256:0),(0===k&&0===C||4===t)&&0===P&&(P=-5),P)},t.inflateEnd=function(e){if(!e||!e.state)return d;var t=e.state;return t.window&&(t.window=null),e.state=null,0},t.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?d:(r.head=t,t.done=!1,0):d},t.inflateSetDictionary=function(e,t){var r,i=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?d:11===r.mode&&n(1,t,i,0)!==r.check?-3:w(e,t,i,i)?(r.mode=31,-4):(r.havedict=1,0):d},t.inflateInfo="pako inflate (from Nodeca project)"},function(e,t,r){"use strict";e.exports=function(e,t){var r,i,n,o,a,s,d,h,u,l,c,f,p,m,y,g,_,b,v,w,k,C,x,E,B;r=e.state,i=e.next_in,E=e.input,n=i+(e.avail_in-5),o=e.next_out,B=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),d=r.dmax,h=r.wsize,u=r.whave,l=r.wnext,c=r.window,f=r.hold,p=r.bits,m=r.lencode,y=r.distcode,g=(1<<r.lenbits)-1,_=(1<<r.distbits)-1;e:do{p<15&&(f+=E[i++]<<p,p+=8,f+=E[i++]<<p,p+=8),b=m[f&g];t:for(;;){if(f>>>=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)-1)];continue t}if(32&v){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}w=65535&b,(v&=15)&&(p<v&&(f+=E[i++]<<p,p+=8),w+=f&(1<<v)-1,f>>>=v,p-=v),p<15&&(f+=E[i++]<<p,p+=8,f+=E[i++]<<p,p+=8),b=y[f&_];r:for(;;){if(f>>>=v=b>>>24,p-=v,!(16&(v=b>>>16&255))){if(0==(64&v)){b=y[(65535&b)+(f&(1<<v)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&b,p<(v&=15)&&(f+=E[i++]<<p,(p+=8)<v&&(f+=E[i++]<<p,p+=8)),(k+=f&(1<<v)-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,v<w){w-=v;do{B[o++]=c[C++]}while(--v);C=o-k,x=B}}else if(l<v){if(C+=h+l-v,(v-=l)<w){w-=v;do{B[o++]=c[C++]}while(--v);if(C=0,l<w){w-=v=l;do{B[o++]=c[C++]}while(--v);C=o-k,x=B}}}else if(C+=l-v,v<w){w-=v;do{B[o++]=c[C++]}while(--v);C=o-k,x=B}for(;w>2;)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<n&&o<s);i-=w=p>>3,f&=(1<<(p-=w<<3))-1,e.next_in=i,e.next_out=o,e.avail_in=i<n?n-i+5:5-(i-n),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=f,r.bits=p}},function(e,t,r){"use strict";var i=r(5),n=15,o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(e,t,r,h,u,l,c,f){var p,m,y,g,_,b,v,w,k,C=f.bits,x=0,E=0,B=0,T=0,A=0,S=0,U=0,D=0,I=0,N=0,P=null,M=0,F=new i.Buf16(16),z=new i.Buf16(16),O=null,V=0;for(x=0;x<=n;x++)F[x]=0;for(E=0;E<h;E++)F[t[r+E]]++;for(A=C,T=n;T>=1&&0===F[T];T--);if(A>T&&(A=T),0===T)return u[l++]=20971520,u[l++]=20971520,f.bits=1,0;for(B=1;B<T&&0===F[B];B++);for(A<B&&(A=B),D=1,x=1;x<=n;x++)if(D<<=1,(D-=F[x])<0)return-1;if(D>0&&(0===e||1!==T))return-1;for(z[1]=0,x=1;x<n;x++)z[x+1]=z[x]+F[x];for(E=0;E<h;E++)0!==t[r+E]&&(c[z[t[r+E]]++]=E);if(0===e?(P=O=c,b=19):1===e?(P=o,M-=257,O=a,V-=257,b=256):(P=s,O=d,b=-1),N=0,E=0,x=B,_=l,S=A,U=0,y=-1,g=(I=1<<A)-1,1===e&&I>852||2===e&&I>592)return 1;for(;;){v=x-U,c[E]<b?(w=0,k=c[E]):c[E]>b?(w=O[V+c[E]],k=P[M+c[E]]):(w=96,k=0),p=1<<x-U,B=m=1<<S;do{u[_+(N>>U)+(m-=p)]=v<<24|w<<16|k|0}while(0!==m);for(p=1<<x-1;N&p;)p>>=1;if(0!==p?(N&=p-1,N+=p):N=0,E++,0==--F[x]){if(x===T)break;x=t[r+c[E]]}if(x>A&&(N&g)!==y){for(0===U&&(U=A),_+=B,D=1<<(S=x-U);S+U<T&&!((D-=F[S+U])<=0);)S++,D<<=1;if(I+=1<<S,1===e&&I>852||2===e&&I>592)return 1;u[y=N&g]=A<<24|S<<16|_-l|0}}return 0!==N&&(u[_+N]=x-U<<24|64<<16|0),f.bits=A,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={};function c(e,t){if(!(this instanceof c))throw TypeError("Called as a function. Did you forget 'new'?");e=void 0!==e?String(e):"utf-8",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?");var n=this;return n._encoding=r,Boolean(t.fatal)&&(n._error_mode="fatal"),Boolean(t.ignoreBOM)&&(n._ignoreBOM=!0),n}function f(e,r){if(!(this instanceof f))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 p(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 m(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(c.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(c.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(c.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),c.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<e.length;++r){var i=e[r];i<=65535?t+=String.fromCharCode(i):(i-=65536,t+=String.fromCharCode(55296+(i>>10),56320+(1023&i)))}return t}(e)}.call(this,h)},Object.defineProperty&&Object.defineProperty(f.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),f.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=[];i<r;){var o=t.charCodeAt(i);if(o<55296||o>57343)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 m(e)},l["UTF-8"]=function(e){return new p(e)},t.TextEncoder||(t.TextEncoder=f),t.TextDecoder||(t.TextDecoder=c),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);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;f<d.length;f++)i.set(new Uint8Array(d[f]),c),c+=d[f].byteLength;return i.buffer};return l()}))},e.exports.encrypt=function(e){return Promise.resolve().then((function(){var t=e.byteLength,r=0,n=0,o=0,a=[],d=function(){if(t>0){var h=Math.min(1048576,t);t-=h;var u=e.slice(r,r+h);return s.sha256(u).then((function(e){var t=new ArrayBuffer(40),s=new i(t);return s.setUint32(n,!0),s.writeBytes(e),s.setUint32(h,!0),a.push(t),o+=t.byteLength,a.push(u),o+=u.byteLength,n++,r+=h,d()}))}var l=new ArrayBuffer(40);new DataView(l).setUint32(0,n,!0),a.push(l),o+=l.byteLength;for(var c=new Uint8Array(o),f=0,p=0;p<a.length;p++)c.set(new Uint8Array(a[p]),f),f+=a[p].byteLength;return c.buffer};return d()}))}},function(e,t,r){"use strict";var i=r(8),n=r(2),o=r(1),a=r(0),s=r(11),d=r(3);function h(e,t){var r=new Uint8Array(8+e.byteLength);r.set(new Uint8Array(e),8);var i=new DataView(r.buffer);return i.setUint32(0,t.lo,!0),i.setUint32(4,t.hi,!0),d.sha512(a.arrayToBuffer(r)).then((function(e){return a.zeroBuffer(r),e}))}function u(e,t,r,n){return h(e,new i(t)).then((function(e){var i=new Uint8Array(n.byteLength+4+8),o=new DataView(i.buffer);return i.set(new Uint8Array(n),12),o.setInt32(0,t,!0),o.setInt32(8,r,!0),d.hmacSha256(e,i.buffer)}))}e.exports.getHmacKey=h,e.exports.decrypt=function(e,t){var r=new s(e);return Promise.resolve().then((function(){var e,i=[],s=0,d=0,h=0,l=function(){if(e=r.readBytes(32),(d=r.getUint32(!0))>0){h+=d;var c=r.readBytes(d);return u(t,s,d,c).then((function(t){if(a.arrayBufferEquals(t,e))return i.push(c),s++,l();throw new n(o.ErrorCodes.FileCorrupt,"invalid hash block")}))}for(var f=new Uint8Array(h),p=0,m=0;m<i.length;m++)f.set(new Uint8Array(i[m]),p),p+=i[m].byteLength;return f.buffer};return l()}))},e.exports.encrypt=function(e,t){return Promise.resolve().then((function(){var r=e.byteLength,i=0,n=0,o=0,a=[],d=function(){var h=Math.min(1048576,r);r-=h;var l=e.slice(i,i+h);return u(t,n,h,l).then((function(e){var t=new ArrayBuffer(36),r=new s(t);if(r.writeBytes(e),r.setUint32(h,!0),a.push(t),o+=t.byteLength,l.byteLength>0)return a.push(l),o+=l.byteLength,n++,i+=h,d();for(var u=new Uint8Array(o),c=0,f=0;f<a.length;f++)u.set(new Uint8Array(a[f]),c),c+=a[f].byteLength;return u.buffer}))};return d()}))}},function(e,t,r){"use strict";var i=r(23),n=r(24),o=r(1),a=r(2),s=r(3),d=r(0),h=[232,48,9,75,151,32,93,42],u=function(e){this.algo=e};u.prototype.getSalt=function(e){return d.arrayToBuffer(this.algo.getBytes(e))},u.create=function(e,t){switch(t){case o.CrsAlgorithm.Salsa20:return s.sha256(d.arrayToBuffer(e)).then((function(e){var t=new Uint8Array(e),r=new i(t,h);return new u(r)}));case o.CrsAlgorithm.ChaCha20:return s.sha512(d.arrayToBuffer(e)).then((function(e){var t=new Uint8Array(e,0,32),r=new Uint8Array(e,32,12),i=new n(t,r);return new u(i)}));default:return Promise.reject(new a(o.ErrorCodes.Unsupported,"crsAlgorithm"))}},e.exports=u},function(e,t,r){"use strict";var i=r(1),n=r(0),o=r(14),a=r(8),s=r(3),d=r(2),h=r(25),u=[{name:"salt",field:"S",type:o.ValueType.Bytes},{name:"parallelism",field:"P",type:o.ValueType.UInt32},{name:"memory",field:"M",type:o.ValueType.UInt64},{name:"iterations",field:"I",type:o.ValueType.UInt64},{name:"version",field:"V",type:o.ValueType.UInt32},{name:"secretKey",field:"K",type:o.ValueType.Bytes},{name:"assocData",field:"A",type:o.ValueType.Bytes},{name:"rounds",field:"R",type:o.ValueType.UInt64}];function l(e){var t={};return u.forEach((function(r){var i=e.get(r.field);i&&(i instanceof a&&(i=i.value),t[r.name]=i)})),t}e.exports.encrypt=function(e,t){var r=t.get("$UUID");if(!(r&&r instanceof ArrayBuffer))return Promise.reject(new d(i.ErrorCodes.FileCorrupt,"no kdf uuid"));switch(n.bytesToBase64(r)){case i.KdfId.Argon2:return function(e,t){var r=l(t);if(!(r.salt instanceof ArrayBuffer)||32!==r.salt.byteLength)return Promise.reject(new d(i.ErrorCodes.FileCorrupt,"bad argon2 salt"));if("number"!=typeof r.parallelism||r.parallelism<1)return Promise.reject(new d(i.ErrorCodes.FileCorrupt,"bad argon2 parallelism"));if("number"!=typeof r.iterations||r.iterations<1)return Promise.reject(new d(i.ErrorCodes.FileCorrupt,"bad argon2 iterations"));if("number"!=typeof r.memory||r.memory<1||r.memory%1024!=0)return Promise.reject(new d(i.ErrorCodes.FileCorrupt,"bad argon2 memory"));if(19!==r.version&&16!==r.version)return Promise.reject(new d(i.ErrorCodes.FileCorrupt,"bad argon2 version"));if(r.secretKey)return Promise.reject(new d(i.ErrorCodes.Unsupported,"argon2 secret key"));if(r.assocData)return Promise.reject(new d(i.ErrorCodes.Unsupported,"argon2 assoc data"));return s.argon2(e,r.salt,r.memory/1024,r.iterations,32,r.parallelism,0,r.version)}(e,t);case i.KdfId.Aes:return function(e,t){var r=l(t);if(!(r.salt instanceof ArrayBuffer)||32!==r.salt.byteLength)return Promise.reject(new d(i.ErrorCodes.FileCorrupt,"bad aes salt"));if("number"!=typeof r.rounds||r.rounds<1)return Promise.reject(new d(i.ErrorCodes.FileCorrupt,"bad aes rounds"));return h.encrypt(new Uint8Array(e),new Uint8Array(r.salt),r.rounds).then((function(e){return s.sha256(e).then((function(t){return n.zeroBuffer(e),t}))}))}(e,t);default:return Promise.reject(new d(i.ErrorCodes.Unsupported,"bad kdf"))}}},function(e,t,r){"use strict";var i=r(6),n=r(7),o=r(15),a=r(4),s=r(1),d={Generator:"KdbxWeb"},h=function(){this.generator=void 0,this.headerHash=void 0,this.settingsChanged=void 0,this._name=void 0,this.nameChanged=void 0,this._desc=void 0,this.descChanged=void 0,this._defaultUser=void 0,this.defaultUserChanged=void 0,this._mntncHistoryDays=void 0,this._color=void 0,this.keyChanged=void 0,this._keyChangeRec=void 0,this._keyChangeForce=void 0,this._recycleBinEnabled=void 0,this._recycleBinUuid=void 0,this.recycleBinChanged=void 0,this._entryTemplatesGroup=void 0,this.entryTemplatesGroupChanged=void 0,this._historyMaxItems=void 0,this._historyMaxSize=void 0,this._lastSelectedGroup=void 0,this._lastTopVisibleGroup=void 0,this._memoryProtection={title:void 0,userName:void 0,password:void 0,url:void 0,notes:void 0},this.customData={},this.customIcons={},this._editState=void 0,Object.preventExtensions(this)},u={name:"nameChanged",desc:"descChanged",defaultUser:"defaultUserChanged",mntncHistoryDays:null,color:null,keyChangeRec:null,keyChangeForce:null,recycleBinEnabled:"recycleBinChanged",recycleBinUuid:"recycleBinChanged",entryTemplatesGroup:"entryTemplatesGroupChanged",historyMaxItems:null,historyMaxSize:null,lastSelectedGroup:null,lastTopVisibleGroup:null,memoryProtection:null};Object.keys(u).forEach((function(e){!function(e,t){var r="_"+e;Object.defineProperty(h.prototype,e,{enumerable:!0,get:function(){return this[r]},set:function(i){i!==this[r]&&(this[r]=i,t?this[t]=new Date:this._setPropModDate(e))}})}(e,u[e])})),h.prototype._setPropModDate=function(e){this._editState||(this._editState={}),this._editState[e]=(new Date).getTime()},h.prototype._readNode=function(e,t){switch(e.tagName){case i.Elem.Generator:this.generator=a.getText(e);break;case i.Elem.HeaderHash:this.headerHash=a.getBytes(e);break;case i.Elem.SettingsChanged:this.settingsChanged=a.getDate(e);break;case i.Elem.DbName:this._name=a.getText(e);break;case i.Elem.DbNameChanged:this.nameChanged=a.getDate(e);break;case i.Elem.DbDesc:this._desc=a.getText(e);break;case i.Elem.DbDescChanged:this.descChanged=a.getDate(e);break;case i.Elem.DbDefaultUser:this._defaultUser=a.getText(e);break;case i.Elem.DbDefaultUserChanged:this.defaultUserChanged=a.getDate(e);break;case i.Elem.DbMntncHistoryDays:this._mntncHistoryDays=a.getNumber(e);break;case i.Elem.DbColor:this._color=a.getText(e);break;case i.Elem.DbKeyChanged:this.keyChanged=a.getDate(e);break;case i.Elem.DbKeyChangeRec:this._keyChangeRec=a.getNumber(e);break;case i.Elem.DbKeyChangeForce:this._keyChangeForce=a.getNumber(e);break;case i.Elem.RecycleBinEnabled:this._recycleBinEnabled=a.getBoolean(e);break;case i.Elem.RecycleBinUuid:this._recycleBinUuid=a.getUuid(e);break;case i.Elem.RecycleBinChanged:this.recycleBinChanged=a.getDate(e);break;case i.Elem.EntryTemplatesGroup:this._entryTemplatesGroup=a.getUuid(e);break;case i.Elem.EntryTemplatesGroupChanged:this.entryTemplatesGroupChanged=a.getDate(e);break;case i.Elem.HistoryMaxItems:this._historyMaxItems=a.getNumber(e);break;case i.Elem.HistoryMaxSize:this._historyMaxSize=a.getNumber(e);break;case i.Elem.LastSelectedGroup:this._lastSelectedGroup=a.getUuid(e);break;case i.Elem.LastTopVisibleGroup:this._lastTopVisibleGroup=a.getUuid(e);break;case i.Elem.MemoryProt:this._readMemoryProtection(e);break;case i.Elem.CustomIcons:this._readCustomIcons(e);break;case i.Elem.Binaries:this._readBinaries(e,t);break;case i.Elem.CustomData:this._readCustomData(e)}},h.prototype._readMemoryProtection=function(e){for(var t=0,r=e.childNodes,n=r.length;t<n;t++){var o=r[t];switch(o.tagName){case i.Elem.ProtTitle:this.memoryProtection.title=a.getBoolean(o);break;case i.Elem.ProtUserName:this.memoryProtection.userName=a.getBoolean(o);break;case i.Elem.ProtPassword:this.memoryProtection.password=a.getBoolean(o);break;case i.Elem.ProtUrl:this.memoryProtection.url=a.getBoolean(o);break;case i.Elem.ProtNotes:this.memoryProtection.notes=a.getBoolean(o)}}},h.prototype._writeMemoryProtection=function(e){var t=a.addChildNode(e,i.Elem.MemoryProt);a.setBoolean(a.addChildNode(t,i.Elem.ProtTitle),this.memoryProtection.title),a.setBoolean(a.addChildNode(t,i.Elem.ProtUserName),this.memoryProtection.userName),a.setBoolean(a.addChildNode(t,i.Elem.ProtPassword),this.memoryProtection.password),a.setBoolean(a.addChildNode(t,i.Elem.ProtUrl),this.memoryProtection.url),a.setBoolean(a.addChildNode(t,i.Elem.ProtNotes),this.memoryProtection.notes)},h.prototype._readCustomIcons=function(e){for(var t=0,r=e.childNodes,n=r.length;t<n;t++){var o=r[t];o.tagName===i.Elem.CustomIconItem&&this._readCustomIcon(o)}},h.prototype._readCustomIcon=function(e){for(var t,r,n=0,o=e.childNodes,s=o.length;n<s;n++){var d=o[n];switch(d.tagName){case i.Elem.CustomIconItemID:t=a.getUuid(d);break;case i.Elem.CustomIconItemData:r=a.getBytes(d)}}t&&r&&(this.customIcons[t]=r)},h.prototype._writeCustomIcons=function(e){var t=a.addChildNode(e,i.Elem.CustomIcons),r=this.customIcons;Object.keys(r).forEach((function(e){var n=r[e];if(n){var o=a.addChildNode(t,i.Elem.CustomIconItem);a.setUuid(a.addChildNode(o,i.Elem.CustomIconItemID),e),a.setBytes(a.addChildNode(o,i.Elem.CustomIconItemData),n)}}))},h.prototype._readBinaries=function(e,t){for(var r=0,n=e.childNodes,o=n.length;r<o;r++){var a=n[r];a.tagName===i.Elem.Binary&&this._readBinary(a,t)}},h.prototype._readBinary=function(e,t){var r=e.getAttribute(i.Attr.Id),n=a.getProtectedBinary(e);r&&n&&(t.kdbx.binaries[r]=n)},h.prototype._writeBinaries=function(e,t){var r=a.addChildNode(e,i.Elem.Binaries),n=t.kdbx.binaries;n.hashOrder.forEach((function(e,t){var o=n[e];if(o){var s=a.addChildNode(r,i.Elem.Binary);s.setAttribute(i.Attr.Id,t.toString()),a.setProtectedBinary(s,o)}}))},h.prototype._readCustomData=function(e){this.customData=o.read(e)},h.prototype._writeCustomData=function(e){o.write(e,this.customData)},h.prototype.write=function(e,t){this.generator=d.generator;var r=a.addChildNode(e,i.Elem.Meta);a.setText(a.addChildNode(r,i.Elem.Generator),d.Generator),t.kdbx.header.versionMajor<4?a.setBytes(a.addChildNode(r,i.Elem.HeaderHash),this.headerHash):this.settingsChanged&&t.setXmlDate(a.addChildNode(r,i.Elem.SettingsChanged),this.settingsChanged),a.setText(a.addChildNode(r,i.Elem.DbName),this.name),t.setXmlDate(a.addChildNode(r,i.Elem.DbNameChanged),this.nameChanged),a.setText(a.addChildNode(r,i.Elem.DbDesc),this.desc),t.setXmlDate(a.addChildNode(r,i.Elem.DbDescChanged),this.descChanged),a.setText(a.addChildNode(r,i.Elem.DbDefaultUser),this.defaultUser),t.setXmlDate(a.addChildNode(r,i.Elem.DbDefaultUserChanged),this.defaultUserChanged),a.setText(a.addChildNode(r,i.Elem.DbMntncHistoryDays),this.mntncHistoryDays),a.setText(a.addChildNode(r,i.Elem.DbColor),this.color),t.setXmlDate(a.addChildNode(r,i.Elem.DbKeyChanged),this.keyChanged),a.setNumber(a.addChildNode(r,i.Elem.DbKeyChangeRec),this.keyChangeRec),a.setNumber(a.addChildNode(r,i.Elem.DbKeyChangeForce),this.keyChangeForce),a.setBoolean(a.addChildNode(r,i.Elem.RecycleBinEnabled),this.recycleBinEnabled),a.setUuid(a.addChildNode(r,i.Elem.RecycleBinUuid),this.recycleBinUuid),t.setXmlDate(a.addChildNode(r,i.Elem.RecycleBinChanged),this.recycleBinChanged),a.setUuid(a.addChildNode(r,i.Elem.EntryTemplatesGroup),this.entryTemplatesGroup),t.setXmlDate(a.addChildNode(r,i.Elem.EntryTemplatesGroupChanged),this.entryTemplatesGroupChanged),a.setNumber(a.addChildNode(r,i.Elem.HistoryMaxItems),this.historyMaxItems),a.setNumber(a.addChildNode(r,i.Elem.HistoryMaxSize),this.historyMaxSize),a.setUuid(a.addChildNode(r,i.Elem.LastSelectedGroup),this.lastSelectedGroup),a.setUuid(a.addChildNode(r,i.Elem.LastTopVisibleGroup),this.lastTopVisibleGroup),this._writeMemoryProtection(r),this._writeCustomIcons(r),(t.exportXml||t.kdbx.header.versionMajor<4)&&this._writeBinaries(r,t),this._writeCustomData(r)},h.prototype.merge=function(e,t){e.nameChanged>this.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;i<o;i++){var a=n[i];a.tagName&&r._readNode(a,t)}return r},e.exports=h},function(e,t,r){"use strict";var i=r(9),n=r(3),o=r(0),a=function(){Object.defineProperties(this,{idToHash:{value:{}},hashOrder:{value:null,configurable:!0}})};a.prototype.hash=function(){var e=[],t=this;return Object.keys(t).forEach((function(r){var i=t[r];e.push(t.getBinaryHash(i).then((function(e){t.idToHash[r]=e,t[e]=t[r],delete t[r]})))})),Promise.all(e)},a.prototype.getBinaryHash=function(e){var t;return e instanceof i?t=e.getHash():(e instanceof ArrayBuffer||e instanceof Uint8Array)&&(e=o.arrayToBuffer(e),t=n.sha256(e)),t.then((function(e){return o.bytesToHex(e)}))},a.prototype.assignIds=function(){Object.defineProperty(this,"hashOrder",{value:Object.keys(this),configurable:!0})},a.prototype.add=function(e){var t=this;return this.getBinaryHash(e).then((function(r){return t[r]=e,{ref:r,value:e}}))},e.exports=a},function(e,t,r){"use strict";var i=r(6),n=r(4),o=r(1),a=r(15),s=r(27),d=r(7),h=r(28),u=function(){this.uuid=void 0,this.name=void 0,this.notes=void 0,this.icon=void 0,this.customIcon=void 0,this.times=new s,this.expanded=void 0,this.defaultAutoTypeSeq=void 0,this.enableAutoType=void 0,this.enableSearching=void 0,this.lastTopVisibleEntry=void 0,this.groups=[],this.entries=[],this.parentGroup=void 0,this.customData=void 0,Object.preventExtensions(this)};u.prototype._readNode=function(e,t){switch(e.tagName){case i.Elem.Uuid:this.uuid=n.getUuid(e);break;case i.Elem.Name:this.name=n.getText(e);break;case i.Elem.Notes:this.notes=n.getText(e);break;case i.Elem.Icon:this.icon=n.getNumber(e);break;case i.Elem.CustomIconID:this.customIcon=n.getUuid(e);break;case i.Elem.Times:this.times=s.read(e);break;case i.Elem.IsExpanded:this.expanded=n.getBoolean(e);break;case i.Elem.GroupDefaultAutoTypeSeq:this.defaultAutoTypeSeq=n.getText(e);break;case i.Elem.EnableAutoType:this.enableAutoType=n.getBoolean(e);break;case i.Elem.EnableSearching:this.enableSearching=n.getBoolean(e);break;case i.Elem.LastTopVisibleEntry:this.lastTopVisibleEntry=n.getUuid(e);break;case i.Elem.Group:this.groups.push(u.read(e,t,this));break;case i.Elem.Entry:this.entries.push(h.read(e,t,this));break;case i.Elem.CustomData:this.customData=a.read(e)}},u.prototype.write=function(e,t){var r=n.addChildNode(e,i.Elem.Group);n.setUuid(n.addChildNode(r,i.Elem.Uuid),this.uuid),n.setText(n.addChildNode(r,i.Elem.Name),this.name),n.setText(n.addChildNode(r,i.Elem.Notes),this.notes),n.setNumber(n.addChildNode(r,i.Elem.Icon),this.icon),this.customIcon&&n.setUuid(n.addChildNode(r,i.Elem.CustomIconID),this.customIcon),a.write(r,this.customData),this.times.write(r,t),n.setBoolean(n.addChildNode(r,i.Elem.IsExpanded),this.expanded),n.setText(n.addChildNode(r,i.Elem.GroupDefaultAutoTypeSeq),this.defaultAutoTypeSeq),n.setBoolean(n.addChildNode(r,i.Elem.EnableAutoType),this.enableAutoType),n.setBoolean(n.addChildNode(r,i.Elem.EnableSearching),this.enableSearching),n.setUuid(n.addChildNode(r,i.Elem.LastTopVisibleEntry),this.lastTopVisibleEntry),this.groups.forEach((function(e){e.write(r,t)})),this.entries.forEach((function(e){e.write(r,t)}))},u.prototype.forEach=function(e,t){e.call(t,void 0,this),this.entries.forEach((function(r){e.call(t,r)})),this.groups.forEach((function(r){r.forEach(e,t)}))},u.prototype.merge=function(e){var t=e.remote[this.uuid];t&&(t.times.lastModTime>this.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+1<t.length?t[r+1].uuid.id:void 0,h=o>0?e[o-1].uuid.id:void 0,u=o<e.length?e[o].uuid.id:void 0;s||h?s===h&&(a+=5):a+=1,d||u?d===u&&(a+=5):a+=2,a>n&&(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<a;n++){var s=o[n];s.tagName&&i._readNode(s,t)}return i.uuid||(i.uuid=d.random()),i.parentGroup=r,i},e.exports=u},function(e,t,r){"use strict";var i=r(6),n=r(4),o=function(){this.uuid=void 0,this.deletionTime=void 0,Object.preventExtensions(this)};o.prototype._readNode=function(e){switch(e.tagName){case i.Elem.Uuid:this.uuid=n.getUuid(e);break;case i.Elem.DeletionTime:this.deletionTime=n.getDate(e)}},o.prototype.write=function(e,t){var r=n.addChildNode(e,i.Elem.DeletedObject);n.setUuid(n.addChildNode(r,i.Elem.Uuid),this.uuid),t.setXmlDate(n.addChildNode(r,i.Elem.DeletionTime),this.deletionTime)},o.read=function(e){for(var t=new o,r=0,i=e.childNodes,n=i.length;r<n;r++){var a=i[r];a.tagName&&t._readNode(a)}return t},e.exports=o}])})); |