@certd/plugin-cert 1.2.1 → 1.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/bundle.js +1 -1
- package/package.json +4 -6
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@certd/pipeline"),t=require("dayjs"),r=require("@certd/acme-client"),n=require("lodash"),i=require("fs"),a=require("os"),s=require("crypto"),o=require("path"),u=require("stream"),c=require("events"),l=require("buffer"),h=require("util");function f(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=f(r);function p(e,t,r,n){var i,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,r,s):i(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}class g{userContext;logger;constructor(e){this.userContext=e.userContext,this.logger=e.logger,d.setLogger((e=>{this.logger.info(e)}))}async getAccountConfig(e){return await this.userContext.getObj(this.buildAccountKey(e))||{}}buildAccountKey(e){return"acme.config."+e}async saveAccountConfig(e,t){await this.userContext.setObj(this.buildAccountKey(e),t)}async getAcmeClient(e,t=!1){const r=await this.getAccountConfig(e);null==r.key&&(r.key=await this.createNewKey(),await this.saveAccountConfig(e,r));const n=new d.Client({directoryUrl:t?d.directory.letsencrypt.staging:d.directory.letsencrypt.production,accountKey:r.key,accountUrl:r.accountUrl,backoffAttempts:20,backoffMin:5e3,backoffMax:1e4});if(null==r.accountUrl){const t={termsOfServiceAgreed:!0,contact:[`mailto:${e}`]};await n.createAccount(t),r.accountUrl=n.getAccountUrl(),await this.saveAccountConfig(e,r)}return n}async createNewKey(){return(await d.forge.createPrivateKey()).toString()}async challengeCreateFn(e,t,r,n){if(this.logger.info("Triggered challengeCreateFn()"),"http-01"===t.type){const n=`/var/www/html/.well-known/acme-challenge/${t.token}`,i=r;this.logger.info(`Creating challenge response for ${e.identifier.value} at path: ${n}`),this.logger.info(`Would write "${i}" to path "${n}"`)}else if("dns-01"===t.type){const t=`_acme-challenge.${e.identifier.value}`,i=r;return this.logger.info(`Creating TXT record for ${e.identifier.value}: ${t}`),this.logger.info(`Would create TXT record "${t}" with value "${i}"`),await n.createRecord({fullRecord:t,type:"TXT",value:i})}}async challengeRemoveFn(e,t,r,n,i){if(this.logger.info("Triggered challengeRemoveFn()"),"http-01"===t.type){const r=`/var/www/html/.well-known/acme-challenge/${t.token}`;this.logger.info(`Removing challenge response for ${e.identifier.value} at path: ${r}`),this.logger.info(`Would remove file on path "${r}"`)}else if("dns-01"===t.type){const t=`_acme-challenge.${e.identifier.value}`,a=r;this.logger.info(`Removing TXT record for ${e.identifier.value}: ${t}`),this.logger.info(`Would remove TXT record "${t}" with value "${a}"`);try{await i.removeRecord({fullRecord:t,type:"TXT",value:r,record:n})}catch(e){throw this.logger.error("删除解析记录出错:",e),e}}}async order(e){const{email:t,isTest:r,domains:n,csrInfo:i,dnsProvider:a}=e,s=await this.getAcmeClient(t,r),{commonName:o,altNames:u}=this.buildCommonNameByDomains(n),[c,l]=await d.forge.createCsr({commonName:o,...i,altNames:u});if(null==a)throw new Error("dnsProvider 不能为空");const h={crt:(await s.auto({csr:l,email:t,termsOfServiceAgreed:!0,challengePriority:["dns-01"],challengeCreateFn:async(e,t,r)=>await this.challengeCreateFn(e,t,r,a),challengeRemoveFn:async(e,t,r,n)=>await this.challengeRemoveFn(e,t,r,n,a)})).toString(),key:c.toString(),csr:l.toString()};return this.logger.debug(`CSR:\n${h.csr}`),this.logger.debug(`Certificate:\n${h.crt}`),this.logger.info("证书申请成功"),h}buildCommonNameByDomains(e){if("string"==typeof e&&(e=e.split(",")),0===e.length)throw new Error("domain can not be empty");const t=e[0];let r;return e.length>1&&(r=n.slice(e,1)),{commonName:t,altNames:r}}}const y=new e.Registry,m="pipeline:dns-provider";var v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function C(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E={},b={get exports(){return E},set exports(e){E=e}},S={options:{usePureJavaScript:!1}},T={},_=T,w={};T.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,a=t.length,s=t.charAt(0),o=[0];for(i=0;i<e.length;++i){for(var u=0,c=e[i];u<o.length;++u)c+=o[u]<<8,o[u]=c%a,c=c/a|0;for(;c>0;)o.push(c%a),c=c/a|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=s;for(i=o.length-1;i>=0;--i)n+=t[o[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),a=[0];for(r=0;r<e.length();++r){for(var s=0,o=e.at(r);s<a.length;++s)o+=a[s]<<8,a[s]=o%n,o=o/n|0;for(;o>0;)a.push(o%n),o=o/n|0}var u="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)u+=i;for(r=a.length-1;r>=0;--r)u+=t[a[r]];return u}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},T.decode=function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=w[t];if(!r){r=w[t]=[];for(var n=0;n<t.length;++n)r[t.charCodeAt(n)]=n}e=e.replace(/\s/g,"");var i=t.length,a=t.charAt(0),s=[0];for(n=0;n<e.length;n++){var o=r[e.charCodeAt(n)];if(void 0===o)return;for(var u=0,c=o;u<s.length;++u)c+=s[u]*i,s[u]=255&c,c>>=8;for(;c>0;)s.push(255&c),c>>=8}for(var l=0;e[l]===a&&l<e.length-1;++l)s.push(0);return"undefined"!=typeof Buffer?Buffer.from(s.reverse()):new Uint8Array(s.reverse())};var I=S,A=_,B=I.util=I.util||{};function k(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function N(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(B.isArrayBuffer(e)||B.isArrayBufferView(e))if("undefined"!=typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(e){for(var r=0;r<t.length;++r)this.putByte(t[r])}}else(e instanceof N||"object"==typeof e&&"string"==typeof e.data&&"number"==typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!=typeof process&&process.nextTick&&!process.browser)return B.nextTick=process.nextTick,void("function"==typeof setImmediate?B.setImmediate=setImmediate:B.setImmediate=B.nextTick);if("function"==typeof setImmediate)return B.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(B.nextTick=function(e){return setImmediate(e)});if(B.setImmediate=function(e){setTimeout(e,0)},"undefined"!=typeof window&&"function"==typeof window.postMessage){var e="forge.setImmediate",t=[];function s(r){if(r.source===window&&r.data===e){r.stopPropagation();var n=t.slice();t.length=0,n.forEach((function(e){e()}))}}B.setImmediate=function(r){t.push(r),1===t.length&&window.postMessage(e,"*")},window.addEventListener("message",s,!0)}if("undefined"!=typeof MutationObserver){var r=Date.now(),n=!0,i=document.createElement("div");t=[];new MutationObserver((function(){var e=t.slice();t.length=0,e.forEach((function(e){e()}))})).observe(i,{attributes:!0});var a=B.setImmediate;B.setImmediate=function(e){Date.now()-r>15?(r=Date.now(),a(e)):(t.push(e),1===t.length&&i.setAttribute("a",n=!n))}}B.nextTick=B.setImmediate}(),B.isNodejs="undefined"!=typeof process&&process.versions&&process.versions.node,B.globalScope=B.isNodejs?v:"undefined"==typeof self?window:self,B.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},B.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},B.isArrayBufferView=function(e){return e&&B.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},B.ByteBuffer=N,B.ByteStringBuffer=N;B.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},B.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},B.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},B.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},B.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},B.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},B.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(B.encodeUtf8(e))},B.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},B.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},B.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},B.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},B.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},B.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},B.ByteStringBuffer.prototype.putInt=function(e,t){k(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},B.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},B.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},B.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},B.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},B.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},B.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},B.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},B.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},B.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},B.ByteStringBuffer.prototype.getInt=function(e){k(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},B.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},B.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},B.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},B.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},B.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},B.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},B.ByteStringBuffer.prototype.copy=function(){var e=B.createBuffer(this.data);return e.read=this.read,e},B.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},B.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},B.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},B.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},B.ByteStringBuffer.prototype.toString=function(){return B.decodeUtf8(this.bytes())},B.DataBuffer=function(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var r=B.isArrayBuffer(e),n=B.isArrayBufferView(e);if(r||n)return this.data=r?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in t?t.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=e&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)},B.DataBuffer.prototype.length=function(){return this.write-this.read},B.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},B.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},B.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},B.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},B.DataBuffer.prototype.putBytes=function(e,t){if(B.isArrayBufferView(e)){var r=(n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-n.byteOffset;return this.accommodate(r),new Uint8Array(this.data.buffer,this.write).set(n),this.write+=r,this}if(B.isArrayBuffer(e)){var n=new Uint8Array(e);return this.accommodate(n.byteLength),new Uint8Array(this.data.buffer).set(n,this.write),this.write+=n.byteLength,this}if(e instanceof B.DataBuffer||"object"==typeof e&&"number"==typeof e.read&&"number"==typeof e.write&&B.isArrayBufferView(e.data)){n=new Uint8Array(e.data.byteLength,e.read,e.length());return this.accommodate(n.byteLength),new Uint8Array(e.data.byteLength,this.write).set(n),this.write+=n.byteLength,this}if(e instanceof B.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary","string"==typeof e){var i;if("hex"===t)return this.accommodate(Math.ceil(e.length/2)),i=new Uint8Array(this.data.buffer,this.write),this.write+=B.binary.hex.decode(e,i,this.write),this;if("base64"===t)return this.accommodate(3*Math.ceil(e.length/4)),i=new Uint8Array(this.data.buffer,this.write),this.write+=B.binary.base64.decode(e,i,this.write),this;if("utf8"===t&&(e=B.encodeUtf8(e),t="binary"),"binary"===t||"raw"===t)return this.accommodate(e.length),i=new Uint8Array(this.data.buffer,this.write),this.write+=B.binary.raw.decode(i),this;if("utf16"===t)return this.accommodate(2*e.length),i=new Uint16Array(this.data.buffer,this.write),this.write+=B.text.utf16.encode(i),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)},B.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},B.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},B.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},B.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},B.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},B.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},B.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},B.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},B.DataBuffer.prototype.putInt=function(e,t){k(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},B.DataBuffer.prototype.putSignedInt=function(e,t){return k(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},B.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},B.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},B.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},B.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},B.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},B.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},B.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},B.DataBuffer.prototype.getInt=function(e){k(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},B.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},B.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},B.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},B.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},B.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},B.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},B.DataBuffer.prototype.copy=function(){return new B.DataBuffer(this)},B.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},B.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},B.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},B.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},B.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return B.binary.raw.encode(t);if("hex"===e)return B.binary.hex.encode(t);if("base64"===e)return B.binary.base64.encode(t);if("utf8"===e)return B.text.utf8.decode(t);if("utf16"===e)return B.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)},B.createBuffer=function(e,t){return t=t||"raw",void 0!==e&&"utf8"===t&&(e=B.encodeUtf8(e)),new B.ByteBuffer(e)},B.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},B.xorBytes=function(e,t,r){for(var n="",i="",a="",s=0,o=0;r>0;--r,++s)i=e.charCodeAt(s)^t.charCodeAt(s),o>=10&&(n+=a,a="",o=0),a+=String.fromCharCode(i),++o;return n+=a},B.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},B.bytesToHex=function(e){return B.createBuffer(e).toHex()},B.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",L=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],D="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";B.encode64=function(e,t){for(var r,n,i,a="",s="",o=0;o<e.length;)r=e.charCodeAt(o++),n=e.charCodeAt(o++),i=e.charCodeAt(o++),a+=R.charAt(r>>2),a+=R.charAt((3&r)<<4|n>>4),isNaN(n)?a+="==":(a+=R.charAt((15&n)<<2|i>>6),a+=isNaN(i)?"=":R.charAt(63&i)),t&&a.length>t&&(s+=a.substr(0,t)+"\r\n",a=a.substr(t));return s+=a},B.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,a="",s=0;s<e.length;)t=L[e.charCodeAt(s++)-43],r=L[e.charCodeAt(s++)-43],n=L[e.charCodeAt(s++)-43],i=L[e.charCodeAt(s++)-43],a+=String.fromCharCode(t<<2|r>>4),64!==n&&(a+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(a+=String.fromCharCode((3&n)<<6|i)));return a},B.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},B.decodeUtf8=function(e){return decodeURIComponent(escape(e))},B.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:A.encode,decode:A.decode}},B.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},B.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,a=0;a<e.length;++a)n[i++]=e.charCodeAt(a);return t?i-r:n},B.binary.hex.encode=B.bytesToHex,B.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var i=0,a=r=r||0;for(1&e.length&&(i=1,n[a++]=parseInt(e[0],16));i<e.length;i+=2)n[a++]=parseInt(e.substr(i,2),16);return t?a-r:n},B.binary.base64.encode=function(e,t){for(var r,n,i,a="",s="",o=0;o<e.byteLength;)r=e[o++],n=e[o++],i=e[o++],a+=R.charAt(r>>2),a+=R.charAt((3&r)<<4|n>>4),isNaN(n)?a+="==":(a+=R.charAt((15&n)<<2|i>>6),a+=isNaN(i)?"=":R.charAt(63&i)),t&&a.length>t&&(s+=a.substr(0,t)+"\r\n",a=a.substr(t));return s+=a},B.binary.base64.decode=function(e,t,r){var n,i,a,s,o=t;o||(o=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var u=0,c=r=r||0;u<e.length;)n=L[e.charCodeAt(u++)-43],i=L[e.charCodeAt(u++)-43],a=L[e.charCodeAt(u++)-43],s=L[e.charCodeAt(u++)-43],o[c++]=n<<2|i>>4,64!==a&&(o[c++]=(15&i)<<4|a>>2,64!==s&&(o[c++]=(3&a)<<6|s));return t?c-r:o.subarray(0,c)},B.binary.base58.encode=function(e,t){return B.binary.baseN.encode(e,D,t)},B.binary.base58.decode=function(e,t){return B.binary.baseN.decode(e,D,t)},B.text={utf8:{},utf16:{}},B.text.utf8.encode=function(e,t,r){e=B.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,a=0;a<e.length;++a)n[i++]=e.charCodeAt(a);return t?i-r:n},B.text.utf8.decode=function(e){return B.decodeUtf8(String.fromCharCode.apply(null,e))},B.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var i=new Uint16Array(n.buffer),a=r=r||0,s=r,o=0;o<e.length;++o)i[s++]=e.charCodeAt(o),a+=2;return t?a-r:n},B.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},B.deflate=function(e,t,r){if(t=B.decode64(e.deflate(B.encode64(t)).rval),r){var n=2;32&t.charCodeAt(1)&&(n=6),t=t.substring(n,t.length-4)}return t},B.inflate=function(e,t,r){var n=e.inflate(B.encode64(t)).rval;return null===n?null:B.decode64(n)};var U=function(e,t,r){if(!e)throw new Error("WebStorage not available.");var n;if(null===r?n=e.removeItem(t):(r=B.encode64(JSON.stringify(r)),n=e.setItem(t,r)),void 0!==n&&!0!==n.rval){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}},x=function(e,t){if(!e)throw new Error("WebStorage not available.");var r=e.getItem(t);if(e.init)if(null===r.rval){if(r.error){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}r=null}else r=r.rval;return null!==r&&(r=JSON.parse(B.decode64(r))),r},O=function(e,t,r,n){var i=x(e,t);null===i&&(i={}),i[r]=n,U(e,t,i)},P=function(e,t,r){var n=x(e,t);return null!==n&&(n=r in n?n[r]:null),n},V=function(e,t,r){var n=x(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var a in n){i=!1;break}i&&(n=null),U(e,t,n)}},K=function(e,t){U(e,t,null)},M=function(e,t,r){var n,i=null;void 0===r&&(r=["web","flash"]);var a=!1,s=null;for(var o in r){n=r[o];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");i=e.apply(this,t),a="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),a=!0)}catch(e){s=e}if(a)break}if(!a)throw s;return i};B.setItem=function(e,t,r,n,i){M(O,arguments,i)},B.getItem=function(e,t,r,n){return M(P,arguments,n)},B.removeItem=function(e,t,r,n){M(V,arguments,n)},B.clearItems=function(e,t,r){M(K,arguments,r)},B.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),n=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return n&&(n.fullHost=n.host,n.port?(80!==n.port&&"http"===n.scheme||443!==n.port&&"https"===n.scheme)&&(n.fullHost+=":"+n.port):"http"===n.scheme?n.port=80:"https"===n.scheme&&(n.port=443),n.full=n.scheme+"://"+n.fullHost),n};var F=null;B.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),n=0;n<r.length;n++){var i,a,s=r[n].indexOf("=");s>0?(i=r[n].substring(0,s),a=r[n].substring(s+1)):(i=r[n],a=null),i in t||(t[i]=[]),i in Object.prototype||null===a||t[i].push(unescape(a))}return t};return void 0===e?(null===F&&(F="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=F):t=r(e),t},B.parseFragment=function(e){var t=e,r="",n=e.indexOf("?");n>0&&(t=e.substring(0,n),r=e.substring(n+1));var i=t.split("/");return i.length>0&&""===i[0]&&i.shift(),{pathString:t,queryString:r,path:i,query:""===r?{}:B.getQueryVariables(r)}},B.makeRequest=function(e){var t=B.parseFragment(e),r={path:t.pathString,query:t.queryString,getPath:function(e){return void 0===e?t.path:t.path[e]},getQuery:function(e,r){var n;return void 0===e?n=t.query:(n=t.query[e])&&void 0!==r&&(n=n[r]),n},getQueryLast:function(e,t){var n=r.getQuery(e);return n?n[n.length-1]:t}};return r},B.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var n=jQuery.param(t||{});return r=r||"",e+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},B.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},B.format=function(e){for(var t,r,n=/%./g,i=0,a=[],s=0;t=n.exec(e);){(r=e.substring(s,n.lastIndex-2)).length>0&&a.push(r),s=n.lastIndex;var o=t[0][1];switch(o){case"s":case"o":i<arguments.length?a.push(arguments[1+i++]):a.push("<?>");break;case"%":a.push("%");break;default:a.push("<%"+o+"?>")}}return a.push(e.substring(s)),a.join("")},B.formatNumber=function(e,t,r,n){var i=e,a=isNaN(t=Math.abs(t))?2:t,s=void 0===r?",":r,o=void 0===n?".":n,u=i<0?"-":"",c=parseInt(i=Math.abs(+i||0).toFixed(a),10)+"",l=c.length>3?c.length%3:0;return u+(l?c.substr(0,l)+o:"")+c.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+o)+(a?s+Math.abs(i-c).toFixed(a).slice(2):"")},B.formatSize=function(e){return e=e>=1073741824?B.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?B.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?B.formatNumber(e/1024,0)+" KiB":B.formatNumber(e,0)+" bytes"},B.bytesFromIP=function(e){return-1!==e.indexOf(".")?B.bytesFromIPv4(e):-1!==e.indexOf(":")?B.bytesFromIPv6(e):null},B.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=B.createBuffer(),r=0;r<e.length;++r){var n=parseInt(e[r],10);if(isNaN(n))return null;t.putByte(n)}return t.getBytes()},B.bytesFromIPv6=function(e){for(var t=0,r=2*(8-(e=e.split(":").filter((function(e){return 0===e.length&&++t,!0}))).length+t),n=B.createBuffer(),i=0;i<8;++i)if(e[i]&&0!==e[i].length){var a=B.hexToBytes(e[i]);a.length<2&&n.putByte(0),n.putBytes(a)}else n.fillWithByte(0,r),r=0;return n.getBytes()},B.bytesToIP=function(e){return 4===e.length?B.bytesToIPv4(e):16===e.length?B.bytesToIPv6(e):null},B.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},B.bytesToIPv6=function(e){if(16!==e.length)return null;for(var t=[],r=[],n=0,i=0;i<e.length;i+=2){for(var a=B.bytesToHex(e[i]+e[i+1]);"0"===a[0]&&"0"!==a;)a=a.substr(1);if("0"===a){var s=r[r.length-1],o=t.length;s&&o===s.end+1?(s.end=o,s.end-s.start>r[n].end-r[n].start&&(n=r.length-1)):r.push({start:o,end:o})}t.push(a)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},B.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in B&&!e.update)return t(null,B.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return B.cores=navigator.hardwareConcurrency,t(null,B.cores);if("undefined"==typeof Worker)return B.cores=1,t(null,B.cores);if("undefined"==typeof Blob)return B.cores=2,t(null,B.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){var t=Date.now(),r=t+4;self.postMessage({st:t,et:r})}))}.toString(),")()"],{type:"application/javascript"}));!function e(n,i,a){if(0===i){var s=Math.floor(n.reduce((function(e,t){return e+t}),0)/n.length);return B.cores=Math.max(1,s),URL.revokeObjectURL(r),t(null,B.cores)}!function(e,t){for(var n=[],i=[],a=0;a<e;++a){var s=new Worker(r);s.addEventListener("message",(function(r){if(i.push(r.data),i.length===e){for(var a=0;a<e;++a)n[a].terminate();t(null,i)}})),n.push(s)}for(a=0;a<e;++a)n[a].postMessage(a)}(a,(function(t,r){n.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],a=r[n]=[],s=0;s<e;++s)if(n!==s){var o=t[s];(i.st>o.st&&i.st<o.et||o.st>i.st&&o.st<i.et)&&a.push(s)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(a,r)),e(n,i-1,a)}))}([],5,16)};var z=S;z.cipher=z.cipher||{},z.cipher.algorithms=z.cipher.algorithms||{},z.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=z.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new z.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},z.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=z.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new z.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},z.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),z.cipher.algorithms[e]=t},z.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in z.cipher.algorithms?z.cipher.algorithms[e]:null};var j=z.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};j.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=z.util.createBuffer(),this.output=e.output||z.util.createBuffer(),this.mode.start(t)},j.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},j.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))};var q=S;q.cipher=q.cipher||{};var H=q.cipher.modes=q.cipher.modes||{};function G(e,t){if("string"==typeof e&&(e=q.util.createBuffer(e)),q.util.isArray(e)&&e.length>4){var r=e;e=q.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!q.util.isArray(e)){var i=[],a=t/4;for(n=0;n<a;++n)i.push(e.getInt32());e=i}return e}function W(e){e[e.length-1]=e[e.length-1]+1&4294967295}function Q(e){return[e/4294967296|0,4294967295&e]}H.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},H.ecb.prototype.start=function(e){},H.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},H.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},H.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},H.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},H.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},H.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=G(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},H.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},H.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},H.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},H.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},H.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=q.util.createBuffer(),this._partialBytes=0},H.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=G(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},H.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32()^this._outBlock[i],t.putInt32(this._inBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},H.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32(),t.putInt32(this._inBlock[i]^this._outBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},H.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=q.util.createBuffer(),this._partialBytes=0},H.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=G(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},H.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},H.ofb.prototype.decrypt=H.ofb.prototype.encrypt,H.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=q.util.createBuffer(),this._partialBytes=0},H.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=G(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},H.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}W(this._inBlock)},H.ctr.prototype.decrypt=H.ctr.prototype.encrypt,H.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=q.util.createBuffer(),this._partialBytes=0,this._R=3774873600},H.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=q.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?q.util.createBuffer(e.additionalData):q.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=q.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var n=r.length();if(12===n)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(Q(8*n)))}this._inBlock=this._j0.slice(0),W(this._inBlock),this._partialBytes=0,t=q.util.createBuffer(t),this._aDataLength=Q(8*t.length());var i=t.length()%this.blockSize;for(i&&t.fillWithByte(0,this.blockSize-i),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},H.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^=e.getInt32());this._cipherLength+=this.blockSize}else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a<=0||r){if(r){var s=n%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),W(this._inBlock)},H.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n<this.blockSize&&!(r&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),W(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^this._hashBlock[i]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize},H.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=q.util.createBuffer();var n=this._aDataLength.concat(Q(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,n);var i=[];this.cipher.encrypt(this._j0,i);for(var a=0;a<this._ints;++a)this.tag.putInt32(this._s[a]^i[a]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},H.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),i=0;i<128;++i){e[i/32|0]&1<<31-i%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r},H.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},H.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},H.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},H.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,a=new Array(i),s=0;s<i;++s){var o=[0,0,0,0],u=(n-1-s%n)*t;o[s/n|0]=1<<t-1<<u,a[s]=this.generateSubHashTable(this.multiply(o,e),t)}return a},H.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,i=new Array(r);i[n]=e.slice(0);for(var a=n>>>1;a>0;)this.pow(i[2*a],i[a]=[]),a>>=1;for(a=2;a<n;){for(var s=1;s<a;++s){var o=i[a],u=i[s];i[a+s]=[o[0]^u[0],o[1]^u[1],o[2]^u[2],o[3]^u[3]]}a*=2}for(i[0]=[0,0,0,0],a=n+1;a<r;++a){var c=i[a^n];i[a]=[e[0]^c[0],e[1]^c[1],e[2]^c[2],e[3]^c[3]]}return i};var Y=S;function Z(e,t){Y.cipher.registerAlgorithm(e,(function(){return new Y.aes.Algorithm(e,t)}))}Y.aes=Y.aes||{},Y.aes.startEncrypting=function(e,t,r,n){var i=oe({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},Y.aes.createEncryptionCipher=function(e,t){return oe({key:e,output:null,decrypt:!1,mode:t})},Y.aes.startDecrypting=function(e,t,r,n){var i=oe({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},Y.aes.createDecryptionCipher=function(e,t){return oe({key:e,output:null,decrypt:!0,mode:t})},Y.aes.Algorithm=function(e,t){re||ie();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return se(r._w,e,t,!1)},decrypt:function(e,t){return se(r._w,e,t,!0)}}}),r._init=!1},Y.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(Y.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=Y.util.createBuffer();for(var n=0;n<t.length;++n)r.putByte(t[n])}}else r=Y.util.createBuffer(r);if(!Y.util.isArray(r)){t=r,r=[];var i=t.length();if(16===i||24===i||32===i){i>>>=2;for(n=0;n<i;++n)r.push(t.getInt32())}}if(!Y.util.isArray(r)||4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key parameter.");var a=this.mode.name,s=-1!==["CFB","OFB","CTR","GCM"].indexOf(a);this._w=ae(r,e.decrypt&&!s),this._init=!0}},Y.aes._expandKey=function(e,t){return re||ie(),ae(e,t)},Y.aes._updateBlock=se,Z("AES-ECB",Y.cipher.modes.ecb),Z("AES-CBC",Y.cipher.modes.cbc),Z("AES-CFB",Y.cipher.modes.cfb),Z("AES-OFB",Y.cipher.modes.ofb),Z("AES-CTR",Y.cipher.modes.ctr),Z("AES-GCM",Y.cipher.modes.gcm);var X,$,J,ee,te,re=!1,ne=4;function ie(){re=!0,J=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;X=new Array(256),$=new Array(256),ee=new Array(4),te=new Array(4);for(t=0;t<4;++t)ee[t]=new Array(256),te[t]=new Array(256);var r,n,i,a,s,o,u,c=0,l=0;for(t=0;t<256;++t){a=(a=l^l<<1^l<<2^l<<3^l<<4)>>8^255&a^99,X[c]=a,$[a]=c,o=(s=e[a])<<24^a<<16^a<<8^a^s,u=((r=e[c])^(n=e[r])^(i=e[n]))<<24^(c^i)<<16^(c^n^i)<<8^c^r^i;for(var h=0;h<4;++h)ee[h][c]=o,te[h][a]=u,o=o<<24|o>>>8,u=u<<24|u>>>8;0===c?c=l=1:(c=r^e[e[e[r^i]]],l^=e[e[l]])}}function ae(e,t){for(var r,n=e.slice(0),i=1,a=n.length,s=ne*(a+6+1),o=a;o<s;++o)r=n[o-1],o%a==0?(r=X[r>>>16&255]<<24^X[r>>>8&255]<<16^X[255&r]<<8^X[r>>>24]^J[i]<<24,i++):a>6&&o%a==4&&(r=X[r>>>24]<<24^X[r>>>16&255]<<16^X[r>>>8&255]<<8^X[255&r]),n[o]=n[o-a]^r;if(t){for(var u,c=te[0],l=te[1],h=te[2],f=te[3],d=n.slice(0),p=(o=0,(s=n.length)-ne);o<s;o+=ne,p-=ne)if(0===o||o===s-ne)d[o]=n[p],d[o+1]=n[p+3],d[o+2]=n[p+2],d[o+3]=n[p+1];else for(var g=0;g<ne;++g)u=n[p+g],d[o+(3&-g)]=c[X[u>>>24]]^l[X[u>>>16&255]]^h[X[u>>>8&255]]^f[X[255&u]];n=d}return n}function se(e,t,r,n){var i,a,s,o,u,c,l,h,f,d,p,g,y=e.length/4-1;n?(i=te[0],a=te[1],s=te[2],o=te[3],u=$):(i=ee[0],a=ee[1],s=ee[2],o=ee[3],u=X),c=t[0]^e[0],l=t[n?3:1]^e[1],h=t[2]^e[2],f=t[n?1:3]^e[3];for(var m=3,v=1;v<y;++v)d=i[c>>>24]^a[l>>>16&255]^s[h>>>8&255]^o[255&f]^e[++m],p=i[l>>>24]^a[h>>>16&255]^s[f>>>8&255]^o[255&c]^e[++m],g=i[h>>>24]^a[f>>>16&255]^s[c>>>8&255]^o[255&l]^e[++m],f=i[f>>>24]^a[c>>>16&255]^s[l>>>8&255]^o[255&h]^e[++m],c=d,l=p,h=g;r[0]=u[c>>>24]<<24^u[l>>>16&255]<<16^u[h>>>8&255]<<8^u[255&f]^e[++m],r[n?3:1]=u[l>>>24]<<24^u[h>>>16&255]<<16^u[f>>>8&255]<<8^u[255&c]^e[++m],r[2]=u[h>>>24]<<24^u[f>>>16&255]<<16^u[c>>>8&255]<<8^u[255&l]^e[++m],r[n?1:3]=u[f>>>24]<<24^u[c>>>16&255]<<16^u[l>>>8&255]<<8^u[255&h]^e[++m]}function oe(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?Y.cipher.createDecipher(r,e.key):Y.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof Y.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}var ue=S;ue.pki=ue.pki||{};var ce=ue.pki.oids=ue.oids=ue.oids||{};function le(e,t){ce[e]=t,ce[t]=e}function he(e,t){ce[e]=t}le("1.2.840.113549.1.1.1","rsaEncryption"),le("1.2.840.113549.1.1.4","md5WithRSAEncryption"),le("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),le("1.2.840.113549.1.1.7","RSAES-OAEP"),le("1.2.840.113549.1.1.8","mgf1"),le("1.2.840.113549.1.1.9","pSpecified"),le("1.2.840.113549.1.1.10","RSASSA-PSS"),le("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),le("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),le("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),le("1.3.101.112","EdDSA25519"),le("1.2.840.10040.4.3","dsa-with-sha1"),le("1.3.14.3.2.7","desCBC"),le("1.3.14.3.2.26","sha1"),le("2.16.840.1.101.3.4.2.1","sha256"),le("2.16.840.1.101.3.4.2.2","sha384"),le("2.16.840.1.101.3.4.2.3","sha512"),le("1.2.840.113549.2.5","md5"),le("1.2.840.113549.1.7.1","data"),le("1.2.840.113549.1.7.2","signedData"),le("1.2.840.113549.1.7.3","envelopedData"),le("1.2.840.113549.1.7.4","signedAndEnvelopedData"),le("1.2.840.113549.1.7.5","digestedData"),le("1.2.840.113549.1.7.6","encryptedData"),le("1.2.840.113549.1.9.1","emailAddress"),le("1.2.840.113549.1.9.2","unstructuredName"),le("1.2.840.113549.1.9.3","contentType"),le("1.2.840.113549.1.9.4","messageDigest"),le("1.2.840.113549.1.9.5","signingTime"),le("1.2.840.113549.1.9.6","counterSignature"),le("1.2.840.113549.1.9.7","challengePassword"),le("1.2.840.113549.1.9.8","unstructuredAddress"),le("1.2.840.113549.1.9.14","extensionRequest"),le("1.2.840.113549.1.9.20","friendlyName"),le("1.2.840.113549.1.9.21","localKeyId"),le("1.2.840.113549.1.9.22.1","x509Certificate"),le("1.2.840.113549.1.12.10.1.1","keyBag"),le("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),le("1.2.840.113549.1.12.10.1.3","certBag"),le("1.2.840.113549.1.12.10.1.4","crlBag"),le("1.2.840.113549.1.12.10.1.5","secretBag"),le("1.2.840.113549.1.12.10.1.6","safeContentsBag"),le("1.2.840.113549.1.5.13","pkcs5PBES2"),le("1.2.840.113549.1.5.12","pkcs5PBKDF2"),le("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),le("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),le("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),le("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),le("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),le("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),le("1.2.840.113549.2.7","hmacWithSHA1"),le("1.2.840.113549.2.8","hmacWithSHA224"),le("1.2.840.113549.2.9","hmacWithSHA256"),le("1.2.840.113549.2.10","hmacWithSHA384"),le("1.2.840.113549.2.11","hmacWithSHA512"),le("1.2.840.113549.3.7","des-EDE3-CBC"),le("2.16.840.1.101.3.4.1.2","aes128-CBC"),le("2.16.840.1.101.3.4.1.22","aes192-CBC"),le("2.16.840.1.101.3.4.1.42","aes256-CBC"),le("2.5.4.3","commonName"),le("2.5.4.5","serialName"),le("2.5.4.6","countryName"),le("2.5.4.7","localityName"),le("2.5.4.8","stateOrProvinceName"),le("2.5.4.9","streetAddress"),le("2.5.4.10","organizationName"),le("2.5.4.11","organizationalUnitName"),le("2.5.4.13","description"),le("2.5.4.15","businessCategory"),le("2.5.4.17","postalCode"),le("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),le("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),le("2.16.840.1.113730.1.1","nsCertType"),le("2.16.840.1.113730.1.13","nsComment"),he("2.5.29.1","authorityKeyIdentifier"),he("2.5.29.2","keyAttributes"),he("2.5.29.3","certificatePolicies"),he("2.5.29.4","keyUsageRestriction"),he("2.5.29.5","policyMapping"),he("2.5.29.6","subtreesConstraint"),he("2.5.29.7","subjectAltName"),he("2.5.29.8","issuerAltName"),he("2.5.29.9","subjectDirectoryAttributes"),he("2.5.29.10","basicConstraints"),he("2.5.29.11","nameConstraints"),he("2.5.29.12","policyConstraints"),he("2.5.29.13","basicConstraints"),le("2.5.29.14","subjectKeyIdentifier"),le("2.5.29.15","keyUsage"),he("2.5.29.16","privateKeyUsagePeriod"),le("2.5.29.17","subjectAltName"),le("2.5.29.18","issuerAltName"),le("2.5.29.19","basicConstraints"),he("2.5.29.20","cRLNumber"),he("2.5.29.21","cRLReason"),he("2.5.29.22","expirationDate"),he("2.5.29.23","instructionCode"),he("2.5.29.24","invalidityDate"),he("2.5.29.25","cRLDistributionPoints"),he("2.5.29.26","issuingDistributionPoint"),he("2.5.29.27","deltaCRLIndicator"),he("2.5.29.28","issuingDistributionPoint"),he("2.5.29.29","certificateIssuer"),he("2.5.29.30","nameConstraints"),le("2.5.29.31","cRLDistributionPoints"),le("2.5.29.32","certificatePolicies"),he("2.5.29.33","policyMappings"),he("2.5.29.34","policyConstraints"),le("2.5.29.35","authorityKeyIdentifier"),he("2.5.29.36","policyConstraints"),le("2.5.29.37","extKeyUsage"),he("2.5.29.46","freshestCRL"),he("2.5.29.54","inhibitAnyPolicy"),le("1.3.6.1.4.1.11129.2.4.2","timestampList"),le("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),le("1.3.6.1.5.5.7.3.1","serverAuth"),le("1.3.6.1.5.5.7.3.2","clientAuth"),le("1.3.6.1.5.5.7.3.3","codeSigning"),le("1.3.6.1.5.5.7.3.4","emailProtection"),le("1.3.6.1.5.5.7.3.8","timeStamping");var fe=S,de=fe.asn1=fe.asn1||{};function pe(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}de.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},de.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},de.create=function(e,t,r,n,i){if(fe.util.isArray(n)){for(var a=[],s=0;s<n.length;++s)void 0!==n[s]&&a.push(n[s]);n=a}var o={tagClass:e,type:t,constructed:r,composed:r||fe.util.isArray(n),value:n};return i&&"bitStringContents"in i&&(o.bitStringContents=i.bitStringContents,o.original=de.copy(o)),o},de.copy=function(e,t){var r;if(fe.util.isArray(e)){r=[];for(var n=0;n<e.length;++n)r.push(de.copy(e[n],t));return r}return"string"==typeof e?e:(r={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:de.copy(e.value,t)},t&&!t.excludeBitStringContents&&(r.bitStringContents=e.bitStringContents),r)},de.equals=function(e,t,r){if(fe.util.isArray(e)){if(!fe.util.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(!de.equals(e[n],t[n]))return!1;return!0}if(typeof e!=typeof t)return!1;if("string"==typeof e)return e===t;var i=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&de.equals(e.value,t.value);return r&&r.includeBitStringContents&&(i=i&&e.bitStringContents===t.bitStringContents),i},de.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};function ge(e,t,r,n){var i;pe(e,t,2);var a=e.getByte();t--;var s=192&a,o=31&a;i=e.length();var u,c,l=function(e,t){var r=e.getByte();if(t--,128!==r){var n;if(128&r){var i=127&r;pe(e,t,i),n=e.getInt(i<<3)}else n=r;if(n<0)throw new Error("Negative length: "+n);return n}}(e,t);if(t-=i-e.length(),void 0!==l&&l>t){if(n.strict){var h=new Error("Too few bytes to read ASN.1 value.");throw h.available=e.length(),h.remaining=t,h.requested=l,h}l=t}var f=32==(32&a);if(f)if(u=[],void 0===l)for(;;){if(pe(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}i=e.length(),u.push(ge(e,t,r+1,n)),t-=i-e.length()}else for(;l>0;)i=e.length(),u.push(ge(e,l,r+1,n)),t-=i-e.length(),l-=i-e.length();if(void 0===u&&s===de.Class.UNIVERSAL&&o===de.Type.BITSTRING&&(c=e.bytes(l)),void 0===u&&n.decodeBitStrings&&s===de.Class.UNIVERSAL&&o===de.Type.BITSTRING&&l>1){var d=e.read,p=t,g=0;if(o===de.Type.BITSTRING&&(pe(e,t,1),g=e.getByte(),t--),0===g)try{i=e.length();var y=ge(e,t,r+1,{verbose:n.verbose,strict:!0,decodeBitStrings:!0}),m=i-e.length();t-=m,o==de.Type.BITSTRING&&m++;var v=y.tagClass;m!==l||v!==de.Class.UNIVERSAL&&v!==de.Class.CONTEXT_SPECIFIC||(u=[y])}catch(e){}void 0===u&&(e.read=d,t=p)}if(void 0===u){if(void 0===l){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");l=t}if(o===de.Type.BMPSTRING)for(u="";l>0;l-=2)pe(e,t,2),u+=String.fromCharCode(e.getInt16()),t-=2;else u=e.getBytes(l)}var C=void 0===c?null:{bitStringContents:c};return de.create(s,o,f,u,C)}de.fromDer=function(e,t){return void 0===t&&(t={strict:!0,decodeBitStrings:!0}),"boolean"==typeof t&&(t={strict:t,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"==typeof e&&(e=fe.util.createBuffer(e)),ge(e,e.length(),0,t)},de.toDer=function(e){var t=fe.util.createBuffer(),r=e.tagClass|e.type,n=fe.util.createBuffer(),i=!1;if("bitStringContents"in e&&(i=!0,e.original&&(i=de.equals(e,e.original))),i)n.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:n.putByte(0);for(var a=0;a<e.value.length;++a)void 0!==e.value[a]&&n.putBuffer(de.toDer(e.value[a]))}else if(e.type===de.Type.BMPSTRING)for(a=0;a<e.value.length;++a)n.putInt16(e.value.charCodeAt(a));else e.type===de.Type.INTEGER&&e.value.length>1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?n.putBytes(e.value.substr(1)):n.putBytes(e.value);if(t.putByte(r),n.length()<=127)t.putByte(127&n.length());else{var s=n.length(),o="";do{o+=String.fromCharCode(255&s),s>>>=8}while(s>0);t.putByte(128|o.length);for(a=o.length-1;a>=0;--a)t.putByte(o.charCodeAt(a))}return t.putBuffer(n),t},de.oidToDer=function(e){var t,r,n,i,a=e.split("."),s=fe.util.createBuffer();s.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var o=2;o<a.length;++o){t=!0,r=[],n=parseInt(a[o],10);do{i=127&n,n>>>=7,t||(i|=128),r.push(i),t=!1}while(n>0);for(var u=r.length-1;u>=0;--u)s.putByte(r[u])}return s},de.derToOid=function(e){var t;"string"==typeof e&&(e=fe.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)n<<=7,128&(r=e.getByte())?n+=127&r:(t+="."+(n+r),n=0);return t},de.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),a=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var u=e.charAt(10),c=10;"+"!==u&&"-"!==u&&(o=parseInt(e.substr(10,2),10),c+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(a,s,o,0),c&&("+"===(u=e.charAt(c))||"-"===u)){var l=60*parseInt(e.substr(c+1,2),10)+parseInt(e.substr(c+4,2),10);l*=6e4,"+"===u?t.setTime(+t-l):t.setTime(+t+l)}return t},de.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),u=0,c=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var h=e.length-5,f=e.charAt(h);"+"!==f&&"-"!==f||(c=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),c*=6e4,"+"===f&&(c*=-1),l=!0);return"."===e.charAt(14)&&(u=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(a,s,o,u),t.setTime(+t+c)):(t.setFullYear(r,n,i),t.setHours(a,s,o,u)),t},de.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},de.dateToGeneralizedTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},de.integerToDer=function(e){var t=fe.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},de.derToInteger=function(e){"string"==typeof e&&(e=fe.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},de.validate=function(e,t,r,n){var i=!1;if(e.tagClass!==t.tagClass&&void 0!==t.tagClass||e.type!==t.type&&void 0!==t.type)n&&(e.tagClass!==t.tagClass&&n.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&n.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||void 0===t.constructed){if(i=!0,t.value&&fe.util.isArray(t.value))for(var a=0,s=0;i&&s<t.value.length;++s)i=t.value[s].optional||!1,e.value[a]&&((i=de.validate(e.value[a],t.value[s],r,n))?++a:t.value[s].optional&&(i=!0)),!i&&n&&n.push("["+t.name+'] Tag class "'+t.tagClass+'", type "'+t.type+'" expected value length "'+t.value.length+'", got "'+e.value.length+'"');if(i&&r&&(t.capture&&(r[t.capture]=e.value),t.captureAsn1&&(r[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(r[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)r[t.captureBitStringValue]="";else{if(0!==e.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");r[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else n&&n.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');return i};var ye=/[^\\u0000-\\u00ff]/;de.prettyPrint=function(e,t,r){var n="";r=r||2,(t=t||0)>0&&(n+="\n");for(var i="",a=0;a<t*r;++a)i+=" ";switch(n+=i+"Tag: ",e.tagClass){case de.Class.UNIVERSAL:n+="Universal:";break;case de.Class.APPLICATION:n+="Application:";break;case de.Class.CONTEXT_SPECIFIC:n+="Context-Specific:";break;case de.Class.PRIVATE:n+="Private:"}if(e.tagClass===de.Class.UNIVERSAL)switch(n+=e.type,e.type){case de.Type.NONE:n+=" (None)";break;case de.Type.BOOLEAN:n+=" (Boolean)";break;case de.Type.INTEGER:n+=" (Integer)";break;case de.Type.BITSTRING:n+=" (Bit string)";break;case de.Type.OCTETSTRING:n+=" (Octet string)";break;case de.Type.NULL:n+=" (Null)";break;case de.Type.OID:n+=" (Object Identifier)";break;case de.Type.ODESC:n+=" (Object Descriptor)";break;case de.Type.EXTERNAL:n+=" (External or Instance of)";break;case de.Type.REAL:n+=" (Real)";break;case de.Type.ENUMERATED:n+=" (Enumerated)";break;case de.Type.EMBEDDED:n+=" (Embedded PDV)";break;case de.Type.UTF8:n+=" (UTF8)";break;case de.Type.ROID:n+=" (Relative Object Identifier)";break;case de.Type.SEQUENCE:n+=" (Sequence)";break;case de.Type.SET:n+=" (Set)";break;case de.Type.PRINTABLESTRING:n+=" (Printable String)";break;case de.Type.IA5String:n+=" (IA5String (ASCII))";break;case de.Type.UTCTIME:n+=" (UTC time)";break;case de.Type.GENERALIZEDTIME:n+=" (Generalized time)";break;case de.Type.BMPSTRING:n+=" (BMP String)"}else n+=e.type;if(n+="\n",n+=i+"Constructed: "+e.constructed+"\n",e.composed){var s=0,o="";for(a=0;a<e.value.length;++a)void 0!==e.value[a]&&(s+=1,o+=de.prettyPrint(e.value[a],t+1,r),a+1<e.value.length&&(o+=","));n+=i+"Sub values: "+s+o}else{if(n+=i+"Value: ",e.type===de.Type.OID){var u=de.derToOid(e.value);n+=u,fe.pki&&fe.pki.oids&&u in fe.pki.oids&&(n+=" ("+fe.pki.oids[u]+") ")}if(e.type===de.Type.INTEGER)try{n+=de.derToInteger(e.value)}catch(t){n+="0x"+fe.util.bytesToHex(e.value)}else if(e.type===de.Type.BITSTRING){if(e.value.length>1?n+="0x"+fe.util.bytesToHex(e.value.slice(1)):n+="(none)",e.value.length>0){var c=e.value.charCodeAt(0);1==c?n+=" (1 unused bit shown)":c>1&&(n+=" ("+c+" unused bits shown)")}}else e.type===de.Type.OCTETSTRING?(ye.test(e.value)||(n+="("+e.value+") "),n+="0x"+fe.util.bytesToHex(e.value)):e.type===de.Type.UTF8?n+=fe.util.decodeUtf8(e.value):e.type===de.Type.PRINTABLESTRING||e.type===de.Type.IA5String?n+=e.value:ye.test(e.value)?n+="0x"+fe.util.bytesToHex(e.value):0===e.value.length?n+="[null]":n+=e.value}return n};var me=S,ve=me.md=me.md||{};me.md.algorithms=me.md.algorithms||{};var Ce=S;(Ce.hmac=Ce.hmac||{}).create=function(){var e=null,t=null,r=null,n=null,i={start:function(i,a){if(null!==i)if("string"==typeof i){if(!((i=i.toLowerCase())in Ce.md.algorithms))throw new Error('Unknown hash algorithm "'+i+'"');t=Ce.md.algorithms[i].create()}else t=i;if(null===a)a=e;else{if("string"==typeof a)a=Ce.util.createBuffer(a);else if(Ce.util.isArray(a)){var s=a;a=Ce.util.createBuffer();for(var o=0;o<s.length;++o)a.putByte(s[o])}var u=a.length();u>t.blockLength&&(t.start(),t.update(a.bytes()),a=t.digest()),r=Ce.util.createBuffer(),n=Ce.util.createBuffer(),u=a.length();for(o=0;o<u;++o){s=a.at(o);r.putByte(54^s),n.putByte(92^s)}if(u<t.blockLength)for(s=t.blockLength-u,o=0;o<s;++o)r.putByte(54),n.putByte(92);e=a,r=r.bytes(),n=n.bytes()}t.start(),t.update(r)},update:function(e){t.update(e)},getMac:function(){var e=t.digest().bytes();return t.start(),t.update(n),t.update(e),t.digest()}};return i.digest=i.getMac,i};var Ee=S,be=Ee.md5=Ee.md5||{};Ee.md.md5=Ee.md.algorithms.md5=be,be.create=function(){Ie||function(){Se=String.fromCharCode(128),Se+=Ee.util.fillString(String.fromCharCode(0),64),Te=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],_e=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],we=new Array(64);for(var e=0;e<64;++e)we[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));Ie=!0}();var e=null,t=Ee.util.createBuffer(),r=new Array(16),n={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var r=n.messageLengthSize/4,i=0;i<r;++i)n.fullMessageLength.push(0);return t=Ee.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},n}};return n.start(),n.update=function(i,a){"utf8"===a&&(i=Ee.util.encodeUtf8(i));var s=i.length;n.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=s[1],s[1]=s[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(i),Ae(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var i=Ee.util.createBuffer();i.putBytes(t.bytes());var a=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;i.putBytes(Se.substr(0,n.blockLength-a));for(var s,o=0,u=n.fullMessageLength.length-1;u>=0;--u)o=(s=8*n.fullMessageLength[u]+o)/4294967296>>>0,i.putInt32Le(s>>>0);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};Ae(c,r,i);var l=Ee.util.createBuffer();return l.putInt32Le(c.h0),l.putInt32Le(c.h1),l.putInt32Le(c.h2),l.putInt32Le(c.h3),l},n};var Se=null,Te=null,_e=null,we=null,Ie=!1;function Ae(e,t,r){for(var n,i,a,s,o,u,c,l=r.length();l>=64;){for(i=e.h0,a=e.h1,s=e.h2,o=e.h3,c=0;c<16;++c)t[c]=r.getInt32Le(),n=i+(o^a&(s^o))+we[c]+t[c],i=o,o=s,s=a,a+=n<<(u=_e[c])|n>>>32-u;for(;c<32;++c)n=i+(s^o&(a^s))+we[c]+t[Te[c]],i=o,o=s,s=a,a+=n<<(u=_e[c])|n>>>32-u;for(;c<48;++c)n=i+(a^s^o)+we[c]+t[Te[c]],i=o,o=s,s=a,a+=n<<(u=_e[c])|n>>>32-u;for(;c<64;++c)n=i+(s^(a|~o))+we[c]+t[Te[c]],i=o,o=s,s=a,a+=n<<(u=_e[c])|n>>>32-u;e.h0=e.h0+i|0,e.h1=e.h1+a|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,l-=64}}var Be=S,ke=Be.pem=Be.pem||{};function Ne(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i<e.values.length;++i)r.push(e.values[i].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var a=0,s=-1;for(i=0;i<t.length;++i,++a)if(a>65&&-1!==s){var o=t[s];","===o?(++s,t=t.substr(0,s)+"\r\n "+t.substr(s)):t=t.substr(0,s)+"\r\n"+o+t.substr(s+1),a=i-s-1,s=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(s=i);return t}function Re(e){return e.replace(/^\s+/,"")}ke.encode=function(e,t){t=t||{};var r,n="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(n+=Ne(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(n+=Ne(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),n+=Ne(r)),e.headers)for(var i=0;i<e.headers.length;++i)n+=Ne(e.headers[i]);return e.procType&&(n+="\r\n"),n+=Be.util.encode64(e.body,t.maxline||64)+"\r\n",n+="-----END "+e.type+"-----\r\n"},ke.decode=function(e){for(var t,r=[],n=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,i=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,a=/\r?\n/;t=n.exec(e);){var s={type:t[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:Be.util.decode64(t[3])};if(r.push(s),t[2]){for(var o=t[2].split(a),u=0;t&&u<o.length;){for(var c=o[u].replace(/\s+$/,""),l=u+1;l<o.length;++l){var h=o[l];if(!/\s/.test(h[0]))break;c+=h,u=l}if(t=c.match(i)){for(var f={name:t[1],values:[]},d=t[2].split(","),p=0;p<d.length;++p)f.values.push(Re(d[p]));if(s.procType)if(s.contentDomain||"Content-Domain"!==f.name)if(s.dekInfo||"DEK-Info"!==f.name)s.headers.push(f);else{if(0===f.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');s.dekInfo={algorithm:d[0],parameters:d[1]||null}}else s.contentDomain=d[0]||"";else{if("Proc-Type"!==f.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==f.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');s.procType={version:d[0],type:d[1]}}}++u}if("ENCRYPTED"===s.procType&&!s.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===r.length)throw new Error("Invalid PEM formatted message.");return r};var Le=S;function De(e,t){Le.cipher.registerAlgorithm(e,(function(){return new Le.des.Algorithm(e,t)}))}Le.des=Le.des||{},Le.des.startEncrypting=function(e,t,r,n){var i=je({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},Le.des.createEncryptionCipher=function(e,t){return je({key:e,output:null,decrypt:!1,mode:t})},Le.des.startDecrypting=function(e,t,r,n){var i=je({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},Le.des.createDecryptionCipher=function(e,t){return je({key:e,output:null,decrypt:!0,mode:t})},Le.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return ze(r._keys,e,t,!1)},decrypt:function(e,t){return ze(r._keys,e,t,!0)}}}),r._init=!1},Le.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=Le.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],a=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],u=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],d=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],y=e.length()>8?3:1,m=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],C=0,E=0;E<y;E++){var b=e.getInt32(),S=e.getInt32();b^=(t=252645135&(b>>>4^S))<<4,b^=t=65535&((S^=t)>>>-16^b),b^=(t=858993459&(b>>>2^(S^=t<<-16)))<<2,b^=t=65535&((S^=t)>>>-16^b),b^=(t=1431655765&(b>>>1^(S^=t<<-16)))<<1,b^=t=16711935&((S^=t)>>>8^b),t=(b^=(t=1431655765&(b>>>1^(S^=t<<8)))<<1)<<8|(S^=t)>>>20&240,b=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=t;for(var T=0;T<v.length;++T){v[T]?(b=b<<2|b>>>26,S=S<<2|S>>>26):(b=b<<1|b>>>27,S=S<<1|S>>>27),S&=-15;var _=r[(b&=-15)>>>28]|n[b>>>24&15]|i[b>>>20&15]|a[b>>>16&15]|s[b>>>12&15]|o[b>>>8&15]|u[b>>>4&15],w=c[S>>>28]|l[S>>>24&15]|h[S>>>20&15]|f[S>>>16&15]|d[S>>>12&15]|p[S>>>8&15]|g[S>>>4&15];t=65535&(w>>>16^_),m[C++]=_^t,m[C++]=w^t<<16}}return m}(t),this._init=!0}},De("DES-ECB",Le.cipher.modes.ecb),De("DES-CBC",Le.cipher.modes.cbc),De("DES-CFB",Le.cipher.modes.cfb),De("DES-OFB",Le.cipher.modes.ofb),De("DES-CTR",Le.cipher.modes.ctr),De("3DES-ECB",Le.cipher.modes.ecb),De("3DES-CBC",Le.cipher.modes.cbc),De("3DES-CFB",Le.cipher.modes.cfb),De("3DES-OFB",Le.cipher.modes.ofb),De("3DES-CTR",Le.cipher.modes.ctr);var Ue=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],xe=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],Oe=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],Pe=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],Ve=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],Ke=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],Me=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],Fe=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function ze(e,t,r,n){var i,a,s=32===e.length?3:9;i=3===s?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var o=t[0],u=t[1];o^=(a=252645135&(o>>>4^u))<<4,o^=(a=65535&(o>>>16^(u^=a)))<<16,o^=a=858993459&((u^=a)>>>2^o),o^=a=16711935&((u^=a<<2)>>>8^o),o=(o^=(a=1431655765&(o>>>1^(u^=a<<8)))<<1)<<1|o>>>31,u=(u^=a)<<1|u>>>31;for(var c=0;c<s;c+=3){for(var l=i[c+1],h=i[c+2],f=i[c];f!=l;f+=h){var d=u^e[f],p=(u>>>4|u<<28)^e[f+1];a=o,o=u,u=a^(xe[d>>>24&63]|Pe[d>>>16&63]|Ke[d>>>8&63]|Fe[63&d]|Ue[p>>>24&63]|Oe[p>>>16&63]|Ve[p>>>8&63]|Me[63&p])}a=o,o=u,u=a}u=u>>>1|u<<31,u^=a=1431655765&((o=o>>>1|o<<31)>>>1^u),u^=(a=16711935&(u>>>8^(o^=a<<1)))<<8,u^=(a=858993459&(u>>>2^(o^=a)))<<2,u^=a=65535&((o^=a)>>>16^u),u^=a=252645135&((o^=a<<16)>>>4^u),o^=a<<4,r[0]=o,r[1]=u}function je(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?Le.cipher.createDecipher(r,e.key):Le.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof Le.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}var qe,He=S,Ge=He.pkcs5=He.pkcs5||{};He.util.isNodejs&&!He.options.usePureJavaScript&&(qe=s),He.pbkdf2=Ge.pbkdf2=function(e,t,r,n,i,a){if("function"==typeof i&&(a=i,i=null),He.util.isNodejs&&!He.options.usePureJavaScript&&qe.pbkdf2&&(null===i||"object"!=typeof i)&&(qe.pbkdf2Sync.length>4||!i||"sha1"===i))return"string"!=typeof i&&(i="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),a?4===qe.pbkdf2Sync.length?qe.pbkdf2(e,t,r,n,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):qe.pbkdf2(e,t,r,n,i,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):4===qe.pbkdf2Sync.length?qe.pbkdf2Sync(e,t,r,n).toString("binary"):qe.pbkdf2Sync(e,t,r,n,i).toString("binary");if(null==i&&(i="sha1"),"string"==typeof i){if(!(i in He.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=He.md[i].create()}var s=i.digestLength;if(n>4294967295*s){var o=new Error("Derived key is too long.");if(a)return a(o);throw o}var u=Math.ceil(n/s),c=n-(u-1)*s,l=He.hmac.create();l.start(i,e);var h,f,d,p="";if(!a){for(var g=1;g<=u;++g){l.start(null,null),l.update(t),l.update(He.util.int32ToBytes(g)),h=d=l.digest().getBytes();for(var y=2;y<=r;++y)l.start(null,null),l.update(d),f=l.digest().getBytes(),h=He.util.xorBytes(h,f,s),d=f;p+=g<u?h:h.substr(0,c)}return p}g=1;function m(){if(g>u)return a(null,p);l.start(null,null),l.update(t),l.update(He.util.int32ToBytes(g)),h=d=l.digest().getBytes(),y=2,v()}function v(){if(y<=r)return l.start(null,null),l.update(d),f=l.digest().getBytes(),h=He.util.xorBytes(h,f,s),d=f,++y,He.util.setImmediate(v);p+=g<u?h:h.substr(0,c),++g,m()}m()};var We=S,Qe=We.sha256=We.sha256||{};We.md.sha256=We.md.algorithms.sha256=Qe,Qe.create=function(){Ze||(Ye=String.fromCharCode(128),Ye+=We.util.fillString(String.fromCharCode(0),64),Xe=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Ze=!0);var e=null,t=We.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var r=n.messageLengthSize/4,i=0;i<r;++i)n.fullMessageLength.push(0);return t=We.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n}};return n.start(),n.update=function(i,a){"utf8"===a&&(i=We.util.encodeUtf8(i));var s=i.length;n.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=s[1],s[1]=s[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(i),$e(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var i=We.util.createBuffer();i.putBytes(t.bytes());var a,s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;i.putBytes(Ye.substr(0,n.blockLength-s));for(var o=8*n.fullMessageLength[0],u=0;u<n.fullMessageLength.length-1;++u)o+=(a=8*n.fullMessageLength[u+1])/4294967296>>>0,i.putInt32(o>>>0),o=a>>>0;i.putInt32(o);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};$e(c,r,i);var l=We.util.createBuffer();return l.putInt32(c.h0),l.putInt32(c.h1),l.putInt32(c.h2),l.putInt32(c.h3),l.putInt32(c.h4),l.putInt32(c.h5),l.putInt32(c.h6),l.putInt32(c.h7),l},n};var Ye=null,Ze=!1,Xe=null;function $e(e,t,r){for(var n,i,a,s,o,u,c,l,h,f,d,p,g,y=r.length();y>=64;){for(o=0;o<16;++o)t[o]=r.getInt32();for(;o<64;++o)n=((n=t[o-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[o-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[o]=n+t[o-7]+i+t[o-16]|0;for(u=e.h0,c=e.h1,l=e.h2,h=e.h3,f=e.h4,d=e.h5,p=e.h6,g=e.h7,o=0;o<64;++o)a=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&c|l&(u^c),n=g+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(p^f&(d^p))+Xe[o]+t[o],g=p,p=d,d=f,f=h+n>>>0,h=l,l=c,c=u,u=n+(i=a+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+c|0,e.h2=e.h2+l|0,e.h3=e.h3+h|0,e.h4=e.h4+f|0,e.h5=e.h5+d|0,e.h6=e.h6+p|0,e.h7=e.h7+g|0,y-=64}}var Je=S,et=null;!Je.util.isNodejs||Je.options.usePureJavaScript||process.versions["node-webkit"]||(et=s),(Je.prng=Je.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,n=new Array(32),i=0;i<32;++i)n[i]=r.create();function a(){if(t.pools[0].messageLength>=32)return s();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),s()}function s(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r==0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function o(e){var t=null,r=Je.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var i=Je.util.createBuffer();if(t)for(;i.length()<e;){var a=Math.max(1,Math.min(e-i.length(),65536)/4),s=new Uint32Array(Math.floor(a));try{t(s);for(var o=0;o<s.length;++o)i.putInt32(s[o])}catch(e){if(!("undefined"!=typeof QuotaExceededError&&e instanceof QuotaExceededError))throw e}}if(i.length()<e)for(var u,c,l,h=Math.floor(65536*Math.random());i.length()<e;){c=16807*(65535&h),c+=(32767&(u=16807*(h>>16)))<<16,h=4294967295&(c=(2147483647&(c+=u>>15))+(c>>31));for(o=0;o<3;++o)l=h>>>(o<<3),l^=Math.floor(256*Math.random()),i.putByte(String.fromCharCode(255&l))}return i.getBytes(e)}return t.pools=n,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,i=t.plugin.increment,a=t.plugin.formatKey,o=t.plugin.formatSeed,u=Je.util.createBuffer();t.key=null,function c(l){if(l)return r(l);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return Je.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return s(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),s(),e()}))}(c)}));var h=n(t.key,t.seed);t.generated+=h.length,u.putBytes(h),t.key=a(n(t.key,i(t.seed))),t.seed=o(n(t.key,t.seed)),Je.util.setImmediate(c)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,i=t.plugin.formatKey,s=t.plugin.formatSeed;t.key=null;for(var o=Je.util.createBuffer();o.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,o.putBytes(u),t.key=i(r(t.key,n(t.seed))),t.seed=s(r(t.key,t.seed))}return o.getBytes(e)},et?(t.seedFile=function(e,t){et.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return et.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,o(e))}catch(e){t(e)}},t.seedFileSync=o),t.collect=function(e){for(var r=e.length,n=0;n<r;++n)t.pools[t.pool].update(e.substr(n,1)),t.pool=31===t.pool?0:t.pool+1},t.collectInt=function(e,r){for(var n="",i=0;i<r;i+=8)n+=String.fromCharCode(e>>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t};var tt=S;tt.random&&tt.random.getBytes?tt.random:function(e){var t={},r=new Array(4),n=tt.util.createBuffer();function i(){var e=tt.prng.create(t);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}t.formatKey=function(e){var t=tt.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),tt.aes._expandKey(e,!1)},t.formatSeed=function(e){var t=tt.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},t.cipher=function(e,t){return tt.aes._updateBlock(e,t,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},t.increment=function(e){return++e[3],e},t.md=tt.md.sha256;var a=i(),s=null,o=tt.util.globalScope,u=o.crypto||o.msCrypto;if(u&&u.getRandomValues&&(s=function(e){return u.getRandomValues(e)}),tt.options.usePureJavaScript||!tt.util.isNodejs&&!s){if(a.collectInt(+new Date,32),"undefined"!=typeof navigator){var c="";for(var l in navigator)try{"string"==typeof navigator[l]&&(c+=navigator[l])}catch(e){}a.collect(c),c=null}e&&(e().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),e().keypress((function(e){a.collectInt(e.charCode,8)})))}if(tt.random)for(var l in a)tt.random[l]=a[l];else tt.random=a;tt.random.createInstance=i,tt.random}("undefined"!=typeof jQuery?jQuery:null);var rt=S,nt=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],it=[1,2,3,5],at=function(e,t){return e<<t&65535|(65535&e)>>16-t},st=function(e,t){return(65535&e)>>t|e<<16-t&65535};rt.rc2=rt.rc2||{},rt.rc2.expandKey=function(e,t){"string"==typeof e&&(e=rt.util.createBuffer(e)),t=t||128;var r,n=e,i=e.length(),a=t,s=Math.ceil(a/8),o=255>>(7&a);for(r=i;r<128;r++)n.putByte(nt[n.at(r-1)+n.at(r-i)&255]);for(n.setAt(128-s,nt[n.at(128-s)&o]),r=127-s;r>=0;r--)n.setAt(r,nt[n.at(r+1)^n.at(r+s)]);return n};var ot=function(e,t,r){var n,i,a,s,o=!1,u=null,c=null,l=null,h=[];for(e=rt.rc2.expandKey(e,t),a=0;a<64;a++)h.push(e.getInt16Le());r?(n=function(e){for(a=0;a<4;a++)e[a]+=h[s]+(e[(a+3)%4]&e[(a+2)%4])+(~e[(a+3)%4]&e[(a+1)%4]),e[a]=at(e[a],it[a]),s++},i=function(e){for(a=0;a<4;a++)e[a]+=h[63&e[(a+3)%4]]}):(n=function(e){for(a=3;a>=0;a--)e[a]=st(e[a],it[a]),e[a]-=h[s]+(e[(a+3)%4]&e[(a+2)%4])+(~e[(a+3)%4]&e[(a+1)%4]),s--},i=function(e){for(a=3;a>=0;a--)e[a]-=h[63&e[(a+3)%4]]});var f=function(e){var t=[];for(a=0;a<4;a++){var n=u.getInt16Le();null!==l&&(r?n^=l.getInt16Le():l.putInt16Le(n)),t.push(65535&n)}s=r?0:63;for(var i=0;i<e.length;i++)for(var o=0;o<e[i][0];o++)e[i][1](t);for(a=0;a<4;a++)null!==l&&(r?l.putInt16Le(t[a]):t[a]^=l.getInt16Le()),c.putInt16Le(t[a])},d=null;return d={start:function(e,t){e&&"string"==typeof e&&(e=rt.util.createBuffer(e)),o=!1,u=rt.util.createBuffer(),c=t||new rt.util.createBuffer,l=e,d.output=c},update:function(e){for(o||u.putBuffer(e);u.length()>=8;)f([[5,n],[1,i],[6,n],[1,i],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,u,!r);else{var n=8===u.length()?8:8-u.length();u.fillWithByte(n,n)}if(t&&(o=!0,d.update()),!r&&(t=0===u.length()))if(e)t=e(8,c,!r);else{var i=c.length(),a=c.at(i-1);a>i?t=!1:c.truncate(a)}return t}}};rt.rc2.startEncrypting=function(e,t,r){var n=rt.rc2.createEncryptionCipher(e,128);return n.start(t,r),n},rt.rc2.createEncryptionCipher=function(e,t){return ot(e,t,!0)},rt.rc2.startDecrypting=function(e,t,r){var n=rt.rc2.createDecryptionCipher(e,128);return n.start(t,r),n},rt.rc2.createDecryptionCipher=function(e,t){return ot(e,t,!1)};var ut,ct=S;function lt(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function ht(){return new lt(null)}function ft(e,t,r,n,i,a){for(var s=16383&t,o=t>>14;--a>=0;){var u=16383&this.data[e],c=this.data[e++]>>14,l=o*u+c*s;i=((u=s*u+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+o*c,r.data[n++]=268435455&u}return i}ct.jsbn=ct.jsbn||{},ct.jsbn.BigInteger=lt,"undefined"==typeof navigator?(lt.prototype.am=ft,ut=28):"Microsoft Internet Explorer"==navigator.appName?(lt.prototype.am=function(e,t,r,n,i,a){for(var s=32767&t,o=t>>15;--a>=0;){var u=32767&this.data[e],c=this.data[e++]>>15,l=o*u+c*s;i=((u=s*u+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+o*c+(i>>>30),r.data[n++]=1073741823&u}return i},ut=30):"Netscape"!=navigator.appName?(lt.prototype.am=function(e,t,r,n,i,a){for(;--a>=0;){var s=t*this.data[e++]+r.data[n]+i;i=Math.floor(s/67108864),r.data[n++]=67108863&s}return i},ut=26):(lt.prototype.am=ft,ut=28),lt.prototype.DB=ut,lt.prototype.DM=(1<<ut)-1,lt.prototype.DV=1<<ut;lt.prototype.FV=Math.pow(2,52),lt.prototype.F1=52-ut,lt.prototype.F2=2*ut-52;var dt,pt,gt="0123456789abcdefghijklmnopqrstuvwxyz",yt=new Array;for(dt="0".charCodeAt(0),pt=0;pt<=9;++pt)yt[dt++]=pt;for(dt="a".charCodeAt(0),pt=10;pt<36;++pt)yt[dt++]=pt;for(dt="A".charCodeAt(0),pt=10;pt<36;++pt)yt[dt++]=pt;function mt(e){return gt.charAt(e)}function vt(e,t){var r=yt[e.charCodeAt(t)];return null==r?-1:r}function Ct(e){var t=ht();return t.fromInt(e),t}function Et(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function bt(e){this.m=e}function St(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function Tt(e,t){return e&t}function _t(e,t){return e|t}function wt(e,t){return e^t}function It(e,t){return e&~t}function At(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function Bt(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function kt(){}function Nt(e){return e}function Rt(e){this.r2=ht(),this.q3=ht(),lt.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}bt.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},bt.prototype.revert=function(e){return e},bt.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},bt.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},bt.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},St.prototype.convert=function(e){var t=ht();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(lt.ZERO)>0&&this.m.subTo(t,t),t},St.prototype.revert=function(e){var t=ht();return e.copyTo(t),this.reduce(t),t},St.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},St.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},St.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},lt.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},lt.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},lt.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,a=0;--n>=0;){var s=8==r?255&e[n]:vt(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==a?this.data[this.t++]=s:a+r>this.DB?(this.data[this.t-1]|=(s&(1<<this.DB-a)-1)<<a,this.data[this.t++]=s>>this.DB-a):this.data[this.t-1]|=s<<a,(a+=r)>=this.DB&&(a-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),i&<.ZERO.subTo(this,this)},lt.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},lt.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},lt.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},lt.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,a=(1<<i)-1,s=Math.floor(e/this.DB),o=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+s+1]=this.data[r]>>i|o,o=(this.data[r]&a)<<n;for(r=s-1;r>=0;--r)t.data[r]=0;t.data[s]=o,t.t=this.t+s+1,t.s=this.s,t.clamp()},lt.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,a=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var s=r+1;s<this.t;++s)t.data[s-r-1]|=(this.data[s]&a)<<i,t.data[s-r]=this.data[s]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&a)<<i),t.t=this.t-r,t.clamp()}},lt.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},lt.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i<n.t;++i)t.data[i+r.t]=r.am(0,n.data[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&<.ZERO.subTo(t,t)},lt.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},lt.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=ht());var a=ht(),s=this.s,o=e.s,u=this.DB-Et(n.data[n.t-1]);u>0?(n.lShiftTo(u,a),i.lShiftTo(u,r)):(n.copyTo(a),i.copyTo(r));var c=a.t,l=a.data[c-1];if(0!=l){var h=l*(1<<this.F1)+(c>1?a.data[c-2]>>this.F2:0),f=this.FV/h,d=(1<<this.F1)/h,p=1<<this.F2,g=r.t,y=g-c,m=null==t?ht():t;for(a.dlShiftTo(y,m),r.compareTo(m)>=0&&(r.data[r.t++]=1,r.subTo(m,r)),lt.ONE.dlShiftTo(c,m),m.subTo(a,a);a.t<c;)a.data[a.t++]=0;for(;--y>=0;){var v=r.data[--g]==l?this.DM:Math.floor(r.data[g]*f+(r.data[g-1]+p)*d);if((r.data[g]+=a.am(0,v,r,y,0,c))<v)for(a.dlShiftTo(y,m),r.subTo(m,r);r.data[g]<--v;)r.subTo(m,r)}null!=t&&(r.drShiftTo(c,t),s!=o&<.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&<.ZERO.subTo(r,r)}}},lt.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},lt.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},lt.prototype.exp=function(e,t){if(e>4294967295||e<1)return lt.ONE;var r=ht(),n=ht(),i=t.convert(this),a=Et(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<<a)>0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)},lt.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,a="",s=this.t,o=this.DB-s*this.DB%t;if(s-- >0)for(o<this.DB&&(r=this.data[s]>>o)>0&&(i=!0,a=mt(r));s>=0;)o<t?(r=(this.data[s]&(1<<o)-1)<<t-o,r|=this.data[--s]>>(o+=this.DB-t)):(r=this.data[s]>>(o-=t)&n,o<=0&&(o+=this.DB,--s)),r>0&&(i=!0),i&&(a+=mt(r));return i?a:"0"},lt.prototype.negate=function(){var e=ht();return lt.ZERO.subTo(this,e),e},lt.prototype.abs=function(){return this.s<0?this.negate():this},lt.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},lt.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+Et(this.data[this.t-1]^this.s&this.DM)},lt.prototype.mod=function(e){var t=ht();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(lt.ZERO)>0&&e.subTo(t,t),t},lt.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new bt(t):new St(t),this.exp(e,r)},lt.ZERO=Ct(0),lt.ONE=Ct(1),kt.prototype.convert=Nt,kt.prototype.revert=Nt,kt.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},kt.prototype.sqrTo=function(e,t){e.squareTo(t)},Rt.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=ht();return e.copyTo(t),this.reduce(t),t},Rt.prototype.revert=function(e){return e},Rt.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},Rt.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Rt.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var Lt=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],Dt=(1<<26)/Lt[Lt.length-1];lt.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},lt.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=Ct(r),i=ht(),a=ht(),s="";for(this.divRemTo(n,i,a);i.signum()>0;)s=(r+a.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,a);return a.intValue().toString(e)+s},lt.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,s=0,o=0;o<e.length;++o){var u=vt(e,o);u<0?"-"==e.charAt(o)&&0==this.signum()&&(i=!0):(s=t*s+u,++a>=r&&(this.dMultiply(n),this.dAddOffset(s,0),a=0,s=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),i&<.ZERO.subTo(this,this)},lt.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(lt.ONE.shiftLeft(e-1),_t,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(lt.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},lt.prototype.bitwiseTo=function(e,t,r){var n,i,a=Math.min(e.t,this.t);for(n=0;n<a;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=a;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=a;n<e.t;++n)r.data[n]=t(i,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},lt.prototype.changeBit=function(e,t){var r=lt.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},lt.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},lt.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},lt.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},lt.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i<n;++i)r.data[i+this.t]=this.am(0,e.data[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e.data[i],r,i,0,t-i);r.clamp()},lt.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},lt.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},lt.prototype.millerRabin=function(e){var t=this.subtract(lt.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),a={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},s=0;s<e;++s){do{n=new lt(this.bitLength(),a)}while(n.compareTo(lt.ONE)<=0||n.compareTo(t)>=0);var o=n.modPow(i,this);if(0!=o.compareTo(lt.ONE)&&0!=o.compareTo(t)){for(var u=1;u++<r&&0!=o.compareTo(t);)if(0==(o=o.modPowInt(2,this)).compareTo(lt.ONE))return!1;if(0!=o.compareTo(t))return!1}}return!0},lt.prototype.clone=function(){var e=ht();return this.copyTo(e),e},lt.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},lt.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},lt.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},lt.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},lt.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},lt.prototype.equals=function(e){return 0==this.compareTo(e)},lt.prototype.min=function(e){return this.compareTo(e)<0?this:e},lt.prototype.max=function(e){return this.compareTo(e)>0?this:e},lt.prototype.and=function(e){var t=ht();return this.bitwiseTo(e,Tt,t),t},lt.prototype.or=function(e){var t=ht();return this.bitwiseTo(e,_t,t),t},lt.prototype.xor=function(e){var t=ht();return this.bitwiseTo(e,wt,t),t},lt.prototype.andNot=function(e){var t=ht();return this.bitwiseTo(e,It,t),t},lt.prototype.not=function(){for(var e=ht(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},lt.prototype.shiftLeft=function(e){var t=ht();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},lt.prototype.shiftRight=function(e){var t=ht();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},lt.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+At(this.data[e]);return this.s<0?this.t*this.DB:-1},lt.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=Bt(this.data[r]^t);return e},lt.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this.data[t]&1<<e%this.DB)},lt.prototype.setBit=function(e){return this.changeBit(e,_t)},lt.prototype.clearBit=function(e){return this.changeBit(e,It)},lt.prototype.flipBit=function(e){return this.changeBit(e,wt)},lt.prototype.add=function(e){var t=ht();return this.addTo(e,t),t},lt.prototype.subtract=function(e){var t=ht();return this.subTo(e,t),t},lt.prototype.multiply=function(e){var t=ht();return this.multiplyTo(e,t),t},lt.prototype.divide=function(e){var t=ht();return this.divRemTo(e,t,null),t},lt.prototype.remainder=function(e){var t=ht();return this.divRemTo(e,null,t),t},lt.prototype.divideAndRemainder=function(e){var t=ht(),r=ht();return this.divRemTo(e,t,r),new Array(t,r)},lt.prototype.modPow=function(e,t){var r,n,i=e.bitLength(),a=Ct(1);if(i<=0)return a;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new bt(t):t.isEven()?new Rt(t):new St(t);var s=new Array,o=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=ht();for(n.sqrTo(s[1],l);o<=c;)s[o]=ht(),n.mulTo(l,s[o-2],s[o]),o+=2}var h,f,d=e.t-1,p=!0,g=ht();for(i=Et(e.data[d])-1;d>=0;){for(i>=u?h=e.data[d]>>i-u&c:(h=(e.data[d]&(1<<i+1)-1)<<u-i,d>0&&(h|=e.data[d-1]>>this.DB+i-u)),o=r;0==(1&h);)h>>=1,--o;if((i-=o)<0&&(i+=this.DB,--d),p)s[h].copyTo(a),p=!1;else{for(;o>1;)n.sqrTo(a,g),n.sqrTo(g,a),o-=2;o>0?n.sqrTo(a,g):(f=a,a=g,g=f),n.mulTo(g,s[h],a)}for(;d>=0&&0==(e.data[d]&1<<i);)n.sqrTo(a,g),f=a,a=g,g=f,--i<0&&(i=this.DB-1,--d)}return n.revert(a)},lt.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return lt.ZERO;for(var r=e.clone(),n=this.clone(),i=Ct(1),a=Ct(0),s=Ct(0),o=Ct(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&a.isEven()||(i.addTo(this,i),a.subTo(e,a)),i.rShiftTo(1,i)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(e,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),a.subTo(o,a)):(n.subTo(r,n),t&&s.subTo(i,s),o.subTo(a,o))}return 0!=n.compareTo(lt.ONE)?lt.ZERO:o.compareTo(e)>=0?o.subtract(e):o.signum()<0?(o.addTo(e,o),o.signum()<0?o.add(e):o):o},lt.prototype.pow=function(e){return this.exp(e,new kt)},lt.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),a=r.getLowestSetBit();if(a<0)return t;for(i<a&&(a=i),a>0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r},lt.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=Lt[Lt.length-1]){for(t=0;t<Lt.length;++t)if(r.data[0]==Lt[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<Lt.length;){for(var n=Lt[t],i=t+1;i<Lt.length&&n<Dt;)n*=Lt[i++];for(n=r.modInt(n);t<i;)if(n%Lt[t++]==0)return!1}return r.millerRabin(e)};var Ut=S,xt=Ut.sha1=Ut.sha1||{};Ut.md.sha1=Ut.md.algorithms.sha1=xt,xt.create=function(){Pt||(Ot=String.fromCharCode(128),Ot+=Ut.util.fillString(String.fromCharCode(0),64),Pt=!0);var e=null,t=Ut.util.createBuffer(),r=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var r=n.messageLengthSize/4,i=0;i<r;++i)n.fullMessageLength.push(0);return t=Ut.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n}};return n.start(),n.update=function(i,a){"utf8"===a&&(i=Ut.util.encodeUtf8(i));var s=i.length;n.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=s[1],s[1]=s[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(i),Vt(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var i=Ut.util.createBuffer();i.putBytes(t.bytes());var a,s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;i.putBytes(Ot.substr(0,n.blockLength-s));for(var o=8*n.fullMessageLength[0],u=0;u<n.fullMessageLength.length-1;++u)o+=(a=8*n.fullMessageLength[u+1])/4294967296>>>0,i.putInt32(o>>>0),o=a>>>0;i.putInt32(o);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};Vt(c,r,i);var l=Ut.util.createBuffer();return l.putInt32(c.h0),l.putInt32(c.h1),l.putInt32(c.h2),l.putInt32(c.h3),l.putInt32(c.h4),l},n};var Ot=null,Pt=!1;function Vt(e,t,r){for(var n,i,a,s,o,u,c,l=r.length();l>=64;){for(i=e.h0,a=e.h1,s=e.h2,o=e.h3,u=e.h4,c=0;c<16;++c)n=r.getInt32(),t[c]=n,n=(i<<5|i>>>27)+(o^a&(s^o))+u+1518500249+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<20;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(o^a&(s^o))+u+1518500249+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<32;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(a^s^o)+u+1859775393+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<40;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(a^s^o)+u+1859775393+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<60;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(a&s|o&(a^s))+u+2400959708+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<80;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(a^s^o)+u+3395469782+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+a|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,e.h4=e.h4+u|0,l-=64}}var Kt=S,Mt=Kt.pkcs1=Kt.pkcs1||{};function Ft(e,t,r){r||(r=Kt.md.sha1.create());for(var n="",i=Math.ceil(t/r.digestLength),a=0;a<i;++a){var s=String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a);r.start(),r.update(e+s),n+=r.digest().getBytes()}return n.substring(0,t)}Mt.encode_rsa_oaep=function(e,t,r){var n,i,a,s;"string"==typeof r?(n=r,i=arguments[3]||void 0,a=arguments[4]||void 0):r&&(n=r.label||void 0,i=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md)),a?a.start():a=Kt.md.sha1.create(),s||(s=a);var o=Math.ceil(e.n.bitLength()/8),u=o-2*a.digestLength-2;if(t.length>u)throw(p=new Error("RSAES-OAEP input message length is too long.")).length=t.length,p.maxLength=u,p;n||(n=""),a.update(n,"raw");for(var c=a.digest(),l="",h=u-t.length,f=0;f<h;f++)l+="\0";var d=c.getBytes()+l+""+t;if(i){if(i.length!==a.digestLength){var p;throw(p=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=i.length,p.digestLength=a.digestLength,p}}else i=Kt.random.getBytes(a.digestLength);var g=Ft(i,o-a.digestLength-1,s),y=Kt.util.xorBytes(d,g,d.length),m=Ft(y,a.digestLength,s);return"\0"+Kt.util.xorBytes(i,m,i.length)+y},Mt.decode_rsa_oaep=function(e,t,r){var n,i,a;"string"==typeof r?(n=r,i=arguments[3]||void 0):r&&(n=r.label||void 0,i=r.md||void 0,r.mgf1&&r.mgf1.md&&(a=r.mgf1.md));var s=Math.ceil(e.n.bitLength()/8);if(t.length!==s)throw(g=new Error("RSAES-OAEP encoded message length is invalid.")).length=t.length,g.expectedLength=s,g;if(void 0===i?i=Kt.md.sha1.create():i.start(),a||(a=i),s<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),i.update(n,"raw");for(var o=i.digest().getBytes(),u=t.charAt(0),c=t.substring(1,i.digestLength+1),l=t.substring(1+i.digestLength),h=Ft(l,i.digestLength,a),f=Ft(Kt.util.xorBytes(c,h,c.length),s-i.digestLength-1,a),d=Kt.util.xorBytes(l,f,l.length),p=d.substring(0,i.digestLength),g="\0"!==u,y=0;y<i.digestLength;++y)g|=o.charAt(y)!==p.charAt(y);for(var m=1,v=i.digestLength,C=i.digestLength;C<d.length;C++){var E=d.charCodeAt(C);g|=E&(m?65534:0),v+=m&=1&E^1}if(g||1!==d.charCodeAt(v))throw new Error("Invalid RSAES-OAEP padding.");return d.substring(v+1)};var zt=S;!function(){if(zt.prime)zt.prime;else{var e=zt.prime=zt.prime||{},t=zt.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new t(null);n.fromInt(30);var i=function(e,t){return e|t};e.generateProbablePrime=function(e,r,n){"function"==typeof r&&(n=r,r={});var i=(r=r||{}).algorithm||"PRIMEINC";"string"==typeof i&&(i={name:i}),i.options=i.options||{};var s=r.prng||zt.random,u={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===i.name)return function(e,r,n,i){if("workers"in n)return function(e,r,n,i){if("undefined"==typeof Worker)return a(e,r,n,i);var s=o(e,r),u=n.workers,c=n.workLoad||100,l=30*c/8,h=n.workerScript||"forge/prime.worker.js";if(-1===u)return zt.util.estimateCores((function(e,t){e&&(t=2),u=t-1,f()}));function f(){u=Math.max(1,u);for(var n=[],a=0;a<u;++a)n[a]=new Worker(h);for(a=0;a<u;++a)n[a].addEventListener("message",d);var f=!1;function d(a){if(!f){var u=a.data;if(u.found){for(var h=0;h<n.length;++h)n[h].terminate();return f=!0,i(null,new t(u.prime,16))}s.bitLength()>e&&(s=o(e,r));var d=s.toString(16);a.target.postMessage({hex:d,workLoad:c}),s.dAddOffset(l,0)}}}f()}(e,r,n,i);return a(e,r,n,i)}(e,u,i.options,n);throw new Error("Invalid prime generation algorithm: "+i.name)}}function a(e,t,r,n){var i=o(e,t),a=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var u=10;"maxBlockTime"in r&&(u=r.maxBlockTime),s(i,e,t,0,a,u,n)}function s(e,t,n,i,a,u,c){var l=+new Date;do{if(e.bitLength()>t&&(e=o(t,n)),e.isProbablePrime(a))return c(null,e);e.dAddOffset(r[i++%8],0)}while(u<0||+new Date-l<u);zt.util.setImmediate((function(){s(e,t,n,i,a,u,c)}))}function o(e,r){var a=new t(e,r),s=e-1;return a.testBit(s)||a.bitwiseTo(t.ONE.shiftLeft(s),i,a),a.dAddOffset(31-a.mod(n).byteValue(),0),a}}();var jt=S;if(void 0===qt)var qt=jt.jsbn.BigInteger;var Ht=jt.util.isNodejs?s:null,Gt=jt.asn1,Wt=jt.util;jt.pki=jt.pki||{},jt.pki.rsa=jt.rsa=jt.rsa||{};var Qt=jt.pki,Yt=[6,4,2,4,2,4,6,2],Zt={name:"PrivateKeyInfo",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},Xt={name:"RSAPrivateKey",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},$t={name:"RSAPublicKey",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},Jt=jt.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},er=function(e){var t;if(!(e.algorithm in Qt.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=Qt.oids[e.algorithm];var n=Gt.oidToDer(t).getBytes(),i=Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[]),a=Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[]);a.value.push(Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OID,!1,n)),a.value.push(Gt.create(Gt.Class.UNIVERSAL,Gt.Type.NULL,!1,""));var s=Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(a),i.value.push(s),Gt.toDer(i).getBytes()},tr=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var n;t.dP||(t.dP=t.d.mod(t.p.subtract(qt.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(qt.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{n=new qt(jt.util.bytesToHex(jt.random.getBytes(t.n.bitLength()/8)),16)}while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(qt.ONE));for(var i=(e=e.multiply(n.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);i.compareTo(a)<0;)i=i.add(t.p);var s=i.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return s=s.multiply(n.modInverse(t.n)).mod(t.n)};function rr(e,t,r){var n=jt.util.createBuffer(),i=Math.ceil(t.n.bitLength()/8);if(e.length>i-11){var a=new Error("Message is too long for PKCS#1 v1.5 padding.");throw a.length=e.length,a.max=i-11,a}n.putByte(0),n.putByte(r);var s,o=i-3-e.length;if(0===r||1===r){s=0===r?0:255;for(var u=0;u<o;++u)n.putByte(s)}else for(;o>0;){var c=0,l=jt.random.getBytes(o);for(u=0;u<o;++u)0===(s=l.charCodeAt(u))?++c:n.putByte(s);o=c}return n.putByte(0),n.putBytes(e),n}function nr(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8),a=jt.util.createBuffer(e),s=a.getByte(),o=a.getByte();if(0!==s||r&&0!==o&&1!==o||!r&&2!=o||r&&0===o&&void 0===n)throw new Error("Encryption block is invalid.");var u=0;if(0===o){u=i-3-n;for(var c=0;c<u;++c)if(0!==a.getByte())throw new Error("Encryption block is invalid.")}else if(1===o)for(u=0;a.length()>1;){if(255!==a.getByte()){--a.read;break}++u}else if(2===o)for(u=0;a.length()>1;){if(0===a.getByte()){--a.read;break}++u}if(0!==a.getByte()||u!==i-3-a.length())throw new Error("Encryption block is invalid.");return a.getBytes()}function ir(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=jt.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function ar(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function sr(e){return jt.util.isNodejs&&"function"==typeof Ht[e]}function or(e){return void 0!==Wt.globalScope&&"object"==typeof Wt.globalScope.crypto&&"object"==typeof Wt.globalScope.crypto.subtle&&"function"==typeof Wt.globalScope.crypto.subtle[e]}function ur(e){return void 0!==Wt.globalScope&&"object"==typeof Wt.globalScope.msCrypto&&"object"==typeof Wt.globalScope.msCrypto.subtle&&"function"==typeof Wt.globalScope.msCrypto.subtle[e]}function cr(e){for(var t=jt.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}Qt.rsa.encrypt=function(e,t,r){var n,i=r,a=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(i=2===r,n=rr(e,t,r)):(n=jt.util.createBuffer()).putBytes(e);for(var s=new qt(n.toHex(),16),o=tr(s,t,i).toString(16),u=jt.util.createBuffer(),c=a-Math.ceil(o.length/2);c>0;)u.putByte(0),--c;return u.putBytes(jt.util.hexToBytes(o)),u.getBytes()},Qt.rsa.decrypt=function(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8);if(e.length!==i){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=i,a}var s=new qt(jt.util.createBuffer(e).toHex(),16);if(s.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var o=tr(s,t,r).toString(16),u=jt.util.createBuffer(),c=i-Math.ceil(o.length/2);c>0;)u.putByte(0),--c;return u.putBytes(jt.util.hexToBytes(o)),!1!==n?nr(u.getBytes(),t,r):u.getBytes()},Qt.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var n,i=(r=r||{}).prng||jt.random,a={nextBytes:function(e){for(var t=i.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},s=r.algorithm||"PRIMEINC";if("PRIMEINC"!==s)throw new Error("Invalid key generation algorithm: "+s);return(n={algorithm:s,state:0,bits:e,rng:a,eInt:t||65537,e:new qt(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},Qt.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new qt(null);r.fromInt(30);for(var n,i=0,a=function(e,t){return e|t},s=+new Date,o=0;null===e.keys&&(t<=0||o<t);){if(0===e.state){var u=null===e.p?e.pBits:e.qBits,c=u-1;0===e.pqState?(e.num=new qt(u,e.rng),e.num.testBit(c)||e.num.bitwiseTo(qt.ONE.shiftLeft(c),a,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),i=0,++e.pqState):1===e.pqState?e.num.bitLength()>u?e.pqState=0:e.num.isProbablePrime(ar(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(Yt[i++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(qt.ONE).gcd(e.e).compareTo(qt.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(qt.ONE),e.q1=e.q.subtract(qt.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(qt.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var l=e.e.modInverse(e.phi);e.keys={privateKey:Qt.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:Qt.rsa.setPublicKey(e.n,e.e)}}o+=(n=+new Date)-s,s=n}return null!==e.keys},Qt.rsa.generateKeyPair=function(e,t,r,n){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(n=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(n=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!jt.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(n){if(sr("generateKeyPair"))return Ht.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return n(e);n(null,{privateKey:Qt.privateKeyFromPem(r),publicKey:Qt.publicKeyFromPem(t)})}));if(or("generateKey")&&or("exportKey"))return Wt.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:cr(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return Wt.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){n(e)})).then((function(e){if(e){var t=Qt.privateKeyFromAsn1(Gt.fromDer(jt.util.createBuffer(e)));n(null,{privateKey:t,publicKey:Qt.setRsaPublicKey(t.n,t.e)})}}));if(ur("generateKey")&&ur("exportKey")){var i=Wt.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:cr(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return i.oncomplete=function(e){var t=e.target.result,r=Wt.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=Qt.privateKeyFromAsn1(Gt.fromDer(jt.util.createBuffer(t)));n(null,{privateKey:r,publicKey:Qt.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){n(e)}},void(i.onerror=function(e){n(e)})}}else if(sr("generateKeyPairSync")){var a=Ht.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:Qt.privateKeyFromPem(a.privateKey),publicKey:Qt.publicKeyFromPem(a.publicKey)}}var s=Qt.rsa.createKeyPairGenerationState(e,t,r);if(!n)return Qt.rsa.stepKeyPairGenerationState(s,0),s.keys;!function(e,t,r){"function"==typeof t&&(r=t,t={});t=t||{};var n={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(n.prng=t.prng);function i(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?s(t,e.q):void a(e.qBits,s))}))}function a(e,t){jt.prime.generateProbablePrime(e,n,t)}function s(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var o=e.p;e.p=e.q,e.q=o}if(0!==e.p.subtract(qt.ONE).gcd(e.e).compareTo(qt.ONE))return e.p=null,void i();if(0!==e.q.subtract(qt.ONE).gcd(e.e).compareTo(qt.ONE))return e.q=null,void a(e.qBits,s);if(e.p1=e.p.subtract(qt.ONE),e.q1=e.q.subtract(qt.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(qt.ONE))return e.p=e.q=null,void i();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,s);var u=e.e.modInverse(e.phi);e.keys={privateKey:Qt.rsa.setPrivateKey(e.n,e.e,u,e.p,e.q,u.mod(e.p1),u.mod(e.q1),e.q.modInverse(e.p)),publicKey:Qt.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}i()}(s,r,n)},Qt.setRsaPublicKey=Qt.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return rr(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return jt.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var i=t.encode(e,r,!0);return Qt.rsa.encrypt(i,r,!0)},verify:function(e,t,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=nr(t,r,!0),e===Gt.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===(t=nr(t,r,!0))}});var i=Qt.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},Qt.setRsaPrivateKey=Qt.rsa.setPrivateKey=function(e,t,r,n,i,a,s,o){var u={n:e,e:t,d:r,p:n,q:i,dP:a,dQ:s,qInv:o,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var n=Qt.rsa.decrypt(e,u,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:nr};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return jt.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,u,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:er},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,u.n.bitLength());return Qt.rsa.encrypt(n,u,r)}};return u},Qt.wrapRsaPrivateKey=function(e){return Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,Gt.integerToDer(0).getBytes()),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OID,!1,Gt.oidToDer(Qt.oids.rsaEncryption).getBytes()),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.NULL,!1,"")]),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OCTETSTRING,!1,Gt.toDer(e).getBytes())])},Qt.privateKeyFromAsn1=function(e){var t,r,n,i,a,s,o,u,c={},l=[];if(Gt.validate(e,Zt,c,l)&&(e=Gt.fromDer(jt.util.createBuffer(c.privateKey))),c={},l=[],!Gt.validate(e,Xt,c,l)){var h=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw h.errors=l,h}return t=jt.util.createBuffer(c.privateKeyModulus).toHex(),r=jt.util.createBuffer(c.privateKeyPublicExponent).toHex(),n=jt.util.createBuffer(c.privateKeyPrivateExponent).toHex(),i=jt.util.createBuffer(c.privateKeyPrime1).toHex(),a=jt.util.createBuffer(c.privateKeyPrime2).toHex(),s=jt.util.createBuffer(c.privateKeyExponent1).toHex(),o=jt.util.createBuffer(c.privateKeyExponent2).toHex(),u=jt.util.createBuffer(c.privateKeyCoefficient).toHex(),Qt.setRsaPrivateKey(new qt(t,16),new qt(r,16),new qt(n,16),new qt(i,16),new qt(a,16),new qt(s,16),new qt(o,16),new qt(u,16))},Qt.privateKeyToAsn1=Qt.privateKeyToRSAPrivateKey=function(e){return Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,Gt.integerToDer(0).getBytes()),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.n)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.e)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.d)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.p)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.q)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.dP)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.dQ)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.qInv))])},Qt.publicKeyFromAsn1=function(e){var t={},r=[];if(Gt.validate(e,Jt,t,r)){var n,i=Gt.derToOid(t.publicKeyOid);if(i!==Qt.oids.rsaEncryption)throw(n=new Error("Cannot read public key. Unknown OID.")).oid=i,n;e=t.rsaPublicKey}if(r=[],!Gt.validate(e,$t,t,r))throw(n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,n;var a=jt.util.createBuffer(t.publicKeyModulus).toHex(),s=jt.util.createBuffer(t.publicKeyExponent).toHex();return Qt.setRsaPublicKey(new qt(a,16),new qt(s,16))},Qt.publicKeyToAsn1=Qt.publicKeyToSubjectPublicKeyInfo=function(e){return Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OID,!1,Gt.oidToDer(Qt.oids.rsaEncryption).getBytes()),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.NULL,!1,"")]),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.BITSTRING,!1,[Qt.publicKeyToRSAPublicKey(e)])])},Qt.publicKeyToRSAPublicKey=function(e){return Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.n)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.e))])};var lr=S;if(void 0===hr)var hr=lr.jsbn.BigInteger;var fr=lr.asn1,dr=lr.pki=lr.pki||{};dr.pbe=lr.pbe=lr.pbe||{};var pr=dr.oids,gr={name:"EncryptedPrivateKeyInfo",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},yr={name:"PBES2Algorithms",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:fr.Class.UNIVERSAL,type:fr.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:fr.Class.UNIVERSAL,type:fr.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},mr={name:"pkcs-12PbeParams",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:fr.Class.UNIVERSAL,type:fr.Type.INTEGER,constructed:!1,capture:"iterations"}]};function vr(e,t){return e.start().update(t).digest().getBytes()}function Cr(e){var t;if(e){if(!(t=dr.oids[fr.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return Er(t)}function Er(e){var t=lr.md;switch(e){case"hmacWithSHA224":t=lr.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}dr.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n,i,a,s=lr.random.getBytesSync(r.saltSize),o=r.count,u=fr.integerToDer(o);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var c,l,h;switch(r.algorithm){case"aes128":n=16,c=16,l=pr["aes128-CBC"],h=lr.aes.createEncryptionCipher;break;case"aes192":n=24,c=16,l=pr["aes192-CBC"],h=lr.aes.createEncryptionCipher;break;case"aes256":n=32,c=16,l=pr["aes256-CBC"],h=lr.aes.createEncryptionCipher;break;case"des":n=8,c=8,l=pr.desCBC,h=lr.des.createEncryptionCipher;break;default:throw(m=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,m}var f="hmacWith"+r.prfAlgorithm.toUpperCase(),d=Er(f),p=lr.pkcs5.pbkdf2(t,s,o,n,d),g=lr.random.getBytesSync(c);(v=h(p)).start(g),v.update(fr.toDer(e)),v.finish(),a=v.output.getBytes();var y=function(e,t,r,n){var i=fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OCTETSTRING,!1,e),fr.create(fr.Class.UNIVERSAL,fr.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==n&&i.value.push(fr.create(fr.Class.UNIVERSAL,fr.Type.INTEGER,!1,lr.util.hexToBytes(r.toString(16))),fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(dr.oids[n]).getBytes()),fr.create(fr.Class.UNIVERSAL,fr.Type.NULL,!1,"")]));return i}(s,u,n,f);i=fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(pr.pkcs5PBES2).getBytes()),fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(pr.pkcs5PBKDF2).getBytes()),y]),fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(l).getBytes()),fr.create(fr.Class.UNIVERSAL,fr.Type.OCTETSTRING,!1,g)])])])}else{var m;if("3des"!==r.algorithm)throw(m=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,m;n=24;var v,C=new lr.util.ByteBuffer(s);p=dr.pbe.generatePkcs12Key(t,C,1,o,n),g=dr.pbe.generatePkcs12Key(t,C,2,o,n);(v=lr.des.createEncryptionCipher(p)).start(g),v.update(fr.toDer(e)),v.finish(),a=v.output.getBytes(),i=fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(pr["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OCTETSTRING,!1,s),fr.create(fr.Class.UNIVERSAL,fr.Type.INTEGER,!1,u.getBytes())])])}return fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[i,fr.create(fr.Class.UNIVERSAL,fr.Type.OCTETSTRING,!1,a)])},dr.decryptPrivateKeyInfo=function(e,t){var r=null,n={},i=[];if(!fr.validate(e,gr,n,i)){var a=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=i,a}var s=fr.derToOid(n.encryptionOid),o=dr.pbe.getCipher(s,n.encryptionParams,t),u=lr.util.createBuffer(n.encryptedData);return o.update(u),o.finish()&&(r=fr.fromDer(o.output)),r},dr.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:fr.toDer(e).getBytes()};return lr.pem.encode(r,{maxline:t})},dr.encryptedPrivateKeyFromPem=function(e){var t=lr.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return fr.fromDer(t.body)},dr.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var n=dr.wrapRsaPrivateKey(dr.privateKeyToAsn1(e));return n=dr.encryptPrivateKeyInfo(n,t,r),dr.encryptedPrivateKeyToPem(n)}var i,a,s,o;switch(r.algorithm){case"aes128":i="AES-128-CBC",s=16,a=lr.random.getBytesSync(16),o=lr.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",s=24,a=lr.random.getBytesSync(16),o=lr.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",s=32,a=lr.random.getBytesSync(16),o=lr.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",s=24,a=lr.random.getBytesSync(8),o=lr.des.createEncryptionCipher;break;case"des":i="DES-CBC",s=8,a=lr.random.getBytesSync(8),o=lr.des.createEncryptionCipher;break;default:var u=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw u.algorithm=r.algorithm,u}var c=o(lr.pbe.opensslDeriveBytes(t,a.substr(0,8),s));c.start(a),c.update(fr.toDer(dr.privateKeyToAsn1(e))),c.finish();var l={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:lr.util.bytesToHex(a).toUpperCase()},body:c.output.getBytes()};return lr.pem.encode(l)},dr.decryptRsaPrivateKey=function(e,t){var r=null,n=lr.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw(s=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=s,s;if(n.procType&&"ENCRYPTED"===n.procType.type){var i,a;switch(n.dekInfo.algorithm){case"DES-CBC":i=8,a=lr.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,a=lr.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,a=lr.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,a=lr.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,a=lr.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,a=function(e){return lr.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":i=8,a=function(e){return lr.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":i=16,a=function(e){return lr.rc2.createDecryptionCipher(e,128)};break;default:var s;throw(s=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".')).algorithm=n.dekInfo.algorithm,s}var o=lr.util.hexToBytes(n.dekInfo.parameters),u=a(lr.pbe.opensslDeriveBytes(t,o.substr(0,8),i));if(u.start(o),u.update(lr.util.createBuffer(n.body)),!u.finish())return r;r=u.output.getBytes()}else r=n.body;return null!==(r="ENCRYPTED PRIVATE KEY"===n.type?dr.decryptPrivateKeyInfo(fr.fromDer(r),t):fr.fromDer(r))&&(r=dr.privateKeyFromAsn1(r)),r},dr.pbe.generatePkcs12Key=function(e,t,r,n,i,a){var s,o;if(null==a){if(!("sha1"in lr.md))throw new Error('"sha1" hash algorithm unavailable.');a=lr.md.sha1.create()}var u=a.digestLength,c=a.blockLength,l=new lr.util.ByteBuffer,h=new lr.util.ByteBuffer;if(null!=e){for(o=0;o<e.length;o++)h.putInt16(e.charCodeAt(o));h.putInt16(0)}var f=h.length(),d=t.length(),p=new lr.util.ByteBuffer;p.fillWithByte(r,c);var g=c*Math.ceil(d/c),y=new lr.util.ByteBuffer;for(o=0;o<g;o++)y.putByte(t.at(o%d));var m=c*Math.ceil(f/c),v=new lr.util.ByteBuffer;for(o=0;o<m;o++)v.putByte(h.at(o%f));var C=y;C.putBuffer(v);for(var E=Math.ceil(i/u),b=1;b<=E;b++){var S=new lr.util.ByteBuffer;S.putBytes(p.bytes()),S.putBytes(C.bytes());for(var T=0;T<n;T++)a.start(),a.update(S.getBytes()),S=a.digest();var _=new lr.util.ByteBuffer;for(o=0;o<c;o++)_.putByte(S.at(o%u));var w=Math.ceil(d/c)+Math.ceil(f/c),I=new lr.util.ByteBuffer;for(s=0;s<w;s++){var A=new lr.util.ByteBuffer(C.getBytes(c)),B=511;for(o=_.length()-1;o>=0;o--)B>>=8,B+=_.at(o)+A.at(o),A.setAt(o,255&B);I.putBuffer(A)}C=I,l.putBuffer(S)}return l.truncate(l.length()-i),l},dr.pbe.getCipher=function(e,t,r){switch(e){case dr.oids.pkcs5PBES2:return dr.pbe.getCipherForPBES2(e,t,r);case dr.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case dr.oids["pbewithSHAAnd40BitRC2-CBC"]:return dr.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},dr.pbe.getCipherForPBES2=function(e,t,r){var n,i={},a=[];if(!fr.validate(t,yr,i,a))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,n;if((e=fr.derToOid(i.kdfOid))!==dr.oids.pkcs5PBKDF2)throw(n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,n.supportedOids=["pkcs5PBKDF2"],n;if((e=fr.derToOid(i.encOid))!==dr.oids["aes128-CBC"]&&e!==dr.oids["aes192-CBC"]&&e!==dr.oids["aes256-CBC"]&&e!==dr.oids["des-EDE3-CBC"]&&e!==dr.oids.desCBC)throw(n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n;var s,o,u=i.kdfSalt,c=lr.util.createBuffer(i.kdfIterationCount);switch(c=c.getInt(c.length()<<3),dr.oids[e]){case"aes128-CBC":s=16,o=lr.aes.createDecryptionCipher;break;case"aes192-CBC":s=24,o=lr.aes.createDecryptionCipher;break;case"aes256-CBC":s=32,o=lr.aes.createDecryptionCipher;break;case"des-EDE3-CBC":s=24,o=lr.des.createDecryptionCipher;break;case"desCBC":s=8,o=lr.des.createDecryptionCipher}var l=Cr(i.prfOid),h=lr.pkcs5.pbkdf2(r,u,c,s,l),f=i.encIv,d=o(h);return d.start(f),d},dr.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},i=[];if(!fr.validate(t,mr,n,i))throw(l=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=i,l;var a,s,o,u=lr.util.createBuffer(n.salt),c=lr.util.createBuffer(n.iterations);switch(c=c.getInt(c.length()<<3),e){case dr.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:a=24,s=8,o=lr.des.startDecrypting;break;case dr.oids["pbewithSHAAnd40BitRC2-CBC"]:a=5,s=8,o=function(e,t){var r=lr.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var l;throw(l=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,l}var h=Cr(n.prfOid),f=dr.pbe.generatePkcs12Key(r,u,1,c,a,h);return h.start(),o(f,dr.pbe.generatePkcs12Key(r,u,2,c,s,h))},dr.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!("md5"in lr.md))throw new Error('"md5" hash algorithm unavailable.');n=lr.md.md5.create()}null===t&&(t="");for(var i=[vr(n,e+t)],a=16,s=1;a<r;++s,a+=16)i.push(vr(n,i[s-1]+e+t));return i.join("").substr(0,r)};var br=S,Sr=br.asn1,Tr=br.pkcs7asn1=br.pkcs7asn1||{};br.pkcs7=br.pkcs7||{},br.pkcs7.asn1=Tr;var _r={name:"ContentInfo",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};Tr.contentInfoValidator=_r;var wr={name:"EncryptedContentInfo",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:Sr.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};Tr.envelopedDataValidator={name:"EnvelopedData",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(wr)},Tr.encryptedDataValidator={name:"EncryptedData",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"version"}].concat(wr)};var Ir={name:"SignerInfo",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:Sr.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};Tr.signedDataValidator={name:"SignedData",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},_r,{name:"SignedData.Certificates",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SET,capture:"signerInfos",optional:!0,value:[Ir]}]},Tr.recipientInfoValidator={name:"RecipientInfo",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:Sr.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]};var Ar=S;Ar.mgf=Ar.mgf||{},(Ar.mgf.mgf1=Ar.mgf1=Ar.mgf1||{}).create=function(e){var t={generate:function(t,r){for(var n=new Ar.util.ByteBuffer,i=Math.ceil(r/e.digestLength),a=0;a<i;a++){var s=new Ar.util.ByteBuffer;s.putInt32(a),e.start(),e.update(t+s.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}};return t};var Br=S;Br.mgf=Br.mgf||{},Br.mgf.mgf1=Br.mgf1;var kr=S;(kr.pss=kr.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,n=e.mgf,i=r.digestLength,a=e.salt||null;if("string"==typeof a&&(a=kr.util.createBuffer(a)),"saltLength"in e)t=e.saltLength;else{if(null===a)throw new Error("Salt length not specified or specific salt not given.");t=a.length()}if(null!==a&&a.length()!==t)throw new Error("Given salt length does not match length of given salt.");var s=e.prng||kr.random,o={encode:function(e,o){var u,c,l=o-1,h=Math.ceil(l/8),f=e.digest().getBytes();if(h<i+t+2)throw new Error("Message is too long to encrypt.");c=null===a?s.getBytesSync(t):a.bytes();var d=new kr.util.ByteBuffer;d.fillWithByte(0,8),d.putBytes(f),d.putBytes(c),r.start(),r.update(d.getBytes());var p=r.digest().getBytes(),g=new kr.util.ByteBuffer;g.fillWithByte(0,h-t-i-2),g.putByte(1),g.putBytes(c);var y=g.getBytes(),m=h-i-1,v=n.generate(p,m),C="";for(u=0;u<m;u++)C+=String.fromCharCode(y.charCodeAt(u)^v.charCodeAt(u));var E=65280>>8*h-l&255;return(C=String.fromCharCode(C.charCodeAt(0)&~E)+C.substr(1))+p+String.fromCharCode(188)},verify:function(e,a,s){var o,u=s-1,c=Math.ceil(u/8);if(a=a.substr(-c),c<i+t+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==a.charCodeAt(c-1))throw new Error("Encoded message does not end in 0xBC.");var l=c-i-1,h=a.substr(0,l),f=a.substr(l,i),d=65280>>8*c-u&255;if(0!=(h.charCodeAt(0)&d))throw new Error("Bits beyond keysize not zero as expected.");var p=n.generate(f,l),g="";for(o=0;o<l;o++)g+=String.fromCharCode(h.charCodeAt(o)^p.charCodeAt(o));g=String.fromCharCode(g.charCodeAt(0)&~d)+g.substr(1);var y=c-i-t-2;for(o=0;o<y;o++)if(0!==g.charCodeAt(o))throw new Error("Leftmost octets not zero as expected");if(1!==g.charCodeAt(y))throw new Error("Inconsistent PSS signature, 0x01 marker not found");var m=g.substr(-t),v=new kr.util.ByteBuffer;return v.fillWithByte(0,8),v.putBytes(e),v.putBytes(m),r.start(),r.update(v.getBytes()),f===r.digest().getBytes()}};return o};var Nr=S,Rr=Nr.asn1,Lr=Nr.pki=Nr.pki||{},Dr=Lr.oids,Ur={};Ur.CN=Dr.commonName,Ur.commonName="CN",Ur.C=Dr.countryName,Ur.countryName="C",Ur.L=Dr.localityName,Ur.localityName="L",Ur.ST=Dr.stateOrProvinceName,Ur.stateOrProvinceName="ST",Ur.O=Dr.organizationName,Ur.organizationName="O",Ur.OU=Dr.organizationalUnitName,Ur.organizationalUnitName="OU",Ur.E=Dr.emailAddress,Ur.emailAddress="E";var xr=Nr.pki.rsa.publicKeyValidator,Or={name:"Certificate",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:Rr.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},xr,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:Rr.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},Pr={name:"rsapss",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:Rr.Class.UNIVERSAL,type:Rr.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:Rr.Class.UNIVERSAL,type:Rr.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:Rr.Class.UNIVERSAL,type:Rr.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:Rr.Class.UNIVERSAL,type:Rr.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},Vr={name:"CertificationRequestInfo",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},xr,{name:"CertificationRequestInfo.attributes",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SET,constructed:!0}]}]}]},Kr={name:"CertificationRequest",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[Vr,{name:"CertificationRequest.signatureAlgorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:Rr.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function Mr(e,t){"string"==typeof t&&(t={shortName:t});for(var r,n=null,i=0;null===n&&i<e.attributes.length;++i)r=e.attributes[i],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(n=r);return n}Lr.RDNAttributesAsArray=function(e,t){for(var r,n,i,a=[],s=0;s<e.value.length;++s){r=e.value[s];for(var o=0;o<r.value.length;++o)i={},n=r.value[o],i.type=Rr.derToOid(n.value[0].value),i.value=n.value[1].value,i.valueTagClass=n.value[1].type,i.type in Dr&&(i.name=Dr[i.type],i.name in Ur&&(i.shortName=Ur[i.name])),t&&(t.update(i.type),t.update(i.value)),a.push(i)}return a},Lr.CRIAttributesAsArray=function(e){for(var t=[],r=0;r<e.length;++r)for(var n=e[r],i=Rr.derToOid(n.value[0].value),a=n.value[1].value,s=0;s<a.length;++s){var o={};if(o.type=i,o.value=a[s].value,o.valueTagClass=a[s].type,o.type in Dr&&(o.name=Dr[o.type],o.name in Ur&&(o.shortName=Ur[o.name])),o.type===Dr.extensionRequest){o.extensions=[];for(var u=0;u<o.value.length;++u)o.extensions.push(Lr.certificateExtensionFromAsn1(o.value[u]))}t.push(o)}return t};var Fr=function(e,t,r){var n={};if(e!==Dr["RSASSA-PSS"])return n;r&&(n={hash:{algorithmOid:Dr.sha1},mgf:{algorithmOid:Dr.mgf1,hash:{algorithmOid:Dr.sha1}},saltLength:20});var i={},a=[];if(!Rr.validate(t,Pr,i,a)){var s=new Error("Cannot read RSASSA-PSS parameter block.");throw s.errors=a,s}return void 0!==i.hashOid&&(n.hash=n.hash||{},n.hash.algorithmOid=Rr.derToOid(i.hashOid)),void 0!==i.maskGenOid&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=Rr.derToOid(i.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=Rr.derToOid(i.maskGenHashOid)),void 0!==i.saltLength&&(n.saltLength=i.saltLength.charCodeAt(0)),n};function zr(e){for(var t,r,n=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]),i=e.attributes,a=0;a<i.length;++a){var s=(t=i[a]).value,o=Rr.Type.PRINTABLESTRING;"valueTagClass"in t&&(o=t.valueTagClass)===Rr.Type.UTF8&&(s=Nr.util.encodeUtf8(s)),r=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SET,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(t.type).getBytes()),Rr.create(Rr.Class.UNIVERSAL,o,!1,s)])]),n.value.push(r)}return n}function jr(e){for(var t,r=0;r<e.length;++r){if(void 0===(t=e[r]).name&&(t.type&&t.type in Lr.oids?t.name=Lr.oids[t.type]:t.shortName&&t.shortName in Ur&&(t.name=Lr.oids[Ur[t.shortName]])),void 0===t.type){if(!t.name||!(t.name in Lr.oids))throw(i=new Error("Attribute type not specified.")).attribute=t,i;t.type=Lr.oids[t.name]}if(void 0===t.shortName&&t.name&&t.name in Ur&&(t.shortName=Ur[t.name]),t.type===Dr.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=Rr.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var n=0;n<t.extensions.length;++n)t.value.push(Lr.certificateExtensionToAsn1(qr(t.extensions[n])))}var i;if(void 0===t.value)throw(i=new Error("Attribute value not specified.")).attribute=t,i}}function qr(e,t){if(t=t||{},void 0===e.name&&e.id&&e.id in Lr.oids&&(e.name=Lr.oids[e.id]),void 0===e.id){if(!e.name||!(e.name in Lr.oids))throw(y=new Error("Extension ID not specified.")).extension=e,y;e.id=Lr.oids[e.name]}if(void 0!==e.value)return e;if("keyUsage"===e.name){var r=0,n=0,i=0;e.digitalSignature&&(n|=128,r=7),e.nonRepudiation&&(n|=64,r=6),e.keyEncipherment&&(n|=32,r=5),e.dataEncipherment&&(n|=16,r=4),e.keyAgreement&&(n|=8,r=3),e.keyCertSign&&(n|=4,r=2),e.cRLSign&&(n|=2,r=1),e.encipherOnly&&(n|=1,r=0),e.decipherOnly&&(i|=128,r=7);var a=String.fromCharCode(r);0!==i?a+=String.fromCharCode(n)+String.fromCharCode(i):0!==n&&(a+=String.fromCharCode(n)),e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,a)}else if("basicConstraints"===e.name)e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Rr.integerToDer(e.pathLenConstraint).getBytes()));else if("extKeyUsage"===e.name){e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);var s=e.value.value;for(var o in e)!0===e[o]&&(o in Dr?s.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(Dr[o]).getBytes())):-1!==o.indexOf(".")&&s.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(o).getBytes())))}else if("nsCertType"===e.name){r=0,n=0;e.client&&(n|=128,r=7),e.server&&(n|=64,r=6),e.email&&(n|=32,r=5),e.objsign&&(n|=16,r=4),e.reserved&&(n|=8,r=3),e.sslCA&&(n|=4,r=2),e.emailCA&&(n|=2,r=1),e.objCA&&(n|=1,r=0);a=String.fromCharCode(r);0!==n&&(a+=String.fromCharCode(n)),e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,a)}else if("subjectAltName"===e.name||"issuerAltName"===e.name){e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);for(var u=0;u<e.altNames.length;++u){a=(d=e.altNames[u]).value;if(7===d.type&&d.ip){if(null===(a=Nr.util.bytesFromIP(d.ip)))throw(y=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,y}else 8===d.type&&(a=d.oid?Rr.oidToDer(Rr.oidToDer(d.oid)):Rr.oidToDer(a));e.value.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,d.type,!1,a))}}else if("nsComment"===e.name&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&t.cert){var c=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=c.toHex(),e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OCTETSTRING,!1,c.getBytes())}else if("authorityKeyIdentifier"===e.name&&t.cert){e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);s=e.value.value;if(e.keyIdentifier){var l=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;s.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!1,l))}if(e.authorityCertIssuer){var h=[Rr.create(Rr.Class.CONTEXT_SPECIFIC,4,!0,[zr(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];s.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,1,!0,h))}if(e.serialNumber){var f=Nr.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);s.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,2,!1,f))}}else if("cRLDistributionPoints"===e.name){e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);s=e.value.value;var d,p=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]),g=Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[]);for(u=0;u<e.altNames.length;++u){a=(d=e.altNames[u]).value;if(7===d.type&&d.ip){if(null===(a=Nr.util.bytesFromIP(d.ip)))throw(y=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,y}else 8===d.type&&(a=d.oid?Rr.oidToDer(Rr.oidToDer(d.oid)):Rr.oidToDer(a));g.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,d.type,!1,a))}p.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[g])),s.push(p)}var y;if(void 0===e.value)throw(y=new Error("Extension value not specified.")).extension=e,y;return e}function Hr(e,t){if(e===Dr["RSASSA-PSS"]){var r=[];return void 0!==t.hash.algorithmOid&&r.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(t.hash.algorithmOid).getBytes()),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.NULL,!1,"")])])),void 0!==t.mgf.algorithmOid&&r.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,1,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(t.mgf.algorithmOid).getBytes()),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(t.mgf.hash.algorithmOid).getBytes()),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.NULL,!1,"")])])])),void 0!==t.saltLength&&r.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,2,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Rr.integerToDer(t.saltLength).getBytes())])),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,r)}return Rr.create(Rr.Class.UNIVERSAL,Rr.Type.NULL,!1,"")}function Gr(e){var t=Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===e.attributes.length)return t;for(var r=e.attributes,n=0;n<r.length;++n){var i=r[n],a=i.value,s=Rr.Type.UTF8;"valueTagClass"in i&&(s=i.valueTagClass),s===Rr.Type.UTF8&&(a=Nr.util.encodeUtf8(a));var o=!1;"valueConstructed"in i&&(o=i.valueConstructed);var u=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(i.type).getBytes()),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SET,!0,[Rr.create(Rr.Class.UNIVERSAL,s,o,a)])]);t.value.push(u)}return t}Lr.certificateFromPem=function(e,t,r){var n=Nr.pem.decode(e)[0];if("CERTIFICATE"!==n.type&&"X509 CERTIFICATE"!==n.type&&"TRUSTED CERTIFICATE"!==n.type){var i=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var a=Rr.fromDer(n.body,r);return Lr.certificateFromAsn1(a,t)},Lr.certificateToPem=function(e,t){var r={type:"CERTIFICATE",body:Rr.toDer(Lr.certificateToAsn1(e)).getBytes()};return Nr.pem.encode(r,{maxline:t})},Lr.publicKeyFromPem=function(e){var t=Nr.pem.decode(e)[0];if("PUBLIC KEY"!==t.type&&"RSA PUBLIC KEY"!==t.type){var r=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert public key from PEM; PEM is encrypted.");var n=Rr.fromDer(t.body);return Lr.publicKeyFromAsn1(n)},Lr.publicKeyToPem=function(e,t){var r={type:"PUBLIC KEY",body:Rr.toDer(Lr.publicKeyToAsn1(e)).getBytes()};return Nr.pem.encode(r,{maxline:t})},Lr.publicKeyToRSAPublicKeyPem=function(e,t){var r={type:"RSA PUBLIC KEY",body:Rr.toDer(Lr.publicKeyToRSAPublicKey(e)).getBytes()};return Nr.pem.encode(r,{maxline:t})},Lr.getPublicKeyFingerprint=function(e,t){var r,n=(t=t||{}).md||Nr.md.sha1.create();switch(t.type||"RSAPublicKey"){case"RSAPublicKey":r=Rr.toDer(Lr.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":r=Rr.toDer(Lr.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+t.type+'".')}n.start(),n.update(r);var i=n.digest();if("hex"===t.encoding){var a=i.toHex();return t.delimiter?a.match(/.{2}/g).join(t.delimiter):a}if("binary"===t.encoding)return i.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return i},Lr.certificationRequestFromPem=function(e,t,r){var n=Nr.pem.decode(e)[0];if("CERTIFICATE REQUEST"!==n.type){var i=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var a=Rr.fromDer(n.body,r);return Lr.certificationRequestFromAsn1(a,t)},Lr.certificationRequestToPem=function(e,t){var r={type:"CERTIFICATE REQUEST",body:Rr.toDer(Lr.certificationRequestToAsn1(e)).getBytes()};return Nr.pem.encode(r,{maxline:t})},Lr.createCertificate=function(){var e={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return Mr(e.issuer,t)},e.issuer.addField=function(t){jr([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return Mr(e.subject,t)},e.subject.addField=function(t){jr([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,r){jr(t),e.subject.attributes=t,delete e.subject.uniqueId,r&&(e.subject.uniqueId=r),e.subject.hash=null},e.setIssuer=function(t,r){jr(t),e.issuer.attributes=t,delete e.issuer.uniqueId,r&&(e.issuer.uniqueId=r),e.issuer.hash=null},e.setExtensions=function(t){for(var r=0;r<t.length;++r)qr(t[r],{cert:e});e.extensions=t},e.getExtension=function(t){"string"==typeof t&&(t={name:t});for(var r,n=null,i=0;null===n&&i<e.extensions.length;++i)r=e.extensions[i],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(n=r);return n},e.sign=function(t,r){e.md=r||Nr.md.sha1.create();var n=Dr[e.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw i.algorithm=e.md.algorithm,i}e.signatureOid=e.siginfo.algorithmOid=n,e.tbsCertificate=Lr.getTBSCertificate(e);var a=Rr.toDer(e.tbsCertificate);e.md.update(a.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var r=!1;if(!e.issued(t)){var n=t.issuer,i=e.subject;throw(h=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.")).expectedIssuer=n.attributes,h.actualIssuer=i.attributes,h}var a=t.md;if(null===a){if(t.signatureOid in Dr)switch(Dr[t.signatureOid]){case"sha1WithRSAEncryption":a=Nr.md.sha1.create();break;case"md5WithRSAEncryption":a=Nr.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":a=Nr.md.sha256.create();break;case"sha384WithRSAEncryption":a=Nr.md.sha384.create();break;case"sha512WithRSAEncryption":a=Nr.md.sha512.create()}if(null===a)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=t.signatureOid,h;var s=t.tbsCertificate||Lr.getTBSCertificate(t),o=Rr.toDer(s);a.update(o.getBytes())}if(null!==a){var u;switch(t.signatureOid){case Dr.sha1WithRSAEncryption:u=void 0;break;case Dr["RSASSA-PSS"]:var c,l,h;if(void 0===(c=Dr[t.signatureParameters.mgf.hash.algorithmOid])||void 0===Nr.md[c])throw(h=new Error("Unsupported MGF hash function.")).oid=t.signatureParameters.mgf.hash.algorithmOid,h.name=c,h;if(void 0===(l=Dr[t.signatureParameters.mgf.algorithmOid])||void 0===Nr.mgf[l])throw(h=new Error("Unsupported MGF function.")).oid=t.signatureParameters.mgf.algorithmOid,h.name=l,h;if(l=Nr.mgf[l].create(Nr.md[c].create()),void 0===(c=Dr[t.signatureParameters.hash.algorithmOid])||void 0===Nr.md[c])throw{message:"Unsupported RSASSA-PSS hash function.",oid:t.signatureParameters.hash.algorithmOid,name:c};u=Nr.pss.create(Nr.md[c].create(),l,t.signatureParameters.saltLength)}r=e.publicKey.verify(a.digest().getBytes(),t.signature,u)}return r},e.isIssuer=function(t){var r=!1,n=e.issuer,i=t.subject;if(n.hash&&i.hash)r=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){var a,s;r=!0;for(var o=0;r&&o<n.attributes.length;++o)a=n.attributes[o],s=i.attributes[o],a.type===s.type&&a.value===s.value||(r=!1)}return r},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return Lr.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=Dr.subjectKeyIdentifier,r=0;r<e.extensions.length;++r){var n=e.extensions[r];if(n.id===t){var i=e.generateSubjectKeyIdentifier().getBytes();return Nr.util.hexToBytes(n.subjectKeyIdentifier)===i}}return!1},e},Lr.certificateFromAsn1=function(e,t){var r={},n=[];if(!Rr.validate(e,Or,r,n))throw(o=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.")).errors=n,o;if(Rr.derToOid(r.publicKeyOid)!==Lr.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=Lr.createCertificate();i.version=r.certVersion?r.certVersion.charCodeAt(0):0;var a=Nr.util.createBuffer(r.certSerialNumber);i.serialNumber=a.toHex(),i.signatureOid=Nr.asn1.derToOid(r.certSignatureOid),i.signatureParameters=Fr(i.signatureOid,r.certSignatureParams,!0),i.siginfo.algorithmOid=Nr.asn1.derToOid(r.certinfoSignatureOid),i.siginfo.parameters=Fr(i.siginfo.algorithmOid,r.certinfoSignatureParams,!1),i.signature=r.certSignature;var s=[];if(void 0!==r.certValidity1UTCTime&&s.push(Rr.utcTimeToDate(r.certValidity1UTCTime)),void 0!==r.certValidity2GeneralizedTime&&s.push(Rr.generalizedTimeToDate(r.certValidity2GeneralizedTime)),void 0!==r.certValidity3UTCTime&&s.push(Rr.utcTimeToDate(r.certValidity3UTCTime)),void 0!==r.certValidity4GeneralizedTime&&s.push(Rr.generalizedTimeToDate(r.certValidity4GeneralizedTime)),s.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(s.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(i.validity.notBefore=s[0],i.validity.notAfter=s[1],i.tbsCertificate=r.tbsCertificate,t){var o;if(i.md=null,i.signatureOid in Dr)switch(Dr[i.signatureOid]){case"sha1WithRSAEncryption":i.md=Nr.md.sha1.create();break;case"md5WithRSAEncryption":i.md=Nr.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":i.md=Nr.md.sha256.create();break;case"sha384WithRSAEncryption":i.md=Nr.md.sha384.create();break;case"sha512WithRSAEncryption":i.md=Nr.md.sha512.create()}if(null===i.md)throw(o=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=i.signatureOid,o;var u=Rr.toDer(i.tbsCertificate);i.md.update(u.getBytes())}var c=Nr.md.sha1.create();i.issuer.getField=function(e){return Mr(i.issuer,e)},i.issuer.addField=function(e){jr([e]),i.issuer.attributes.push(e)},i.issuer.attributes=Lr.RDNAttributesAsArray(r.certIssuer,c),r.certIssuerUniqueId&&(i.issuer.uniqueId=r.certIssuerUniqueId),i.issuer.hash=c.digest().toHex();var l=Nr.md.sha1.create();return i.subject.getField=function(e){return Mr(i.subject,e)},i.subject.addField=function(e){jr([e]),i.subject.attributes.push(e)},i.subject.attributes=Lr.RDNAttributesAsArray(r.certSubject,l),r.certSubjectUniqueId&&(i.subject.uniqueId=r.certSubjectUniqueId),i.subject.hash=l.digest().toHex(),r.certExtensions?i.extensions=Lr.certificateExtensionsFromAsn1(r.certExtensions):i.extensions=[],i.publicKey=Lr.publicKeyFromAsn1(r.subjectPublicKeyInfo),i},Lr.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r<e.value.length;++r)for(var n=e.value[r],i=0;i<n.value.length;++i)t.push(Lr.certificateExtensionFromAsn1(n.value[i]));return t},Lr.certificateExtensionFromAsn1=function(e){var t={};if(t.id=Rr.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===Rr.Type.BOOLEAN?(t.critical=0!==e.value[1].value.charCodeAt(0),t.value=e.value[2].value):t.value=e.value[1].value,t.id in Dr)if(t.name=Dr[t.id],"keyUsage"===t.name){var r=0,n=0;(a=Rr.fromDer(t.value)).value.length>1&&(r=a.value.charCodeAt(1),n=a.value.length>2?a.value.charCodeAt(2):0),t.digitalSignature=128==(128&r),t.nonRepudiation=64==(64&r),t.keyEncipherment=32==(32&r),t.dataEncipherment=16==(16&r),t.keyAgreement=8==(8&r),t.keyCertSign=4==(4&r),t.cRLSign=2==(2&r),t.encipherOnly=1==(1&r),t.decipherOnly=128==(128&n)}else if("basicConstraints"===t.name){(a=Rr.fromDer(t.value)).value.length>0&&a.value[0].type===Rr.Type.BOOLEAN?t.cA=0!==a.value[0].value.charCodeAt(0):t.cA=!1;var i=null;a.value.length>0&&a.value[0].type===Rr.Type.INTEGER?i=a.value[0].value:a.value.length>1&&(i=a.value[1].value),null!==i&&(t.pathLenConstraint=Rr.derToInteger(i))}else if("extKeyUsage"===t.name)for(var a=Rr.fromDer(t.value),s=0;s<a.value.length;++s){var o=Rr.derToOid(a.value[s].value);o in Dr?t[Dr[o]]=!0:t[o]=!0}else if("nsCertType"===t.name){r=0;(a=Rr.fromDer(t.value)).value.length>1&&(r=a.value.charCodeAt(1)),t.client=128==(128&r),t.server=64==(64&r),t.email=32==(32&r),t.objsign=16==(16&r),t.reserved=8==(8&r),t.sslCA=4==(4&r),t.emailCA=2==(2&r),t.objCA=1==(1&r)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){var u;t.altNames=[];a=Rr.fromDer(t.value);for(var c=0;c<a.value.length;++c){var l={type:(u=a.value[c]).type,value:u.value};switch(t.altNames.push(l),u.type){case 1:case 2:case 6:break;case 7:l.ip=Nr.util.bytesToIP(u.value);break;case 8:l.oid=Rr.derToOid(u.value)}}}else if("subjectKeyIdentifier"===t.name){a=Rr.fromDer(t.value);t.subjectKeyIdentifier=Nr.util.bytesToHex(a.value)}return t},Lr.certificationRequestFromAsn1=function(e,t){var r={},n=[];if(!Rr.validate(e,Kr,r,n))throw(a=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.")).errors=n,a;if(Rr.derToOid(r.publicKeyOid)!==Lr.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=Lr.createCertificationRequest();if(i.version=r.csrVersion?r.csrVersion.charCodeAt(0):0,i.signatureOid=Nr.asn1.derToOid(r.csrSignatureOid),i.signatureParameters=Fr(i.signatureOid,r.csrSignatureParams,!0),i.siginfo.algorithmOid=Nr.asn1.derToOid(r.csrSignatureOid),i.siginfo.parameters=Fr(i.siginfo.algorithmOid,r.csrSignatureParams,!1),i.signature=r.csrSignature,i.certificationRequestInfo=r.certificationRequestInfo,t){var a;if(i.md=null,i.signatureOid in Dr)switch(Dr[i.signatureOid]){case"sha1WithRSAEncryption":i.md=Nr.md.sha1.create();break;case"md5WithRSAEncryption":i.md=Nr.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":i.md=Nr.md.sha256.create();break;case"sha384WithRSAEncryption":i.md=Nr.md.sha384.create();break;case"sha512WithRSAEncryption":i.md=Nr.md.sha512.create()}if(null===i.md)throw(a=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=i.signatureOid,a;var s=Rr.toDer(i.certificationRequestInfo);i.md.update(s.getBytes())}var o=Nr.md.sha1.create();return i.subject.getField=function(e){return Mr(i.subject,e)},i.subject.addField=function(e){jr([e]),i.subject.attributes.push(e)},i.subject.attributes=Lr.RDNAttributesAsArray(r.certificationRequestInfoSubject,o),i.subject.hash=o.digest().toHex(),i.publicKey=Lr.publicKeyFromAsn1(r.subjectPublicKeyInfo),i.getAttribute=function(e){return Mr(i,e)},i.addAttribute=function(e){jr([e]),i.attributes.push(e)},i.attributes=Lr.CRIAttributesAsArray(r.certificationRequestInfoAttributes||[]),i},Lr.createCertificationRequest=function(){var e={version:0,signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return Mr(e.subject,t)},e.subject.addField=function(t){jr([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return Mr(e,t)},e.addAttribute=function(t){jr([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){jr(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){jr(t),e.attributes=t},e.sign=function(t,r){e.md=r||Nr.md.sha1.create();var n=Dr[e.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw i.algorithm=e.md.algorithm,i}e.signatureOid=e.siginfo.algorithmOid=n,e.certificationRequestInfo=Lr.getCertificationRequestInfo(e);var a=Rr.toDer(e.certificationRequestInfo);e.md.update(a.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,r=e.md;if(null===r){if(e.signatureOid in Dr)switch(Dr[e.signatureOid]){case"sha1WithRSAEncryption":r=Nr.md.sha1.create();break;case"md5WithRSAEncryption":r=Nr.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":r=Nr.md.sha256.create();break;case"sha384WithRSAEncryption":r=Nr.md.sha384.create();break;case"sha512WithRSAEncryption":r=Nr.md.sha512.create()}if(null===r)throw(u=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=e.signatureOid,u;var n=e.certificationRequestInfo||Lr.getCertificationRequestInfo(e),i=Rr.toDer(n);r.update(i.getBytes())}if(null!==r){var a;switch(e.signatureOid){case Dr.sha1WithRSAEncryption:break;case Dr["RSASSA-PSS"]:var s,o,u;if(void 0===(s=Dr[e.signatureParameters.mgf.hash.algorithmOid])||void 0===Nr.md[s])throw(u=new Error("Unsupported MGF hash function.")).oid=e.signatureParameters.mgf.hash.algorithmOid,u.name=s,u;if(void 0===(o=Dr[e.signatureParameters.mgf.algorithmOid])||void 0===Nr.mgf[o])throw(u=new Error("Unsupported MGF function.")).oid=e.signatureParameters.mgf.algorithmOid,u.name=o,u;if(o=Nr.mgf[o].create(Nr.md[s].create()),void 0===(s=Dr[e.signatureParameters.hash.algorithmOid])||void 0===Nr.md[s])throw(u=new Error("Unsupported RSASSA-PSS hash function.")).oid=e.signatureParameters.hash.algorithmOid,u.name=s,u;a=Nr.pss.create(Nr.md[s].create(),o,e.signatureParameters.saltLength)}t=e.publicKey.verify(r.digest().getBytes(),e.signature,a)}return t},e};var Wr=new Date("1950-01-01T00:00:00Z"),Qr=new Date("2050-01-01T00:00:00Z");function Yr(e){return e>=Wr&&e<Qr?Rr.create(Rr.Class.UNIVERSAL,Rr.Type.UTCTIME,!1,Rr.dateToUtcTime(e)):Rr.create(Rr.Class.UNIVERSAL,Rr.Type.GENERALIZEDTIME,!1,Rr.dateToGeneralizedTime(e))}Lr.getTBSCertificate=function(e){var t=Yr(e.validity.notBefore),r=Yr(e.validity.notAfter),n=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Rr.integerToDer(e.version).getBytes())]),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Nr.util.hexToBytes(e.serialNumber)),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(e.siginfo.algorithmOid).getBytes()),Hr(e.siginfo.algorithmOid,e.siginfo.parameters)]),zr(e.issuer),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[t,r]),zr(e.subject),Lr.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&n.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,1,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&n.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,2,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&n.value.push(Lr.certificateExtensionsToAsn1(e.extensions)),n},Lr.getCertificationRequestInfo=function(e){return Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Rr.integerToDer(e.version).getBytes()),zr(e.subject),Lr.publicKeyToAsn1(e.publicKey),Gr(e)])},Lr.distinguishedNameToAsn1=function(e){return zr(e)},Lr.certificateToAsn1=function(e){var t=e.tbsCertificate||Lr.getTBSCertificate(e);return Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[t,Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(e.signatureOid).getBytes()),Hr(e.signatureOid,e.signatureParameters)]),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},Lr.certificateExtensionsToAsn1=function(e){var t=Rr.create(Rr.Class.CONTEXT_SPECIFIC,3,!0,[]),r=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);t.value.push(r);for(var n=0;n<e.length;++n)r.value.push(Lr.certificateExtensionToAsn1(e[n]));return t},Lr.certificateExtensionToAsn1=function(e){var t=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);t.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(e.id).getBytes())),e.critical&&t.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BOOLEAN,!1,String.fromCharCode(255)));var r=e.value;return"string"!=typeof e.value&&(r=Rr.toDer(r).getBytes()),t.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OCTETSTRING,!1,r)),t},Lr.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||Lr.getCertificationRequestInfo(e);return Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[t,Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(e.signatureOid).getBytes()),Hr(e.signatureOid,e.signatureParameters)]),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},Lr.createCaStore=function(e){var t={certs:{}};function r(e){return n(e),t.certs[e.hash]||null}function n(e){if(!e.hash){var t=Nr.md.sha1.create();e.attributes=Lr.RDNAttributesAsArray(zr(e),t),e.hash=t.digest().toHex()}}if(t.getIssuer=function(e){return r(e.issuer)},t.addCertificate=function(e){if("string"==typeof e&&(e=Nr.pki.certificateFromPem(e)),n(e.subject),!t.hasCertificate(e))if(e.subject.hash in t.certs){var r=t.certs[e.subject.hash];Nr.util.isArray(r)||(r=[r]),r.push(e),t.certs[e.subject.hash]=r}else t.certs[e.subject.hash]=e},t.hasCertificate=function(e){"string"==typeof e&&(e=Nr.pki.certificateFromPem(e));var t=r(e.subject);if(!t)return!1;Nr.util.isArray(t)||(t=[t]);for(var n=Rr.toDer(Lr.certificateToAsn1(e)).getBytes(),i=0;i<t.length;++i){if(n===Rr.toDer(Lr.certificateToAsn1(t[i])).getBytes())return!0}return!1},t.listAllCertificates=function(){var e=[];for(var r in t.certs)if(t.certs.hasOwnProperty(r)){var n=t.certs[r];if(Nr.util.isArray(n))for(var i=0;i<n.length;++i)e.push(n[i]);else e.push(n)}return e},t.removeCertificate=function(e){var i;if("string"==typeof e&&(e=Nr.pki.certificateFromPem(e)),n(e.subject),!t.hasCertificate(e))return null;var a=r(e.subject);if(!Nr.util.isArray(a))return i=t.certs[e.subject.hash],delete t.certs[e.subject.hash],i;for(var s=Rr.toDer(Lr.certificateToAsn1(e)).getBytes(),o=0;o<a.length;++o){s===Rr.toDer(Lr.certificateToAsn1(a[o])).getBytes()&&(i=a[o],a.splice(o,1))}return 0===a.length&&delete t.certs[e.subject.hash],i},e)for(var i=0;i<e.length;++i){var a=e[i];t.addCertificate(a)}return t},Lr.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},Lr.verifyCertificateChain=function(e,t,r){"function"==typeof r&&(r={verify:r}),r=r||{};var n=(t=t.slice(0)).slice(0),i=r.validityCheckDate;void 0===i&&(i=new Date);var a=!0,s=null,o=0;do{var u=t.shift(),c=null,l=!1;if(i&&(i<u.validity.notBefore||i>u.validity.notAfter)&&(s={message:"Certificate is not valid yet or has expired.",error:Lr.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:i}),null===s){if(null===(c=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(l=!0,c=u),c){var h=c;Nr.util.isArray(h)||(h=[h]);for(var f=!1;!f&&h.length>0;){c=h.shift();try{f=c.verify(u)}catch(e){}}f||(s={message:"Certificate signature is invalid.",error:Lr.certificateError.bad_certificate})}null!==s||c&&!l||e.hasCertificate(u)||(s={message:"Certificate is not trusted.",error:Lr.certificateError.unknown_ca})}if(null===s&&c&&!u.isIssuer(c)&&(s={message:"Certificate issuer is invalid.",error:Lr.certificateError.bad_certificate}),null===s)for(var d={keyUsage:!0,basicConstraints:!0},p=0;null===s&&p<u.extensions.length;++p){var g=u.extensions[p];g.critical&&!(g.name in d)&&(s={message:"Certificate has an unsupported critical extension.",error:Lr.certificateError.unsupported_certificate})}if(null===s&&(!a||0===t.length&&(!c||l))){var y=u.getExtension("basicConstraints"),m=u.getExtension("keyUsage");if(null!==m&&(m.keyCertSign&&null!==y||(s={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:Lr.certificateError.bad_certificate})),null!==s||null===y||y.cA||(s={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:Lr.certificateError.bad_certificate}),null===s&&null!==m&&"pathLenConstraint"in y)o-1>y.pathLenConstraint&&(s={message:"Certificate basicConstraints pathLenConstraint violated.",error:Lr.certificateError.bad_certificate})}var v=null===s||s.error,C=r.verify?r.verify(v,o,n):v;if(!0!==C)throw!0===v&&(s={message:"The application rejected the certificate.",error:Lr.certificateError.bad_certificate}),(C||0===C)&&("object"!=typeof C||Nr.util.isArray(C)?"string"==typeof C&&(s.error=C):(C.message&&(s.message=C.message),C.error&&(s.error=C.error))),s;s=null,a=!1,++o}while(t.length>0);return!0};var Zr=S,Xr=Zr.asn1,$r=Zr.pki,Jr=Zr.pkcs12=Zr.pkcs12||{},en={name:"ContentInfo",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:Xr.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},tn={name:"PFX",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.INTEGER,constructed:!1,capture:"version"},en,{name:"PFX.macData",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:Xr.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},rn={name:"SafeBag",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:Xr.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},nn={name:"Attribute",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SET,constructed:!0,capture:"values"}]},an={name:"CertBag",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:Xr.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:Xr.Class.UNIVERSAL,type:Xr.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function sn(e,t,r,n){for(var i=[],a=0;a<e.length;a++)for(var s=0;s<e[a].safeBags.length;s++){var o=e[a].safeBags[s];void 0!==n&&o.type!==n||(null!==t?void 0!==o.attributes[t]&&o.attributes[t].indexOf(r)>=0&&i.push(o):i.push(o))}return i}function on(e){if(e.composed||e.constructed){for(var t=Zr.util.createBuffer(),r=0;r<e.value.length;++r)t.putBytes(e.value[r].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function un(e,t){var r={},n=[];if(!Xr.validate(e,Zr.pkcs7.asn1.encryptedDataValidator,r,n))throw(i=new Error("Cannot read EncryptedContentInfo.")).errors=n,i;var i,a=Xr.derToOid(r.contentType);if(a!==$r.oids.data)throw(i=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=a,i;a=Xr.derToOid(r.encAlgorithm);var s=$r.pbe.getCipher(a,r.encParameter,t),o=on(r.encryptedContentAsn1),u=Zr.util.createBuffer(o.value);if(s.update(u),!s.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return s.output.getBytes()}function cn(e,t,r){if(!t&&0===e.length)return[];if((e=Xr.fromDer(e,t)).tagClass!==Xr.Class.UNIVERSAL||e.type!==Xr.Type.SEQUENCE||!0!==e.constructed)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var n=[],i=0;i<e.value.length;i++){var a=e.value[i],s={},o=[];if(!Xr.validate(a,rn,s,o))throw(f=new Error("Cannot read SafeBag.")).errors=o,f;var u,c,l={type:Xr.derToOid(s.bagId),attributes:ln(s.bagAttributes)};n.push(l);var h=s.bagValue.value[0];switch(l.type){case $r.oids.pkcs8ShroudedKeyBag:if(null===(h=$r.decryptPrivateKeyInfo(h,r)))throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case $r.oids.keyBag:try{l.key=$r.privateKeyFromAsn1(h)}catch(e){l.key=null,l.asn1=h}continue;case $r.oids.certBag:u=an,c=function(){if(Xr.derToOid(s.certId)!==$r.oids.x509Certificate){var e=new Error("Unsupported certificate type, only X.509 supported.");throw e.oid=Xr.derToOid(s.certId),e}var r=Xr.fromDer(s.cert,t);try{l.cert=$r.certificateFromAsn1(r,!0)}catch(e){l.cert=null,l.asn1=r}};break;default:var f;throw(f=new Error("Unsupported PKCS#12 SafeBag type.")).oid=l.type,f}if(void 0!==u&&!Xr.validate(h,u,s,o))throw(f=new Error("Cannot read PKCS#12 "+u.name)).errors=o,f;c()}return n}function ln(e){var t={};if(void 0!==e)for(var r=0;r<e.length;++r){var n={},i=[];if(!Xr.validate(e[r],nn,n,i)){var a=new Error("Cannot read PKCS#12 BagAttribute.");throw a.errors=i,a}var s=Xr.derToOid(n.oid);if(void 0!==$r.oids[s]){t[$r.oids[s]]=[];for(var o=0;o<n.values.length;++o)t[$r.oids[s]].push(n.values[o].value)}}return t}Jr.pkcs12FromAsn1=function(e,t,r){"string"==typeof t?(r=t,t=!0):void 0===t&&(t=!0);var n={};if(!Xr.validate(e,tn,n,[]))throw(i=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.")).errors=i,i;var i,a={version:n.version.charCodeAt(0),safeContents:[],getBags:function(e){var t,r={};return"localKeyId"in e?t=e.localKeyId:"localKeyIdHex"in e&&(t=Zr.util.hexToBytes(e.localKeyIdHex)),void 0===t&&!("friendlyName"in e)&&"bagType"in e&&(r[e.bagType]=sn(a.safeContents,null,null,e.bagType)),void 0!==t&&(r.localKeyId=sn(a.safeContents,"localKeyId",t,e.bagType)),"friendlyName"in e&&(r.friendlyName=sn(a.safeContents,"friendlyName",e.friendlyName,e.bagType)),r},getBagsByFriendlyName:function(e,t){return sn(a.safeContents,"friendlyName",e,t)},getBagsByLocalKeyId:function(e,t){return sn(a.safeContents,"localKeyId",e,t)}};if(3!==n.version.charCodeAt(0))throw(i=new Error("PKCS#12 PFX of version other than 3 not supported.")).version=n.version.charCodeAt(0),i;if(Xr.derToOid(n.contentType)!==$r.oids.data)throw(i=new Error("Only PKCS#12 PFX in password integrity mode supported.")).oid=Xr.derToOid(n.contentType),i;var s=n.content.value[0];if(s.tagClass!==Xr.Class.UNIVERSAL||s.type!==Xr.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(s=on(s),n.mac){var o=null,u=0,c=Xr.derToOid(n.macAlgorithm);switch(c){case $r.oids.sha1:o=Zr.md.sha1.create(),u=20;break;case $r.oids.sha256:o=Zr.md.sha256.create(),u=32;break;case $r.oids.sha384:o=Zr.md.sha384.create(),u=48;break;case $r.oids.sha512:o=Zr.md.sha512.create(),u=64;break;case $r.oids.md5:o=Zr.md.md5.create(),u=16}if(null===o)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+c);var l=new Zr.util.ByteBuffer(n.macSalt),h="macIterations"in n?parseInt(Zr.util.bytesToHex(n.macIterations),16):1,f=Jr.generateKey(r,l,3,h,u,o),d=Zr.hmac.create();if(d.start(o,f),d.update(s.value),d.getMac().getBytes()!==n.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,t,r,n){if(t=Xr.fromDer(t,r),t.tagClass!==Xr.Class.UNIVERSAL||t.type!==Xr.Type.SEQUENCE||!0!==t.constructed)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var i=0;i<t.value.length;i++){var a=t.value[i],s={},o=[];if(!Xr.validate(a,en,s,o))throw(h=new Error("Cannot read ContentInfo.")).errors=o,h;var u={encrypted:!1},c=null,l=s.content.value[0];switch(Xr.derToOid(s.contentType)){case $r.oids.data:if(l.tagClass!==Xr.Class.UNIVERSAL||l.type!==Xr.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");c=on(l).value;break;case $r.oids.encryptedData:c=un(l,n),u.encrypted=!0;break;default:var h;throw(h=new Error("Unsupported PKCS#12 contentType.")).contentType=Xr.derToOid(s.contentType),h}u.safeBags=cn(c,r,n),e.safeContents.push(u)}}(a,s.value,t,r),a},Jr.toPkcs12Asn1=function(e,t,r,n){(n=n||{}).saltSize=n.saltSize||8,n.count=n.count||2048,n.algorithm=n.algorithm||n.encAlgorithm||"aes128","useMac"in n||(n.useMac=!0),"localKeyId"in n||(n.localKeyId=null),"generateLocalKeyId"in n||(n.generateLocalKeyId=!0);var i,a=n.localKeyId;if(null!==a)a=Zr.util.hexToBytes(a);else if(n.generateLocalKeyId)if(t){var s=Zr.util.isArray(t)?t[0]:t;"string"==typeof s&&(s=$r.certificateFromPem(s)),(T=Zr.md.sha1.create()).update(Xr.toDer($r.certificateToAsn1(s)).getBytes()),a=T.digest().getBytes()}else a=Zr.random.getBytes(20);var o=[];null!==a&&o.push(Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.localKeyId).getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SET,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,a)])])),"friendlyName"in n&&o.push(Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.friendlyName).getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SET,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.BMPSTRING,!1,n.friendlyName)])])),o.length>0&&(i=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SET,!0,o));var u=[],c=[];null!==t&&(c=Zr.util.isArray(t)?t:[t]);for(var l=[],h=0;h<c.length;++h){"string"==typeof(t=c[h])&&(t=$r.certificateFromPem(t));var f=0===h?i:void 0,d=$r.certificateToAsn1(t),p=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.certBag).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.x509Certificate).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,Xr.toDer(d).getBytes())])])]),f]);l.push(p)}if(l.length>0){var g=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,l),y=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.data).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,Xr.toDer(g).getBytes())])]);u.push(y)}var m=null;if(null!==e){var v=$r.wrapRsaPrivateKey($r.privateKeyToAsn1(e));m=null===r?Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.keyBag).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[v]),i]):Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.pkcs8ShroudedKeyBag).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[$r.encryptPrivateKeyInfo(v,r,n)]),i]);var C=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[m]),E=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.data).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,Xr.toDer(C).getBytes())])]);u.push(E)}var b,S=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,u);if(n.useMac){var T=Zr.md.sha1.create(),_=new Zr.util.ByteBuffer(Zr.random.getBytes(n.saltSize)),w=n.count,I=(e=Jr.generateKey(r,_,3,w,20),Zr.hmac.create());I.start(T,e),I.update(Xr.toDer(S).getBytes());var A=I.getMac();b=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.sha1).getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.NULL,!1,"")]),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,A.getBytes())]),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,_.getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.INTEGER,!1,Xr.integerToDer(w).getBytes())])}return Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.INTEGER,!1,Xr.integerToDer(3).getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.data).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,Xr.toDer(S).getBytes())])]),b])},Jr.generateKey=Zr.pbe.generatePkcs12Key;var hn=S,fn=hn.asn1,dn=hn.pki=hn.pki||{};dn.pemToDer=function(e){var t=hn.pem.decode(e)[0];if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return hn.util.createBuffer(t.body)},dn.privateKeyFromPem=function(e){var t=hn.pem.decode(e)[0];if("PRIVATE KEY"!==t.type&&"RSA PRIVATE KEY"!==t.type){var r=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var n=fn.fromDer(t.body);return dn.privateKeyFromAsn1(n)},dn.privateKeyToPem=function(e,t){var r={type:"RSA PRIVATE KEY",body:fn.toDer(dn.privateKeyToAsn1(e)).getBytes()};return hn.pem.encode(r,{maxline:t})},dn.privateKeyInfoToPem=function(e,t){var r={type:"PRIVATE KEY",body:fn.toDer(e).getBytes()};return hn.pem.encode(r,{maxline:t})};var pn=S,gn=function(e,t,r,n){var i=pn.util.createBuffer(),a=e.length>>1,s=a+(1&e.length),o=e.substr(0,s),u=e.substr(a,s),c=pn.util.createBuffer(),l=pn.hmac.create();r=t+r;var h=Math.ceil(n/16),f=Math.ceil(n/20);l.start("MD5",o);var d=pn.util.createBuffer();c.putBytes(r);for(var p=0;p<h;++p)l.start(null,null),l.update(c.getBytes()),c.putBuffer(l.digest()),l.start(null,null),l.update(c.bytes()+r),d.putBuffer(l.digest());l.start("SHA1",u);var g=pn.util.createBuffer();c.clear(),c.putBytes(r);for(p=0;p<f;++p)l.start(null,null),l.update(c.getBytes()),c.putBuffer(l.digest()),l.start(null,null),l.update(c.bytes()+r),g.putBuffer(l.digest());return i.putBytes(pn.util.xorBytes(d.getBytes(),g.getBytes(),n)),i},yn=function(e,t,r){var n=!1;try{var i=e.deflate(t.fragment.getBytes());t.fragment=pn.util.createBuffer(i),t.length=i.length,n=!0}catch(e){}return n},mn=function(e,t,r){var n=!1;try{var i=e.inflate(t.fragment.getBytes());t.fragment=pn.util.createBuffer(i),t.length=i.length,n=!0}catch(e){}return n},vn=function(e,t){var r=0;switch(t){case 1:r=e.getByte();break;case 2:r=e.getInt16();break;case 3:r=e.getInt24();break;case 4:r=e.getInt32()}return pn.util.createBuffer(e.getBytes(r))},Cn=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},En={Versions:{TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}}};En.SupportedVersions=[En.Versions.TLS_1_1,En.Versions.TLS_1_0],En.Version=En.SupportedVersions[0],En.MaxFragment=15360,En.ConnectionEnd={server:0,client:1},En.PRFAlgorithm={tls_prf_sha256:0},En.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},En.CipherType={stream:0,block:1,aead:2},En.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},En.CompressionMethod={none:0,deflate:1},En.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},En.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},En.Alert={},En.Alert.Level={warning:1,fatal:2},En.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},En.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},En.CipherSuites={},En.getCipherSuite=function(e){var t=null;for(var r in En.CipherSuites){var n=En.CipherSuites[r];if(n.id[0]===e.charCodeAt(0)&&n.id[1]===e.charCodeAt(1)){t=n;break}}return t},En.handleUnexpected=function(e,t){!e.open&&e.entity===En.ConnectionEnd.client||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.unexpected_message}})},En.handleHelloRequest=function(e,t,r){!e.handshaking&&e.handshakes>0&&(En.queue(e,En.createAlert(e,{level:En.Alert.Level.warning,description:En.Alert.Description.no_renegotiation})),En.flush(e)),e.process()},En.parseHelloMessage=function(e,t,r){var n=null,i=e.entity===En.ConnectionEnd.client;if(r<38)e.error(e,{message:i?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});else{var a=t.fragment,s=a.length();if(n={version:{major:a.getByte(),minor:a.getByte()},random:pn.util.createBuffer(a.getBytes(32)),session_id:vn(a,1),extensions:[]},i?(n.cipher_suite=a.getBytes(2),n.compression_method=a.getByte()):(n.cipher_suites=vn(a,2),n.compression_methods=vn(a,1)),(s=r-(s-a.length()))>0){for(var o=vn(a,2);o.length()>0;)n.extensions.push({type:[o.getByte(),o.getByte()],data:vn(o,2)});if(!i)for(var u=0;u<n.extensions.length;++u){var c=n.extensions[u];if(0===c.type[0]&&0===c.type[1])for(var l=vn(c.data,2);l.length()>0;){if(0!==l.getByte())break;e.session.extensions.server_name.serverNameList.push(vn(l,2).getBytes())}}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.protocol_version}});if(i)e.session.cipherSuite=En.getCipherSuite(n.cipher_suite);else for(var h=pn.util.createBuffer(n.cipher_suites.bytes());h.length()>0&&(e.session.cipherSuite=En.getCipherSuite(h.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.handshake_failure},cipherSuite:pn.util.bytesToHex(n.cipher_suite)});e.session.compressionMethod=i?n.compression_method:En.CompressionMethod.none}return n},En.createSecurityParameters=function(e,t){var r=e.entity===En.ConnectionEnd.client,n=t.random.bytes(),i=r?e.session.sp.client_random:n,a=r?n:En.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:En.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:i,server_random:a}},En.handleServerHello=function(e,t,r){var n=En.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var i=n.session_id.bytes();i.length>0&&i===e.session.id?(e.expect=wn,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=bn,e.session.resuming=!1,En.createSecurityParameters(e,n)),e.session.id=i,e.process()}},En.handleClientHello=function(e,t,r){var n=En.parseHelloMessage(e,t,r);if(!e.fail){var i=n.session_id.bytes(),a=null;if(e.sessionCache&&(null===(a=e.sessionCache.getSession(i))?i="":(a.version.major!==n.version.major||a.version.minor>n.version.minor)&&(a=null,i="")),0===i.length&&(i=pn.random.getBytes(32)),e.session.id=i,e.session.clientHelloVersion=n.version,e.session.sp={},a)e.version=e.session.version=a.version,e.session.sp=a.sp;else{for(var s,o=1;o<En.SupportedVersions.length&&!((s=En.SupportedVersions[o]).minor<=n.version.minor);++o);e.version={major:s.major,minor:s.minor},e.session.version=e.version}null!==a?(e.expect=Ln,e.session.resuming=!0,e.session.sp.client_random=n.random.bytes()):(e.expect=!1!==e.verifyClient?kn:Nn,e.session.resuming=!1,En.createSecurityParameters(e,n)),e.open=!0,En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createServerHello(e)})),e.session.resuming?(En.queue(e,En.createRecord(e,{type:En.ContentType.change_cipher_spec,data:En.createChangeCipherSpec()})),e.state.pending=En.createConnectionState(e),e.state.current.write=e.state.pending.write,En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createFinished(e)}))):(En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createCertificate(e)})),e.fail||(En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createServerKeyExchange(e)})),!1!==e.verifyClient&&En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createCertificateRequest(e)})),En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createServerHelloDone(e)})))),En.flush(e),e.process()}},En.handleCertificate=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});var n,i,a=t.fragment,s={certificate_list:vn(a,3)},o=[];try{for(;s.certificate_list.length()>0;)n=vn(s.certificate_list,3),i=pn.asn1.fromDer(n),n=pn.pki.certificateFromAsn1(i,!0),o.push(n)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.bad_certificate}})}var u=e.entity===En.ConnectionEnd.client;!u&&!0!==e.verifyClient||0!==o.length?0===o.length?e.expect=u?Sn:Nn:(u?e.session.serverCertificate=o[0]:e.session.clientCertificate=o[0],En.verifyCertificateChain(e,o)&&(e.expect=u?Sn:Nn)):e.error(e,{message:u?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}}),e.process()},En.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.unsupported_certificate}});e.expect=Tn,e.process()},En.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.unsupported_certificate}});var n=t.fragment,i={enc_pre_master_secret:vn(n,2).getBytes()},a=null;if(e.getPrivateKey)try{a=e.getPrivateKey(e,e.session.serverCertificate),a=pn.pki.privateKeyFromPem(a)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}})}if(null===a)return e.error(e,{message:"No private key set.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}});try{var s=e.session.sp;s.pre_master_secret=a.decrypt(i.enc_pre_master_secret);var o=e.session.clientHelloVersion;if(o.major!==s.pre_master_secret.charCodeAt(0)||o.minor!==s.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){s.pre_master_secret=pn.random.getBytes(48)}e.expect=Ln,null!==e.session.clientCertificate&&(e.expect=Rn),e.process()},En.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});var n=t.fragment,i={certificate_types:vn(n,1),certificate_authorities:vn(n,2)};e.session.certificateRequest=i,e.expect=_n,e.process()},En.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var a={signature:vn(n,2).getBytes()},s=pn.util.createBuffer();s.putBuffer(e.session.md5.digest()),s.putBuffer(e.session.sha1.digest()),s=s.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(s,a.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(i),e.session.sha1.update(i)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.handshake_failure}})}e.expect=Ln,e.process()},En.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.record_overflow}});if(null===e.serverCertificate){var n={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.insufficient_security}},i=e.verify(e,n.alert.description,0,[]);if(!0!==i)return(i||0===i)&&("object"!=typeof i||pn.util.isArray(i)?"number"==typeof i&&(n.alert.description=i):(i.message&&(n.message=i.message),i.alert&&(n.alert.description=i.alert))),e.error(e,n)}null!==e.session.certificateRequest&&(t=En.createRecord(e,{type:En.ContentType.handshake,data:En.createCertificate(e)}),En.queue(e,t)),t=En.createRecord(e,{type:En.ContentType.handshake,data:En.createClientKeyExchange(e)}),En.queue(e,t),e.expect=Bn;var a=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createCertificateVerify(e,t)})),En.queue(e,En.createRecord(e,{type:En.ContentType.change_cipher_spec,data:En.createChangeCipherSpec()})),e.state.pending=En.createConnectionState(e),e.state.current.write=e.state.pending.write,En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createFinished(e)})),e.expect=wn,En.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return a(e,null);En.getClientSignature(e,a)},En.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});var r=e.entity===En.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=En.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?In:Dn,e.process()},En.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var a=t.fragment.getBytes();(n=pn.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var s=e.entity===En.ConnectionEnd.client,o=s?"server finished":"client finished",u=e.session.sp;if((n=gn(u.master_secret,o,n.getBytes(),12)).getBytes()!==a)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.decrypt_error}});e.session.md5.update(i),e.session.sha1.update(i),(e.session.resuming&&s||!e.session.resuming&&!s)&&(En.queue(e,En.createRecord(e,{type:En.ContentType.change_cipher_spec,data:En.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createFinished(e)}))),e.expect=s?An:Un,e.handshaking=!1,++e.handshakes,e.peerCertificate=s?e.session.serverCertificate:e.session.clientCertificate,En.flush(e),e.isConnected=!0,e.connected(e),e.process()},En.handleAlert=function(e,t){var r,n=t.fragment,i={level:n.getByte(),description:n.getByte()};switch(i.description){case En.Alert.Description.close_notify:r="Connection closed.";break;case En.Alert.Description.unexpected_message:r="Unexpected message.";break;case En.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case En.Alert.Description.decryption_failed:r="Decryption failed.";break;case En.Alert.Description.record_overflow:r="Record overflow.";break;case En.Alert.Description.decompression_failure:r="Decompression failed.";break;case En.Alert.Description.handshake_failure:r="Handshake failure.";break;case En.Alert.Description.bad_certificate:r="Bad certificate.";break;case En.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case En.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case En.Alert.Description.certificate_expired:r="Certificate expired.";break;case En.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case En.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case En.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case En.Alert.Description.access_denied:r="Access denied.";break;case En.Alert.Description.decode_error:r="Decode error.";break;case En.Alert.Description.decrypt_error:r="Decrypt error.";break;case En.Alert.Description.export_restriction:r="Export restriction.";break;case En.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case En.Alert.Description.insufficient_security:r="Insufficient security.";break;case En.Alert.Description.internal_error:r="Internal error.";break;case En.Alert.Description.user_canceled:r="User canceled.";break;case En.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(i.description===En.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===En.ConnectionEnd.client?"server":"client",alert:i}),e.process()},En.handleHandshake=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt24();if(i>r.length())return e.fragmented=t,t.fragment=pn.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var a=r.bytes(i+4);r.read+=4,n in Yn[e.entity][e.expect]?(e.entity!==En.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:pn.md.md5.create(),sha1:pn.md.sha1.create()}),n!==En.HandshakeType.hello_request&&n!==En.HandshakeType.certificate_verify&&n!==En.HandshakeType.finished&&(e.session.md5.update(a),e.session.sha1.update(a)),Yn[e.entity][e.expect][n](e,t,i)):En.handleUnexpected(e,t)},En.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},En.handleHeartbeat=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt16(),a=r.getBytes(i);if(n===En.HeartbeatMessageType.heartbeat_request){if(e.handshaking||i>a.length)return e.process();En.queue(e,En.createRecord(e,{type:En.ContentType.heartbeat,data:En.createHeartbeat(En.HeartbeatMessageType.heartbeat_response,a)})),En.flush(e)}else if(n===En.HeartbeatMessageType.heartbeat_response){if(a!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,pn.util.createBuffer(a))}e.process()};var bn=1,Sn=2,Tn=3,_n=4,wn=5,In=6,An=7,Bn=8,kn=1,Nn=2,Rn=3,Ln=4,Dn=5,Un=6,xn=En.handleUnexpected,On=En.handleChangeCipherSpec,Pn=En.handleAlert,Vn=En.handleHandshake,Kn=En.handleApplicationData,Mn=En.handleHeartbeat,Fn=[];Fn[En.ConnectionEnd.client]=[[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[On,Pn,xn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,Kn,Mn],[xn,Pn,Vn,xn,Mn]],Fn[En.ConnectionEnd.server]=[[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[On,Pn,xn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,Kn,Mn],[xn,Pn,Vn,xn,Mn]];var zn=En.handleHelloRequest,jn=En.handleServerHello,qn=En.handleCertificate,Hn=En.handleServerKeyExchange,Gn=En.handleCertificateRequest,Wn=En.handleServerHelloDone,Qn=En.handleFinished,Yn=[];Yn[En.ConnectionEnd.client]=[[xn,xn,jn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,qn,Hn,Gn,Wn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Hn,Gn,Wn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Gn,Wn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Wn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Qn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn]];var Zn=En.handleClientHello,Xn=En.handleClientKeyExchange,$n=En.handleCertificateVerify;Yn[En.ConnectionEnd.server]=[[xn,Zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,qn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,$n,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Qn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn]],En.generateKeys=function(e,t){var r=gn,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var i=2*t.mac_key_length+2*t.enc_key_length,a=e.version.major===En.Versions.TLS_1_0.major&&e.version.minor===En.Versions.TLS_1_0.minor;a&&(i+=2*t.fixed_iv_length);var s=r(t.master_secret,"key expansion",n,i),o={client_write_MAC_key:s.getBytes(t.mac_key_length),server_write_MAC_key:s.getBytes(t.mac_key_length),client_write_key:s.getBytes(t.enc_key_length),server_write_key:s.getBytes(t.enc_key_length)};return a&&(o.client_write_IV=s.getBytes(t.fixed_iv_length),o.server_write_IV=s.getBytes(t.fixed_iv_length)),o},En.createConnectionState=function(e){var t=e.entity===En.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},n={read:r(),write:r()};if(n.read.update=function(e,t){return n.read.cipherFunction(t,n.read)?n.read.compressFunction(e,t,n.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.bad_record_mac}}),!e.fail},n.write.update=function(e,t){return n.write.compressFunction(e,t,n.write)?n.write.cipherFunction(t,n.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}}),!e.fail},e.session){var i=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(i),i.keys=En.generateKeys(e,i),n.read.macKey=t?i.keys.server_write_MAC_key:i.keys.client_write_MAC_key,n.write.macKey=t?i.keys.client_write_MAC_key:i.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,i),i.compression_algorithm){case En.CompressionMethod.none:break;case En.CompressionMethod.deflate:n.read.compressFunction=mn,n.write.compressFunction=yn;break;default:throw new Error("Unsupported compression algorithm.")}}return n},En.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=pn.util.createBuffer();return r.putInt32(t),r.putBytes(pn.random.getBytes(28)),r},En.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},En.createAlert=function(e,t){var r=pn.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),En.createRecord(e,{type:En.ContentType.alert,data:r})},En.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=pn.util.createBuffer(),r=0;r<e.cipherSuites.length;++r){var n=e.cipherSuites[r];t.putByte(n.id[0]),t.putByte(n.id[1])}var i=t.length(),a=pn.util.createBuffer();a.putByte(En.CompressionMethod.none);var s=a.length(),o=pn.util.createBuffer();if(e.virtualHost){var u=pn.util.createBuffer();u.putByte(0),u.putByte(0);var c=pn.util.createBuffer();c.putByte(0),Cn(c,2,pn.util.createBuffer(e.virtualHost));var l=pn.util.createBuffer();Cn(l,2,c),Cn(u,2,l),o.putBuffer(u)}var h=o.length();h>0&&(h+=2);var f=e.session.id,d=f.length+1+2+4+28+2+i+1+s+h,p=pn.util.createBuffer();return p.putByte(En.HandshakeType.client_hello),p.putInt24(d),p.putByte(e.version.major),p.putByte(e.version.minor),p.putBytes(e.session.sp.client_random),Cn(p,1,pn.util.createBuffer(f)),Cn(p,2,t),Cn(p,1,a),h>0&&Cn(p,2,o),p},En.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,n=pn.util.createBuffer();return n.putByte(En.HandshakeType.server_hello),n.putInt24(r),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),Cn(n,1,pn.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n},En.createCertificate=function(e){var t,r=e.entity===En.ConnectionEnd.client,n=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,n=e.getCertificate(e,t));var i=pn.util.createBuffer();if(null!==n)try{pn.util.isArray(n)||(n=[n]);for(var a=null,s=0;s<n.length;++s){var o=pn.pem.decode(n[s])[0];if("CERTIFICATE"!==o.type&&"X509 CERTIFICATE"!==o.type&&"TRUSTED CERTIFICATE"!==o.type){var u=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw u.headerType=o.type,u}if(o.procType&&"ENCRYPTED"===o.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var c=pn.util.createBuffer(o.body);null===a&&(a=pn.asn1.fromDer(c.bytes(),!1));var l=pn.util.createBuffer();Cn(l,3,c),i.putBuffer(l)}n=pn.pki.certificateFromAsn1(a),r?e.session.clientCertificate=n:e.session.serverCertificate=n}catch(t){return e.error(e,{message:"Could not send certificate list.",cause:t,send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.bad_certificate}})}var h=3+i.length(),f=pn.util.createBuffer();return f.putByte(En.HandshakeType.certificate),f.putInt24(h),Cn(f,3,i),f},En.createClientKeyExchange=function(e){var t=pn.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(pn.random.getBytes(46));var r=e.session.sp;r.pre_master_secret=t.getBytes();var n=(t=e.session.serverCertificate.publicKey.encrypt(r.pre_master_secret)).length+2,i=pn.util.createBuffer();return i.putByte(En.HandshakeType.client_key_exchange),i.putInt24(n),i.putInt16(t.length),i.putBytes(t),i},En.createServerKeyExchange=function(e){return pn.util.createBuffer()},En.getClientSignature=function(e,t){var r=pn.util.createBuffer();r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest()),r=r.getBytes(),e.getSignature=e.getSignature||function(e,t,r){var n=null;if(e.getPrivateKey)try{n=e.getPrivateKey(e,e.session.clientCertificate),n=pn.pki.privateKeyFromPem(n)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}})}null===n?e.error(e,{message:"No private key set.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}}):t=n.sign(t,null),r(e,t)},e.getSignature(e,r,t)},En.createCertificateVerify=function(e,t){var r=t.length+2,n=pn.util.createBuffer();return n.putByte(En.HandshakeType.certificate_verify),n.putInt24(r),n.putInt16(t.length),n.putBytes(t),n},En.createCertificateRequest=function(e){var t=pn.util.createBuffer();t.putByte(1);var r=pn.util.createBuffer();for(var n in e.caStore.certs){var i=e.caStore.certs[n],a=pn.pki.distinguishedNameToAsn1(i.subject),s=pn.asn1.toDer(a);r.putInt16(s.length()),r.putBuffer(s)}var o=1+t.length()+2+r.length(),u=pn.util.createBuffer();return u.putByte(En.HandshakeType.certificate_request),u.putInt24(o),Cn(u,1,t),Cn(u,2,r),u},En.createServerHelloDone=function(e){var t=pn.util.createBuffer();return t.putByte(En.HandshakeType.server_hello_done),t.putInt24(0),t},En.createChangeCipherSpec=function(){var e=pn.util.createBuffer();return e.putByte(1),e},En.createFinished=function(e){var t=pn.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var r=e.entity===En.ConnectionEnd.client,n=e.session.sp,i=r?"client finished":"server finished";t=gn(n.master_secret,i,t.getBytes(),12);var a=pn.util.createBuffer();return a.putByte(En.HandshakeType.finished),a.putInt24(t.length()),a.putBuffer(t),a},En.createHeartbeat=function(e,t,r){void 0===r&&(r=t.length);var n=pn.util.createBuffer();n.putByte(e),n.putInt16(r),n.putBytes(t);var i=n.length(),a=Math.max(16,i-r-3);return n.putBytes(pn.random.getBytes(a)),n},En.queue=function(e,t){if(t&&(0!==t.fragment.length()||t.type!==En.ContentType.handshake&&t.type!==En.ContentType.alert&&t.type!==En.ContentType.change_cipher_spec)){if(t.type===En.ContentType.handshake){var r=t.fragment.bytes();e.session.md5.update(r),e.session.sha1.update(r),r=null}var n;if(t.fragment.length()<=En.MaxFragment)n=[t];else{n=[];for(var i=t.fragment.bytes();i.length>En.MaxFragment;)n.push(En.createRecord(e,{type:t.type,data:pn.util.createBuffer(i.slice(0,En.MaxFragment))})),i=i.slice(En.MaxFragment);i.length>0&&n.push(En.createRecord(e,{type:t.type,data:pn.util.createBuffer(i)}))}for(var a=0;a<n.length&&!e.fail;++a){var s=n[a];e.state.current.write.update(e,s)&&e.records.push(s)}}},En.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var Jn=function(e){switch(e){case!0:return!0;case pn.pki.certificateError.bad_certificate:return En.Alert.Description.bad_certificate;case pn.pki.certificateError.unsupported_certificate:return En.Alert.Description.unsupported_certificate;case pn.pki.certificateError.certificate_revoked:return En.Alert.Description.certificate_revoked;case pn.pki.certificateError.certificate_expired:return En.Alert.Description.certificate_expired;case pn.pki.certificateError.certificate_unknown:return En.Alert.Description.certificate_unknown;case pn.pki.certificateError.unknown_ca:return En.Alert.Description.unknown_ca;default:return En.Alert.Description.bad_certificate}};for(var ei in En.verifyCertificateChain=function(e,t){try{var r={};for(var n in e.verifyOptions)r[n]=e.verifyOptions[n];r.verify=function(t,r,n){Jn(t);var i=e.verify(e,t,r,n);if(!0!==i){if("object"==typeof i&&!pn.util.isArray(i)){var a=new Error("The application rejected the certificate.");throw a.send=!0,a.alert={level:En.Alert.Level.fatal,description:En.Alert.Description.bad_certificate},i.message&&(a.message=i.message),i.alert&&(a.alert.description=i.alert),a}i!==t&&(i=function(e){switch(e){case!0:return!0;case En.Alert.Description.bad_certificate:return pn.pki.certificateError.bad_certificate;case En.Alert.Description.unsupported_certificate:return pn.pki.certificateError.unsupported_certificate;case En.Alert.Description.certificate_revoked:return pn.pki.certificateError.certificate_revoked;case En.Alert.Description.certificate_expired:return pn.pki.certificateError.certificate_expired;case En.Alert.Description.certificate_unknown:return pn.pki.certificateError.certificate_unknown;case En.Alert.Description.unknown_ca:return pn.pki.certificateError.unknown_ca;default:return pn.pki.certificateError.bad_certificate}}(i))}return i},pn.pki.verifyCertificateChain(e.caStore,t,r)}catch(t){var i=t;("object"!=typeof i||pn.util.isArray(i))&&(i={send:!0,alert:{level:En.Alert.Level.fatal,description:Jn(t)}}),"send"in i||(i.send=!0),"alert"in i||(i.alert={level:En.Alert.Level.fatal,description:Jn(i.error)}),e.error(e,i)}return!e.fail},En.createSessionCache=function(e,t){var r=null;if(e&&e.getSession&&e.setSession&&e.order)r=e;else{for(var n in(r={}).cache=e||{},r.capacity=Math.max(t||100,1),r.order=[],e)r.order.length<=t?r.order.push(n):delete e[n];r.getSession=function(e){var t=null,n=null;if(e?n=pn.util.bytesToHex(e):r.order.length>0&&(n=r.order[0]),null!==n&&n in r.cache)for(var i in t=r.cache[n],delete r.cache[n],r.order)if(r.order[i]===n){r.order.splice(i,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var n=r.order.shift();delete r.cache[n]}n=pn.util.bytesToHex(e);r.order.push(n),r.cache[n]=t}}return r},En.createConnection=function(e){var t=null;t=e.caStore?pn.util.isArray(e.caStore)?pn.pki.createCaStore(e.caStore):e.caStore:pn.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var n in r=[],En.CipherSuites)r.push(En.CipherSuites[n]);var i=e.server?En.ConnectionEnd.server:En.ConnectionEnd.client,a=e.sessionCache?En.createSessionCache(e.sessionCache):null,s={version:{major:En.Version.major,minor:En.Version.minor},entity:i,sessionId:e.sessionId,caStore:t,sessionCache:a,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,n){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:pn.util.createBuffer(),tlsData:pn.util.createBuffer(),data:pn.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===En.ConnectionEnd.client?"client":"server"),r.send&&(En.queue(t,En.createAlert(t,r.alert)),En.flush(t));var n=!1!==r.fatal;n&&(t.fail=!0),e.error(t,r),n&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){s.version={major:En.Version.major,minor:En.Version.minor},s.record=null,s.session=null,s.peerCertificate=null,s.state={pending:null,current:null},s.expect=(s.entity,En.ConnectionEnd.client,0),s.fragmented=null,s.records=[],s.open=!1,s.handshakes=0,s.handshaking=!1,s.isConnected=!1,s.fail=!(e||void 0===e),s.input.clear(),s.tlsData.clear(),s.data.clear(),s.state.current=En.createConnectionState(s)}};s.reset();return s.handshake=function(e){if(s.entity!==En.ConnectionEnd.client)s.error(s,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(s.handshaking)s.error(s,{message:"Handshake already in progress.",fatal:!1});else{s.fail&&!s.open&&0===s.handshakes&&(s.fail=!1),s.handshaking=!0;var t=null;(e=e||"").length>0&&(s.sessionCache&&(t=s.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&s.sessionCache&&null!==(t=s.sessionCache.getSession())&&(e=t.id),s.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:pn.md.md5.create(),sha1:pn.md.sha1.create()},t&&(s.version=t.version,s.session.sp=t.sp),s.session.sp.client_random=En.createRandom().getBytes(),s.open=!0,En.queue(s,En.createRecord(s,{type:En.ContentType.handshake,data:En.createClientHello(s)})),En.flush(s)}},s.process=function(e){var t=0;return e&&s.input.putBytes(e),s.fail||(null!==s.record&&s.record.ready&&s.record.fragment.isEmpty()&&(s.record=null),null===s.record&&(t=function(e){var t=0,r=e.input,n=r.length();if(n<5)t=5-n;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:pn.util.createBuffer(),ready:!1};var i=e.record.version.major===e.version.major;i&&e.session&&e.session.version&&(i=e.record.version.minor===e.version.minor),i||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.protocol_version}})}return t}(s)),s.fail||null===s.record||s.record.ready||(t=function(e){var t=0,r=e.input,n=r.length();return n<e.record.length?t=e.record.length-n:(e.record.fragment.putBytes(r.getBytes(e.record.length)),r.compact(),e.state.current.read.update(e,e.record)&&(null!==e.fragmented&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:"Invalid fragmented record.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.unexpected_message}})),e.record.ready=!0)),t}(s)),!s.fail&&null!==s.record&&s.record.ready&&function(e,t){var r=t.type-En.ContentType.change_cipher_spec,n=Fn[e.entity][e.expect];r in n?n[r](e,t):En.handleUnexpected(e,t)}(s,s.record)),t},s.prepare=function(e){return En.queue(s,En.createRecord(s,{type:En.ContentType.application_data,data:pn.util.createBuffer(e)})),En.flush(s)},s.prepareHeartbeatRequest=function(e,t){return e instanceof pn.util.ByteBuffer&&(e=e.bytes()),void 0===t&&(t=e.length),s.expectedHeartbeatPayload=e,En.queue(s,En.createRecord(s,{type:En.ContentType.heartbeat,data:En.createHeartbeat(En.HeartbeatMessageType.heartbeat_request,e,t)})),En.flush(s)},s.close=function(e){if(!s.fail&&s.sessionCache&&s.session){var t={id:s.session.id,version:s.session.version,sp:s.session.sp};t.sp.keys=null,s.sessionCache.setSession(t.id,t)}s.open&&(s.open=!1,s.input.clear(),(s.isConnected||s.handshaking)&&(s.isConnected=s.handshaking=!1,En.queue(s,En.createAlert(s,{level:En.Alert.Level.warning,description:En.Alert.Description.close_notify})),En.flush(s)),s.closed(s)),s.reset(e)},s},pn.tls=pn.tls||{},En)"function"!=typeof En[ei]&&(pn.tls[ei]=En[ei]);pn.tls.prf_tls1=gn,pn.tls.hmac_sha1=function(e,t,r){var n=pn.hmac.create();n.start("SHA1",e);var i=pn.util.createBuffer();return i.putInt32(t[0]),i.putInt32(t[1]),i.putByte(r.type),i.putByte(r.version.major),i.putByte(r.version.minor),i.putInt16(r.length),i.putBytes(r.fragment.bytes()),n.update(i.getBytes()),n.digest().getBytes()},pn.tls.createSessionCache=En.createSessionCache,pn.tls.createConnection=En.createConnection;var ti=S,ri=ti.tls;function ni(e,t,r){var n=t.entity===ti.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:ti.cipher.createDecipher("AES-CBC",n?r.keys.server_write_key:r.keys.client_write_key),iv:n?r.keys.server_write_IV:r.keys.client_write_IV},e.write.cipherState={init:!1,cipher:ti.cipher.createCipher("AES-CBC",n?r.keys.client_write_key:r.keys.server_write_key),iv:n?r.keys.client_write_IV:r.keys.server_write_IV},e.read.cipherFunction=oi,e.write.cipherFunction=ii,e.read.macLength=e.write.macLength=r.mac_length,e.read.macFunction=e.write.macFunction=ri.hmac_sha1}function ii(e,t){var r,n=!1,i=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(i),t.updateSequenceNumber(),r=e.version.minor===ri.Versions.TLS_1_0.minor?t.cipherState.init?null:t.cipherState.iv:ti.random.getBytesSync(16),t.cipherState.init=!0;var a=t.cipherState.cipher;return a.start({iv:r}),e.version.minor>=ri.Versions.TLS_1_1.minor&&a.output.putBytes(r),a.update(e.fragment),a.finish(ai)&&(e.fragment=a.output,e.length=e.fragment.length(),n=!0),n}function ai(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function si(e,t,r){var n=!0;if(r){for(var i=t.length(),a=t.last(),s=i-1-a;s<i-1;++s)n=n&&t.at(s)==a;n&&t.truncate(a+1)}return n}function oi(e,t){var r,n=!1;r=e.version.minor===ri.Versions.TLS_1_0.minor?t.cipherState.init?null:t.cipherState.iv:e.fragment.getBytes(16),t.cipherState.init=!0;var i=t.cipherState.cipher;i.start({iv:r}),i.update(e.fragment),n=i.finish(si);var a=t.macLength,s=ti.random.getBytesSync(a),o=i.output.length();o>=a?(e.fragment=i.output.getBytes(o-a),s=i.output.getBytes(a)):e.fragment=i.output.getBytes(),e.fragment=ti.util.createBuffer(e.fragment),e.length=e.fragment.length();var u=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),n=function(e,t,r){var n=ti.hmac.create();return n.start("SHA1",e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(r),r=n.digest().getBytes(),t===r}(t.macKey,s,u)&&n,n}ri.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=ri.BulkCipherAlgorithm.aes,e.cipher_type=ri.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=ri.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:ni},ri.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=ri.BulkCipherAlgorithm.aes,e.cipher_type=ri.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=ri.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:ni};var ui=S;ui.debug=ui.debug||{},ui.debug.storage={},ui.debug.get=function(e,t){var r;return void 0===e?r=ui.debug.storage:e in ui.debug.storage&&(r=void 0===t?ui.debug.storage[e]:ui.debug.storage[e][t]),r},ui.debug.set=function(e,t,r){e in ui.debug.storage||(ui.debug.storage[e]={}),ui.debug.storage[e][t]=r},ui.debug.clear=function(e,t){void 0===e?ui.debug.storage={}:e in ui.debug.storage&&(void 0===t?delete ui.debug.storage[e]:delete ui.debug.storage[e][t])};var ci=S,li=ci.sha512=ci.sha512||{};ci.md.sha512=ci.md.algorithms.sha512=li;var hi=ci.sha384=ci.sha512.sha384=ci.sha512.sha384||{};hi.create=function(){return li.create("SHA-384")},ci.md.sha384=ci.md.algorithms.sha384=hi,ci.sha512.sha256=ci.sha512.sha256||{create:function(){return li.create("SHA-512/256")}},ci.md["sha512/256"]=ci.md.algorithms["sha512/256"]=ci.sha512.sha256,ci.sha512.sha224=ci.sha512.sha224||{create:function(){return li.create("SHA-512/224")}},ci.md["sha512/224"]=ci.md.algorithms["sha512/224"]=ci.sha512.sha224,li.create=function(e){if(di||(fi=String.fromCharCode(128),fi+=ci.util.fillString(String.fromCharCode(0),128),pi=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(gi={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],gi["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],gi["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],gi["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],di=!0),void 0===e&&(e="SHA-512"),!(e in gi))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=gi[e],r=null,n=ci.util.createBuffer(),i=new Array(80),a=0;a<80;++a)i[a]=new Array(2);var s=64;switch(e){case"SHA-384":s=48;break;case"SHA-512/256":s=32;break;case"SHA-512/224":s=28}var o={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:s,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){o.messageLength=0,o.fullMessageLength=o.messageLength128=[];for(var e=o.messageLengthSize/4,i=0;i<e;++i)o.fullMessageLength.push(0);n=ci.util.createBuffer(),r=new Array(t.length);for(i=0;i<t.length;++i)r[i]=t[i].slice(0);return o}};return o.start(),o.update=function(e,t){"utf8"===t&&(e=ci.util.encodeUtf8(e));var a=e.length;o.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var s=o.fullMessageLength.length-1;s>=0;--s)o.fullMessageLength[s]+=a[1],a[1]=a[0]+(o.fullMessageLength[s]/4294967296>>>0),o.fullMessageLength[s]=o.fullMessageLength[s]>>>0,a[0]=a[1]/4294967296>>>0;return n.putBytes(e),yi(r,i,n),(n.read>2048||0===n.length())&&n.compact(),o},o.digest=function(){var t=ci.util.createBuffer();t.putBytes(n.bytes());var a,s=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;t.putBytes(fi.substr(0,o.blockLength-s));for(var u=8*o.fullMessageLength[0],c=0;c<o.fullMessageLength.length-1;++c)u+=(a=8*o.fullMessageLength[c+1])/4294967296>>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var l=new Array(r.length);for(c=0;c<r.length;++c)l[c]=r[c].slice(0);yi(l,i,t);var h,f=ci.util.createBuffer();h="SHA-512"===e?l.length:"SHA-384"===e?l.length-2:l.length-4;for(c=0;c<h;++c)f.putInt32(l[c][0]),c===h-1&&"SHA-512/224"===e||f.putInt32(l[c][1]);return f},o};var fi=null,di=!1,pi=null,gi=null;function yi(e,t,r){for(var n,i,a,s,o,u,c,l,h,f,d,p,g,y,m,v,C,E,b,S,T,_,w,I,A,B,k,N,R,L,D,U,x,O=r.length();O>=128;){for(k=0;k<16;++k)t[k][0]=r.getInt32()>>>0,t[k][1]=r.getInt32()>>>0;for(;k<80;++k)n=(((N=(L=t[k-2])[0])>>>19|(R=L[1])<<13)^(R>>>29|N<<3)^N>>>6)>>>0,i=((N<<13|R>>>19)^(R<<3|N>>>29)^(N<<26|R>>>6))>>>0,a=(((N=(U=t[k-15])[0])>>>1|(R=U[1])<<31)^(N>>>8|R<<24)^N>>>7)>>>0,s=((N<<31|R>>>1)^(N<<24|R>>>8)^(N<<25|R>>>7))>>>0,D=t[k-7],x=t[k-16],R=i+D[1]+s+x[1],t[k][0]=n+D[0]+a+x[0]+(R/4294967296>>>0)>>>0,t[k][1]=R>>>0;for(d=e[0][0],p=e[0][1],g=e[1][0],y=e[1][1],m=e[2][0],v=e[2][1],C=e[3][0],E=e[3][1],b=e[4][0],S=e[4][1],T=e[5][0],_=e[5][1],w=e[6][0],I=e[6][1],A=e[7][0],B=e[7][1],k=0;k<80;++k)c=((b>>>14|S<<18)^(b>>>18|S<<14)^(S>>>9|b<<23))>>>0,l=(w^b&(T^w))>>>0,o=((d>>>28|p<<4)^(p>>>2|d<<30)^(p>>>7|d<<25))>>>0,u=((d<<4|p>>>28)^(p<<30|d>>>2)^(p<<25|d>>>7))>>>0,h=(d&g|m&(d^g))>>>0,f=(p&y|v&(p^y))>>>0,R=B+(((b<<18|S>>>14)^(b<<14|S>>>18)^(S<<23|b>>>9))>>>0)+((I^S&(_^I))>>>0)+pi[k][1]+t[k][1],n=A+c+l+pi[k][0]+t[k][0]+(R/4294967296>>>0)>>>0,i=R>>>0,a=o+h+((R=u+f)/4294967296>>>0)>>>0,s=R>>>0,A=w,B=I,w=T,I=_,T=b,_=S,b=C+n+((R=E+i)/4294967296>>>0)>>>0,S=R>>>0,C=m,E=v,m=g,v=y,g=d,y=p,d=n+a+((R=i+s)/4294967296>>>0)>>>0,p=R>>>0;R=e[0][1]+p,e[0][0]=e[0][0]+d+(R/4294967296>>>0)>>>0,e[0][1]=R>>>0,R=e[1][1]+y,e[1][0]=e[1][0]+g+(R/4294967296>>>0)>>>0,e[1][1]=R>>>0,R=e[2][1]+v,e[2][0]=e[2][0]+m+(R/4294967296>>>0)>>>0,e[2][1]=R>>>0,R=e[3][1]+E,e[3][0]=e[3][0]+C+(R/4294967296>>>0)>>>0,e[3][1]=R>>>0,R=e[4][1]+S,e[4][0]=e[4][0]+b+(R/4294967296>>>0)>>>0,e[4][1]=R>>>0,R=e[5][1]+_,e[5][0]=e[5][0]+T+(R/4294967296>>>0)>>>0,e[5][1]=R>>>0,R=e[6][1]+I,e[6][0]=e[6][0]+w+(R/4294967296>>>0)>>>0,e[6][1]=R>>>0,R=e[7][1]+B,e[7][0]=e[7][0]+A+(R/4294967296>>>0)>>>0,e[7][1]=R>>>0,O-=128}}var mi={},vi=S.asn1;mi.privateKeyValidator={name:"PrivateKeyInfo",tagClass:vi.Class.UNIVERSAL,type:vi.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:vi.Class.UNIVERSAL,type:vi.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:vi.Class.UNIVERSAL,type:vi.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:vi.Class.UNIVERSAL,type:vi.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:vi.Class.UNIVERSAL,type:vi.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},mi.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:vi.Class.UNIVERSAL,type:vi.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:vi.Class.UNIVERSAL,type:vi.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:vi.Class.UNIVERSAL,type:vi.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:vi.Class.UNIVERSAL,type:vi.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]};var Ci=S,Ei=mi,bi=Ei.publicKeyValidator,Si=Ei.privateKeyValidator;if(void 0===Ti)var Ti=Ci.jsbn.BigInteger;var _i=Ci.util.ByteBuffer,wi="undefined"==typeof Buffer?Uint8Array:Buffer;Ci.pki=Ci.pki||{},Ci.pki.ed25519=Ci.ed25519=Ci.ed25519||{};var Ii=Ci.ed25519;function Ai(e){var t=e.message;if(t instanceof Uint8Array||t instanceof wi)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if("undefined"!=typeof Buffer)return Buffer.from(t,r);t=new _i(t,r)}else if(!(t instanceof _i))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new wi(t.length()),i=0;i<n.length;++i)n[i]=t.at(i);return n}Ii.constants={},Ii.constants.PUBLIC_KEY_BYTE_LENGTH=32,Ii.constants.PRIVATE_KEY_BYTE_LENGTH=64,Ii.constants.SEED_BYTE_LENGTH=32,Ii.constants.SIGN_BYTE_LENGTH=64,Ii.constants.HASH_BYTE_LENGTH=64,Ii.generateKeyPair=function(e){var t=(e=e||{}).seed;if(void 0===t)t=Ci.random.getBytesSync(Ii.constants.SEED_BYTE_LENGTH);else if("string"==typeof t){if(t.length!==Ii.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+Ii.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=Ai({message:t,encoding:"binary"});for(var r=new wi(Ii.constants.PUBLIC_KEY_BYTE_LENGTH),n=new wi(Ii.constants.PRIVATE_KEY_BYTE_LENGTH),i=0;i<32;++i)n[i]=t[i];return function(e,t){var r,n=[Xi(),Xi(),Xi(),Xi()],i=Oi(t,32);for(i[0]&=248,i[31]&=127,i[31]|=64,Wi(n,i),Fi(e,n),r=0;r<32;++r)t[r+32]=e[r]}(r,n),{publicKey:r,privateKey:n}},Ii.privateKeyFromAsn1=function(e){var t={},r=[];if(!Ci.asn1.validate(e,Si,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=Ci.asn1.derToOid(t.privateKeyOid),a=Ci.oids.EdDSA25519;if(i!==a)throw new Error('Invalid OID "'+i+'"; OID must be "'+a+'".');var s=t.privateKey;return{privateKeyBytes:Ai({message:Ci.asn1.fromDer(s).value,encoding:"binary"})}},Ii.publicKeyFromAsn1=function(e){var t={},r=[];if(!Ci.asn1.validate(e,bi,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=Ci.asn1.derToOid(t.publicKeyOid),a=Ci.oids.EdDSA25519;if(i!==a)throw new Error('Invalid OID "'+i+'"; OID must be "'+a+'".');var s=t.ed25519PublicKey;if(s.length!==Ii.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return Ai({message:s,encoding:"binary"})},Ii.publicKeyFromPrivateKey=function(e){var t=Ai({message:(e=e||{}).privateKey,encoding:"binary"});if(t.length!==Ii.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+Ii.constants.PRIVATE_KEY_BYTE_LENGTH);for(var r=new wi(Ii.constants.PUBLIC_KEY_BYTE_LENGTH),n=0;n<r.length;++n)r[n]=t[32+n];return r},Ii.sign=function(e){var t=Ai(e=e||{}),r=Ai({message:e.privateKey,encoding:"binary"});if(r.length===Ii.constants.SEED_BYTE_LENGTH)r=Ii.generateKeyPair({seed:r}).privateKey;else if(r.length!==Ii.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+Ii.constants.SEED_BYTE_LENGTH+" or "+Ii.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new wi(Ii.constants.SIGN_BYTE_LENGTH+t.length);!function(e,t,r,n){var i,a,s=new Float64Array(64),o=[Xi(),Xi(),Xi(),Xi()],u=Oi(n,32);u[0]&=248,u[31]&=127,u[31]|=64;var c=r+64;for(i=0;i<r;++i)e[64+i]=t[i];for(i=0;i<32;++i)e[32+i]=u[32+i];var l=Oi(e.subarray(32),r+32);for(Vi(l),Wi(o,l),Fi(e,o),i=32;i<64;++i)e[i]=n[i];var h=Oi(e,r+64);for(Vi(h),i=32;i<64;++i)s[i]=0;for(i=0;i<32;++i)s[i]=l[i];for(i=0;i<32;++i)for(a=0;a<32;a++)s[i+a]+=h[i]*u[a];Pi(e.subarray(32),s)}(n,t,t.length,r);for(var i=new wi(Ii.constants.SIGN_BYTE_LENGTH),a=0;a<i.length;++a)i[a]=n[a];return i},Ii.verify=function(e){var t=Ai(e=e||{});if(void 0===e.signature)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var r=Ai({message:e.signature,encoding:"binary"});if(r.length!==Ii.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+Ii.constants.SIGN_BYTE_LENGTH);var n=Ai({message:e.publicKey,encoding:"binary"});if(n.length!==Ii.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+Ii.constants.PUBLIC_KEY_BYTE_LENGTH);var i,a=new wi(Ii.constants.SIGN_BYTE_LENGTH+t.length),s=new wi(Ii.constants.SIGN_BYTE_LENGTH+t.length);for(i=0;i<Ii.constants.SIGN_BYTE_LENGTH;++i)a[i]=r[i];for(i=0;i<t.length;++i)a[i+Ii.constants.SIGN_BYTE_LENGTH]=t[i];return function(e,t,r,n){var i,a=new wi(32),s=[Xi(),Xi(),Xi(),Xi()],o=[Xi(),Xi(),Xi(),Xi()];if(-1,r<64)return-1;if(function(e,t){var r=Xi(),n=Xi(),i=Xi(),a=Xi(),s=Xi(),o=Xi(),u=Xi();Qi(e[2],ki),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),ea(i,e[1]),ta(a,i,Ni),Ji(i,i,e[2]),$i(a,e[2],a),ea(s,a),ea(o,s),ta(u,o,s),ta(r,u,i),ta(r,r,a),function(e,t){var r,n=Xi();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)ea(n,n),1!==r&&ta(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),ta(r,r,i),ta(r,r,a),ta(r,r,a),ta(e[0],r,a),ea(n,e[0]),ta(n,n,a),ji(n,i)&&ta(e[0],e[0],xi);if(ea(n,e[0]),ta(n,n,a),ji(n,i))return-1;Hi(e[0])===t[31]>>7&&Ji(e[0],Bi,e[0]);return ta(e[3],e[0],e[1]),0}(o,n))return-1;for(i=0;i<r;++i)e[i]=t[i];for(i=0;i<32;++i)e[i+32]=n[i];var u=Oi(e,r);if(Vi(u),Gi(s,o,u),Wi(o,t.subarray(32)),Ki(s,o),Fi(a,s),r-=64,qi(t,0,a,0)){for(i=0;i<r;++i)e[i]=0;return-1}for(i=0;i<r;++i)e[i]=t[i+64];return r}(s,a,a.length,n)>=0};var Bi=Xi(),ki=Xi([1]),Ni=Xi([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),Ri=Xi([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Li=Xi([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Di=Xi([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Ui=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),xi=Xi([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Oi(e,t){var r=Ci.md.sha512.create(),n=new _i(e);r.update(n.getBytes(t),"binary");var i=r.digest().getBytes();if("undefined"!=typeof Buffer)return Buffer.from(i,"binary");for(var a=new wi(Ii.constants.HASH_BYTE_LENGTH),s=0;s<64;++s)a[s]=i.charCodeAt(s);return a}function Pi(e,t){var r,n,i,a;for(n=63;n>=32;--n){for(r=0,i=n-32,a=n-12;i<a;++i)t[i]+=r-16*t[n]*Ui[i-(n-32)],r=t[i]+128>>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;++i)t[i]+=r-(t[31]>>4)*Ui[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=r*Ui[i];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function Vi(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;Pi(e,t)}function Ki(e,t){var r=Xi(),n=Xi(),i=Xi(),a=Xi(),s=Xi(),o=Xi(),u=Xi(),c=Xi(),l=Xi();Ji(r,e[1],e[0]),Ji(l,t[1],t[0]),ta(r,r,l),$i(n,e[0],e[1]),$i(l,t[0],t[1]),ta(n,n,l),ta(i,e[3],t[3]),ta(i,i,Ri),ta(a,e[2],t[2]),$i(a,a,a),Ji(s,n,r),Ji(o,a,i),$i(u,a,i),$i(c,n,r),ta(e[0],s,o),ta(e[1],c,u),ta(e[2],u,o),ta(e[3],s,c)}function Mi(e,t,r){for(var n=0;n<4;++n)Zi(e[n],t[n],r)}function Fi(e,t){var r=Xi(),n=Xi(),i=Xi();!function(e,t){var r,n=Xi();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)ea(n,n),2!==r&&4!==r&&ta(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(i,t[2]),ta(r,t[0],i),ta(n,t[1],i),zi(e,n),e[31]^=Hi(r)<<7}function zi(e,t){var r,n,i,a=Xi(),s=Xi();for(r=0;r<16;++r)s[r]=t[r];for(Yi(s),Yi(s),Yi(s),n=0;n<2;++n){for(a[0]=s[0]-65517,r=1;r<15;++r)a[r]=s[r]-65535-(a[r-1]>>16&1),a[r-1]&=65535;a[15]=s[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,Zi(s,a,1-i)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function ji(e,t){var r=new wi(32),n=new wi(32);return zi(r,e),zi(n,t),qi(r,0,n,0)}function qi(e,t,r,n){return function(e,t,r,n,i){var a,s=0;for(a=0;a<i;++a)s|=e[t+a]^r[n+a];return(1&s-1>>>8)-1}(e,t,r,n,32)}function Hi(e){var t=new wi(32);return zi(t,e),1&t[0]}function Gi(e,t,r){var n,i;for(Qi(e[0],Bi),Qi(e[1],ki),Qi(e[2],ki),Qi(e[3],Bi),i=255;i>=0;--i)Mi(e,t,n=r[i/8|0]>>(7&i)&1),Ki(t,e),Ki(e,e),Mi(e,t,n)}function Wi(e,t){var r=[Xi(),Xi(),Xi(),Xi()];Qi(r[0],Li),Qi(r[1],Di),Qi(r[2],ki),ta(r[3],Li,Di),Gi(e,r,t)}function Qi(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function Yi(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function Zi(e,t,r){for(var n,i=~(r-1),a=0;a<16;++a)n=i&(e[a]^t[a]),e[a]^=n,t[a]^=n}function Xi(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;++t)r[t]=e[t];return r}function $i(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]+r[n]}function Ji(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]-r[n]}function ea(e,t){ta(e,t,t)}function ta(e,t,r){var n,i,a=0,s=0,o=0,u=0,c=0,l=0,h=0,f=0,d=0,p=0,g=0,y=0,m=0,v=0,C=0,E=0,b=0,S=0,T=0,_=0,w=0,I=0,A=0,B=0,k=0,N=0,R=0,L=0,D=0,U=0,x=0,O=r[0],P=r[1],V=r[2],K=r[3],M=r[4],F=r[5],z=r[6],j=r[7],q=r[8],H=r[9],G=r[10],W=r[11],Q=r[12],Y=r[13],Z=r[14],X=r[15];a+=(n=t[0])*O,s+=n*P,o+=n*V,u+=n*K,c+=n*M,l+=n*F,h+=n*z,f+=n*j,d+=n*q,p+=n*H,g+=n*G,y+=n*W,m+=n*Q,v+=n*Y,C+=n*Z,E+=n*X,s+=(n=t[1])*O,o+=n*P,u+=n*V,c+=n*K,l+=n*M,h+=n*F,f+=n*z,d+=n*j,p+=n*q,g+=n*H,y+=n*G,m+=n*W,v+=n*Q,C+=n*Y,E+=n*Z,b+=n*X,o+=(n=t[2])*O,u+=n*P,c+=n*V,l+=n*K,h+=n*M,f+=n*F,d+=n*z,p+=n*j,g+=n*q,y+=n*H,m+=n*G,v+=n*W,C+=n*Q,E+=n*Y,b+=n*Z,S+=n*X,u+=(n=t[3])*O,c+=n*P,l+=n*V,h+=n*K,f+=n*M,d+=n*F,p+=n*z,g+=n*j,y+=n*q,m+=n*H,v+=n*G,C+=n*W,E+=n*Q,b+=n*Y,S+=n*Z,T+=n*X,c+=(n=t[4])*O,l+=n*P,h+=n*V,f+=n*K,d+=n*M,p+=n*F,g+=n*z,y+=n*j,m+=n*q,v+=n*H,C+=n*G,E+=n*W,b+=n*Q,S+=n*Y,T+=n*Z,_+=n*X,l+=(n=t[5])*O,h+=n*P,f+=n*V,d+=n*K,p+=n*M,g+=n*F,y+=n*z,m+=n*j,v+=n*q,C+=n*H,E+=n*G,b+=n*W,S+=n*Q,T+=n*Y,_+=n*Z,w+=n*X,h+=(n=t[6])*O,f+=n*P,d+=n*V,p+=n*K,g+=n*M,y+=n*F,m+=n*z,v+=n*j,C+=n*q,E+=n*H,b+=n*G,S+=n*W,T+=n*Q,_+=n*Y,w+=n*Z,I+=n*X,f+=(n=t[7])*O,d+=n*P,p+=n*V,g+=n*K,y+=n*M,m+=n*F,v+=n*z,C+=n*j,E+=n*q,b+=n*H,S+=n*G,T+=n*W,_+=n*Q,w+=n*Y,I+=n*Z,A+=n*X,d+=(n=t[8])*O,p+=n*P,g+=n*V,y+=n*K,m+=n*M,v+=n*F,C+=n*z,E+=n*j,b+=n*q,S+=n*H,T+=n*G,_+=n*W,w+=n*Q,I+=n*Y,A+=n*Z,B+=n*X,p+=(n=t[9])*O,g+=n*P,y+=n*V,m+=n*K,v+=n*M,C+=n*F,E+=n*z,b+=n*j,S+=n*q,T+=n*H,_+=n*G,w+=n*W,I+=n*Q,A+=n*Y,B+=n*Z,k+=n*X,g+=(n=t[10])*O,y+=n*P,m+=n*V,v+=n*K,C+=n*M,E+=n*F,b+=n*z,S+=n*j,T+=n*q,_+=n*H,w+=n*G,I+=n*W,A+=n*Q,B+=n*Y,k+=n*Z,N+=n*X,y+=(n=t[11])*O,m+=n*P,v+=n*V,C+=n*K,E+=n*M,b+=n*F,S+=n*z,T+=n*j,_+=n*q,w+=n*H,I+=n*G,A+=n*W,B+=n*Q,k+=n*Y,N+=n*Z,R+=n*X,m+=(n=t[12])*O,v+=n*P,C+=n*V,E+=n*K,b+=n*M,S+=n*F,T+=n*z,_+=n*j,w+=n*q,I+=n*H,A+=n*G,B+=n*W,k+=n*Q,N+=n*Y,R+=n*Z,L+=n*X,v+=(n=t[13])*O,C+=n*P,E+=n*V,b+=n*K,S+=n*M,T+=n*F,_+=n*z,w+=n*j,I+=n*q,A+=n*H,B+=n*G,k+=n*W,N+=n*Q,R+=n*Y,L+=n*Z,D+=n*X,C+=(n=t[14])*O,E+=n*P,b+=n*V,S+=n*K,T+=n*M,_+=n*F,w+=n*z,I+=n*j,A+=n*q,B+=n*H,k+=n*G,N+=n*W,R+=n*Q,L+=n*Y,D+=n*Z,U+=n*X,E+=(n=t[15])*O,s+=38*(S+=n*V),o+=38*(T+=n*K),u+=38*(_+=n*M),c+=38*(w+=n*F),l+=38*(I+=n*z),h+=38*(A+=n*j),f+=38*(B+=n*q),d+=38*(k+=n*H),p+=38*(N+=n*G),g+=38*(R+=n*W),y+=38*(L+=n*Q),m+=38*(D+=n*Y),v+=38*(U+=n*Z),C+=38*(x+=n*X),a=(n=(a+=38*(b+=n*P))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),E=(n=E+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=(a+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),E=(n=E+i+65535)-65536*(i=Math.floor(n/65536)),a+=i-1+37*(i-1),e[0]=a,e[1]=s,e[2]=o,e[3]=u,e[4]=c,e[5]=l,e[6]=h,e[7]=f,e[8]=d,e[9]=p,e[10]=g,e[11]=y,e[12]=m,e[13]=v,e[14]=C,e[15]=E}var ra=S;ra.kem=ra.kem||{};var na=ra.jsbn.BigInteger;function ia(e,t,r,n){e.generate=function(e,i){for(var a=new ra.util.ByteBuffer,s=Math.ceil(i/n)+r,o=new ra.util.ByteBuffer,u=r;u<s;++u){o.putInt32(u),t.start(),t.update(e+o.getBytes());var c=t.digest();a.putBytes(c.getBytes(n))}return a.truncate(a.length()-i),a.getBytes()}}ra.kem.rsa={},ra.kem.rsa.create=function(e,t){var r=(t=t||{}).prng||ra.random,n={encrypt:function(t,n){var i,a=Math.ceil(t.n.bitLength()/8);do{i=new na(ra.util.bytesToHex(r.getBytesSync(a)),16).mod(t.n)}while(i.compareTo(na.ONE)<=0);var s=a-(i=ra.util.hexToBytes(i.toString(16))).length;return s>0&&(i=ra.util.fillString(String.fromCharCode(0),s)+i),{encapsulation:t.encrypt(i,"NONE"),key:e.generate(i,n)}},decrypt:function(t,r,n){var i=t.decrypt(r,"NONE");return e.generate(i,n)}};return n},ra.kem.kdf1=function(e,t){ia(this,e,0,t||e.digestLength)},ra.kem.kdf2=function(e,t){ia(this,e,1,t||e.digestLength)};var aa=S;aa.log=aa.log||{},aa.log.levels=["none","error","warning","info","debug","verbose","max"];var sa={},oa=[],ua=null;aa.log.LEVEL_LOCKED=2,aa.log.NO_LEVEL_CHECK=4,aa.log.INTERPOLATE=8;for(var ca=0;ca<aa.log.levels.length;++ca){var la=aa.log.levels[ca];sa[la]={index:ca,name:la.toUpperCase()}}aa.log.logMessage=function(e){for(var t=sa[e.level].index,r=0;r<oa.length;++r){var n=oa[r];if(n.flags&aa.log.NO_LEVEL_CHECK)n.f(e);else t<=sa[n.level].index&&n.f(n,e)}},aa.log.prepareStandard=function(e){"standard"in e||(e.standard=sa[e.level].name+" ["+e.category+"] "+e.message)},aa.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]||e.arguments),e.full=aa.util.format.apply(this,t)}},aa.log.prepareStandardFull=function(e){"standardFull"in e||(aa.log.prepareStandard(e),e.standardFull=e.standard)};var ha=["error","warning","info","debug","verbose"];for(ca=0;ca<ha.length;++ca)!function(e){aa.log[e]=function(t,r){var n=Array.prototype.slice.call(arguments).slice(2),i={timestamp:new Date,level:e,category:t,message:r,arguments:n};aa.log.logMessage(i)}}(ha[ca]);if(aa.log.makeLogger=function(e){var t={flags:0,f:e};return aa.log.setLevel(t,"none"),t},aa.log.setLevel=function(e,t){var r=!1;if(e&&!(e.flags&aa.log.LEVEL_LOCKED))for(var n=0;n<aa.log.levels.length;++n){if(t==aa.log.levels[n]){e.level=t,r=!0;break}}return r},aa.log.lock=function(e,t){void 0===t||t?e.flags|=aa.log.LEVEL_LOCKED:e.flags&=~aa.log.LEVEL_LOCKED},aa.log.addLogger=function(e){oa.push(e)},"undefined"!=typeof console&&"log"in console){var fa;if(console.error&&console.warn&&console.info&&console.debug){var da={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},pa=function(e,t){aa.log.prepareStandard(t);var r=da[t.level],n=[t.standard];n=n.concat(t.arguments.slice()),r.apply(console,n)};fa=aa.log.makeLogger(pa)}else{pa=function(e,t){aa.log.prepareStandardFull(t),console.log(t.standardFull)};fa=aa.log.makeLogger(pa)}aa.log.setLevel(fa,"debug"),aa.log.addLogger(fa),ua=fa}else console={log:function(){}};if(null!==ua){var ga=aa.util.getQueryVariables();if("console.level"in ga&&aa.log.setLevel(ua,ga["console.level"].slice(-1)[0]),"console.lock"in ga)"true"==ga["console.lock"].slice(-1)[0]&&aa.log.lock(ua)}aa.log.consoleLogger=ua;var ya={};({get exports(){return ya},set exports(e){ya=e}}).exports=ve;var ma=S,va=ma.asn1,Ca=ma.pkcs7=ma.pkcs7||{};function Ea(e){var t={},r=[];if(!va.validate(e,Ca.asn1.recipientInfoValidator,t,r)){var n=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw n.errors=r,n}return{version:t.version.charCodeAt(0),issuer:ma.pki.RDNAttributesAsArray(t.issuer),serialNumber:ma.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:va.derToOid(t.encAlgorithm),parameter:t.encParameter.value,content:t.encKey}}}function ba(e){for(var t,r=[],n=0;n<e.length;++n)r.push((t=e[n],va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,va.integerToDer(t.version).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[ma.pki.distinguishedNameToAsn1({attributes:t.issuer}),va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,ma.util.hexToBytes(t.serialNumber))]),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(t.encryptedContent.algorithm).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.NULL,!1,"")]),va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,t.encryptedContent.content)])));return r}function Sa(e){var t=va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,va.integerToDer(e.version).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[ma.pki.distinguishedNameToAsn1({attributes:e.issuer}),va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,ma.util.hexToBytes(e.serialNumber))]),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.digestAlgorithm).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.signatureAlgorithm).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.NULL,!1,"")])),t.value.push(va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var r=va.create(va.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<e.unauthenticatedAttributes.length;++n){var i=e.unauthenticatedAttributes[n];r.values.push(Ta(i))}t.value.push(r)}return t}function Ta(e){var t;if(e.type===ma.pki.oids.contentType)t=va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.value).getBytes());else if(e.type===ma.pki.oids.messageDigest)t=va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===ma.pki.oids.signingTime){var r=new Date("1950-01-01T00:00:00Z"),n=new Date("2050-01-01T00:00:00Z"),i=e.value;if("string"==typeof i){var a=Date.parse(i);i=isNaN(a)?13===i.length?va.utcTimeToDate(i):va.generalizedTimeToDate(i):new Date(a)}t=i>=r&&i<n?va.create(va.Class.UNIVERSAL,va.Type.UTCTIME,!1,va.dateToUtcTime(i)):va.create(va.Class.UNIVERSAL,va.Type.GENERALIZEDTIME,!1,va.dateToGeneralizedTime(i))}return va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.type).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SET,!0,[t])])}function _a(e,t,r){var n={};if(!va.validate(t,r,n,[])){var i=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw i.errors=i,i}if(va.derToOid(n.contentType)!==ma.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var a="";if(ma.util.isArray(n.encryptedContent))for(var s=0;s<n.encryptedContent.length;++s){if(n.encryptedContent[s].type!==va.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");a+=n.encryptedContent[s].value}else a=n.encryptedContent;e.encryptedContent={algorithm:va.derToOid(n.encAlgorithm),parameter:ma.util.createBuffer(n.encParameter.value),content:ma.util.createBuffer(a)}}if(n.content){a="";if(ma.util.isArray(n.content))for(s=0;s<n.content.length;++s){if(n.content[s].type!==va.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");a+=n.content[s].value}else a=n.content;e.content=ma.util.createBuffer(a)}return e.version=n.version.charCodeAt(0),e.rawCapture=n,n}function wa(e){if(void 0===e.encryptedContent.key)throw new Error("Symmetric key not available.");if(void 0===e.content){var t;switch(e.encryptedContent.algorithm){case ma.pki.oids["aes128-CBC"]:case ma.pki.oids["aes192-CBC"]:case ma.pki.oids["aes256-CBC"]:t=ma.aes.createDecryptionCipher(e.encryptedContent.key);break;case ma.pki.oids.desCBC:case ma.pki.oids["des-EDE3-CBC"]:t=ma.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}Ca.messageFromPem=function(e){var t=ma.pem.decode(e)[0];if("PKCS7"!==t.type){var r=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var n=va.fromDer(t.body);return Ca.messageFromAsn1(n)},Ca.messageToPem=function(e,t){var r={type:"PKCS7",body:va.toDer(e.toAsn1()).getBytes()};return ma.pem.encode(r,{maxline:t})},Ca.messageFromAsn1=function(e){var t={},r=[];if(!va.validate(e,Ca.asn1.contentInfoValidator,t,r)){var n=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw n.errors=r,n}var i,a=va.derToOid(t.contentType);switch(a){case ma.pki.oids.envelopedData:i=Ca.createEnvelopedData();break;case ma.pki.oids.encryptedData:i=Ca.createEncryptedData();break;case ma.pki.oids.signedData:i=Ca.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+a+" is not (yet) supported.")}return i.fromAsn1(t.content.value[0]),i},Ca.createSignedData=function(){var e=null;return e={type:ma.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){if(_a(e,t,Ca.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var r=e.rawCapture.certificates.value,n=0;n<r.length;++n)e.certificates.push(ma.pki.certificateFromAsn1(r[n]))},toAsn1:function(){e.contentInfo||e.sign();for(var t=[],r=0;r<e.certificates.length;++r)t.push(ma.pki.certificateToAsn1(e.certificates[r]));var n=[],i=va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,va.integerToDer(e.version).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return t.length>0&&i.value[0].value.push(va.create(va.Class.CONTEXT_SPECIFIC,0,!0,t)),n.length>0&&i.value[0].value.push(va.create(va.Class.CONTEXT_SPECIFIC,1,!0,n)),i.value[0].value.push(va.create(va.Class.UNIVERSAL,va.Type.SET,!0,e.signerInfos)),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.type).getBytes()),i])},addSigner:function(t){var r=t.issuer,n=t.serialNumber;if(t.certificate){var i=t.certificate;"string"==typeof i&&(i=ma.pki.certificateFromPem(i)),r=i.issuer.attributes,n=i.serialNumber}var a=t.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof a&&(a=ma.pki.privateKeyFromPem(a));var s=t.digestAlgorithm||ma.pki.oids.sha1;switch(s){case ma.pki.oids.sha1:case ma.pki.oids.sha256:case ma.pki.oids.sha384:case ma.pki.oids.sha512:case ma.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+s)}var o=t.authenticatedAttributes||[];if(o.length>0){for(var u=!1,c=!1,l=0;l<o.length;++l){var h=o[l];if(u||h.type!==ma.pki.oids.contentType){if(c||h.type!==ma.pki.oids.messageDigest);else if(c=!0,u)break}else if(u=!0,c)break}if(!u||!c)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:a,version:1,issuer:r,serialNumber:n,digestAlgorithm:s,signatureAlgorithm:ma.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:o,unauthenticatedAttributes:[]})},sign:function(t){var r;(t=t||{},"object"!=typeof e.content||null===e.contentInfo)&&(e.contentInfo=va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(ma.pki.oids.data).getBytes())]),"content"in e&&(e.content instanceof ma.util.ByteBuffer?r=e.content.bytes():"string"==typeof e.content&&(r=ma.util.encodeUtf8(e.content)),t.detached?e.detachedContent=va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,r):e.contentInfo.value.push(va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,r)]))));if(0!==e.signers.length){var n=function(){for(var t={},r=0;r<e.signers.length;++r){var n=e.signers[r];(i=n.digestAlgorithm)in t||(t[i]=ma.md[ma.pki.oids[i]].create()),0===n.authenticatedAttributes.length?n.md=t[i]:n.md=ma.md[ma.pki.oids[i]].create()}for(var i in e.digestAlgorithmIdentifiers=[],t)e.digestAlgorithmIdentifiers.push(va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(i).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.NULL,!1,"")]));return t}();!function(t){var r;r=e.detachedContent?e.detachedContent:(r=e.contentInfo.value[1]).value[0];if(!r)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var n=va.derToOid(e.contentInfo.value[0].value),i=va.toDer(r);for(var a in i.getByte(),va.getBerValueLength(i),i=i.getBytes(),t)t[a].start().update(i);for(var s=new Date,o=0;o<e.signers.length;++o){var u=e.signers[o];if(0===u.authenticatedAttributes.length){if(n!==ma.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{u.authenticatedAttributesAsn1=va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var c=va.create(va.Class.UNIVERSAL,va.Type.SET,!0,[]),l=0;l<u.authenticatedAttributes.length;++l){var h=u.authenticatedAttributes[l];h.type===ma.pki.oids.messageDigest?h.value=t[u.digestAlgorithm].digest():h.type===ma.pki.oids.signingTime&&(h.value||(h.value=s)),c.value.push(Ta(h)),u.authenticatedAttributesAsn1.value.push(Ta(h))}i=va.toDer(c).getBytes(),u.md.start().update(i)}u.signature=u.key.sign(u.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(Sa(e[r]));return t}(e.signers)}(n)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(t){"string"==typeof t&&(t=ma.pki.certificateFromPem(t)),e.certificates.push(t)},addCertificateRevokationList:function(e){throw new Error("PKCS#7 CRL support not yet implemented.")}},e},Ca.createEncryptedData=function(){var e=null;return e={type:ma.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:ma.pki.oids["aes256-CBC"]},fromAsn1:function(t){_a(e,t,Ca.asn1.encryptedDataValidator)},decrypt:function(t){void 0!==t&&(e.encryptedContent.key=t),wa(e)}},e},Ca.createEnvelopedData=function(){var e=null;return e={type:ma.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:ma.pki.oids["aes256-CBC"]},fromAsn1:function(t){var r=_a(e,t,Ca.asn1.envelopedDataValidator);e.recipients=function(e){for(var t=[],r=0;r<e.length;++r)t.push(Ea(e[r]));return t}(r.recipientInfos.value)},toAsn1:function(){return va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.type).getBytes()),va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,va.integerToDer(e.version).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SET,!0,ba(e.recipients)),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,(t=e.encryptedContent,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(ma.pki.oids.data).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(t.algorithm).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,t.parameter.getBytes())]),va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,t.content.getBytes())])]))])])]);var t},findRecipient:function(t){for(var r=t.issuer.attributes,n=0;n<e.recipients.length;++n){var i=e.recipients[n],a=i.issuer;if(i.serialNumber===t.serialNumber&&a.length===r.length){for(var s=!0,o=0;o<r.length;++o)if(a[o].type!==r[o].type||a[o].value!==r[o].value){s=!1;break}if(s)return i}}return null},decrypt:function(t,r){if(void 0===e.encryptedContent.key&&void 0!==t&&void 0!==r)switch(t.encryptedContent.algorithm){case ma.pki.oids.rsaEncryption:case ma.pki.oids.desCBC:var n=r.decrypt(t.encryptedContent.content);e.encryptedContent.key=ma.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}wa(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:ma.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(void 0===e.encryptedContent.content){var n,i,a;switch(r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key,r){case ma.pki.oids["aes128-CBC"]:n=16,i=16,a=ma.aes.createEncryptionCipher;break;case ma.pki.oids["aes192-CBC"]:n=24,i=16,a=ma.aes.createEncryptionCipher;break;case ma.pki.oids["aes256-CBC"]:n=32,i=16,a=ma.aes.createEncryptionCipher;break;case ma.pki.oids["des-EDE3-CBC"]:n=24,i=8,a=ma.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(void 0===t)t=ma.util.createBuffer(ma.random.getBytes(n));else if(t.length()!=n)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+n+".");e.encryptedContent.algorithm=r,e.encryptedContent.key=t,e.encryptedContent.parameter=ma.util.createBuffer(ma.random.getBytes(i));var s=a(t);if(s.start(e.encryptedContent.parameter.copy()),s.update(e.content),!s.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=s.output}for(var o=0;o<e.recipients.length;++o){var u=e.recipients[o];if(void 0===u.encryptedContent.content){if(u.encryptedContent.algorithm!==ma.pki.oids.rsaEncryption)throw new Error("Unsupported asymmetric cipher, OID "+u.encryptedContent.algorithm);u.encryptedContent.content=u.encryptedContent.key.encrypt(e.encryptedContent.key.data)}}}},e};var Ia=S,Aa=Ia.ssh=Ia.ssh||{};function Ba(e,t){var r=t.toString(16);r[0]>="8"&&(r="00"+r);var n=Ia.util.hexToBytes(r);e.putInt32(n.length),e.putBytes(n)}function ka(e,t){e.putInt32(t.length),e.putString(t)}function Na(){for(var e=Ia.md.sha1.create(),t=arguments.length,r=0;r<t;++r)e.update(arguments[r]);return e.digest()}Aa.privateKeyToPutty=function(e,t,r){var n="ssh-rsa",i=""===(t=t||"")?"none":"aes256-cbc",a="PuTTY-User-Key-File-2: "+n+"\r\n";a+="Encryption: "+i+"\r\n",a+="Comment: "+(r=r||"")+"\r\n";var s=Ia.util.createBuffer();ka(s,n),Ba(s,e.e),Ba(s,e.n);var o=Ia.util.encode64(s.bytes(),64),u=Math.floor(o.length/66)+1;a+="Public-Lines: "+u+"\r\n",a+=o;var c,l=Ia.util.createBuffer();if(Ba(l,e.d),Ba(l,e.p),Ba(l,e.q),Ba(l,e.qInv),t){var h=l.length()+16-1;h-=h%16;var f=Na(l.bytes());f.truncate(f.length()-h+l.length()),l.putBuffer(f);var d=Ia.util.createBuffer();d.putBuffer(Na("\0\0\0\0",t)),d.putBuffer(Na("\0\0\0",t));var p=Ia.aes.createEncryptionCipher(d.truncate(8),"CBC");p.start(Ia.util.createBuffer().fillWithByte(0,16)),p.update(l.copy()),p.finish();var g=p.output;g.truncate(16),c=Ia.util.encode64(g.bytes(),64)}else c=Ia.util.encode64(l.bytes(),64);a+="\r\nPrivate-Lines: "+(u=Math.floor(c.length/66)+1)+"\r\n",a+=c;var y=Na("putty-private-key-file-mac-key",t),m=Ia.util.createBuffer();ka(m,n),ka(m,i),ka(m,r),m.putInt32(s.length()),m.putBuffer(s),m.putInt32(l.length()),m.putBuffer(l);var v=Ia.hmac.create();return v.start("sha1",y),v.update(m.bytes()),a+="\r\nPrivate-MAC: "+v.digest().toHex()+"\r\n"},Aa.publicKeyToOpenSSH=function(e,t){var r="ssh-rsa";t=t||"";var n=Ia.util.createBuffer();return ka(n,r),Ba(n,e.e),Ba(n,e.n),r+" "+Ia.util.encode64(n.bytes())+" "+t},Aa.privateKeyToOpenSSH=function(e,t){return t?Ia.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):Ia.pki.privateKeyToPem(e)},Aa.getPublicKeyFingerprint=function(e,t){var r=(t=t||{}).md||Ia.md.md5.create(),n=Ia.util.createBuffer();ka(n,"ssh-rsa"),Ba(n,e.e),Ba(n,e.n),r.start(),r.update(n.getBytes());var i=r.digest();if("hex"===t.encoding){var a=i.toHex();return t.delimiter?a.match(/.{2}/g).join(t.delimiter):a}if("binary"===t.encoding)return i.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return i};var Ra=S,La="forge.task",Da={},Ua=0;Ra.debug.set(La,"tasks",Da);var xa={};Ra.debug.set(La,"queues",xa);var Oa="ready",Pa="running",Va="blocked",Ka="sleeping",Ma="done",Fa="error",za="stop",ja="start",qa="block",Ha="unblock",Ga="sleep",Wa="wakeup",Qa="cancel",Ya="fail",Za={};Za[Oa]={},Za[Oa][za]=Oa,Za[Oa][ja]=Pa,Za[Oa][Qa]=Ma,Za[Oa][Ya]=Fa,Za[Pa]={},Za[Pa][za]=Oa,Za[Pa][ja]=Pa,Za[Pa][qa]=Va,Za[Pa][Ha]=Pa,Za[Pa][Ga]=Ka,Za[Pa][Wa]=Pa,Za[Pa][Qa]=Ma,Za[Pa][Ya]=Fa,Za[Va]={},Za[Va][za]=Va,Za[Va][ja]=Va,Za[Va][qa]=Va,Za[Va][Ha]=Va,Za[Va][Ga]=Va,Za[Va][Wa]=Va,Za[Va][Qa]=Ma,Za[Va][Ya]=Fa,Za[Ka]={},Za[Ka][za]=Ka,Za[Ka][ja]=Ka,Za[Ka][qa]=Ka,Za[Ka][Ha]=Ka,Za[Ka][Ga]=Ka,Za[Ka][Wa]=Ka,Za[Ka][Qa]=Ma,Za[Ka][Ya]=Fa,Za[Ma]={},Za[Ma][za]=Ma,Za[Ma][ja]=Ma,Za[Ma][qa]=Ma,Za[Ma][Ha]=Ma,Za[Ma][Ga]=Ma,Za[Ma][Wa]=Ma,Za[Ma][Qa]=Ma,Za[Ma][Ya]=Fa,Za[Fa]={},Za[Fa][za]=Fa,Za[Fa][ja]=Fa,Za[Fa][qa]=Fa,Za[Fa][Ha]=Fa,Za[Fa][Ga]=Fa,Za[Fa][Wa]=Fa,Za[Fa][Qa]=Fa,Za[Fa][Ya]=Fa;var Xa=function(e){this.id=-1,this.name=e.name||"?",this.parent=e.parent||null,this.run=e.run,this.subtasks=[],this.error=!1,this.state=Oa,this.blocks=0,this.timeoutId=null,this.swapTime=null,this.userData=null,this.id=Ua++,Da[this.id]=this};Xa.prototype.debug=function(e){e=e||"",Ra.log.debug(La,e,"[%s][%s] task:",this.id,this.name,this,"subtasks:",this.subtasks.length,"queue:",xa)},Xa.prototype.next=function(e,t){"function"==typeof e&&(t=e,e=this.name);var r=new Xa({run:t,name:e,parent:this});return r.state=Pa,r.type=this.type,r.successCallback=this.successCallback||null,r.failureCallback=this.failureCallback||null,this.subtasks.push(r),this},Xa.prototype.parallel=function(e,t){return Ra.util.isArray(e)&&(t=e,e=this.name),this.next(e,(function(r){var n=r;n.block(t.length);for(var i=function(e,r){Ra.task.start({type:e,run:function(e){t[r](e)},success:function(e){n.unblock()},failure:function(e){n.unblock()}})},a=0;a<t.length;a++){i(e+"__parallel-"+r.id+"-"+a,a)}}))},Xa.prototype.stop=function(){this.state=Za[this.state][za]},Xa.prototype.start=function(){this.error=!1,this.state=Za[this.state][ja],this.state===Pa&&(this.start=new Date,this.run(this),$a(this,0))},Xa.prototype.block=function(e){e=void 0===e?1:e,this.blocks+=e,this.blocks>0&&(this.state=Za[this.state][qa])},Xa.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==Ma&&(this.state=Pa,$a(this,0)),this.blocks},Xa.prototype.sleep=function(e){e=void 0===e?0:e,this.state=Za[this.state][Ga];var t=this;this.timeoutId=setTimeout((function(){t.timeoutId=null,t.state=Pa,$a(t,0)}),e)},Xa.prototype.wait=function(e){e.wait(this)},Xa.prototype.wakeup=function(){this.state===Ka&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=Pa,$a(this,0))},Xa.prototype.cancel=function(){this.state=Za[this.state][Qa],this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},Xa.prototype.fail=function(e){if(this.error=!0,Ja(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,$a(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;Ja(t,!0)}this.failureCallback&&this.failureCallback(this)}};var $a=function(e,t){var r=t>30||+new Date-e.swapTime>20,n=function(t){if(t++,e.state===Pa)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var n=e.subtasks.shift();n.error=e.error,n.swapTime=e.swapTime,n.userData=e.userData,n.run(n),n.error||$a(n,t)}else Ja(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,$a(e.parent,t))};r?setTimeout(n,0):n(t)},Ja=function(e,t){e.state=Ma,delete Da[e.id],null===e.parent&&(e.type in xa?0===xa[e.type].length?Ra.log.error(La,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):xa[e.type][0]!==e?Ra.log.error(La,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(xa[e.type].shift(),0===xa[e.type].length?delete xa[e.type]:xa[e.type][0].start()):Ra.log.error(La,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};Ra.task=Ra.task||{},Ra.task.start=function(e){var t=new Xa({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in xa?xa[e.type].push(t):(xa[t.type]=[t],function(e){e.error=!1,e.state=Za[e.state][ja],setTimeout((function(){e.state===Pa&&(e.swapTime=+new Date,e.run(e),$a(e,0))}),0)}(t))},Ra.task.cancel=function(e){e in xa&&(xa[e]=[xa[e][0]])},Ra.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e},b.exports=S;var es=C(E);class ts{crt;key;csr;detail;expires;constructor(e){this.crt=e.crt,this.key=e.key,this.csr=e.csr;const{detail:t,expires:r}=this.getCrtDetail(this.crt);this.detail=t,this.expires=r.getTime()}toCertInfo(){return{crt:this.crt,key:this.key,csr:this.csr}}getCrtDetail(e){const t=es.pki.certificateFromPem(e.toString());return{detail:t,expires:t.validity.notAfter}}saveToFile(e,t){null==t&&(t=o.join(a.tmpdir(),"/certd/tmp/",Math.floor(1e6*Math.random())+"",`cert.${e}`));const r=o.dirname(t);return i.existsSync(r)||i.mkdirSync(r,{recursive:!0}),i.writeFileSync(t,this[e]),t}}var rs,ns,is,as={},ss={},os={},us={},cs={get exports(){return us},set exports(e){us=e}},ls={},hs={get exports(){return ls},set exports(e){ls=e}};function fs(){if(rs)return ls;return rs=1,"undefined"==typeof process||!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?hs.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,a,s=arguments.length;switch(s){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick((function(){e.call(null,t)}));case 3:return process.nextTick((function(){e.call(null,t,r)}));case 4:return process.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),a=0;a<i.length;)i[a++]=arguments[a];return process.nextTick((function(){e.apply(null,i)}))}}}:hs.exports=process,ls}var ds,ps={},gs={get exports(){return ps},set exports(e){ps=e}};function ys(){return ds||(ds=1,gs.exports=u),ps}var ms,vs={},Cs={get exports(){return vs},set exports(e){vs=e}};function Es(){return ms||(ms=1,function(e,t){var r=l,n=r.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=a),i(n,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(Cs,vs)),vs}var bs,Ss={};function Ts(){if(bs)return Ss;function e(e){return Object.prototype.toString.call(e)}return bs=1,Ss.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===e(t)},Ss.isBoolean=function(e){return"boolean"==typeof e},Ss.isNull=function(e){return null===e},Ss.isNullOrUndefined=function(e){return null==e},Ss.isNumber=function(e){return"number"==typeof e},Ss.isString=function(e){return"string"==typeof e},Ss.isSymbol=function(e){return"symbol"==typeof e},Ss.isUndefined=function(e){return void 0===e},Ss.isRegExp=function(t){return"[object RegExp]"===e(t)},Ss.isObject=function(e){return"object"==typeof e&&null!==e},Ss.isDate=function(t){return"[object Date]"===e(t)},Ss.isError=function(t){return"[object Error]"===e(t)||t instanceof Error},Ss.isFunction=function(e){return"function"==typeof e},Ss.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Ss.isBuffer=l.Buffer.isBuffer,Ss}var _s,ws,Is={},As={get exports(){return Is},set exports(e){Is=e}},Bs={},ks={get exports(){return Bs},set exports(e){Bs=e}};function Ns(){return ws||(ws=1,function(e){try{var t=require("util");if("function"!=typeof t.inherits)throw"";e.exports=t.inherits}catch(t){e.exports=(_s||(_s=1,"function"==typeof Object.create?ks.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ks.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}),Bs)}}(As)),Is}var Rs,Ls,Ds,Us,xs,Os,Ps,Vs,Ks,Ms={},Fs={get exports(){return Ms},set exports(e){Ms=e}};function zs(){return Rs||(Rs=1,function(e){var t=Es().Buffer,r=h;e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return t.alloc(0);for(var r,n,i,a=t.allocUnsafe(e>>>0),s=this.head,o=0;s;)r=s.data,n=a,i=o,r.copy(n,i),o+=s.data.length,s=s.next;return a},e}(),r&&r.inspect&&r.inspect.custom&&(e.exports.prototype[r.inspect.custom]=function(){var e=r.inspect({length:this.length});return this.constructor.name+" "+e})}(Fs)),Ms}function js(){if(Ds)return Ls;Ds=1;var e=fs();function t(e,t){e.emit("error",t)}return Ls={destroy:function(r,n){var i=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(n?n(r):r&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(t,this,r)):e.nextTick(t,this,r)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(r||null,(function(r){!n&&r?i._writableState?i._writableState.errorEmitted||(i._writableState.errorEmitted=!0,e.nextTick(t,i,r)):e.nextTick(t,i,r):n&&n(r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}},Ls}function qs(){if(Ps)return Os;Ps=1;var e=fs();function t(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}(t,e)}}Os=p;var r,n=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:e.nextTick;p.WritableState=d;var i=Object.create(Ts());i.inherits=Ns();var a={deprecate:xs?Us:(xs=1,Us=h.deprecate)},s=ys(),o=Es().Buffer,u=(void 0!==v?v:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,l=js();function f(){}function d(i,a){r=r||Hs(),i=i||{};var s=a instanceof r;this.objectMode=!!i.objectMode,s&&(this.objectMode=this.objectMode||!!i.writableObjectMode);var o=i.highWaterMark,u=i.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:s&&(u||0===u)?u:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===i.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=i.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,r){var i=t._writableState,a=i.sync,s=i.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(i),r)!function(t,r,n,i,a){--r.pendingcb,n?(e.nextTick(a,i),e.nextTick(b,t,r),t._writableState.errorEmitted=!0,t.emit("error",i)):(a(i),t._writableState.errorEmitted=!0,t.emit("error",i),b(t,r))}(t,i,a,r,s);else{var o=C(i);o||i.corked||i.bufferProcessing||!i.bufferedRequest||m(t,i),a?n(y,t,i,o,s):y(t,i,o,s)}}(a,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}function p(e){if(r=r||Hs(),!(c.call(p,this)||this instanceof r))return new p(e);this._writableState=new d(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),s.call(this)}function g(e,t,r,n,i,a,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function y(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),b(e,t)}function m(e,r){r.bufferProcessing=!0;var n=r.bufferedRequest;if(e._writev&&n&&n.next){var i=r.bufferedRequestCount,a=new Array(i),s=r.corkedRequestsFree;s.entry=n;for(var o=0,u=!0;n;)a[o]=n,n.isBuf||(u=!1),n=n.next,o+=1;a.allBuffers=u,g(e,r,!0,r.length,a,"",s.finish),r.pendingcb++,r.lastBufferedRequest=null,s.next?(r.corkedRequestsFree=s.next,s.next=null):r.corkedRequestsFree=new t(r),r.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,h=n.callback;if(g(e,r,!1,r.objectMode?1:c.length,c,l,h),n=n.next,r.bufferedRequestCount--,r.writing)break}null===n&&(r.lastBufferedRequest=null)}r.bufferedRequest=n,r.bufferProcessing=!1}function C(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),b(e,t)}))}function b(t,r){var n=C(r);return n&&(!function(t,r){r.prefinished||r.finalCalled||("function"==typeof t._final?(r.pendingcb++,r.finalCalled=!0,e.nextTick(E,t,r)):(r.prefinished=!0,t.emit("prefinish")))}(t,r),0===r.pendingcb&&(r.finished=!0,t.emit("finish"))),n}return i.inherits(p,s),d.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(d.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(c=Function.prototype[Symbol.hasInstance],Object.defineProperty(p,Symbol.hasInstance,{value:function(e){return!!c.call(this,e)||this===p&&(e&&e._writableState instanceof d)}})):c=function(e){return e instanceof this},p.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},p.prototype.write=function(t,r,n){var i,a=this._writableState,s=!1,c=!a.objectMode&&(i=t,o.isBuffer(i)||i instanceof u);return c&&!o.isBuffer(t)&&(t=function(e){return o.from(e)}(t)),"function"==typeof r&&(n=r,r=null),c?r="buffer":r||(r=a.defaultEncoding),"function"!=typeof n&&(n=f),a.ended?function(t,r){var n=new Error("write after end");t.emit("error",n),e.nextTick(r,n)}(this,n):(c||function(t,r,n,i){var a=!0,s=!1;return null===n?s=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||r.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),e.nextTick(i,s),a=!1),a}(this,a,t,n))&&(a.pendingcb++,s=function(e,t,r,n,i,a){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=o.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var u=t.objectMode?1:n.length;t.length+=u;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:a,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else g(e,t,!1,u,n,i,a);return c}(this,a,c,t,r,n)),s},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||m(this,e))},p.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(p.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),p.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},p.prototype._writev=null,p.prototype.end=function(t,r,n){var i=this._writableState;"function"==typeof t?(n=t,t=null,r=null):"function"==typeof r&&(n=r,r=null),null!=t&&this.write(t,r),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,r,n){r.ending=!0,b(t,r),n&&(r.finished?e.nextTick(n):t.once("finish",n));r.ended=!0,t.writable=!1}(this,i,n)},Object.defineProperty(p.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),p.prototype.destroy=l.destroy,p.prototype._undestroy=l.undestroy,p.prototype._destroy=function(e,t){this.end(),t(e)},Os}function Hs(){if(Ks)return Vs;Ks=1;var e=fs(),t=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Vs=u;var r=Object.create(Ts());r.inherits=Ns();var n=ro(),i=qs();r.inherits(u,n);for(var a=t(i.prototype),s=0;s<a.length;s++){var o=a[s];u.prototype[o]||(u.prototype[o]=i.prototype[o])}function u(e){if(!(this instanceof u))return new u(e);n.call(this,e),i.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",c)}function c(){this.allowHalfOpen||this._writableState.ended||e.nextTick(l,this)}function l(e){e.end()}return Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),u.prototype._destroy=function(t,r){this.push(null),this.end(),e.nextTick(r,t)},Vs}var Gs,Ws,Qs,Ys,Zs,Xs,$s,Js,eo={};function to(){if(Gs)return eo;Gs=1;var e=Es().Buffer,t=e.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(r){var n;switch(this.encoding=function(r){var n=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(r);if("string"!=typeof n&&(e.isEncoding===t||!t(r)))throw new Error("Unknown encoding: "+r);return n||r}(r),this.encoding){case"utf16le":this.text=a,this.end=s,n=4;break;case"utf8":this.fillLast=i,n=4;break;case"base64":this.text=o,this.end=u,n=3;break;default:return this.write=c,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=e.allocUnsafe(n)}function n(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function i(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function s(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function o(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function c(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}return eo.StringDecoder=r,r.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},r.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},r.prototype.text=function(e,t){var r=function(e,t,r){var i=t.length-1;if(i<r)return 0;var a=n(t[i]);if(a>=0)return a>0&&(e.lastNeed=a-1),a;if(--i<r||-2===a)return 0;if(a=n(t[i]),a>=0)return a>0&&(e.lastNeed=a-2),a;if(--i<r||-2===a)return 0;if(a=n(t[i]),a>=0)return a>0&&(2===a?a=0:e.lastNeed=a-3),a;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},r.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length},eo}function ro(){if(Qs)return Ws;Qs=1;var e=fs();Ws=m;var t,r=function(){if(is)return ns;is=1;var e={}.toString;return ns=Array.isArray||function(t){return"[object Array]"==e.call(t)}}();m.ReadableState=y,c.EventEmitter;var n=function(e,t){return e.listeners(t).length},i=ys(),a=Es().Buffer,s=(void 0!==v?v:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var o=Object.create(Ts());o.inherits=Ns();var u=h,l=void 0;l=u&&u.debuglog?u.debuglog("stream"):function(){};var f,d=zs(),p=js();o.inherits(m,i);var g=["error","close","destroy","pause","resume"];function y(e,r){e=e||{};var n=r instanceof(t=t||Hs());this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,a=e.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(a||0===a)?a:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=to().StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function m(e){if(t=t||Hs(),!(this instanceof m))return new m(e);this._readableState=new y(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),i.call(this)}function C(e,t,r,n,i){var o,u=e._readableState;null===t?(u.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,T(e)}(e,u)):(i||(o=function(e,t){var r;n=t,a.isBuffer(n)||n instanceof s||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(u,t)),o?e.emit("error",o):u.objectMode||t&&t.length>0?("string"==typeof t||u.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),n?u.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):E(e,u,t,!0):u.ended?e.emit("error",new Error("stream.push() after EOF")):(u.reading=!1,u.decoder&&!r?(t=u.decoder.write(t),u.objectMode||0!==t.length?E(e,u,t,!1):w(e,u)):E(e,u,t,!1))):n||(u.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(u)}function E(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&T(e)),w(e,t)}Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.push(null),t(e)},m.prototype.push=function(e,t){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof e&&((t=t||n.defaultEncoding)!==n.encoding&&(e=a.from(e,t),t=""),r=!0),C(this,e,t,!1,r)},m.prototype.unshift=function(e){return C(this,e,null,!0,!1)},m.prototype.isPaused=function(){return!1===this._readableState.flowing},m.prototype.setEncoding=function(e){return f||(f=to().StringDecoder),this._readableState.decoder=new f(e),this._readableState.encoding=e,this};var b=8388608;function S(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=b?e=b:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function T(t){var r=t._readableState;r.needReadable=!1,r.emittedReadable||(l("emitReadable",r.flowing),r.emittedReadable=!0,r.sync?e.nextTick(_,t):_(t))}function _(e){l("emit readable"),e.emit("readable"),k(e)}function w(t,r){r.readingMore||(r.readingMore=!0,e.nextTick(I,t,r))}function I(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(l("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}function A(e){l("readable nexttick read 0"),e.read(0)}function B(e,t){t.reading||(l("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),k(e),t.flowing&&!t.reading&&e.read(0)}function k(e){var t=e._readableState;for(l("flow",t.flowing);t.flowing&&null!==e.read(););}function N(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):n=e===t.head.data.length?t.shift():r?function(e,t){var r=t.head,n=1,i=r.data;e-=i.length;for(;r=r.next;){var a=r.data,s=e>a.length?a.length:e;if(s===a.length?i+=a:i+=a.slice(0,e),0===(e-=s)){s===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=a.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var s=n.data,o=e>s.length?s.length:e;if(s.copy(r,r.length-e,0,o),0===(e-=o)){o===s.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(o));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function R(t){var r=t._readableState;if(r.length>0)throw new Error('"endReadable()" called on non-empty stream');r.endEmitted||(r.ended=!0,e.nextTick(L,r,t))}function L(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function D(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}return m.prototype.read=function(e){l("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return l("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):T(this),null;if(0===(e=S(e,t))&&t.ended)return 0===t.length&&R(this),null;var n,i=t.needReadable;return l("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&l("length less than watermark",i=!0),t.ended||t.reading?l("reading or ended",i=!1):i&&(l("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=S(r,t))),null===(n=e>0?N(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&R(this)),null!==n&&this.emit("data",n),n},m.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(t,i){var a=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,l("pipe count=%d opts=%j",s.pipesCount,i);var o=(!i||!1!==i.end)&&t!==process.stdout&&t!==process.stderr?c:v;function u(e,r){l("onunpipe"),e===a&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",y),t.removeListener("finish",m),t.removeListener("drain",h),t.removeListener("error",g),t.removeListener("unpipe",u),a.removeListener("end",c),a.removeListener("end",v),a.removeListener("data",p),f=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function c(){l("onend"),t.end()}s.endEmitted?e.nextTick(o):a.once("end",o),t.on("unpipe",u);var h=function(e){return function(){var t=e._readableState;l("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&n(e,"data")&&(t.flowing=!0,k(e))}}(a);t.on("drain",h);var f=!1;var d=!1;function p(e){l("ondata"),d=!1,!1!==t.write(e)||d||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==D(s.pipes,t))&&!f&&(l("false write response, pause",s.awaitDrain),s.awaitDrain++,d=!0),a.pause())}function g(e){l("onerror",e),v(),t.removeListener("error",g),0===n(t,"error")&&t.emit("error",e)}function y(){t.removeListener("finish",m),v()}function m(){l("onfinish"),t.removeListener("close",y),v()}function v(){l("unpipe"),a.unpipe(t)}return a.on("data",p),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?r(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(t,"error",g),t.once("close",y),t.once("finish",m),t.emit("pipe",a),s.flowing||(l("pipe resume"),a.resume()),t},m.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<i;a++)n[a].emit("unpipe",this,{hasUnpiped:!1});return this}var s=D(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},m.prototype.on=function(t,r){var n=i.prototype.on.call(this,t,r);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var a=this._readableState;a.endEmitted||a.readableListening||(a.readableListening=a.needReadable=!0,a.emittedReadable=!1,a.reading?a.length&&T(this):e.nextTick(A,this))}return n},m.prototype.addListener=m.prototype.on,m.prototype.resume=function(){var t=this._readableState;return t.flowing||(l("resume"),t.flowing=!0,function(t,r){r.resumeScheduled||(r.resumeScheduled=!0,e.nextTick(B,t,r))}(this,t)),this},m.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this},m.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(l("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(l("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var a=0;a<g.length;a++)e.on(g[a],this.emit.bind(this,g[a]));return this._read=function(t){l("wrapped _read",t),n&&(n=!1,e.resume())},this},Object.defineProperty(m.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),m._fromList=N,Ws}function no(){if(Zs)return Ys;Zs=1,Ys=n;var e=Hs(),t=Object.create(Ts());function r(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function n(t){if(!(this instanceof n))return new n(t);e.call(this,t),this._transformState={afterTransform:r.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",i)}function i(){var e=this;"function"==typeof this._flush?this._flush((function(t,r){a(e,t,r)})):a(this,null,null)}function a(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}return t.inherits=Ns(),t.inherits(n,e),n.prototype.push=function(t,r){return this._transformState.needTransform=!1,e.prototype.push.call(this,t,r)},n.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")},n.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},n.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},n.prototype._destroy=function(t,r){var n=this;e.prototype._destroy.call(this,t,(function(e){r(e),n.emit("close")}))},Ys}function io(){return Js||(Js=1,function(e,t){var r=u;"disable"===process.env.READABLE_STREAM&&r?(e.exports=r,(t=e.exports=r.Readable).Readable=r.Readable,t.Writable=r.Writable,t.Duplex=r.Duplex,t.Transform=r.Transform,t.PassThrough=r.PassThrough,t.Stream=r):((t=e.exports=ro()).Stream=r||t,t.Readable=t,t.Writable=qs(),t.Duplex=Hs(),t.Transform=no(),t.PassThrough=function(){if($s)return Xs;$s=1,Xs=r;var e=no(),t=Object.create(Ts());function r(t){if(!(this instanceof r))return new r(t);e.call(this,t)}return t.inherits=Ns(),t.inherits(r,e),r.prototype._transform=function(e,t,r){r(null,e)},Xs}())}(cs,us)),us}if(os.base64=!0,os.array=!0,os.string=!0,os.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,os.nodebuffer="undefined"!=typeof Buffer,os.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)os.blob=!1;else{var ao=new ArrayBuffer(0);try{os.blob=0===new Blob([ao],{type:"application/zip"}).size}catch(e){try{var so=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);so.append(ao),os.blob=0===so.getBlob("application/zip").size}catch(e){os.blob=!1}}}try{os.nodestream=!!io().Readable}catch(e){os.nodestream=!1}var oo,uo={};function co(){if(oo)return uo;oo=1;var e=Co(),t=os,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return uo.encode=function(t){for(var n,i,a,s,o,u,c,l=[],h=0,f=t.length,d=f,p="string"!==e.getTypeOf(t);h<t.length;)d=f-h,p?(n=t[h++],i=h<f?t[h++]:0,a=h<f?t[h++]:0):(n=t.charCodeAt(h++),i=h<f?t.charCodeAt(h++):0,a=h<f?t.charCodeAt(h++):0),s=n>>2,o=(3&n)<<4|i>>4,u=d>1?(15&i)<<2|a>>6:64,c=d>2?63&a:64,l.push(r.charAt(s)+r.charAt(o)+r.charAt(u)+r.charAt(c));return l.join("")},uo.decode=function(e){var n,i,a,s,o,u,c=0,l=0,h="data:";if(e.substr(0,5)===h)throw new Error("Invalid base64 input, it looks like a data url.");var f,d=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===r.charAt(64)&&d--,e.charAt(e.length-2)===r.charAt(64)&&d--,d%1!=0)throw new Error("Invalid base64 input, bad content length.");for(f=t.uint8array?new Uint8Array(0|d):new Array(0|d);c<e.length;)n=r.indexOf(e.charAt(c++))<<2|(s=r.indexOf(e.charAt(c++)))>>4,i=(15&s)<<4|(o=r.indexOf(e.charAt(c++)))>>2,a=(3&o)<<6|(u=r.indexOf(e.charAt(c++))),f[l++]=n,64!==o&&(f[l++]=i),64!==u&&(f[l++]=a);return f},uo}var lo,ho,fo,po,go={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}};var yo=null;yo="undefined"!=typeof Promise?Promise:function(){if(po)return fo;po=1;var e=function(){if(ho)return lo;ho=1;var e,t,r=v.MutationObserver||v.WebKitMutationObserver;if(process.browser)if(r){var n=0,i=new r(u),a=v.document.createTextNode("");i.observe(a,{characterData:!0}),e=function(){a.data=n=++n%2}}else if(v.setImmediate||void 0===v.MessageChannel)e="document"in v&&"onreadystatechange"in v.document.createElement("script")?function(){var e=v.document.createElement("script");e.onreadystatechange=function(){u(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},v.document.documentElement.appendChild(e)}:function(){setTimeout(u,0)};else{var s=new v.MessageChannel;s.port1.onmessage=u,e=function(){s.port2.postMessage(0)}}else e=function(){process.nextTick(u)};var o=[];function u(){var e,r;t=!0;for(var n=o.length;n;){for(r=o,o=[],e=-1;++e<n;)r[e]();n=o.length}t=!1}return lo=function(r){1!==o.push(r)||t||e()}}();function t(){}var r={},n=["REJECTED"],i=["FULFILLED"],a=["PENDING"];if(!process.browser)var s=["UNHANDLED"];function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=a,this.queue=[],this.outcome=void 0,process.browser||(this.handled=s),e!==t&&h(this,e)}function u(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function c(t,n,i){e((function(){var e;try{e=n(i)}catch(e){return r.reject(t,e)}e===t?r.reject(t,new TypeError("Cannot resolve promise with itself")):r.resolve(t,e)}))}function l(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function i(t){n||(n=!0,r.reject(e,t))}function a(t){n||(n=!0,r.resolve(e,t))}var s=f((function(){t(a,i)}));"error"===s.status&&i(s.value)}function f(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}return fo=o,o.prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then((function(r){return t.resolve(e()).then((function(){return r}))}),(function(r){return t.resolve(e()).then((function(){throw r}))}))},o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,r){if("function"!=typeof e&&this.state===i||"function"!=typeof r&&this.state===n)return this;var o=new this.constructor(t);return process.browser||this.handled===s&&(this.handled=null),this.state!==a?c(o,this.state===i?e:r,this.outcome):this.queue.push(new u(o,e,r)),o},u.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},u.prototype.otherCallFulfilled=function(e){c(this.promise,this.onFulfilled,e)},u.prototype.callRejected=function(e){r.reject(this.promise,e)},u.prototype.otherCallRejected=function(e){c(this.promise,this.onRejected,e)},r.resolve=function(e,t){var n=f(l,t);if("error"===n.status)return r.reject(e,n.value);var a=n.value;if(a)h(e,a);else{e.state=i,e.outcome=t;for(var s=-1,o=e.queue.length;++s<o;)e.queue[s].callFulfilled(t)}return e},r.reject=function(t,r){t.state=n,t.outcome=r,process.browser||t.handled===s&&e((function(){t.handled===s&&process.emit("unhandledRejection",r,t)}));for(var i=-1,a=t.queue.length;++i<a;)t.queue[i].callRejected(r);return t},o.resolve=function(e){return e instanceof this?e:r.resolve(new this(t),e)},o.reject=function(e){var n=new this(t);return r.reject(n,e)},o.all=function(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var i=e.length,a=!1;if(!i)return this.resolve([]);for(var s=new Array(i),o=0,u=-1,c=new this(t);++u<i;)l(e[u],u);return c;function l(e,t){n.resolve(e).then((function(e){s[t]=e,++o!==i||a||(a=!0,r.resolve(c,s))}),(function(e){a||(a=!0,r.reject(c,e))}))}},o.race=function(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var i=e.length,a=!1;if(!i)return this.resolve([]);for(var s,o=-1,u=new this(t);++o<i;)s=e[o],n.resolve(s).then((function(e){a||(a=!0,r.resolve(u,e))}),(function(e){a||(a=!0,r.reject(u,e))}));return u},fo}();var mo,vo={Promise:yo};function Co(){return mo||(mo=1,function(e){var t=os,r=co(),n=go,i=vo;function a(e){return e}function s(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}e.newBlob=function(t,r){e.checkSupport("blob");try{return new Blob([t],{type:r})}catch(e){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return n.append(t),n.getBlob(r)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var o={stringifyByChunk:function(e,t,r){var n=[],i=0,a=e.length;if(a<=r)return String.fromCharCode.apply(null,e);for(;i<a;)"array"===t||"nodebuffer"===t?n.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+r,a)))):n.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+r,a)))),i+=r;return n.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return t.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return t.nodebuffer&&1===String.fromCharCode.apply(null,n.allocBuffer(1)).length}catch(e){return!1}}()}};function u(t){var r=65536,n=e.getTypeOf(t),i=!0;if("uint8array"===n?i=o.applyCanBeUsed.uint8array:"nodebuffer"===n&&(i=o.applyCanBeUsed.nodebuffer),i)for(;r>1;)try{return o.stringifyByChunk(t,n,r)}catch(e){r=Math.floor(r/2)}return o.stringifyByChar(t)}function c(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}e.applyFromCharCode=u;var l={};l.string={string:a,array:function(e){return s(e,new Array(e.length))},arraybuffer:function(e){return l.string.uint8array(e).buffer},uint8array:function(e){return s(e,new Uint8Array(e.length))},nodebuffer:function(e){return s(e,n.allocBuffer(e.length))}},l.array={string:u,array:a,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return n.newBufferFrom(e)}},l.arraybuffer={string:function(e){return u(new Uint8Array(e))},array:function(e){return c(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:a,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return n.newBufferFrom(new Uint8Array(e))}},l.uint8array={string:u,array:function(e){return c(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:a,nodebuffer:function(e){return n.newBufferFrom(e)}},l.nodebuffer={string:u,array:function(e){return c(e,new Array(e.length))},arraybuffer:function(e){return l.nodebuffer.uint8array(e).buffer},uint8array:function(e){return c(e,new Uint8Array(e.length))},nodebuffer:a},e.transformTo=function(t,r){if(r||(r=""),!t)return r;e.checkSupport(t);var n=e.getTypeOf(r);return l[n][t](r)},e.resolve=function(e){for(var t=e.split("/"),r=[],n=0;n<t.length;n++){var i=t[n];"."===i||""===i&&0!==n&&n!==t.length-1||(".."===i?r.pop():r.push(i))}return r.join("/")},e.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":t.nodebuffer&&n.isBuffer(e)?"nodebuffer":t.uint8array&&e instanceof Uint8Array?"uint8array":t.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},e.checkSupport=function(e){if(!t[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},e.MAX_VALUE_16BITS=65535,e.MAX_VALUE_32BITS=-1,e.pretty=function(e){var t,r,n="";for(r=0;r<(e||"").length;r++)n+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return n},e.delay=function(e,t,r){setImmediate((function(){e.apply(r||null,t||[])}))},e.inherits=function(e,t){var r=function(){};r.prototype=t.prototype,e.prototype=new r},e.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},e.prepareContent=function(n,a,o,u,c){return i.Promise.resolve(a).then((function(e){return t.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new i.Promise((function(t,r){var n=new FileReader;n.onload=function(e){t(e.target.result)},n.onerror=function(e){r(e.target.error)},n.readAsArrayBuffer(e)})):e})).then((function(a){var l,h=e.getTypeOf(a);return h?("arraybuffer"===h?a=e.transformTo("uint8array",a):"string"===h&&(c?a=r.decode(a):o&&!0!==u&&(a=s(l=a,t.uint8array?new Uint8Array(l.length):new Array(l.length)))),a):i.Promise.reject(new Error("Can't read the data of '"+n+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))}))}}(ss)),ss}function Eo(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}!function(e,t){if(!e.setImmediate){var r,n,i,a,s,o=1,u={},c=!1,l=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){process.nextTick((function(){d(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){d(e.data)},r=function(e){i.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(n=l.documentElement,r=function(e){var t=l.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,n.removeChild(t),t=null},n.appendChild(t)}):r=function(e){setTimeout(d,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&d(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),r=function(t){e.postMessage(a+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var i={callback:e,args:t};return u[o]=i,r(o),o++},h.clearImmediate=f}function f(e){delete u[e]}function d(e){if(c)setTimeout(d,0,e);else{var r=u[e];if(r){c=!0;try{!function(e){var r=e.callback,n=e.args;switch(n.length){case 0:r();break;case 1:r(n[0]);break;case 2:r(n[0],n[1]);break;case 3:r(n[0],n[1],n[2]);break;default:r.apply(t,n)}}(r)}finally{f(e),c=!1}}}}}("undefined"==typeof self?v:self),Eo.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r<this._listeners[e].length;r++)this._listeners[e][r].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",(function(e){t.processChunk(e)})),e.on("end",(function(){t.end()})),e.on("error",(function(e){t.error(e)})),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var e=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}};var bo=Eo;!function(e){for(var t=Co(),r=os,n=go,i=bo,a=new Array(256),s=0;s<256;s++)a[s]=s>=252?6:s>=248?5:s>=240?4:s>=224?3:s>=192?2:1;a[254]=a[254]=1;function o(){i.call(this,"utf-8 decode"),this.leftOver=null}function u(){i.call(this,"utf-8 encode")}e.utf8encode=function(e){return r.nodebuffer?n.newBufferFrom(e,"utf-8"):function(e){var t,n,i,a,s,o=e.length,u=0;for(a=0;a<o;a++)55296==(64512&(n=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(i=e.charCodeAt(a+1)))&&(n=65536+(n-55296<<10)+(i-56320),a++),u+=n<128?1:n<2048?2:n<65536?3:4;for(t=r.uint8array?new Uint8Array(u):new Array(u),s=0,a=0;s<u;a++)55296==(64512&(n=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(i=e.charCodeAt(a+1)))&&(n=65536+(n-55296<<10)+(i-56320),a++),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t}(e)},e.utf8decode=function(e){return r.nodebuffer?t.transformTo("nodebuffer",e).toString("utf-8"):function(e){var r,n,i,s,o=e.length,u=new Array(2*o);for(n=0,r=0;r<o;)if((i=e[r++])<128)u[n++]=i;else if((s=a[i])>4)u[n++]=65533,r+=s-1;else{for(i&=2===s?31:3===s?15:7;s>1&&r<o;)i=i<<6|63&e[r++],s--;s>1?u[n++]=65533:i<65536?u[n++]=i:(i-=65536,u[n++]=55296|i>>10&1023,u[n++]=56320|1023&i)}return u.length!==n&&(u.subarray?u=u.subarray(0,n):u.length=n),t.applyFromCharCode(u)}(e=t.transformTo(r.uint8array?"uint8array":"array",e))},t.inherits(o,i),o.prototype.processChunk=function(n){var i=t.transformTo(r.uint8array?"uint8array":"array",n.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var s=i;(i=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),i.set(s,this.leftOver.length)}else i=this.leftOver.concat(i);this.leftOver=null}var o=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}(i),u=i;o!==i.length&&(r.uint8array?(u=i.subarray(0,o),this.leftOver=i.subarray(o,i.length)):(u=i.slice(0,o),this.leftOver=i.slice(o,i.length))),this.push({data:e.utf8decode(u),meta:n.meta})},o.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:e.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},e.Utf8DecodeWorker=o,t.inherits(u,i),u.prototype.processChunk=function(t){this.push({data:e.utf8encode(t.data),meta:t.meta})},e.Utf8EncodeWorker=u}(as);var So=bo,To=Co();function _o(e){So.call(this,"ConvertWorker to "+e),this.destType=e}To.inherits(_o,So),_o.prototype.processChunk=function(e){this.push({data:To.transformTo(this.destType,e.data),meta:e.meta})};var wo,Io,Ao=_o;var Bo=Co(),ko=Ao,No=bo,Ro=co(),Lo=vo,Do=null;if(os.nodestream)try{Do=function(){if(Io)return wo;Io=1;var e=io().Readable;function t(t,r,n){e.call(this,r),this._helper=t;var i=this;t.on("data",(function(e,t){i.push(e)||i._helper.pause(),n&&n(t)})).on("error",(function(e){i.emit("error",e)})).on("end",(function(){i.push(null)}))}return Co().inherits(t,e),t.prototype._read=function(){this._helper.resume()},wo=t}()}catch(e){}function Uo(e,t){return new Lo.Promise((function(r,n){var i=[],a=e._internalType,s=e._outputType,o=e._mimeType;e.on("data",(function(e,r){i.push(e),t&&t(r)})).on("error",(function(e){i=[],n(e)})).on("end",(function(){try{var e=function(e,t,r){switch(e){case"blob":return Bo.newBlob(Bo.transformTo("arraybuffer",t),r);case"base64":return Ro.encode(t);default:return Bo.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,a=0;for(r=0;r<t.length;r++)a+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(a),r=0;r<t.length;r++)i.set(t[r],n),n+=t[r].length;return i;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(a,i),o);r(e)}catch(e){n(e)}i=[]})).resume()}))}function xo(e,t,r){var n=t;switch(t){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string"}try{this._internalType=n,this._outputType=t,this._mimeType=r,Bo.checkSupport(n),this._worker=e.pipe(new ko(n)),e.lock()}catch(e){this._worker=new No("error"),this._worker.error(e)}}xo.prototype={accumulate:function(e){return Uo(this,e)},on:function(e,t){var r=this;return"data"===e?this._worker.on(e,(function(e){t.call(r,e.data,e.meta)})):this._worker.on(e,(function(){Bo.delay(t,arguments,r)})),this},resume:function(){return Bo.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(Bo.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new Do(this,{objectMode:"nodebuffer"!==this._outputType},e)}};var Oo=xo,Po={base64:!1,binary:!1,dir:!1,createFolders:!0,date:null,compression:null,compressionOptions:null,comment:null,unixPermissions:null,dosPermissions:null},Vo=Co(),Ko=bo;function Mo(e){Ko.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=Vo.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}Vo.inherits(Mo,Ko),Mo.prototype.cleanUp=function(){Ko.prototype.cleanUp.call(this),this.data=null},Mo.prototype.resume=function(){return!!Ko.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,Vo.delay(this._tickAndRepeat,[],this)),!0)},Mo.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(Vo.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},Mo.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})};var Fo=Mo,zo=Co();var jo=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var qo=function(e,t){return void 0!==e&&e.length?"string"!==zo.getTypeOf(e)?function(e,t,r,n){var i=jo,a=n+r;e^=-1;for(var s=n;s<a;s++)e=e>>>8^i[255&(e^t[s])];return-1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=jo,a=n+r;e^=-1;for(var s=n;s<a;s++)e=e>>>8^i[255&(e^t.charCodeAt(s))];return-1^e}(0|t,e,e.length,0):0},Ho=bo,Go=qo;function Wo(){Ho.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}Co().inherits(Wo,Ho),Wo.prototype.processChunk=function(e){this.streamInfo.crc32=Go(e.data,this.streamInfo.crc32||0),this.push(e)};var Qo=Wo,Yo=Co(),Zo=bo;function Xo(e){Zo.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}Yo.inherits(Xo,Zo),Xo.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}Zo.prototype.processChunk.call(this,e)};var $o=vo,Jo=Fo,eu=Qo,tu=Xo;function ru(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}ru.prototype={getContentWorker:function(){var e=new Jo($o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new tu("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new Jo($o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},ru.createWorkerFrom=function(e,t,r){return e.pipe(new eu).pipe(new tu("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new tu("compressedSize")).withStreamInfo("compression",t)};var nu=ru,iu=Oo,au=Fo,su=as,ou=nu,uu=bo,cu=function(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}};cu.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var n="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var i=!this._dataBinary;i&&!n&&(t=t.pipe(new su.Utf8EncodeWorker)),!i&&n&&(t=t.pipe(new su.Utf8DecodeWorker))}catch(e){(t=new uu("error")).error(e)}return new iu(t,r,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof ou&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new su.Utf8EncodeWorker)),ou.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof ou?this._data.getContentWorker():this._data instanceof uu?this._data:new au(this._data)}};for(var lu=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],hu=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},fu=0;fu<lu.length;fu++)cu.prototype[lu[fu]]=hu;var du=cu,pu={},gu={},yu={},mu={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.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,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var a=0;a<n;a++)e[i+a]=t[r+a]},flattenChunks:function(e){var t,r,n,i,a,s;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(s=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)a=e[t],s.set(a,i),i+=a.length;return s}},i={arraySet:function(e,t,r,n,i){for(var a=0;a<n;a++)e[i+a]=t[r+a]},flattenChunks:function(e){return[].concat.apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(mu);var vu={},Cu={},Eu={},bu=mu,Su=0,Tu=1;function _u(e){for(var t=e.length;--t>=0;)e[t]=0}var wu=0,Iu=29,Au=256,Bu=Au+1+Iu,ku=30,Nu=19,Ru=2*Bu+1,Lu=15,Du=16,Uu=7,xu=256,Ou=16,Pu=17,Vu=18,Ku=[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],Mu=[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],Fu=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],zu=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ju=new Array(2*(Bu+2));_u(ju);var qu=new Array(2*ku);_u(qu);var Hu=new Array(512);_u(Hu);var Gu=new Array(256);_u(Gu);var Wu=new Array(Iu);_u(Wu);var Qu,Yu,Zu,Xu=new Array(ku);function $u(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function Ju(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function ec(e){return e<256?Hu[e]:Hu[256+(e>>>7)]}function tc(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function rc(e,t,r){e.bi_valid>Du-r?(e.bi_buf|=t<<e.bi_valid&65535,tc(e,e.bi_buf),e.bi_buf=t>>Du-e.bi_valid,e.bi_valid+=r-Du):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function nc(e,t,r){rc(e,r[2*t],r[2*t+1])}function ic(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function ac(e,t,r){var n,i,a=new Array(Lu+1),s=0;for(n=1;n<=Lu;n++)a[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=ic(a[o]++,o))}}function sc(e){var t;for(t=0;t<Bu;t++)e.dyn_ltree[2*t]=0;for(t=0;t<ku;t++)e.dyn_dtree[2*t]=0;for(t=0;t<Nu;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*xu]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function oc(e){e.bi_valid>8?tc(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 uc(e,t,r,n){var i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]}function cc(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&uc(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!uc(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function lc(e,t,r){var n,i,a,s,o=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?nc(e,i,t):(nc(e,(a=Gu[i])+Au+1,t),0!==(s=Ku[a])&&rc(e,i-=Wu[a],s),nc(e,a=ec(--n),r),0!==(s=Mu[a])&&rc(e,n-=Xu[a],s))}while(o<e.last_lit);nc(e,xu,t)}function hc(e,t){var r,n,i,a=t.dyn_tree,s=t.stat_desc.static_tree,o=t.stat_desc.has_stree,u=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=Ru,r=0;r<u;r++)0!==a[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=s[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)cc(e,a,r);i=u;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],cc(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,cc(e,a,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,a,s,o,u=t.dyn_tree,c=t.max_code,l=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(a=0;a<=Lu;a++)e.bl_count[a]=0;for(u[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<Ru;r++)(a=u[2*u[2*(n=e.heap[r])+1]+1]+1)>p&&(a=p,g++),u[2*n+1]=a,n>c||(e.bl_count[a]++,s=0,n>=d&&(s=f[n-d]),o=u[2*n],e.opt_len+=o*(a+s),h&&(e.static_len+=o*(l[2*n+1]+s)));if(0!==g){do{for(a=p-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(a=p;0!==a;a--)for(n=e.bl_count[a];0!==n;)(i=e.heap[--r])>c||(u[2*i+1]!==a&&(e.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),n--)}}(e,t),ac(a,c,e.bl_count)}function fc(e,t,r){var n,i,a=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=t[2*(n+1)+1],++o<u&&i===s||(o<c?e.bl_tree[2*i]+=o:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[2*Ou]++):o<=10?e.bl_tree[2*Pu]++:e.bl_tree[2*Vu]++,o=0,a=i,0===s?(u=138,c=3):i===s?(u=6,c=3):(u=7,c=4))}function dc(e,t,r){var n,i,a=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),n=0;n<=r;n++)if(i=s,s=t[2*(n+1)+1],!(++o<u&&i===s)){if(o<c)do{nc(e,i,e.bl_tree)}while(0!=--o);else 0!==i?(i!==a&&(nc(e,i,e.bl_tree),o--),nc(e,Ou,e.bl_tree),rc(e,o-3,2)):o<=10?(nc(e,Pu,e.bl_tree),rc(e,o-3,3)):(nc(e,Vu,e.bl_tree),rc(e,o-11,7));o=0,a=i,0===s?(u=138,c=3):i===s?(u=6,c=3):(u=7,c=4)}}_u(Xu);var pc=!1;function gc(e,t,r,n){rc(e,(wu<<1)+(n?1:0),3),function(e,t,r,n){oc(e),n&&(tc(e,r),tc(e,~r)),bu.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}Eu._tr_init=function(e){pc||(!function(){var e,t,r,n,i,a=new Array(Lu+1);for(r=0,n=0;n<Iu-1;n++)for(Wu[n]=r,e=0;e<1<<Ku[n];e++)Gu[r++]=n;for(Gu[r-1]=n,i=0,n=0;n<16;n++)for(Xu[n]=i,e=0;e<1<<Mu[n];e++)Hu[i++]=n;for(i>>=7;n<ku;n++)for(Xu[n]=i<<7,e=0;e<1<<Mu[n]-7;e++)Hu[256+i++]=n;for(t=0;t<=Lu;t++)a[t]=0;for(e=0;e<=143;)ju[2*e+1]=8,e++,a[8]++;for(;e<=255;)ju[2*e+1]=9,e++,a[9]++;for(;e<=279;)ju[2*e+1]=7,e++,a[7]++;for(;e<=287;)ju[2*e+1]=8,e++,a[8]++;for(ac(ju,Bu+1,a),e=0;e<ku;e++)qu[2*e+1]=5,qu[2*e]=ic(e,5);Qu=new $u(ju,Ku,Au+1,Bu,Lu),Yu=new $u(qu,Mu,0,ku,Lu),Zu=new $u(new Array(0),Fu,0,Nu,Uu)}(),pc=!0),e.l_desc=new Ju(e.dyn_ltree,Qu),e.d_desc=new Ju(e.dyn_dtree,Yu),e.bl_desc=new Ju(e.bl_tree,Zu),e.bi_buf=0,e.bi_valid=0,sc(e)},Eu._tr_stored_block=gc,Eu._tr_flush_block=function(e,t,r,n){var i,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 Su;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return Tu;for(t=32;t<Au;t++)if(0!==e.dyn_ltree[2*t])return Tu;return Su}(e)),hc(e,e.l_desc),hc(e,e.d_desc),s=function(e){var t;for(fc(e,e.dyn_ltree,e.l_desc.max_code),fc(e,e.dyn_dtree,e.d_desc.max_code),hc(e,e.bl_desc),t=Nu-1;t>=3&&0===e.bl_tree[2*zu[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?gc(e,t,r,n):4===e.strategy||a===i?(rc(e,2+(n?1:0),3),lc(e,ju,qu)):(rc(e,4+(n?1:0),3),function(e,t,r,n){var i;for(rc(e,t-257,5),rc(e,r-1,5),rc(e,n-4,4),i=0;i<n;i++)rc(e,e.bl_tree[2*zu[i]+1],3);dc(e,e.dyn_ltree,t-1),dc(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),lc(e,e.dyn_ltree,e.dyn_dtree)),sc(e),n&&oc(e)},Eu._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*(Gu[r]+Au+1)]++,e.dyn_dtree[2*ec(t)]++),e.last_lit===e.lit_bufsize-1},Eu._tr_align=function(e){rc(e,2,3),nc(e,xu,ju),function(e){16===e.bi_valid?(tc(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)};var yc=function(e,t,r,n){for(var i=65535&e|0,a=e>>>16&65535|0,s=0;0!==r;){r-=s=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--s);i%=65521,a%=65521}return i|a<<16|0};var mc=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var vc,Cc=function(e,t,r,n){var i=mc,a=n+r;e^=-1;for(var s=n;s<a;s++)e=e>>>8^i[255&(e^t[s])];return-1^e},Ec={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"},bc=mu,Sc=Eu,Tc=yc,_c=Cc,wc=Ec,Ic=0,Ac=4,Bc=0,kc=-2,Nc=-1,Rc=4,Lc=2,Dc=8,Uc=9,xc=286,Oc=30,Pc=19,Vc=2*xc+1,Kc=15,Mc=3,Fc=258,zc=Fc+Mc+1,jc=42,qc=103,Hc=113,Gc=666,Wc=1,Qc=2,Yc=3,Zc=4;function Xc(e,t){return e.msg=wc[t],t}function $c(e){return(e<<1)-(e>4?9:0)}function Jc(e){for(var t=e.length;--t>=0;)e[t]=0}function el(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(bc.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 tl(e,t){Sc._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,el(e.strm)}function rl(e,t){e.pending_buf[e.pending++]=t}function nl(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function il(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,bc.arraySet(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=Tc(e.adler,t,i,r):2===e.state.wrap&&(e.adler=_c(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function al(e,t){var r,n,i=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match,u=e.strstart>e.w_size-zc?e.strstart-(e.w_size-zc):0,c=e.window,l=e.w_mask,h=e.prev,f=e.strstart+Fc,d=c[a+s-1],p=c[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(c[(r=t)+s]===p&&c[r+s-1]===d&&c[r]===c[a]&&c[++r]===c[a+1]){a+=2,r++;do{}while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&a<f);if(n=Fc-(f-a),a=f-Fc,n>s){if(e.match_start=t,s=n,n>=o)break;d=c[a+s-1],p=c[a+s]}}}while((t=h[t&l])>u&&0!=--i);return s<=e.lookahead?s:e.lookahead}function sl(e){var t,r,n,i,a,s=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-zc)){bc.arraySet(e.window,e.window,s,s,0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=s?n-s:0}while(--r);t=r=s;do{n=e.prev[--t],e.prev[t]=n>=s?n-s:0}while(--r);i+=s}if(0===e.strm.avail_in)break;if(r=il(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=Mc)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+Mc-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<Mc)););}while(e.lookahead<zc&&0!==e.strm.avail_in)}function ol(e,t){for(var r,n;;){if(e.lookahead<zc){if(sl(e),e.lookahead<zc&&t===Ic)return Wc;if(0===e.lookahead)break}if(r=0,e.lookahead>=Mc&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Mc-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-zc&&(e.match_length=al(e,r)),e.match_length>=Mc)if(n=Sc._tr_tally(e,e.strstart-e.match_start,e.match_length-Mc),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Mc){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Mc-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 n=Sc._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(tl(e,!1),0===e.strm.avail_out))return Wc}return e.insert=e.strstart<Mc-1?e.strstart:Mc-1,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):e.last_lit&&(tl(e,!1),0===e.strm.avail_out)?Wc:Qc}function ul(e,t){for(var r,n,i;;){if(e.lookahead<zc){if(sl(e),e.lookahead<zc&&t===Ic)return Wc;if(0===e.lookahead)break}if(r=0,e.lookahead>=Mc&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Mc-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=Mc-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-zc&&(e.match_length=al(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===Mc&&e.strstart-e.match_start>4096)&&(e.match_length=Mc-1)),e.prev_length>=Mc&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Mc,n=Sc._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Mc),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Mc-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=Mc-1,e.strstart++,n&&(tl(e,!1),0===e.strm.avail_out))return Wc}else if(e.match_available){if((n=Sc._tr_tally(e,0,e.window[e.strstart-1]))&&tl(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return Wc}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Sc._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Mc-1?e.strstart:Mc-1,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):e.last_lit&&(tl(e,!1),0===e.strm.avail_out)?Wc:Qc}function cl(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function ll(){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=Dc,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 bc.Buf16(2*Vc),this.dyn_dtree=new bc.Buf16(2*(2*Oc+1)),this.bl_tree=new bc.Buf16(2*(2*Pc+1)),Jc(this.dyn_ltree),Jc(this.dyn_dtree),Jc(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new bc.Buf16(Kc+1),this.heap=new bc.Buf16(2*xc+1),Jc(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new bc.Buf16(2*xc+1),Jc(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 hl(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=Lc,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?jc:Hc,e.adler=2===t.wrap?0:1,t.last_flush=Ic,Sc._tr_init(t),Bc):Xc(e,kc)}function fl(e){var t=hl(e);return t===Bc&&function(e){e.window_size=2*e.w_size,Jc(e.head),e.max_lazy_match=vc[e.level].max_lazy,e.good_match=vc[e.level].good_length,e.nice_match=vc[e.level].nice_length,e.max_chain_length=vc[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Mc-1,e.match_available=0,e.ins_h=0}(e.state),t}function dl(e,t,r,n,i,a){if(!e)return kc;var s=1;if(t===Nc&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>Uc||r!==Dc||n<8||n>15||t<0||t>9||a<0||a>Rc)return Xc(e,kc);8===n&&(n=9);var o=new ll;return e.state=o,o.strm=e,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+Mc-1)/Mc),o.window=new bc.Buf8(2*o.w_size),o.head=new bc.Buf16(o.hash_size),o.prev=new bc.Buf16(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new bc.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=a,o.method=r,fl(e)}vc=[new cl(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(sl(e),0===e.lookahead&&t===Ic)return Wc;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,tl(e,!1),0===e.strm.avail_out))return Wc;if(e.strstart-e.block_start>=e.w_size-zc&&(tl(e,!1),0===e.strm.avail_out))return Wc}return e.insert=0,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):(e.strstart>e.block_start&&(tl(e,!1),e.strm.avail_out),Wc)})),new cl(4,4,8,4,ol),new cl(4,5,16,8,ol),new cl(4,6,32,32,ol),new cl(4,4,16,16,ul),new cl(8,16,32,32,ul),new cl(8,16,128,128,ul),new cl(8,32,128,256,ul),new cl(32,128,258,1024,ul),new cl(32,258,258,4096,ul)],Cu.deflateInit=function(e,t){return dl(e,t,Dc,15,8,0)},Cu.deflateInit2=dl,Cu.deflateReset=fl,Cu.deflateResetKeep=hl,Cu.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?kc:(e.state.gzhead=t,Bc):kc},Cu.deflate=function(e,t){var r,n,i,a;if(!e||!e.state||t>5||t<0)return e?Xc(e,kc):kc;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===Gc&&t!==Ac)return Xc(e,0===e.avail_out?-5:kc);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===jc)if(2===n.wrap)e.adler=0,rl(n,31),rl(n,139),rl(n,8),n.gzhead?(rl(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)),rl(n,255&n.gzhead.time),rl(n,n.gzhead.time>>8&255),rl(n,n.gzhead.time>>16&255),rl(n,n.gzhead.time>>24&255),rl(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),rl(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(rl(n,255&n.gzhead.extra.length),rl(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=_c(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(rl(n,0),rl(n,0),rl(n,0),rl(n,0),rl(n,0),rl(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),rl(n,3),n.status=Hc);else{var s=Dc+(n.w_bits-8<<4)<<8;s|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(s|=32),s+=31-s%31,n.status=Hc,nl(n,s),0!==n.strstart&&(nl(n,e.adler>>>16),nl(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),el(e),i=n.pending,n.pending!==n.pending_buf_size));)rl(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),el(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,rl(n,a)}while(0!==a);n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),el(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,rl(n,a)}while(0!==a);n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.status=qc)}else n.status=qc;if(n.status===qc&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&el(e),n.pending+2<=n.pending_buf_size&&(rl(n,255&e.adler),rl(n,e.adler>>8&255),e.adler=0,n.status=Hc)):n.status=Hc),0!==n.pending){if(el(e),0===e.avail_out)return n.last_flush=-1,Bc}else if(0===e.avail_in&&$c(t)<=$c(r)&&t!==Ac)return Xc(e,-5);if(n.status===Gc&&0!==e.avail_in)return Xc(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==Ic&&n.status!==Gc){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(sl(e),0===e.lookahead)){if(t===Ic)return Wc;break}if(e.match_length=0,r=Sc._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(tl(e,!1),0===e.strm.avail_out))return Wc}return e.insert=0,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):e.last_lit&&(tl(e,!1),0===e.strm.avail_out)?Wc:Qc}(n,t):3===n.strategy?function(e,t){for(var r,n,i,a,s=e.window;;){if(e.lookahead<=Fc){if(sl(e),e.lookahead<=Fc&&t===Ic)return Wc;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=Mc&&e.strstart>0&&(n=s[i=e.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=e.strstart+Fc;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);e.match_length=Fc-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Mc?(r=Sc._tr_tally(e,1,e.match_length-Mc),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Sc._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(tl(e,!1),0===e.strm.avail_out))return Wc}return e.insert=0,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):e.last_lit&&(tl(e,!1),0===e.strm.avail_out)?Wc:Qc}(n,t):vc[n.level].func(n,t);if(o!==Yc&&o!==Zc||(n.status=Gc),o===Wc||o===Yc)return 0===e.avail_out&&(n.last_flush=-1),Bc;if(o===Qc&&(1===t?Sc._tr_align(n):5!==t&&(Sc._tr_stored_block(n,0,0,!1),3===t&&(Jc(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),el(e),0===e.avail_out))return n.last_flush=-1,Bc}return t!==Ac?Bc:n.wrap<=0?1:(2===n.wrap?(rl(n,255&e.adler),rl(n,e.adler>>8&255),rl(n,e.adler>>16&255),rl(n,e.adler>>24&255),rl(n,255&e.total_in),rl(n,e.total_in>>8&255),rl(n,e.total_in>>16&255),rl(n,e.total_in>>24&255)):(nl(n,e.adler>>>16),nl(n,65535&e.adler)),el(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Bc:1)},Cu.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==jc&&69!==t&&73!==t&&91!==t&&t!==qc&&t!==Hc&&t!==Gc?Xc(e,kc):(e.state=null,t===Hc?Xc(e,-3):Bc):kc},Cu.deflateSetDictionary=function(e,t){var r,n,i,a,s,o,u,c,l=t.length;if(!e||!e.state)return kc;if(2===(a=(r=e.state).wrap)||1===a&&r.status!==jc||r.lookahead)return kc;for(1===a&&(e.adler=Tc(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===a&&(Jc(r.head),r.strstart=0,r.block_start=0,r.insert=0),c=new bc.Buf8(r.w_size),bc.arraySet(c,t,l-r.w_size,r.w_size,0),t=c,l=r.w_size),s=e.avail_in,o=e.next_in,u=e.input,e.avail_in=l,e.next_in=0,e.input=t,sl(r);r.lookahead>=Mc;){n=r.strstart,i=r.lookahead-(Mc-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+Mc-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=Mc-1,sl(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Mc-1,r.match_available=0,e.next_in=o,e.input=u,e.avail_in=s,r.wrap=a,Bc},Cu.deflateInfo="pako deflate (from Nodeca project)";var pl={},gl=mu,yl=!0,ml=!0;try{String.fromCharCode.apply(null,[0])}catch(xn){yl=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(xn){ml=!1}for(var vl=new gl.Buf8(256),Cl=0;Cl<256;Cl++)vl[Cl]=Cl>=252?6:Cl>=248?5:Cl>=240?4:Cl>=224?3:Cl>=192?2:1;function El(e,t){if(t<65534&&(e.subarray&&ml||!e.subarray&&yl))return String.fromCharCode.apply(null,gl.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}vl[254]=vl[254]=1,pl.string2buf=function(e){var t,r,n,i,a,s=e.length,o=0;for(i=0;i<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<s&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new gl.Buf8(o),a=0,i=0;a<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<s&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),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},pl.buf2binstring=function(e){return El(e,e.length)},pl.binstring2buf=function(e){for(var t=new gl.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},pl.buf2string=function(e,t){var r,n,i,a,s=t||e.length,o=new Array(2*s);for(n=0,r=0;r<s;)if((i=e[r++])<128)o[n++]=i;else if((a=vl[i])>4)o[n++]=65533,r+=a-1;else{for(i&=2===a?31:3===a?15:7;a>1&&r<s;)i=i<<6|63&e[r++],a--;a>1?o[n++]=65533:i<65536?o[n++]=i:(i-=65536,o[n++]=55296|i>>10&1023,o[n++]=56320|1023&i)}return El(o,n)},pl.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+vl[e[r]]>t?r:t};var bl=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},Sl=Cu,Tl=mu,_l=pl,wl=Ec,Il=bl,Al=Object.prototype.toString,Bl=0,kl=-1,Nl=0,Rl=8;function Ll(e){if(!(this instanceof Ll))return new Ll(e);this.options=Tl.assign({level:kl,method:Rl,chunkSize:16384,windowBits:15,memLevel:8,strategy:Nl,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 Il,this.strm.avail_out=0;var r=Sl.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Bl)throw new Error(wl[r]);if(t.header&&Sl.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?_l.string2buf(t.dictionary):"[object ArrayBuffer]"===Al.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=Sl.deflateSetDictionary(this.strm,n))!==Bl)throw new Error(wl[r]);this._dict_set=!0}}function Dl(e,t){var r=new Ll(t);if(r.push(e,!0),r.err)throw r.msg||wl[r.err];return r.result}Ll.prototype.push=function(e,t){var r,n,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=_l.string2buf(e):"[object ArrayBuffer]"===Al.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new Tl.Buf8(a),i.next_out=0,i.avail_out=a),1!==(r=Sl.deflate(i,n))&&r!==Bl)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(_l.buf2binstring(Tl.shrinkBuf(i.output,i.next_out))):this.onData(Tl.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=Sl.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Bl):2!==n||(this.onEnd(Bl),i.avail_out=0,!0)},Ll.prototype.onData=function(e){this.chunks.push(e)},Ll.prototype.onEnd=function(e){e===Bl&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Tl.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},vu.Deflate=Ll,vu.deflate=Dl,vu.deflateRaw=function(e,t){return(t=t||{}).raw=!0,Dl(e,t)},vu.gzip=function(e,t){return(t=t||{}).gzip=!0,Dl(e,t)};var Ul={},xl={},Ol=mu,Pl=15,Vl=[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],Kl=[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],Ml=[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],Fl=[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],zl=mu,jl=yc,ql=Cc,Hl=function(e,t){var r,n,i,a,s,o,u,c,l,h,f,d,p,g,y,m,v,C,E,b,S,T,_,w,I;r=e.state,n=e.next_in,w=e.input,i=n+(e.avail_in-5),a=e.next_out,I=e.output,s=a-(t-e.avail_out),o=a+(e.avail_out-257),u=r.dmax,c=r.wsize,l=r.whave,h=r.wnext,f=r.window,d=r.hold,p=r.bits,g=r.lencode,y=r.distcode,m=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;e:do{p<15&&(d+=w[n++]<<p,p+=8,d+=w[n++]<<p,p+=8),C=g[d&m];t:for(;;){if(d>>>=E=C>>>24,p-=E,0===(E=C>>>16&255))I[a++]=65535&C;else{if(!(16&E)){if(0==(64&E)){C=g[(65535&C)+(d&(1<<E)-1)];continue t}if(32&E){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&C,(E&=15)&&(p<E&&(d+=w[n++]<<p,p+=8),b+=d&(1<<E)-1,d>>>=E,p-=E),p<15&&(d+=w[n++]<<p,p+=8,d+=w[n++]<<p,p+=8),C=y[d&v];r:for(;;){if(d>>>=E=C>>>24,p-=E,!(16&(E=C>>>16&255))){if(0==(64&E)){C=y[(65535&C)+(d&(1<<E)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(S=65535&C,p<(E&=15)&&(d+=w[n++]<<p,(p+=8)<E&&(d+=w[n++]<<p,p+=8)),(S+=d&(1<<E)-1)>u){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=E,p-=E,S>(E=a-s)){if((E=S-E)>l&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(T=0,_=f,0===h){if(T+=c-E,E<b){b-=E;do{I[a++]=f[T++]}while(--E);T=a-S,_=I}}else if(h<E){if(T+=c+h-E,(E-=h)<b){b-=E;do{I[a++]=f[T++]}while(--E);if(T=0,h<b){b-=E=h;do{I[a++]=f[T++]}while(--E);T=a-S,_=I}}}else if(T+=h-E,E<b){b-=E;do{I[a++]=f[T++]}while(--E);T=a-S,_=I}for(;b>2;)I[a++]=_[T++],I[a++]=_[T++],I[a++]=_[T++],b-=3;b&&(I[a++]=_[T++],b>1&&(I[a++]=_[T++]))}else{T=a-S;do{I[a++]=I[T++],I[a++]=I[T++],I[a++]=I[T++],b-=3}while(b>2);b&&(I[a++]=I[T++],b>1&&(I[a++]=I[T++]))}break}}break}}while(n<i&&a<o);n-=b=p>>3,d&=(1<<(p-=b<<3))-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=a<o?o-a+257:257-(a-o),r.hold=d,r.bits=p},Gl=function(e,t,r,n,i,a,s,o){var u,c,l,h,f,d,p,g,y,m=o.bits,v=0,C=0,E=0,b=0,S=0,T=0,_=0,w=0,I=0,A=0,B=null,k=0,N=new Ol.Buf16(16),R=new Ol.Buf16(16),L=null,D=0;for(v=0;v<=Pl;v++)N[v]=0;for(C=0;C<n;C++)N[t[r+C]]++;for(S=m,b=Pl;b>=1&&0===N[b];b--);if(S>b&&(S=b),0===b)return i[a++]=20971520,i[a++]=20971520,o.bits=1,0;for(E=1;E<b&&0===N[E];E++);for(S<E&&(S=E),w=1,v=1;v<=Pl;v++)if(w<<=1,(w-=N[v])<0)return-1;if(w>0&&(0===e||1!==b))return-1;for(R[1]=0,v=1;v<Pl;v++)R[v+1]=R[v]+N[v];for(C=0;C<n;C++)0!==t[r+C]&&(s[R[t[r+C]]++]=C);if(0===e?(B=L=s,d=19):1===e?(B=Vl,k-=257,L=Kl,D-=257,d=256):(B=Ml,L=Fl,d=-1),A=0,C=0,v=E,f=a,T=S,_=0,l=-1,h=(I=1<<S)-1,1===e&&I>852||2===e&&I>592)return 1;for(;;){p=v-_,s[C]<d?(g=0,y=s[C]):s[C]>d?(g=L[D+s[C]],y=B[k+s[C]]):(g=96,y=0),u=1<<v-_,E=c=1<<T;do{i[f+(A>>_)+(c-=u)]=p<<24|g<<16|y|0}while(0!==c);for(u=1<<v-1;A&u;)u>>=1;if(0!==u?(A&=u-1,A+=u):A=0,C++,0==--N[v]){if(v===b)break;v=t[r+s[C]]}if(v>S&&(A&h)!==l){for(0===_&&(_=S),f+=E,w=1<<(T=v-_);T+_<b&&!((w-=N[T+_])<=0);)T++,w<<=1;if(I+=1<<T,1===e&&I>852||2===e&&I>592)return 1;i[l=A&h]=S<<24|T<<16|f-a|0}}return 0!==A&&(i[f+A]=v-_<<24|64<<16|0),o.bits=S,0},Wl=1,Ql=2,Yl=0,Zl=-2,Xl=1,$l=12,Jl=30,eh=852,th=592;function rh(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function nh(){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 zl.Buf16(320),this.work=new zl.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ih(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=Xl,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new zl.Buf32(eh),t.distcode=t.distdyn=new zl.Buf32(th),t.sane=1,t.back=-1,Yl):Zl}function ah(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,ih(e)):Zl}function sh(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Zl:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ah(e))):Zl}function oh(e,t){var r,n;return e?(n=new nh,e.state=n,n.window=null,(r=sh(e,t))!==Yl&&(e.state=null),r):Zl}var uh,ch,lh=!0;function hh(e){if(lh){var t;for(uh=new zl.Buf32(512),ch=new zl.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(Gl(Wl,e.lens,0,288,uh,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Gl(Ql,e.lens,0,32,ch,0,e.work,{bits:5}),lh=!1}e.lencode=uh,e.lenbits=9,e.distcode=ch,e.distbits=5}function fh(e,t,r,n){var i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new zl.Buf8(a.wsize)),n>=a.wsize?(zl.arraySet(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),zl.arraySet(a.window,t,r-n,i,a.wnext),(n-=i)?(zl.arraySet(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}xl.inflateReset=ah,xl.inflateReset2=sh,xl.inflateResetKeep=ih,xl.inflateInit=function(e){return oh(e,15)},xl.inflateInit2=oh,xl.inflate=function(e,t){var r,n,i,a,s,o,u,c,l,h,f,d,p,g,y,m,v,C,E,b,S,T,_,w,I=0,A=new zl.Buf8(4),B=[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 Zl;(r=e.state).mode===$l&&(r.mode=13),s=e.next_out,i=e.output,u=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,c=r.hold,l=r.bits,h=o,f=u,T=Yl;e:for(;;)switch(r.mode){case Xl:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(2&r.wrap&&35615===c){r.check=0,A[0]=255&c,A[1]=c>>>8&255,r.check=ql(r.check,A,2,0),c=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=Jl;break}if(8!=(15&c)){e.msg="unknown compression method",r.mode=Jl;break}if(l-=4,S=8+(15&(c>>>=4)),0===r.wbits)r.wbits=S;else if(S>r.wbits){e.msg="invalid window size",r.mode=Jl;break}r.dmax=1<<S,e.adler=r.check=1,r.mode=512&c?10:$l,c=0,l=0;break;case 2:for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(r.flags=c,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=Jl;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=Jl;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&(A[0]=255&c,A[1]=c>>>8&255,r.check=ql(r.check,A,2,0)),c=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.head&&(r.head.time=c),512&r.flags&&(A[0]=255&c,A[1]=c>>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,r.check=ql(r.check,A,4,0)),c=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&(A[0]=255&c,A[1]=c>>>8&255,r.check=ql(r.check,A,2,0)),c=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&(A[0]=255&c,A[1]=c>>>8&255,r.check=ql(r.check,A,2,0)),c=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>o&&(d=o),d&&(r.head&&(S=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),zl.arraySet(r.head.extra,n,a,d,S)),512&r.flags&&(r.check=ql(r.check,n,d,a)),o-=d,a+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;d=0;do{S=n[a+d++],r.head&&S&&r.length<65536&&(r.head.name+=String.fromCharCode(S))}while(S&&d<o);if(512&r.flags&&(r.check=ql(r.check,n,d,a)),o-=d,a+=d,S)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break e;d=0;do{S=n[a+d++],r.head&&S&&r.length<65536&&(r.head.comment+=String.fromCharCode(S))}while(S&&d<o);if(512&r.flags&&(r.check=ql(r.check,n,d,a)),o-=d,a+=d,S)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Jl;break}c=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=$l;break;case 10:for(;l<32;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}e.adler=r.check=rh(c),c=0,l=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=l,2;e.adler=r.check=1,r.mode=$l;case $l:if(5===t||6===t)break e;case 13:if(r.last){c>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}switch(r.last=1&c,l-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(hh(r),r.mode=20,6===t){c>>>=2,l-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=Jl}c>>>=2,l-=2;break;case 14:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Jl;break}if(r.length=65535&c,c=0,l=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>o&&(d=o),d>u&&(d=u),0===d)break e;zl.arraySet(i,n,a,d,s),o-=d,a+=d,u-=d,s+=d,r.length-=d;break}r.mode=$l;break;case 17:for(;l<14;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(r.nlen=257+(31&c),c>>>=5,l-=5,r.ndist=1+(31&c),c>>>=5,l-=5,r.ncode=4+(15&c),c>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Jl;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.lens[B[r.have++]]=7&c,c>>>=3,l-=3}for(;r.have<19;)r.lens[B[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,_={bits:r.lenbits},T=Gl(0,r.lens,0,19,r.lencode,0,r.work,_),r.lenbits=_.bits,T){e.msg="invalid code lengths set",r.mode=Jl;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(I=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,v=65535&I,!((y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(v<16)c>>>=y,l-=y,r.lens[r.have++]=v;else{if(16===v){for(w=y+2;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(c>>>=y,l-=y,0===r.have){e.msg="invalid bit length repeat",r.mode=Jl;break}S=r.lens[r.have-1],d=3+(3&c),c>>>=2,l-=2}else if(17===v){for(w=y+3;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}l-=y,S=0,d=3+(7&(c>>>=y)),c>>>=3,l-=3}else{for(w=y+7;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}l-=y,S=0,d=11+(127&(c>>>=y)),c>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Jl;break}for(;d--;)r.lens[r.have++]=S}}if(r.mode===Jl)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Jl;break}if(r.lenbits=9,_={bits:r.lenbits},T=Gl(Wl,r.lens,0,r.nlen,r.lencode,0,r.work,_),r.lenbits=_.bits,T){e.msg="invalid literal/lengths set",r.mode=Jl;break}if(r.distbits=6,r.distcode=r.distdyn,_={bits:r.distbits},T=Gl(Ql,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,_),r.distbits=_.bits,T){e.msg="invalid distances set",r.mode=Jl;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=l,Hl(e,f),s=e.next_out,i=e.output,u=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,c=r.hold,l=r.bits,r.mode===$l&&(r.back=-1);break}for(r.back=0;m=(I=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,v=65535&I,!((y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(m&&0==(240&m)){for(C=y,E=m,b=v;m=(I=r.lencode[b+((c&(1<<C+E)-1)>>C)])>>>16&255,v=65535&I,!(C+(y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}c>>>=C,l-=C,r.back+=C}if(c>>>=y,l-=y,r.back+=y,r.length=v,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=$l;break}if(64&m){e.msg="invalid literal/length code",r.mode=Jl;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(w=r.extra;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(I=r.distcode[c&(1<<r.distbits)-1])>>>16&255,v=65535&I,!((y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(0==(240&m)){for(C=y,E=m,b=v;m=(I=r.distcode[b+((c&(1<<C+E)-1)>>C)])>>>16&255,v=65535&I,!(C+(y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}c>>>=C,l-=C,r.back+=C}if(c>>>=y,l-=y,r.back+=y,64&m){e.msg="invalid distance code",r.mode=Jl;break}r.offset=v,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(w=r.extra;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Jl;break}r.mode=25;case 25:if(0===u)break e;if(d=f-u,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Jl;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),g=r.window}else g=i,p=s-r.offset,d=r.length;d>u&&(d=u),u-=d,r.length-=d;do{i[s++]=g[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===u)break e;i[s++]=r.length,u--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===o)break e;o--,c|=n[a++]<<l,l+=8}if(f-=u,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?ql(r.check,i,f,s-f):jl(r.check,i,f,s-f)),f=u,(r.flags?c:rh(c))!==r.check){e.msg="incorrect data check",r.mode=Jl;break}c=0,l=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(c!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Jl;break}c=0,l=0}r.mode=29;case 29:T=1;break e;case Jl:T=-3;break e;case 31:return-4;default:return Zl}return e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=l,(r.wsize||f!==e.avail_out&&r.mode<Jl&&(r.mode<27||4!==t))&&fh(e,e.output,e.next_out,f-e.avail_out),h-=e.avail_in,f-=e.avail_out,e.total_in+=h,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?ql(r.check,i,f,e.next_out-f):jl(r.check,i,f,e.next_out-f)),e.data_type=r.bits+(r.last?64:0)+(r.mode===$l?128:0)+(20===r.mode||15===r.mode?256:0),(0===h&&0===f||4===t)&&T===Yl&&(T=-5),T},xl.inflateEnd=function(e){if(!e||!e.state)return Zl;var t=e.state;return t.window&&(t.window=null),e.state=null,Yl},xl.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?Zl:(r.head=t,t.done=!1,Yl):Zl},xl.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?Zl:11===r.mode&&jl(1,t,n,0)!==r.check?-3:fh(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,Yl):Zl},xl.inflateInfo="pako inflate (from Nodeca project)";var dh={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};var ph=xl,gh=mu,yh=pl,mh=dh,vh=Ec,Ch=bl,Eh=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},bh=Object.prototype.toString;function Sh(e){if(!(this instanceof Sh))return new Sh(e);this.options=gh.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 Ch,this.strm.avail_out=0;var r=ph.inflateInit2(this.strm,t.windowBits);if(r!==mh.Z_OK)throw new Error(vh[r]);if(this.header=new Eh,ph.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=yh.string2buf(t.dictionary):"[object ArrayBuffer]"===bh.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=ph.inflateSetDictionary(this.strm,t.dictionary))!==mh.Z_OK))throw new Error(vh[r])}function Th(e,t){var r=new Sh(t);if(r.push(e,!0),r.err)throw r.msg||vh[r.err];return r.result}Sh.prototype.push=function(e,t){var r,n,i,a,s,o=this.strm,u=this.options.chunkSize,c=this.options.dictionary,l=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?mh.Z_FINISH:mh.Z_NO_FLUSH,"string"==typeof e?o.input=yh.binstring2buf(e):"[object ArrayBuffer]"===bh.call(e)?o.input=new Uint8Array(e):o.input=e,o.next_in=0,o.avail_in=o.input.length;do{if(0===o.avail_out&&(o.output=new gh.Buf8(u),o.next_out=0,o.avail_out=u),(r=ph.inflate(o,mh.Z_NO_FLUSH))===mh.Z_NEED_DICT&&c&&(r=ph.inflateSetDictionary(this.strm,c)),r===mh.Z_BUF_ERROR&&!0===l&&(r=mh.Z_OK,l=!1),r!==mh.Z_STREAM_END&&r!==mh.Z_OK)return this.onEnd(r),this.ended=!0,!1;o.next_out&&(0!==o.avail_out&&r!==mh.Z_STREAM_END&&(0!==o.avail_in||n!==mh.Z_FINISH&&n!==mh.Z_SYNC_FLUSH)||("string"===this.options.to?(i=yh.utf8border(o.output,o.next_out),a=o.next_out-i,s=yh.buf2string(o.output,i),o.next_out=a,o.avail_out=u-a,a&&gh.arraySet(o.output,o.output,i,a,0),this.onData(s)):this.onData(gh.shrinkBuf(o.output,o.next_out)))),0===o.avail_in&&0===o.avail_out&&(l=!0)}while((o.avail_in>0||0===o.avail_out)&&r!==mh.Z_STREAM_END);return r===mh.Z_STREAM_END&&(n=mh.Z_FINISH),n===mh.Z_FINISH?(r=ph.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===mh.Z_OK):n!==mh.Z_SYNC_FLUSH||(this.onEnd(mh.Z_OK),o.avail_out=0,!0)},Sh.prototype.onData=function(e){this.chunks.push(e)},Sh.prototype.onEnd=function(e){e===mh.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=gh.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Ul.Inflate=Sh,Ul.inflate=Th,Ul.inflateRaw=function(e,t){return(t=t||{}).raw=!0,Th(e,t)},Ul.ungzip=Th;var _h={};(0,mu.assign)(_h,vu,Ul,dh);var wh="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,Ih=_h,Ah=Co(),Bh=bo,kh=wh?"uint8array":"array";function Nh(e,t){Bh.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}yu.magic="\b\0",Ah.inherits(Nh,Bh),Nh.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(Ah.transformTo(kh,e.data),!1)},Nh.prototype.flush=function(){Bh.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},Nh.prototype.cleanUp=function(){Bh.prototype.cleanUp.call(this),this._pako=null},Nh.prototype._createPako=function(){this._pako=new Ih[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},yu.compressWorker=function(e){return new Nh("Deflate",e)},yu.uncompressWorker=function(){return new Nh("Inflate",{})};var Rh=bo;gu.STORE={magic:"\0\0",compressWorker:function(){return new Rh("STORE compression")},uncompressWorker:function(){return new Rh("STORE decompression")}},gu.DEFLATE=yu;var Lh={LOCAL_FILE_HEADER:"PK",CENTRAL_FILE_HEADER:"PK",CENTRAL_DIRECTORY_END:"PK",ZIP64_CENTRAL_DIRECTORY_LOCATOR:"PK",ZIP64_CENTRAL_DIRECTORY_END:"PK",DATA_DESCRIPTOR:"PK\b"},Dh=Co(),Uh=bo,xh=as,Oh=qo,Ph=Lh,Vh=function(e,t){var r,n="";for(r=0;r<t;r++)n+=String.fromCharCode(255&e),e>>>=8;return n},Kh=function(e,t,r,n,i,a){var s,o,u=e.file,c=e.compression,l=a!==xh.utf8encode,h=Dh.transformTo("string",a(u.name)),f=Dh.transformTo("string",xh.utf8encode(u.name)),d=u.comment,p=Dh.transformTo("string",a(d)),g=Dh.transformTo("string",xh.utf8encode(d)),y=f.length!==u.name.length,m=g.length!==d.length,v="",C="",E="",b=u.dir,S=u.date,T={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(T.crc32=e.crc32,T.compressedSize=e.compressedSize,T.uncompressedSize=e.uncompressedSize);var _=0;t&&(_|=8),l||!y&&!m||(_|=2048);var w,I,A,B=0,k=0;b&&(B|=16),"UNIX"===i?(k=798,B|=(w=u.unixPermissions,I=b,A=w,w||(A=I?16893:33204),(65535&A)<<16)):(k=20,B|=63&(u.dosPermissions||0)),s=S.getUTCHours(),s<<=6,s|=S.getUTCMinutes(),s<<=5,s|=S.getUTCSeconds()/2,o=S.getUTCFullYear()-1980,o<<=4,o|=S.getUTCMonth()+1,o<<=5,o|=S.getUTCDate(),y&&(C=Vh(1,1)+Vh(Oh(h),4)+f,v+="up"+Vh(C.length,2)+C),m&&(E=Vh(1,1)+Vh(Oh(p),4)+g,v+="uc"+Vh(E.length,2)+E);var N="";return N+="\n\0",N+=Vh(_,2),N+=c.magic,N+=Vh(s,2),N+=Vh(o,2),N+=Vh(T.crc32,4),N+=Vh(T.compressedSize,4),N+=Vh(T.uncompressedSize,4),N+=Vh(h.length,2),N+=Vh(v.length,2),{fileRecord:Ph.LOCAL_FILE_HEADER+N+h+v,dirRecord:Ph.CENTRAL_FILE_HEADER+Vh(k,2)+N+Vh(p.length,2)+"\0\0\0\0"+Vh(B,4)+Vh(n,4)+h+v+p}},Mh=function(e){return Ph.DATA_DESCRIPTOR+Vh(e.crc32,4)+Vh(e.compressedSize,4)+Vh(e.uncompressedSize,4)};function Fh(e,t,r,n){Uh.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}Dh.inherits(Fh,Uh),Fh.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,Uh.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},Fh.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=Kh(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},Fh.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=Kh(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:Mh(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},Fh.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var r=this.bytesWritten-e,n=function(e,t,r,n,i){var a=Dh.transformTo("string",i(n));return Ph.CENTRAL_DIRECTORY_END+"\0\0\0\0"+Vh(e,2)+Vh(e,2)+Vh(t,4)+Vh(r,4)+Vh(a.length,2)+a}(this.dirRecords.length,r,e,this.zipComment,this.encodeFileName);this.push({data:n,meta:{percent:100}})},Fh.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},Fh.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",(function(e){t.processChunk(e)})),e.on("end",(function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()})),e.on("error",(function(e){t.error(e)})),this},Fh.prototype.resume=function(){return!!Uh.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},Fh.prototype.error=function(e){var t=this._sources;if(!Uh.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(e){}return!0},Fh.prototype.lock=function(){Uh.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()};var zh=gu,jh=Fh;pu.generateWorker=function(e,t,r){var n=new jh(t.streamFiles,r,t.platform,t.encodeFileName),i=0;try{e.forEach((function(e,r){i++;var a=function(e,t){var r=e||t,n=zh[r];if(!n)throw new Error(r+" is not a valid compression method !");return n}(r.options.compression,t.compression),s=r.options.compressionOptions||t.compressionOptions||{},o=r.dir,u=r.date;r._compressWorker(a,s).withStreamInfo("file",{name:e,dir:o,date:u,comment:r.comment||"",unixPermissions:r.unixPermissions,dosPermissions:r.dosPermissions}).pipe(n)})),n.entriesCount=i}catch(e){n.error(e)}return n};var qh=Co(),Hh=bo;function Gh(e,t){Hh.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}qh.inherits(Gh,Hh),Gh.prototype._bindStream=function(e){var t=this;this._stream=e,e.pause(),e.on("data",(function(e){t.push({data:e,meta:{percent:0}})})).on("error",(function(e){t.isPaused?this.generatedError=e:t.error(e)})).on("end",(function(){t.isPaused?t._upstreamEnded=!0:t.end()}))},Gh.prototype.pause=function(){return!!Hh.prototype.pause.call(this)&&(this._stream.pause(),!0)},Gh.prototype.resume=function(){return!!Hh.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)};var Wh=Gh,Qh=as,Yh=Co(),Zh=bo,Xh=Oo,$h=Po,Jh=nu,ef=du,tf=pu,rf=go,nf=Wh,af=function(e,t,r){var n,i=Yh.getTypeOf(t),a=Yh.extend(r||{},$h);a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),"string"==typeof a.unixPermissions&&(a.unixPermissions=parseInt(a.unixPermissions,8)),a.unixPermissions&&16384&a.unixPermissions&&(a.dir=!0),a.dosPermissions&&16&a.dosPermissions&&(a.dir=!0),a.dir&&(e=of(e)),a.createFolders&&(n=sf(e))&&uf.call(this,n,!0);var s="string"===i&&!1===a.binary&&!1===a.base64;r&&void 0!==r.binary||(a.binary=!s),(t instanceof Jh&&0===t.uncompressedSize||a.dir||!t||0===t.length)&&(a.base64=!1,a.binary=!0,t="",a.compression="STORE",i="string");var o=null;o=t instanceof Jh||t instanceof Zh?t:rf.isNode&&rf.isStream(t)?new nf(e,t):Yh.prepareContent(e,t,a.binary,a.optimizedBinaryString,a.base64);var u=new ef(e,o,a);this.files[e]=u},sf=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return t>0?e.substring(0,t):""},of=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},uf=function(e,t){return t=void 0!==t?t:$h.createFolders,e=of(e),this.files[e]||af.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function cf(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var lf={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,r,n;for(t in this.files)n=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,n)},filter:function(e){var t=[];return this.forEach((function(r,n){e(r,n)&&t.push(n)})),t},file:function(e,t,r){if(1===arguments.length){if(cf(e)){var n=e;return this.filter((function(e,t){return!t.dir&&n.test(e)}))}var i=this.files[this.root+e];return i&&!i.dir?i:null}return e=this.root+e,af.call(this,e,t,r),this},folder:function(e){if(!e)return this;if(cf(e))return this.filter((function(t,r){return r.dir&&e.test(t)}));var t=this.root+e,r=uf.call(this,t),n=this.clone();return n.root=r.name,n},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!==e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var r=this.filter((function(t,r){return r.name.slice(0,e.length)===e})),n=0;n<r.length;n++)delete this.files[r[n].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,r={};try{if((r=Yh.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:Qh.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");Yh.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var n=r.comment||this.comment||"";t=tf.generateWorker(this,r,n)}catch(e){(t=new Zh("error")).error(e)}return new Xh(t,r.type||"string",r.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}},hf=lf,ff=Co();function df(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}df.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return ff.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}};var pf=df,gf=pf;function yf(e){gf.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}Co().inherits(yf,gf),yf.prototype.byteAt=function(e){return this.data[this.zero+e]},yf.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),a=this.length-4;a>=0;--a)if(this.data[a]===t&&this.data[a+1]===r&&this.data[a+2]===n&&this.data[a+3]===i)return a-this.zero;return-1},yf.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),a=this.readData(4);return t===a[0]&&r===a[1]&&n===a[2]&&i===a[3]},yf.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};var mf=yf,vf=pf;function Cf(e){vf.call(this,e)}Co().inherits(Cf,vf),Cf.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},Cf.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},Cf.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},Cf.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};var Ef=Cf,bf=mf;function Sf(e){bf.call(this,e)}Co().inherits(Sf,bf),Sf.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};var Tf=Sf,_f=Tf;function wf(e){_f.call(this,e)}Co().inherits(wf,_f),wf.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};var If=wf,Af=Co(),Bf=os,kf=mf,Nf=Ef,Rf=If,Lf=Tf,Df=function(e){var t=Af.getTypeOf(e);return Af.checkSupport(t),"string"!==t||Bf.uint8array?"nodebuffer"===t?new Rf(e):Bf.uint8array?new Lf(Af.transformTo("uint8array",e)):new kf(Af.transformTo("array",e)):new Nf(e)},Uf=Df,xf=Co(),Of=nu,Pf=qo,Vf=as,Kf=gu,Mf=os;function Ff(e,t){this.options=e,this.loadOptions=t}Ff.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(e){var t,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in Kf)if(Object.prototype.hasOwnProperty.call(Kf,t)&&Kf[t].magic===e)return Kf[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+xf.pretty(this.compressionMethod)+" unknown (inner file : "+xf.transformTo("string",this.fileName)+")");this.decompressed=new Of(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0===e&&(this.dosPermissions=63&this.externalFileAttributes),3===e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=Uf(this.extraFields[1].value);this.uncompressedSize===xf.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===xf.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===xf.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===xf.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),r=e.readInt(2),n=e.readData(r),this.extraFields[t]={id:t,length:r,value:n};e.setIndex(i)},handleUTF8:function(){var e=Mf.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=Vf.utf8decode(this.fileName),this.fileCommentStr=Vf.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var r=xf.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var n=this.findExtraFieldUnicodeComment();if(null!==n)this.fileCommentStr=n;else{var i=xf.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(i)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=Uf(e.value);return 1!==t.readInt(1)||Pf(this.fileName)!==t.readInt(4)?null:Vf.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=Uf(e.value);return 1!==t.readInt(1)||Pf(this.fileComment)!==t.readInt(4)?null:Vf.utf8decode(t.readData(e.length-5))}return null}};var zf=Ff,jf=Df,qf=Co(),Hf=Lh,Gf=zf,Wf=os;function Qf(e){this.files=[],this.loadOptions=e}Qf.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+qf.pretty(t)+", expected "+qf.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var n=this.reader.readString(4)===t;return this.reader.setIndex(r),n},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=Wf.uint8array?"uint8array":"array",r=qf.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,r,n=this.zip64EndOfCentralSize-44;0<n;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(Hf.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(Hf.CENTRAL_FILE_HEADER);)(e=new Gf({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(Hf.CENTRAL_DIRECTORY_END);if(e<0)throw!this.isSignature(0,Hf.LOCAL_FILE_HEADER)?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory");this.reader.setIndex(e);var t=e;if(this.checkSignature(Hf.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===qf.MAX_VALUE_16BITS||this.diskWithCentralDirStart===qf.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===qf.MAX_VALUE_16BITS||this.centralDirRecords===qf.MAX_VALUE_16BITS||this.centralDirSize===qf.MAX_VALUE_32BITS||this.centralDirOffset===qf.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(Hf.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(Hf.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,Hf.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(Hf.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(Hf.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var n=t-r;if(n>0)this.isSignature(t,Hf.CENTRAL_FILE_HEADER)||(this.reader.zero=n);else if(n<0)throw new Error("Corrupted zip: missing "+Math.abs(n)+" bytes.")},prepareReader:function(e){this.reader=jf(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};var Yf=Qf,Zf=Co(),Xf=vo,$f=as,Jf=Yf,ed=Qo,td=go;function rd(e){return new Xf.Promise((function(t,r){var n=e.decompressed.getContentWorker().pipe(new ed);n.on("error",(function(e){r(e)})).on("end",(function(){n.streamInfo.crc32!==e.decompressed.crc32?r(new Error("Corrupted zip : CRC32 mismatch")):t()})).resume()}))}function nd(){if(!(this instanceof nd))return new nd;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new nd;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}nd.prototype=hf,nd.prototype.loadAsync=function(e,t){var r=this;return t=Zf.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:$f.utf8decode}),td.isNode&&td.isStream(e)?Xf.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):Zf.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then((function(e){var r=new Jf(t);return r.load(e),r})).then((function(e){var r=[Xf.Promise.resolve(e)],n=e.files;if(t.checkCRC32)for(var i=0;i<n.length;i++)r.push(rd(n[i]));return Xf.Promise.all(r)})).then((function(e){for(var n=e.shift(),i=n.files,a=0;a<i.length;a++){var s=i[a],o=s.fileNameStr,u=Zf.resolve(s.fileNameStr);r.file(u,s.decompressed,{binary:!0,optimizedBinaryString:!0,date:s.date,dir:s.dir,comment:s.fileCommentStr.length?s.fileCommentStr:null,unixPermissions:s.unixPermissions,dosPermissions:s.dosPermissions,createFolders:t.createFolders}),s.dir||(r.file(u).unsafeOriginalName=o)}return n.zipComment.length&&(r.comment=n.zipComment),r}))},nd.support=os,nd.defaults=Po,nd.version="3.10.1",nd.loadAsync=function(e,t){return(new nd).loadAsync(e,t)},nd.external=vo;var id=nd;exports.CertApplyPlugin=class extends e.AbstractTaskPlugin{domains;email;dnsProviderType;dnsProviderAccess;renewDays;forceUpdate;csrInfo;acme;logger;userContext;accessService;http;lastStatus;cert;async onInstance(){this.accessService=this.ctx.accessService,this.logger=this.ctx.logger,this.userContext=this.ctx.userContext,this.http=this.ctx.http,this.lastStatus=this.ctx.lastStatus,this.acme=new g({userContext:this.userContext,logger:this.logger})}async execute(){const e=await this.condition();if(null!=e)return await this.output(e.toCertInfo());const t=await this.doCertApply();if(null==t)throw new Error("申请证书失败");await this.output(t.toCertInfo()),this.clearLastStatus()}async output(e){this.cert=e,await this.zipCert(e)}async zipCert(e){const t=new id;t.file("cert.crt",e.crt),t.file("cert.key",e.key);const r=await t.generateAsync({type:"nodebuffer"});this.saveFile("cert.zip",r)}async condition(){if(this.forceUpdate)return null;let e=!1;let r;JSON.stringify(this.lastStatus?.input?.domains)!==JSON.stringify(this.domains)&&(e=!0);try{r=await this.readLastCert()}catch(e){this.logger.warn("读取cert失败:",e)}if(null==r)return this.logger.info("还未申请过,准备申请新证书"),null;if(e)return this.logger.info("输入参数变更,申请新证书"),null;const n=this.isWillExpire(r.expires,this.renewDays);return n.isWillExpire?(this.logger.info("即将过期,开始更新证书"),null):(this.logger.info(`证书还未过期:过期时间${t(r.expires).format("YYYY-MM-DD HH:mm:ss")},剩余${n.leftDays}天`),r)}async doCertApply(){const t=this.email,r=this.domains,i=this.dnsProviderType,a=this.dnsProviderAccess,s=n.merge({country:"CN",state:"GuangDong",locality:"ShengZhen",organization:"CertD Org.",organizationUnit:"IT Department",emailAddress:t},this.csrInfo);this.logger.info("开始申请证书,",t,r);const o=y.get(i),u=o.target,c=o.define,l=await this.accessService.getById(a),h=new u,f={access:l,logger:this.logger,http:this.http};e.Decorator.inject(c.autowire,h,f),await h.onInstance();const d=await this.acme.order({email:t,domains:r,dnsProvider:h,csrInfo:s,isTest:!1}),p=this.formatCerts(d);return new ts(p)}formatCert(e){return e=(e=(e=e.replace(/\r/g,"")).replace(/\n\n/g,"\n")).replace(/\n$/g,"")}formatCerts(e){return{crt:this.formatCert(e.crt),key:this.formatCert(e.key),csr:this.formatCert(e.csr)}}async readLastCert(){const e=this.lastStatus?.status?.output?.cert;if(null!=e)return new ts(e)}isWillExpire(e,r=20){if(null==e)throw new Error("过期时间不能为空");const n=t(e).diff(t(),"day");return{isWillExpire:n<r,leftDays:n}}},p([e.TaskInput({title:"域名",component:{name:"a-select",vModel:"value",mode:"tags",open:!1},required:!0,col:{span:24},helper:"支持通配符域名,例如: *.foo.com 、 *.test.handsfree.work\n支持多个域名、多个子域名、多个通配符域名打到一个证书上(域名必须是在同一个DNS提供商解析)\n多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com)\n输入一个回车之后,再输入下一个"})],exports.CertApplyPlugin.prototype,"domains",void 0),p([e.TaskInput({title:"邮箱",component:{name:"a-input",vModel:"value"},required:!0,helper:"请输入邮箱"})],exports.CertApplyPlugin.prototype,"email",void 0),p([e.TaskInput({title:"DNS提供商",component:{name:"pi-dns-provider-selector"},required:!0,helper:"请选择dns解析提供商"})],exports.CertApplyPlugin.prototype,"dnsProviderType",void 0),p([e.TaskInput({title:"DNS解析授权",component:{name:"pi-access-selector"},required:!0,helper:"请选择dns解析提供商授权",reference:[{src:"form.dnsProviderType",dest:"component.type",type:"computed"}]})],exports.CertApplyPlugin.prototype,"dnsProviderAccess",void 0),p([e.TaskInput({title:"更新天数",component:{name:"a-input-number",vModel:"value"},required:!0,helper:"到期前多少天后更新证书"})],exports.CertApplyPlugin.prototype,"renewDays",void 0),p([e.TaskInput({title:"强制更新",component:{name:"a-switch",vModel:"checked"},helper:"是否强制重新申请证书"})],exports.CertApplyPlugin.prototype,"forceUpdate",void 0),p([e.TaskInput({title:"CsrInfo"})],exports.CertApplyPlugin.prototype,"csrInfo",void 0),p([e.TaskOutput({title:"域名证书"})],exports.CertApplyPlugin.prototype,"cert",void 0),exports.CertApplyPlugin=p([e.IsTaskPlugin({name:"CertApply",title:"证书申请",desc:"免费通配符域名证书申请,支持多个域名打到同一个证书上",default:{input:{renewDays:20,forceUpdate:!1},strategy:{runStrategy:e.RunStrategy.AlwaysRun}}})],exports.CertApplyPlugin),new exports.CertApplyPlugin,exports.CertReader=ts,exports.DNS_PROVIDER_CLASS_KEY=m,exports.IsDnsProvider=function(t){return r=>{r=e.Decorator.target(r);const i={},a=e.Decorator.getClassProperties(r);for(const t in a){const n=Reflect.getMetadata(e.AUTOWIRE_KEY,r,t);n&&(i[t]=n)}n.merge(t,{autowire:i}),Reflect.defineMetadata(m,t,r),r.define=t,y.register(t.name,{define:t,target:r})}},exports.dnsProviderRegistry=y;
|
|
1
|
+
"use strict";var e=require("@certd/pipeline"),t=require("dayjs"),r=require("@certd/acme-client"),n=require("lodash"),i=require("fs"),a=require("os"),s=require("crypto"),o=require("path"),u=require("stream"),c=require("events"),l=require("buffer"),h=require("util");function f(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=f(r);function p(e,t,r,n){var i,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,r,s):i(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}class g{userContext;logger;constructor(e){this.userContext=e.userContext,this.logger=e.logger,d.setLogger((e=>{this.logger.info(e)}))}async getAccountConfig(e){return await this.userContext.getObj(this.buildAccountKey(e))||{}}buildAccountKey(e){return"acme.config."+e}async saveAccountConfig(e,t){await this.userContext.setObj(this.buildAccountKey(e),t)}async getAcmeClient(e,t=!1){const r=await this.getAccountConfig(e);null==r.key&&(r.key=await this.createNewKey(),await this.saveAccountConfig(e,r));const n=new d.Client({directoryUrl:t?d.directory.letsencrypt.staging:d.directory.letsencrypt.production,accountKey:r.key,accountUrl:r.accountUrl,backoffAttempts:20,backoffMin:5e3,backoffMax:1e4});if(null==r.accountUrl){const t={termsOfServiceAgreed:!0,contact:[`mailto:${e}`]};await n.createAccount(t),r.accountUrl=n.getAccountUrl(),await this.saveAccountConfig(e,r)}return n}async createNewKey(){return(await d.forge.createPrivateKey()).toString()}async challengeCreateFn(e,t,r,n){if(this.logger.info("Triggered challengeCreateFn()"),"http-01"===t.type){const n=`/var/www/html/.well-known/acme-challenge/${t.token}`,i=r;this.logger.info(`Creating challenge response for ${e.identifier.value} at path: ${n}`),this.logger.info(`Would write "${i}" to path "${n}"`)}else if("dns-01"===t.type){const t=`_acme-challenge.${e.identifier.value}`,i=r;return this.logger.info(`Creating TXT record for ${e.identifier.value}: ${t}`),this.logger.info(`Would create TXT record "${t}" with value "${i}"`),await n.createRecord({fullRecord:t,type:"TXT",value:i})}}async challengeRemoveFn(e,t,r,n,i){if(this.logger.info("Triggered challengeRemoveFn()"),"http-01"===t.type){const r=`/var/www/html/.well-known/acme-challenge/${t.token}`;this.logger.info(`Removing challenge response for ${e.identifier.value} at path: ${r}`),this.logger.info(`Would remove file on path "${r}"`)}else if("dns-01"===t.type){const t=`_acme-challenge.${e.identifier.value}`,a=r;this.logger.info(`Removing TXT record for ${e.identifier.value}: ${t}`),this.logger.info(`Would remove TXT record "${t}" with value "${a}"`);try{await i.removeRecord({fullRecord:t,type:"TXT",value:r,record:n})}catch(e){throw this.logger.error("删除解析记录出错:",e),e}}}async order(e){const{email:t,isTest:r,domains:n,csrInfo:i,dnsProvider:a}=e,s=await this.getAcmeClient(t,r),{commonName:o,altNames:u}=this.buildCommonNameByDomains(n),[c,l]=await d.forge.createCsr({commonName:o,...i,altNames:u});if(null==a)throw new Error("dnsProvider 不能为空");const h={crt:(await s.auto({csr:l,email:t,termsOfServiceAgreed:!0,challengePriority:["dns-01"],challengeCreateFn:async(e,t,r)=>await this.challengeCreateFn(e,t,r,a),challengeRemoveFn:async(e,t,r,n)=>await this.challengeRemoveFn(e,t,r,n,a)})).toString(),key:c.toString(),csr:l.toString()};return this.logger.debug(`CSR:\n${h.csr}`),this.logger.debug(`Certificate:\n${h.crt}`),this.logger.info("证书申请成功"),h}buildCommonNameByDomains(e){if("string"==typeof e&&(e=e.split(",")),0===e.length)throw new Error("domain can not be empty");const t=e[0];let r;return e.length>1&&(r=n.slice(e,1)),{commonName:t,altNames:r}}}const y=new e.Registry,m="pipeline:dns-provider";var v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function C(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E={},b={get exports(){return E},set exports(e){E=e}},S={options:{usePureJavaScript:!1}},T={},_=T,w={};T.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,a=t.length,s=t.charAt(0),o=[0];for(i=0;i<e.length;++i){for(var u=0,c=e[i];u<o.length;++u)c+=o[u]<<8,o[u]=c%a,c=c/a|0;for(;c>0;)o.push(c%a),c=c/a|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=s;for(i=o.length-1;i>=0;--i)n+=t[o[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),a=[0];for(r=0;r<e.length();++r){for(var s=0,o=e.at(r);s<a.length;++s)o+=a[s]<<8,a[s]=o%n,o=o/n|0;for(;o>0;)a.push(o%n),o=o/n|0}var u="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)u+=i;for(r=a.length-1;r>=0;--r)u+=t[a[r]];return u}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},T.decode=function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=w[t];if(!r){r=w[t]=[];for(var n=0;n<t.length;++n)r[t.charCodeAt(n)]=n}e=e.replace(/\s/g,"");var i=t.length,a=t.charAt(0),s=[0];for(n=0;n<e.length;n++){var o=r[e.charCodeAt(n)];if(void 0===o)return;for(var u=0,c=o;u<s.length;++u)c+=s[u]*i,s[u]=255&c,c>>=8;for(;c>0;)s.push(255&c),c>>=8}for(var l=0;e[l]===a&&l<e.length-1;++l)s.push(0);return"undefined"!=typeof Buffer?Buffer.from(s.reverse()):new Uint8Array(s.reverse())};var I=S,A=_,B=I.util=I.util||{};function k(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function N(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(B.isArrayBuffer(e)||B.isArrayBufferView(e))if("undefined"!=typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(e){for(var r=0;r<t.length;++r)this.putByte(t[r])}}else(e instanceof N||"object"==typeof e&&"string"==typeof e.data&&"number"==typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!=typeof process&&process.nextTick&&!process.browser)return B.nextTick=process.nextTick,void("function"==typeof setImmediate?B.setImmediate=setImmediate:B.setImmediate=B.nextTick);if("function"==typeof setImmediate)return B.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(B.nextTick=function(e){return setImmediate(e)});if(B.setImmediate=function(e){setTimeout(e,0)},"undefined"!=typeof window&&"function"==typeof window.postMessage){var e="forge.setImmediate",t=[];function s(r){if(r.source===window&&r.data===e){r.stopPropagation();var n=t.slice();t.length=0,n.forEach((function(e){e()}))}}B.setImmediate=function(r){t.push(r),1===t.length&&window.postMessage(e,"*")},window.addEventListener("message",s,!0)}if("undefined"!=typeof MutationObserver){var r=Date.now(),n=!0,i=document.createElement("div");t=[];new MutationObserver((function(){var e=t.slice();t.length=0,e.forEach((function(e){e()}))})).observe(i,{attributes:!0});var a=B.setImmediate;B.setImmediate=function(e){Date.now()-r>15?(r=Date.now(),a(e)):(t.push(e),1===t.length&&i.setAttribute("a",n=!n))}}B.nextTick=B.setImmediate}(),B.isNodejs="undefined"!=typeof process&&process.versions&&process.versions.node,B.globalScope=B.isNodejs?v:"undefined"==typeof self?window:self,B.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},B.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},B.isArrayBufferView=function(e){return e&&B.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},B.ByteBuffer=N,B.ByteStringBuffer=N;B.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},B.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},B.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},B.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},B.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},B.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},B.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(B.encodeUtf8(e))},B.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},B.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},B.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},B.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},B.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},B.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},B.ByteStringBuffer.prototype.putInt=function(e,t){k(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},B.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},B.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},B.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},B.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},B.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},B.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},B.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},B.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},B.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},B.ByteStringBuffer.prototype.getInt=function(e){k(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},B.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},B.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},B.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},B.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},B.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},B.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},B.ByteStringBuffer.prototype.copy=function(){var e=B.createBuffer(this.data);return e.read=this.read,e},B.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},B.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},B.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},B.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},B.ByteStringBuffer.prototype.toString=function(){return B.decodeUtf8(this.bytes())},B.DataBuffer=function(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var r=B.isArrayBuffer(e),n=B.isArrayBufferView(e);if(r||n)return this.data=r?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in t?t.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=e&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)},B.DataBuffer.prototype.length=function(){return this.write-this.read},B.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},B.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},B.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},B.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},B.DataBuffer.prototype.putBytes=function(e,t){if(B.isArrayBufferView(e)){var r=(n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-n.byteOffset;return this.accommodate(r),new Uint8Array(this.data.buffer,this.write).set(n),this.write+=r,this}if(B.isArrayBuffer(e)){var n=new Uint8Array(e);return this.accommodate(n.byteLength),new Uint8Array(this.data.buffer).set(n,this.write),this.write+=n.byteLength,this}if(e instanceof B.DataBuffer||"object"==typeof e&&"number"==typeof e.read&&"number"==typeof e.write&&B.isArrayBufferView(e.data)){n=new Uint8Array(e.data.byteLength,e.read,e.length());return this.accommodate(n.byteLength),new Uint8Array(e.data.byteLength,this.write).set(n),this.write+=n.byteLength,this}if(e instanceof B.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary","string"==typeof e){var i;if("hex"===t)return this.accommodate(Math.ceil(e.length/2)),i=new Uint8Array(this.data.buffer,this.write),this.write+=B.binary.hex.decode(e,i,this.write),this;if("base64"===t)return this.accommodate(3*Math.ceil(e.length/4)),i=new Uint8Array(this.data.buffer,this.write),this.write+=B.binary.base64.decode(e,i,this.write),this;if("utf8"===t&&(e=B.encodeUtf8(e),t="binary"),"binary"===t||"raw"===t)return this.accommodate(e.length),i=new Uint8Array(this.data.buffer,this.write),this.write+=B.binary.raw.decode(i),this;if("utf16"===t)return this.accommodate(2*e.length),i=new Uint16Array(this.data.buffer,this.write),this.write+=B.text.utf16.encode(i),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)},B.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},B.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},B.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},B.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},B.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},B.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},B.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},B.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},B.DataBuffer.prototype.putInt=function(e,t){k(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},B.DataBuffer.prototype.putSignedInt=function(e,t){return k(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},B.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},B.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},B.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},B.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},B.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},B.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},B.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},B.DataBuffer.prototype.getInt=function(e){k(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},B.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},B.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},B.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},B.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},B.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},B.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},B.DataBuffer.prototype.copy=function(){return new B.DataBuffer(this)},B.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},B.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},B.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},B.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},B.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return B.binary.raw.encode(t);if("hex"===e)return B.binary.hex.encode(t);if("base64"===e)return B.binary.base64.encode(t);if("utf8"===e)return B.text.utf8.decode(t);if("utf16"===e)return B.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)},B.createBuffer=function(e,t){return t=t||"raw",void 0!==e&&"utf8"===t&&(e=B.encodeUtf8(e)),new B.ByteBuffer(e)},B.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},B.xorBytes=function(e,t,r){for(var n="",i="",a="",s=0,o=0;r>0;--r,++s)i=e.charCodeAt(s)^t.charCodeAt(s),o>=10&&(n+=a,a="",o=0),a+=String.fromCharCode(i),++o;return n+=a},B.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},B.bytesToHex=function(e){return B.createBuffer(e).toHex()},B.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",L=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],D="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";B.encode64=function(e,t){for(var r,n,i,a="",s="",o=0;o<e.length;)r=e.charCodeAt(o++),n=e.charCodeAt(o++),i=e.charCodeAt(o++),a+=R.charAt(r>>2),a+=R.charAt((3&r)<<4|n>>4),isNaN(n)?a+="==":(a+=R.charAt((15&n)<<2|i>>6),a+=isNaN(i)?"=":R.charAt(63&i)),t&&a.length>t&&(s+=a.substr(0,t)+"\r\n",a=a.substr(t));return s+=a},B.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,a="",s=0;s<e.length;)t=L[e.charCodeAt(s++)-43],r=L[e.charCodeAt(s++)-43],n=L[e.charCodeAt(s++)-43],i=L[e.charCodeAt(s++)-43],a+=String.fromCharCode(t<<2|r>>4),64!==n&&(a+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(a+=String.fromCharCode((3&n)<<6|i)));return a},B.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},B.decodeUtf8=function(e){return decodeURIComponent(escape(e))},B.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:A.encode,decode:A.decode}},B.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},B.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,a=0;a<e.length;++a)n[i++]=e.charCodeAt(a);return t?i-r:n},B.binary.hex.encode=B.bytesToHex,B.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var i=0,a=r=r||0;for(1&e.length&&(i=1,n[a++]=parseInt(e[0],16));i<e.length;i+=2)n[a++]=parseInt(e.substr(i,2),16);return t?a-r:n},B.binary.base64.encode=function(e,t){for(var r,n,i,a="",s="",o=0;o<e.byteLength;)r=e[o++],n=e[o++],i=e[o++],a+=R.charAt(r>>2),a+=R.charAt((3&r)<<4|n>>4),isNaN(n)?a+="==":(a+=R.charAt((15&n)<<2|i>>6),a+=isNaN(i)?"=":R.charAt(63&i)),t&&a.length>t&&(s+=a.substr(0,t)+"\r\n",a=a.substr(t));return s+=a},B.binary.base64.decode=function(e,t,r){var n,i,a,s,o=t;o||(o=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var u=0,c=r=r||0;u<e.length;)n=L[e.charCodeAt(u++)-43],i=L[e.charCodeAt(u++)-43],a=L[e.charCodeAt(u++)-43],s=L[e.charCodeAt(u++)-43],o[c++]=n<<2|i>>4,64!==a&&(o[c++]=(15&i)<<4|a>>2,64!==s&&(o[c++]=(3&a)<<6|s));return t?c-r:o.subarray(0,c)},B.binary.base58.encode=function(e,t){return B.binary.baseN.encode(e,D,t)},B.binary.base58.decode=function(e,t){return B.binary.baseN.decode(e,D,t)},B.text={utf8:{},utf16:{}},B.text.utf8.encode=function(e,t,r){e=B.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,a=0;a<e.length;++a)n[i++]=e.charCodeAt(a);return t?i-r:n},B.text.utf8.decode=function(e){return B.decodeUtf8(String.fromCharCode.apply(null,e))},B.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var i=new Uint16Array(n.buffer),a=r=r||0,s=r,o=0;o<e.length;++o)i[s++]=e.charCodeAt(o),a+=2;return t?a-r:n},B.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},B.deflate=function(e,t,r){if(t=B.decode64(e.deflate(B.encode64(t)).rval),r){var n=2;32&t.charCodeAt(1)&&(n=6),t=t.substring(n,t.length-4)}return t},B.inflate=function(e,t,r){var n=e.inflate(B.encode64(t)).rval;return null===n?null:B.decode64(n)};var U=function(e,t,r){if(!e)throw new Error("WebStorage not available.");var n;if(null===r?n=e.removeItem(t):(r=B.encode64(JSON.stringify(r)),n=e.setItem(t,r)),void 0!==n&&!0!==n.rval){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}},x=function(e,t){if(!e)throw new Error("WebStorage not available.");var r=e.getItem(t);if(e.init)if(null===r.rval){if(r.error){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}r=null}else r=r.rval;return null!==r&&(r=JSON.parse(B.decode64(r))),r},O=function(e,t,r,n){var i=x(e,t);null===i&&(i={}),i[r]=n,U(e,t,i)},P=function(e,t,r){var n=x(e,t);return null!==n&&(n=r in n?n[r]:null),n},V=function(e,t,r){var n=x(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var a in n){i=!1;break}i&&(n=null),U(e,t,n)}},K=function(e,t){U(e,t,null)},M=function(e,t,r){var n,i=null;void 0===r&&(r=["web","flash"]);var a=!1,s=null;for(var o in r){n=r[o];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");i=e.apply(this,t),a="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),a=!0)}catch(e){s=e}if(a)break}if(!a)throw s;return i};B.setItem=function(e,t,r,n,i){M(O,arguments,i)},B.getItem=function(e,t,r,n){return M(P,arguments,n)},B.removeItem=function(e,t,r,n){M(V,arguments,n)},B.clearItems=function(e,t,r){M(K,arguments,r)},B.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),n=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return n&&(n.fullHost=n.host,n.port?(80!==n.port&&"http"===n.scheme||443!==n.port&&"https"===n.scheme)&&(n.fullHost+=":"+n.port):"http"===n.scheme?n.port=80:"https"===n.scheme&&(n.port=443),n.full=n.scheme+"://"+n.fullHost),n};var F=null;B.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),n=0;n<r.length;n++){var i,a,s=r[n].indexOf("=");s>0?(i=r[n].substring(0,s),a=r[n].substring(s+1)):(i=r[n],a=null),i in t||(t[i]=[]),i in Object.prototype||null===a||t[i].push(unescape(a))}return t};return void 0===e?(null===F&&(F="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=F):t=r(e),t},B.parseFragment=function(e){var t=e,r="",n=e.indexOf("?");n>0&&(t=e.substring(0,n),r=e.substring(n+1));var i=t.split("/");return i.length>0&&""===i[0]&&i.shift(),{pathString:t,queryString:r,path:i,query:""===r?{}:B.getQueryVariables(r)}},B.makeRequest=function(e){var t=B.parseFragment(e),r={path:t.pathString,query:t.queryString,getPath:function(e){return void 0===e?t.path:t.path[e]},getQuery:function(e,r){var n;return void 0===e?n=t.query:(n=t.query[e])&&void 0!==r&&(n=n[r]),n},getQueryLast:function(e,t){var n=r.getQuery(e);return n?n[n.length-1]:t}};return r},B.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var n=jQuery.param(t||{});return r=r||"",e+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},B.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},B.format=function(e){for(var t,r,n=/%./g,i=0,a=[],s=0;t=n.exec(e);){(r=e.substring(s,n.lastIndex-2)).length>0&&a.push(r),s=n.lastIndex;var o=t[0][1];switch(o){case"s":case"o":i<arguments.length?a.push(arguments[1+i++]):a.push("<?>");break;case"%":a.push("%");break;default:a.push("<%"+o+"?>")}}return a.push(e.substring(s)),a.join("")},B.formatNumber=function(e,t,r,n){var i=e,a=isNaN(t=Math.abs(t))?2:t,s=void 0===r?",":r,o=void 0===n?".":n,u=i<0?"-":"",c=parseInt(i=Math.abs(+i||0).toFixed(a),10)+"",l=c.length>3?c.length%3:0;return u+(l?c.substr(0,l)+o:"")+c.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+o)+(a?s+Math.abs(i-c).toFixed(a).slice(2):"")},B.formatSize=function(e){return e=e>=1073741824?B.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?B.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?B.formatNumber(e/1024,0)+" KiB":B.formatNumber(e,0)+" bytes"},B.bytesFromIP=function(e){return-1!==e.indexOf(".")?B.bytesFromIPv4(e):-1!==e.indexOf(":")?B.bytesFromIPv6(e):null},B.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=B.createBuffer(),r=0;r<e.length;++r){var n=parseInt(e[r],10);if(isNaN(n))return null;t.putByte(n)}return t.getBytes()},B.bytesFromIPv6=function(e){for(var t=0,r=2*(8-(e=e.split(":").filter((function(e){return 0===e.length&&++t,!0}))).length+t),n=B.createBuffer(),i=0;i<8;++i)if(e[i]&&0!==e[i].length){var a=B.hexToBytes(e[i]);a.length<2&&n.putByte(0),n.putBytes(a)}else n.fillWithByte(0,r),r=0;return n.getBytes()},B.bytesToIP=function(e){return 4===e.length?B.bytesToIPv4(e):16===e.length?B.bytesToIPv6(e):null},B.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},B.bytesToIPv6=function(e){if(16!==e.length)return null;for(var t=[],r=[],n=0,i=0;i<e.length;i+=2){for(var a=B.bytesToHex(e[i]+e[i+1]);"0"===a[0]&&"0"!==a;)a=a.substr(1);if("0"===a){var s=r[r.length-1],o=t.length;s&&o===s.end+1?(s.end=o,s.end-s.start>r[n].end-r[n].start&&(n=r.length-1)):r.push({start:o,end:o})}t.push(a)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},B.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in B&&!e.update)return t(null,B.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return B.cores=navigator.hardwareConcurrency,t(null,B.cores);if("undefined"==typeof Worker)return B.cores=1,t(null,B.cores);if("undefined"==typeof Blob)return B.cores=2,t(null,B.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){var t=Date.now(),r=t+4;self.postMessage({st:t,et:r})}))}.toString(),")()"],{type:"application/javascript"}));!function e(n,i,a){if(0===i){var s=Math.floor(n.reduce((function(e,t){return e+t}),0)/n.length);return B.cores=Math.max(1,s),URL.revokeObjectURL(r),t(null,B.cores)}!function(e,t){for(var n=[],i=[],a=0;a<e;++a){var s=new Worker(r);s.addEventListener("message",(function(r){if(i.push(r.data),i.length===e){for(var a=0;a<e;++a)n[a].terminate();t(null,i)}})),n.push(s)}for(a=0;a<e;++a)n[a].postMessage(a)}(a,(function(t,r){n.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],a=r[n]=[],s=0;s<e;++s)if(n!==s){var o=t[s];(i.st>o.st&&i.st<o.et||o.st>i.st&&o.st<i.et)&&a.push(s)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(a,r)),e(n,i-1,a)}))}([],5,16)};var z=S;z.cipher=z.cipher||{},z.cipher.algorithms=z.cipher.algorithms||{},z.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=z.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new z.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},z.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=z.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new z.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},z.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),z.cipher.algorithms[e]=t},z.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in z.cipher.algorithms?z.cipher.algorithms[e]:null};var j=z.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};j.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=z.util.createBuffer(),this.output=e.output||z.util.createBuffer(),this.mode.start(t)},j.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},j.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))};var q=S;q.cipher=q.cipher||{};var H=q.cipher.modes=q.cipher.modes||{};function G(e,t){if("string"==typeof e&&(e=q.util.createBuffer(e)),q.util.isArray(e)&&e.length>4){var r=e;e=q.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!q.util.isArray(e)){var i=[],a=t/4;for(n=0;n<a;++n)i.push(e.getInt32());e=i}return e}function W(e){e[e.length-1]=e[e.length-1]+1&4294967295}function Q(e){return[e/4294967296|0,4294967295&e]}H.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},H.ecb.prototype.start=function(e){},H.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},H.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},H.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},H.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},H.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},H.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=G(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},H.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},H.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},H.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},H.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},H.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=q.util.createBuffer(),this._partialBytes=0},H.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=G(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},H.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32()^this._outBlock[i],t.putInt32(this._inBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},H.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32(),t.putInt32(this._inBlock[i]^this._outBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},H.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=q.util.createBuffer(),this._partialBytes=0},H.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=G(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},H.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},H.ofb.prototype.decrypt=H.ofb.prototype.encrypt,H.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=q.util.createBuffer(),this._partialBytes=0},H.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=G(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},H.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}W(this._inBlock)},H.ctr.prototype.decrypt=H.ctr.prototype.encrypt,H.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=q.util.createBuffer(),this._partialBytes=0,this._R=3774873600},H.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=q.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?q.util.createBuffer(e.additionalData):q.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=q.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var n=r.length();if(12===n)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(Q(8*n)))}this._inBlock=this._j0.slice(0),W(this._inBlock),this._partialBytes=0,t=q.util.createBuffer(t),this._aDataLength=Q(8*t.length());var i=t.length()%this.blockSize;for(i&&t.fillWithByte(0,this.blockSize-i),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},H.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^=e.getInt32());this._cipherLength+=this.blockSize}else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a<=0||r){if(r){var s=n%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),W(this._inBlock)},H.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n<this.blockSize&&!(r&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),W(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^this._hashBlock[i]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize},H.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=q.util.createBuffer();var n=this._aDataLength.concat(Q(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,n);var i=[];this.cipher.encrypt(this._j0,i);for(var a=0;a<this._ints;++a)this.tag.putInt32(this._s[a]^i[a]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},H.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),i=0;i<128;++i){e[i/32|0]&1<<31-i%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r},H.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},H.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},H.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},H.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,a=new Array(i),s=0;s<i;++s){var o=[0,0,0,0],u=(n-1-s%n)*t;o[s/n|0]=1<<t-1<<u,a[s]=this.generateSubHashTable(this.multiply(o,e),t)}return a},H.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,i=new Array(r);i[n]=e.slice(0);for(var a=n>>>1;a>0;)this.pow(i[2*a],i[a]=[]),a>>=1;for(a=2;a<n;){for(var s=1;s<a;++s){var o=i[a],u=i[s];i[a+s]=[o[0]^u[0],o[1]^u[1],o[2]^u[2],o[3]^u[3]]}a*=2}for(i[0]=[0,0,0,0],a=n+1;a<r;++a){var c=i[a^n];i[a]=[e[0]^c[0],e[1]^c[1],e[2]^c[2],e[3]^c[3]]}return i};var Y=S;function Z(e,t){Y.cipher.registerAlgorithm(e,(function(){return new Y.aes.Algorithm(e,t)}))}Y.aes=Y.aes||{},Y.aes.startEncrypting=function(e,t,r,n){var i=oe({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},Y.aes.createEncryptionCipher=function(e,t){return oe({key:e,output:null,decrypt:!1,mode:t})},Y.aes.startDecrypting=function(e,t,r,n){var i=oe({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},Y.aes.createDecryptionCipher=function(e,t){return oe({key:e,output:null,decrypt:!0,mode:t})},Y.aes.Algorithm=function(e,t){re||ie();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return se(r._w,e,t,!1)},decrypt:function(e,t){return se(r._w,e,t,!0)}}}),r._init=!1},Y.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(Y.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=Y.util.createBuffer();for(var n=0;n<t.length;++n)r.putByte(t[n])}}else r=Y.util.createBuffer(r);if(!Y.util.isArray(r)){t=r,r=[];var i=t.length();if(16===i||24===i||32===i){i>>>=2;for(n=0;n<i;++n)r.push(t.getInt32())}}if(!Y.util.isArray(r)||4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key parameter.");var a=this.mode.name,s=-1!==["CFB","OFB","CTR","GCM"].indexOf(a);this._w=ae(r,e.decrypt&&!s),this._init=!0}},Y.aes._expandKey=function(e,t){return re||ie(),ae(e,t)},Y.aes._updateBlock=se,Z("AES-ECB",Y.cipher.modes.ecb),Z("AES-CBC",Y.cipher.modes.cbc),Z("AES-CFB",Y.cipher.modes.cfb),Z("AES-OFB",Y.cipher.modes.ofb),Z("AES-CTR",Y.cipher.modes.ctr),Z("AES-GCM",Y.cipher.modes.gcm);var X,$,J,ee,te,re=!1,ne=4;function ie(){re=!0,J=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;X=new Array(256),$=new Array(256),ee=new Array(4),te=new Array(4);for(t=0;t<4;++t)ee[t]=new Array(256),te[t]=new Array(256);var r,n,i,a,s,o,u,c=0,l=0;for(t=0;t<256;++t){a=(a=l^l<<1^l<<2^l<<3^l<<4)>>8^255&a^99,X[c]=a,$[a]=c,o=(s=e[a])<<24^a<<16^a<<8^a^s,u=((r=e[c])^(n=e[r])^(i=e[n]))<<24^(c^i)<<16^(c^n^i)<<8^c^r^i;for(var h=0;h<4;++h)ee[h][c]=o,te[h][a]=u,o=o<<24|o>>>8,u=u<<24|u>>>8;0===c?c=l=1:(c=r^e[e[e[r^i]]],l^=e[e[l]])}}function ae(e,t){for(var r,n=e.slice(0),i=1,a=n.length,s=ne*(a+6+1),o=a;o<s;++o)r=n[o-1],o%a==0?(r=X[r>>>16&255]<<24^X[r>>>8&255]<<16^X[255&r]<<8^X[r>>>24]^J[i]<<24,i++):a>6&&o%a==4&&(r=X[r>>>24]<<24^X[r>>>16&255]<<16^X[r>>>8&255]<<8^X[255&r]),n[o]=n[o-a]^r;if(t){for(var u,c=te[0],l=te[1],h=te[2],f=te[3],d=n.slice(0),p=(o=0,(s=n.length)-ne);o<s;o+=ne,p-=ne)if(0===o||o===s-ne)d[o]=n[p],d[o+1]=n[p+3],d[o+2]=n[p+2],d[o+3]=n[p+1];else for(var g=0;g<ne;++g)u=n[p+g],d[o+(3&-g)]=c[X[u>>>24]]^l[X[u>>>16&255]]^h[X[u>>>8&255]]^f[X[255&u]];n=d}return n}function se(e,t,r,n){var i,a,s,o,u,c,l,h,f,d,p,g,y=e.length/4-1;n?(i=te[0],a=te[1],s=te[2],o=te[3],u=$):(i=ee[0],a=ee[1],s=ee[2],o=ee[3],u=X),c=t[0]^e[0],l=t[n?3:1]^e[1],h=t[2]^e[2],f=t[n?1:3]^e[3];for(var m=3,v=1;v<y;++v)d=i[c>>>24]^a[l>>>16&255]^s[h>>>8&255]^o[255&f]^e[++m],p=i[l>>>24]^a[h>>>16&255]^s[f>>>8&255]^o[255&c]^e[++m],g=i[h>>>24]^a[f>>>16&255]^s[c>>>8&255]^o[255&l]^e[++m],f=i[f>>>24]^a[c>>>16&255]^s[l>>>8&255]^o[255&h]^e[++m],c=d,l=p,h=g;r[0]=u[c>>>24]<<24^u[l>>>16&255]<<16^u[h>>>8&255]<<8^u[255&f]^e[++m],r[n?3:1]=u[l>>>24]<<24^u[h>>>16&255]<<16^u[f>>>8&255]<<8^u[255&c]^e[++m],r[2]=u[h>>>24]<<24^u[f>>>16&255]<<16^u[c>>>8&255]<<8^u[255&l]^e[++m],r[n?1:3]=u[f>>>24]<<24^u[c>>>16&255]<<16^u[l>>>8&255]<<8^u[255&h]^e[++m]}function oe(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?Y.cipher.createDecipher(r,e.key):Y.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof Y.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}var ue=S;ue.pki=ue.pki||{};var ce=ue.pki.oids=ue.oids=ue.oids||{};function le(e,t){ce[e]=t,ce[t]=e}function he(e,t){ce[e]=t}le("1.2.840.113549.1.1.1","rsaEncryption"),le("1.2.840.113549.1.1.4","md5WithRSAEncryption"),le("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),le("1.2.840.113549.1.1.7","RSAES-OAEP"),le("1.2.840.113549.1.1.8","mgf1"),le("1.2.840.113549.1.1.9","pSpecified"),le("1.2.840.113549.1.1.10","RSASSA-PSS"),le("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),le("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),le("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),le("1.3.101.112","EdDSA25519"),le("1.2.840.10040.4.3","dsa-with-sha1"),le("1.3.14.3.2.7","desCBC"),le("1.3.14.3.2.26","sha1"),le("2.16.840.1.101.3.4.2.1","sha256"),le("2.16.840.1.101.3.4.2.2","sha384"),le("2.16.840.1.101.3.4.2.3","sha512"),le("1.2.840.113549.2.5","md5"),le("1.2.840.113549.1.7.1","data"),le("1.2.840.113549.1.7.2","signedData"),le("1.2.840.113549.1.7.3","envelopedData"),le("1.2.840.113549.1.7.4","signedAndEnvelopedData"),le("1.2.840.113549.1.7.5","digestedData"),le("1.2.840.113549.1.7.6","encryptedData"),le("1.2.840.113549.1.9.1","emailAddress"),le("1.2.840.113549.1.9.2","unstructuredName"),le("1.2.840.113549.1.9.3","contentType"),le("1.2.840.113549.1.9.4","messageDigest"),le("1.2.840.113549.1.9.5","signingTime"),le("1.2.840.113549.1.9.6","counterSignature"),le("1.2.840.113549.1.9.7","challengePassword"),le("1.2.840.113549.1.9.8","unstructuredAddress"),le("1.2.840.113549.1.9.14","extensionRequest"),le("1.2.840.113549.1.9.20","friendlyName"),le("1.2.840.113549.1.9.21","localKeyId"),le("1.2.840.113549.1.9.22.1","x509Certificate"),le("1.2.840.113549.1.12.10.1.1","keyBag"),le("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),le("1.2.840.113549.1.12.10.1.3","certBag"),le("1.2.840.113549.1.12.10.1.4","crlBag"),le("1.2.840.113549.1.12.10.1.5","secretBag"),le("1.2.840.113549.1.12.10.1.6","safeContentsBag"),le("1.2.840.113549.1.5.13","pkcs5PBES2"),le("1.2.840.113549.1.5.12","pkcs5PBKDF2"),le("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),le("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),le("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),le("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),le("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),le("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),le("1.2.840.113549.2.7","hmacWithSHA1"),le("1.2.840.113549.2.8","hmacWithSHA224"),le("1.2.840.113549.2.9","hmacWithSHA256"),le("1.2.840.113549.2.10","hmacWithSHA384"),le("1.2.840.113549.2.11","hmacWithSHA512"),le("1.2.840.113549.3.7","des-EDE3-CBC"),le("2.16.840.1.101.3.4.1.2","aes128-CBC"),le("2.16.840.1.101.3.4.1.22","aes192-CBC"),le("2.16.840.1.101.3.4.1.42","aes256-CBC"),le("2.5.4.3","commonName"),le("2.5.4.5","serialName"),le("2.5.4.6","countryName"),le("2.5.4.7","localityName"),le("2.5.4.8","stateOrProvinceName"),le("2.5.4.9","streetAddress"),le("2.5.4.10","organizationName"),le("2.5.4.11","organizationalUnitName"),le("2.5.4.13","description"),le("2.5.4.15","businessCategory"),le("2.5.4.17","postalCode"),le("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),le("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),le("2.16.840.1.113730.1.1","nsCertType"),le("2.16.840.1.113730.1.13","nsComment"),he("2.5.29.1","authorityKeyIdentifier"),he("2.5.29.2","keyAttributes"),he("2.5.29.3","certificatePolicies"),he("2.5.29.4","keyUsageRestriction"),he("2.5.29.5","policyMapping"),he("2.5.29.6","subtreesConstraint"),he("2.5.29.7","subjectAltName"),he("2.5.29.8","issuerAltName"),he("2.5.29.9","subjectDirectoryAttributes"),he("2.5.29.10","basicConstraints"),he("2.5.29.11","nameConstraints"),he("2.5.29.12","policyConstraints"),he("2.5.29.13","basicConstraints"),le("2.5.29.14","subjectKeyIdentifier"),le("2.5.29.15","keyUsage"),he("2.5.29.16","privateKeyUsagePeriod"),le("2.5.29.17","subjectAltName"),le("2.5.29.18","issuerAltName"),le("2.5.29.19","basicConstraints"),he("2.5.29.20","cRLNumber"),he("2.5.29.21","cRLReason"),he("2.5.29.22","expirationDate"),he("2.5.29.23","instructionCode"),he("2.5.29.24","invalidityDate"),he("2.5.29.25","cRLDistributionPoints"),he("2.5.29.26","issuingDistributionPoint"),he("2.5.29.27","deltaCRLIndicator"),he("2.5.29.28","issuingDistributionPoint"),he("2.5.29.29","certificateIssuer"),he("2.5.29.30","nameConstraints"),le("2.5.29.31","cRLDistributionPoints"),le("2.5.29.32","certificatePolicies"),he("2.5.29.33","policyMappings"),he("2.5.29.34","policyConstraints"),le("2.5.29.35","authorityKeyIdentifier"),he("2.5.29.36","policyConstraints"),le("2.5.29.37","extKeyUsage"),he("2.5.29.46","freshestCRL"),he("2.5.29.54","inhibitAnyPolicy"),le("1.3.6.1.4.1.11129.2.4.2","timestampList"),le("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),le("1.3.6.1.5.5.7.3.1","serverAuth"),le("1.3.6.1.5.5.7.3.2","clientAuth"),le("1.3.6.1.5.5.7.3.3","codeSigning"),le("1.3.6.1.5.5.7.3.4","emailProtection"),le("1.3.6.1.5.5.7.3.8","timeStamping");var fe=S,de=fe.asn1=fe.asn1||{};function pe(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}de.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},de.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},de.create=function(e,t,r,n,i){if(fe.util.isArray(n)){for(var a=[],s=0;s<n.length;++s)void 0!==n[s]&&a.push(n[s]);n=a}var o={tagClass:e,type:t,constructed:r,composed:r||fe.util.isArray(n),value:n};return i&&"bitStringContents"in i&&(o.bitStringContents=i.bitStringContents,o.original=de.copy(o)),o},de.copy=function(e,t){var r;if(fe.util.isArray(e)){r=[];for(var n=0;n<e.length;++n)r.push(de.copy(e[n],t));return r}return"string"==typeof e?e:(r={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:de.copy(e.value,t)},t&&!t.excludeBitStringContents&&(r.bitStringContents=e.bitStringContents),r)},de.equals=function(e,t,r){if(fe.util.isArray(e)){if(!fe.util.isArray(t))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(!de.equals(e[n],t[n]))return!1;return!0}if(typeof e!=typeof t)return!1;if("string"==typeof e)return e===t;var i=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&de.equals(e.value,t.value);return r&&r.includeBitStringContents&&(i=i&&e.bitStringContents===t.bitStringContents),i},de.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};function ge(e,t,r,n){var i;pe(e,t,2);var a=e.getByte();t--;var s=192&a,o=31&a;i=e.length();var u,c,l=function(e,t){var r=e.getByte();if(t--,128!==r){var n;if(128&r){var i=127&r;pe(e,t,i),n=e.getInt(i<<3)}else n=r;if(n<0)throw new Error("Negative length: "+n);return n}}(e,t);if(t-=i-e.length(),void 0!==l&&l>t){if(n.strict){var h=new Error("Too few bytes to read ASN.1 value.");throw h.available=e.length(),h.remaining=t,h.requested=l,h}l=t}var f=32==(32&a);if(f)if(u=[],void 0===l)for(;;){if(pe(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}i=e.length(),u.push(ge(e,t,r+1,n)),t-=i-e.length()}else for(;l>0;)i=e.length(),u.push(ge(e,l,r+1,n)),t-=i-e.length(),l-=i-e.length();if(void 0===u&&s===de.Class.UNIVERSAL&&o===de.Type.BITSTRING&&(c=e.bytes(l)),void 0===u&&n.decodeBitStrings&&s===de.Class.UNIVERSAL&&o===de.Type.BITSTRING&&l>1){var d=e.read,p=t,g=0;if(o===de.Type.BITSTRING&&(pe(e,t,1),g=e.getByte(),t--),0===g)try{i=e.length();var y=ge(e,t,r+1,{verbose:n.verbose,strict:!0,decodeBitStrings:!0}),m=i-e.length();t-=m,o==de.Type.BITSTRING&&m++;var v=y.tagClass;m!==l||v!==de.Class.UNIVERSAL&&v!==de.Class.CONTEXT_SPECIFIC||(u=[y])}catch(e){}void 0===u&&(e.read=d,t=p)}if(void 0===u){if(void 0===l){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");l=t}if(o===de.Type.BMPSTRING)for(u="";l>0;l-=2)pe(e,t,2),u+=String.fromCharCode(e.getInt16()),t-=2;else u=e.getBytes(l)}var C=void 0===c?null:{bitStringContents:c};return de.create(s,o,f,u,C)}de.fromDer=function(e,t){return void 0===t&&(t={strict:!0,decodeBitStrings:!0}),"boolean"==typeof t&&(t={strict:t,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"==typeof e&&(e=fe.util.createBuffer(e)),ge(e,e.length(),0,t)},de.toDer=function(e){var t=fe.util.createBuffer(),r=e.tagClass|e.type,n=fe.util.createBuffer(),i=!1;if("bitStringContents"in e&&(i=!0,e.original&&(i=de.equals(e,e.original))),i)n.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:n.putByte(0);for(var a=0;a<e.value.length;++a)void 0!==e.value[a]&&n.putBuffer(de.toDer(e.value[a]))}else if(e.type===de.Type.BMPSTRING)for(a=0;a<e.value.length;++a)n.putInt16(e.value.charCodeAt(a));else e.type===de.Type.INTEGER&&e.value.length>1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?n.putBytes(e.value.substr(1)):n.putBytes(e.value);if(t.putByte(r),n.length()<=127)t.putByte(127&n.length());else{var s=n.length(),o="";do{o+=String.fromCharCode(255&s),s>>>=8}while(s>0);t.putByte(128|o.length);for(a=o.length-1;a>=0;--a)t.putByte(o.charCodeAt(a))}return t.putBuffer(n),t},de.oidToDer=function(e){var t,r,n,i,a=e.split("."),s=fe.util.createBuffer();s.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var o=2;o<a.length;++o){t=!0,r=[],n=parseInt(a[o],10);do{i=127&n,n>>>=7,t||(i|=128),r.push(i),t=!1}while(n>0);for(var u=r.length-1;u>=0;--u)s.putByte(r[u])}return s},de.derToOid=function(e){var t;"string"==typeof e&&(e=fe.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)n<<=7,128&(r=e.getByte())?n+=127&r:(t+="."+(n+r),n=0);return t},de.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),a=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var u=e.charAt(10),c=10;"+"!==u&&"-"!==u&&(o=parseInt(e.substr(10,2),10),c+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(a,s,o,0),c&&("+"===(u=e.charAt(c))||"-"===u)){var l=60*parseInt(e.substr(c+1,2),10)+parseInt(e.substr(c+4,2),10);l*=6e4,"+"===u?t.setTime(+t-l):t.setTime(+t+l)}return t},de.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),u=0,c=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var h=e.length-5,f=e.charAt(h);"+"!==f&&"-"!==f||(c=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),c*=6e4,"+"===f&&(c*=-1),l=!0);return"."===e.charAt(14)&&(u=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(a,s,o,u),t.setTime(+t+c)):(t.setFullYear(r,n,i),t.setHours(a,s,o,u)),t},de.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},de.dateToGeneralizedTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},de.integerToDer=function(e){var t=fe.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},de.derToInteger=function(e){"string"==typeof e&&(e=fe.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},de.validate=function(e,t,r,n){var i=!1;if(e.tagClass!==t.tagClass&&void 0!==t.tagClass||e.type!==t.type&&void 0!==t.type)n&&(e.tagClass!==t.tagClass&&n.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&n.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||void 0===t.constructed){if(i=!0,t.value&&fe.util.isArray(t.value))for(var a=0,s=0;i&&s<t.value.length;++s)i=t.value[s].optional||!1,e.value[a]&&((i=de.validate(e.value[a],t.value[s],r,n))?++a:t.value[s].optional&&(i=!0)),!i&&n&&n.push("["+t.name+'] Tag class "'+t.tagClass+'", type "'+t.type+'" expected value length "'+t.value.length+'", got "'+e.value.length+'"');if(i&&r&&(t.capture&&(r[t.capture]=e.value),t.captureAsn1&&(r[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(r[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)r[t.captureBitStringValue]="";else{if(0!==e.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");r[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else n&&n.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');return i};var ye=/[^\\u0000-\\u00ff]/;de.prettyPrint=function(e,t,r){var n="";r=r||2,(t=t||0)>0&&(n+="\n");for(var i="",a=0;a<t*r;++a)i+=" ";switch(n+=i+"Tag: ",e.tagClass){case de.Class.UNIVERSAL:n+="Universal:";break;case de.Class.APPLICATION:n+="Application:";break;case de.Class.CONTEXT_SPECIFIC:n+="Context-Specific:";break;case de.Class.PRIVATE:n+="Private:"}if(e.tagClass===de.Class.UNIVERSAL)switch(n+=e.type,e.type){case de.Type.NONE:n+=" (None)";break;case de.Type.BOOLEAN:n+=" (Boolean)";break;case de.Type.INTEGER:n+=" (Integer)";break;case de.Type.BITSTRING:n+=" (Bit string)";break;case de.Type.OCTETSTRING:n+=" (Octet string)";break;case de.Type.NULL:n+=" (Null)";break;case de.Type.OID:n+=" (Object Identifier)";break;case de.Type.ODESC:n+=" (Object Descriptor)";break;case de.Type.EXTERNAL:n+=" (External or Instance of)";break;case de.Type.REAL:n+=" (Real)";break;case de.Type.ENUMERATED:n+=" (Enumerated)";break;case de.Type.EMBEDDED:n+=" (Embedded PDV)";break;case de.Type.UTF8:n+=" (UTF8)";break;case de.Type.ROID:n+=" (Relative Object Identifier)";break;case de.Type.SEQUENCE:n+=" (Sequence)";break;case de.Type.SET:n+=" (Set)";break;case de.Type.PRINTABLESTRING:n+=" (Printable String)";break;case de.Type.IA5String:n+=" (IA5String (ASCII))";break;case de.Type.UTCTIME:n+=" (UTC time)";break;case de.Type.GENERALIZEDTIME:n+=" (Generalized time)";break;case de.Type.BMPSTRING:n+=" (BMP String)"}else n+=e.type;if(n+="\n",n+=i+"Constructed: "+e.constructed+"\n",e.composed){var s=0,o="";for(a=0;a<e.value.length;++a)void 0!==e.value[a]&&(s+=1,o+=de.prettyPrint(e.value[a],t+1,r),a+1<e.value.length&&(o+=","));n+=i+"Sub values: "+s+o}else{if(n+=i+"Value: ",e.type===de.Type.OID){var u=de.derToOid(e.value);n+=u,fe.pki&&fe.pki.oids&&u in fe.pki.oids&&(n+=" ("+fe.pki.oids[u]+") ")}if(e.type===de.Type.INTEGER)try{n+=de.derToInteger(e.value)}catch(t){n+="0x"+fe.util.bytesToHex(e.value)}else if(e.type===de.Type.BITSTRING){if(e.value.length>1?n+="0x"+fe.util.bytesToHex(e.value.slice(1)):n+="(none)",e.value.length>0){var c=e.value.charCodeAt(0);1==c?n+=" (1 unused bit shown)":c>1&&(n+=" ("+c+" unused bits shown)")}}else e.type===de.Type.OCTETSTRING?(ye.test(e.value)||(n+="("+e.value+") "),n+="0x"+fe.util.bytesToHex(e.value)):e.type===de.Type.UTF8?n+=fe.util.decodeUtf8(e.value):e.type===de.Type.PRINTABLESTRING||e.type===de.Type.IA5String?n+=e.value:ye.test(e.value)?n+="0x"+fe.util.bytesToHex(e.value):0===e.value.length?n+="[null]":n+=e.value}return n};var me=S,ve=me.md=me.md||{};me.md.algorithms=me.md.algorithms||{};var Ce=S;(Ce.hmac=Ce.hmac||{}).create=function(){var e=null,t=null,r=null,n=null,i={start:function(i,a){if(null!==i)if("string"==typeof i){if(!((i=i.toLowerCase())in Ce.md.algorithms))throw new Error('Unknown hash algorithm "'+i+'"');t=Ce.md.algorithms[i].create()}else t=i;if(null===a)a=e;else{if("string"==typeof a)a=Ce.util.createBuffer(a);else if(Ce.util.isArray(a)){var s=a;a=Ce.util.createBuffer();for(var o=0;o<s.length;++o)a.putByte(s[o])}var u=a.length();u>t.blockLength&&(t.start(),t.update(a.bytes()),a=t.digest()),r=Ce.util.createBuffer(),n=Ce.util.createBuffer(),u=a.length();for(o=0;o<u;++o){s=a.at(o);r.putByte(54^s),n.putByte(92^s)}if(u<t.blockLength)for(s=t.blockLength-u,o=0;o<s;++o)r.putByte(54),n.putByte(92);e=a,r=r.bytes(),n=n.bytes()}t.start(),t.update(r)},update:function(e){t.update(e)},getMac:function(){var e=t.digest().bytes();return t.start(),t.update(n),t.update(e),t.digest()}};return i.digest=i.getMac,i};var Ee=S,be=Ee.md5=Ee.md5||{};Ee.md.md5=Ee.md.algorithms.md5=be,be.create=function(){Ie||function(){Se=String.fromCharCode(128),Se+=Ee.util.fillString(String.fromCharCode(0),64),Te=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],_e=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],we=new Array(64);for(var e=0;e<64;++e)we[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));Ie=!0}();var e=null,t=Ee.util.createBuffer(),r=new Array(16),n={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var r=n.messageLengthSize/4,i=0;i<r;++i)n.fullMessageLength.push(0);return t=Ee.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},n}};return n.start(),n.update=function(i,a){"utf8"===a&&(i=Ee.util.encodeUtf8(i));var s=i.length;n.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=s[1],s[1]=s[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(i),Ae(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var i=Ee.util.createBuffer();i.putBytes(t.bytes());var a=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;i.putBytes(Se.substr(0,n.blockLength-a));for(var s,o=0,u=n.fullMessageLength.length-1;u>=0;--u)o=(s=8*n.fullMessageLength[u]+o)/4294967296>>>0,i.putInt32Le(s>>>0);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};Ae(c,r,i);var l=Ee.util.createBuffer();return l.putInt32Le(c.h0),l.putInt32Le(c.h1),l.putInt32Le(c.h2),l.putInt32Le(c.h3),l},n};var Se=null,Te=null,_e=null,we=null,Ie=!1;function Ae(e,t,r){for(var n,i,a,s,o,u,c,l=r.length();l>=64;){for(i=e.h0,a=e.h1,s=e.h2,o=e.h3,c=0;c<16;++c)t[c]=r.getInt32Le(),n=i+(o^a&(s^o))+we[c]+t[c],i=o,o=s,s=a,a+=n<<(u=_e[c])|n>>>32-u;for(;c<32;++c)n=i+(s^o&(a^s))+we[c]+t[Te[c]],i=o,o=s,s=a,a+=n<<(u=_e[c])|n>>>32-u;for(;c<48;++c)n=i+(a^s^o)+we[c]+t[Te[c]],i=o,o=s,s=a,a+=n<<(u=_e[c])|n>>>32-u;for(;c<64;++c)n=i+(s^(a|~o))+we[c]+t[Te[c]],i=o,o=s,s=a,a+=n<<(u=_e[c])|n>>>32-u;e.h0=e.h0+i|0,e.h1=e.h1+a|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,l-=64}}var Be=S,ke=Be.pem=Be.pem||{};function Ne(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i<e.values.length;++i)r.push(e.values[i].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var a=0,s=-1;for(i=0;i<t.length;++i,++a)if(a>65&&-1!==s){var o=t[s];","===o?(++s,t=t.substr(0,s)+"\r\n "+t.substr(s)):t=t.substr(0,s)+"\r\n"+o+t.substr(s+1),a=i-s-1,s=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(s=i);return t}function Re(e){return e.replace(/^\s+/,"")}ke.encode=function(e,t){t=t||{};var r,n="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(n+=Ne(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(n+=Ne(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),n+=Ne(r)),e.headers)for(var i=0;i<e.headers.length;++i)n+=Ne(e.headers[i]);return e.procType&&(n+="\r\n"),n+=Be.util.encode64(e.body,t.maxline||64)+"\r\n",n+="-----END "+e.type+"-----\r\n"},ke.decode=function(e){for(var t,r=[],n=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,i=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,a=/\r?\n/;t=n.exec(e);){var s={type:t[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:Be.util.decode64(t[3])};if(r.push(s),t[2]){for(var o=t[2].split(a),u=0;t&&u<o.length;){for(var c=o[u].replace(/\s+$/,""),l=u+1;l<o.length;++l){var h=o[l];if(!/\s/.test(h[0]))break;c+=h,u=l}if(t=c.match(i)){for(var f={name:t[1],values:[]},d=t[2].split(","),p=0;p<d.length;++p)f.values.push(Re(d[p]));if(s.procType)if(s.contentDomain||"Content-Domain"!==f.name)if(s.dekInfo||"DEK-Info"!==f.name)s.headers.push(f);else{if(0===f.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');s.dekInfo={algorithm:d[0],parameters:d[1]||null}}else s.contentDomain=d[0]||"";else{if("Proc-Type"!==f.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==f.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');s.procType={version:d[0],type:d[1]}}}++u}if("ENCRYPTED"===s.procType&&!s.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===r.length)throw new Error("Invalid PEM formatted message.");return r};var Le=S;function De(e,t){Le.cipher.registerAlgorithm(e,(function(){return new Le.des.Algorithm(e,t)}))}Le.des=Le.des||{},Le.des.startEncrypting=function(e,t,r,n){var i=je({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},Le.des.createEncryptionCipher=function(e,t){return je({key:e,output:null,decrypt:!1,mode:t})},Le.des.startDecrypting=function(e,t,r,n){var i=je({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},Le.des.createDecryptionCipher=function(e,t){return je({key:e,output:null,decrypt:!0,mode:t})},Le.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return ze(r._keys,e,t,!1)},decrypt:function(e,t){return ze(r._keys,e,t,!0)}}}),r._init=!1},Le.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=Le.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],a=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],u=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],d=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],y=e.length()>8?3:1,m=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],C=0,E=0;E<y;E++){var b=e.getInt32(),S=e.getInt32();b^=(t=252645135&(b>>>4^S))<<4,b^=t=65535&((S^=t)>>>-16^b),b^=(t=858993459&(b>>>2^(S^=t<<-16)))<<2,b^=t=65535&((S^=t)>>>-16^b),b^=(t=1431655765&(b>>>1^(S^=t<<-16)))<<1,b^=t=16711935&((S^=t)>>>8^b),t=(b^=(t=1431655765&(b>>>1^(S^=t<<8)))<<1)<<8|(S^=t)>>>20&240,b=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=t;for(var T=0;T<v.length;++T){v[T]?(b=b<<2|b>>>26,S=S<<2|S>>>26):(b=b<<1|b>>>27,S=S<<1|S>>>27),S&=-15;var _=r[(b&=-15)>>>28]|n[b>>>24&15]|i[b>>>20&15]|a[b>>>16&15]|s[b>>>12&15]|o[b>>>8&15]|u[b>>>4&15],w=c[S>>>28]|l[S>>>24&15]|h[S>>>20&15]|f[S>>>16&15]|d[S>>>12&15]|p[S>>>8&15]|g[S>>>4&15];t=65535&(w>>>16^_),m[C++]=_^t,m[C++]=w^t<<16}}return m}(t),this._init=!0}},De("DES-ECB",Le.cipher.modes.ecb),De("DES-CBC",Le.cipher.modes.cbc),De("DES-CFB",Le.cipher.modes.cfb),De("DES-OFB",Le.cipher.modes.ofb),De("DES-CTR",Le.cipher.modes.ctr),De("3DES-ECB",Le.cipher.modes.ecb),De("3DES-CBC",Le.cipher.modes.cbc),De("3DES-CFB",Le.cipher.modes.cfb),De("3DES-OFB",Le.cipher.modes.ofb),De("3DES-CTR",Le.cipher.modes.ctr);var Ue=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],xe=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],Oe=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],Pe=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],Ve=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],Ke=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],Me=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],Fe=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function ze(e,t,r,n){var i,a,s=32===e.length?3:9;i=3===s?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var o=t[0],u=t[1];o^=(a=252645135&(o>>>4^u))<<4,o^=(a=65535&(o>>>16^(u^=a)))<<16,o^=a=858993459&((u^=a)>>>2^o),o^=a=16711935&((u^=a<<2)>>>8^o),o=(o^=(a=1431655765&(o>>>1^(u^=a<<8)))<<1)<<1|o>>>31,u=(u^=a)<<1|u>>>31;for(var c=0;c<s;c+=3){for(var l=i[c+1],h=i[c+2],f=i[c];f!=l;f+=h){var d=u^e[f],p=(u>>>4|u<<28)^e[f+1];a=o,o=u,u=a^(xe[d>>>24&63]|Pe[d>>>16&63]|Ke[d>>>8&63]|Fe[63&d]|Ue[p>>>24&63]|Oe[p>>>16&63]|Ve[p>>>8&63]|Me[63&p])}a=o,o=u,u=a}u=u>>>1|u<<31,u^=a=1431655765&((o=o>>>1|o<<31)>>>1^u),u^=(a=16711935&(u>>>8^(o^=a<<1)))<<8,u^=(a=858993459&(u>>>2^(o^=a)))<<2,u^=a=65535&((o^=a)>>>16^u),u^=a=252645135&((o^=a<<16)>>>4^u),o^=a<<4,r[0]=o,r[1]=u}function je(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?Le.cipher.createDecipher(r,e.key):Le.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof Le.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}var qe,He=S,Ge=He.pkcs5=He.pkcs5||{};He.util.isNodejs&&!He.options.usePureJavaScript&&(qe=s),He.pbkdf2=Ge.pbkdf2=function(e,t,r,n,i,a){if("function"==typeof i&&(a=i,i=null),He.util.isNodejs&&!He.options.usePureJavaScript&&qe.pbkdf2&&(null===i||"object"!=typeof i)&&(qe.pbkdf2Sync.length>4||!i||"sha1"===i))return"string"!=typeof i&&(i="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),a?4===qe.pbkdf2Sync.length?qe.pbkdf2(e,t,r,n,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):qe.pbkdf2(e,t,r,n,i,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):4===qe.pbkdf2Sync.length?qe.pbkdf2Sync(e,t,r,n).toString("binary"):qe.pbkdf2Sync(e,t,r,n,i).toString("binary");if(null==i&&(i="sha1"),"string"==typeof i){if(!(i in He.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=He.md[i].create()}var s=i.digestLength;if(n>4294967295*s){var o=new Error("Derived key is too long.");if(a)return a(o);throw o}var u=Math.ceil(n/s),c=n-(u-1)*s,l=He.hmac.create();l.start(i,e);var h,f,d,p="";if(!a){for(var g=1;g<=u;++g){l.start(null,null),l.update(t),l.update(He.util.int32ToBytes(g)),h=d=l.digest().getBytes();for(var y=2;y<=r;++y)l.start(null,null),l.update(d),f=l.digest().getBytes(),h=He.util.xorBytes(h,f,s),d=f;p+=g<u?h:h.substr(0,c)}return p}g=1;function m(){if(g>u)return a(null,p);l.start(null,null),l.update(t),l.update(He.util.int32ToBytes(g)),h=d=l.digest().getBytes(),y=2,v()}function v(){if(y<=r)return l.start(null,null),l.update(d),f=l.digest().getBytes(),h=He.util.xorBytes(h,f,s),d=f,++y,He.util.setImmediate(v);p+=g<u?h:h.substr(0,c),++g,m()}m()};var We=S,Qe=We.sha256=We.sha256||{};We.md.sha256=We.md.algorithms.sha256=Qe,Qe.create=function(){Ze||(Ye=String.fromCharCode(128),Ye+=We.util.fillString(String.fromCharCode(0),64),Xe=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Ze=!0);var e=null,t=We.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var r=n.messageLengthSize/4,i=0;i<r;++i)n.fullMessageLength.push(0);return t=We.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n}};return n.start(),n.update=function(i,a){"utf8"===a&&(i=We.util.encodeUtf8(i));var s=i.length;n.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=s[1],s[1]=s[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(i),$e(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var i=We.util.createBuffer();i.putBytes(t.bytes());var a,s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;i.putBytes(Ye.substr(0,n.blockLength-s));for(var o=8*n.fullMessageLength[0],u=0;u<n.fullMessageLength.length-1;++u)o+=(a=8*n.fullMessageLength[u+1])/4294967296>>>0,i.putInt32(o>>>0),o=a>>>0;i.putInt32(o);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};$e(c,r,i);var l=We.util.createBuffer();return l.putInt32(c.h0),l.putInt32(c.h1),l.putInt32(c.h2),l.putInt32(c.h3),l.putInt32(c.h4),l.putInt32(c.h5),l.putInt32(c.h6),l.putInt32(c.h7),l},n};var Ye=null,Ze=!1,Xe=null;function $e(e,t,r){for(var n,i,a,s,o,u,c,l,h,f,d,p,g,y=r.length();y>=64;){for(o=0;o<16;++o)t[o]=r.getInt32();for(;o<64;++o)n=((n=t[o-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[o-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[o]=n+t[o-7]+i+t[o-16]|0;for(u=e.h0,c=e.h1,l=e.h2,h=e.h3,f=e.h4,d=e.h5,p=e.h6,g=e.h7,o=0;o<64;++o)a=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&c|l&(u^c),n=g+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(p^f&(d^p))+Xe[o]+t[o],g=p,p=d,d=f,f=h+n>>>0,h=l,l=c,c=u,u=n+(i=a+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+c|0,e.h2=e.h2+l|0,e.h3=e.h3+h|0,e.h4=e.h4+f|0,e.h5=e.h5+d|0,e.h6=e.h6+p|0,e.h7=e.h7+g|0,y-=64}}var Je=S,et=null;!Je.util.isNodejs||Je.options.usePureJavaScript||process.versions["node-webkit"]||(et=s),(Je.prng=Je.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,n=new Array(32),i=0;i<32;++i)n[i]=r.create();function a(){if(t.pools[0].messageLength>=32)return s();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),s()}function s(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r==0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function o(e){var t=null,r=Je.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var i=Je.util.createBuffer();if(t)for(;i.length()<e;){var a=Math.max(1,Math.min(e-i.length(),65536)/4),s=new Uint32Array(Math.floor(a));try{t(s);for(var o=0;o<s.length;++o)i.putInt32(s[o])}catch(e){if(!("undefined"!=typeof QuotaExceededError&&e instanceof QuotaExceededError))throw e}}if(i.length()<e)for(var u,c,l,h=Math.floor(65536*Math.random());i.length()<e;){c=16807*(65535&h),c+=(32767&(u=16807*(h>>16)))<<16,h=4294967295&(c=(2147483647&(c+=u>>15))+(c>>31));for(o=0;o<3;++o)l=h>>>(o<<3),l^=Math.floor(256*Math.random()),i.putByte(String.fromCharCode(255&l))}return i.getBytes(e)}return t.pools=n,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,i=t.plugin.increment,a=t.plugin.formatKey,o=t.plugin.formatSeed,u=Je.util.createBuffer();t.key=null,function c(l){if(l)return r(l);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return Je.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return s(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),s(),e()}))}(c)}));var h=n(t.key,t.seed);t.generated+=h.length,u.putBytes(h),t.key=a(n(t.key,i(t.seed))),t.seed=o(n(t.key,t.seed)),Je.util.setImmediate(c)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,i=t.plugin.formatKey,s=t.plugin.formatSeed;t.key=null;for(var o=Je.util.createBuffer();o.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,o.putBytes(u),t.key=i(r(t.key,n(t.seed))),t.seed=s(r(t.key,t.seed))}return o.getBytes(e)},et?(t.seedFile=function(e,t){et.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return et.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,o(e))}catch(e){t(e)}},t.seedFileSync=o),t.collect=function(e){for(var r=e.length,n=0;n<r;++n)t.pools[t.pool].update(e.substr(n,1)),t.pool=31===t.pool?0:t.pool+1},t.collectInt=function(e,r){for(var n="",i=0;i<r;i+=8)n+=String.fromCharCode(e>>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t};var tt=S;tt.random&&tt.random.getBytes?tt.random:function(e){var t={},r=new Array(4),n=tt.util.createBuffer();function i(){var e=tt.prng.create(t);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}t.formatKey=function(e){var t=tt.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),tt.aes._expandKey(e,!1)},t.formatSeed=function(e){var t=tt.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},t.cipher=function(e,t){return tt.aes._updateBlock(e,t,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},t.increment=function(e){return++e[3],e},t.md=tt.md.sha256;var a=i(),s=null,o=tt.util.globalScope,u=o.crypto||o.msCrypto;if(u&&u.getRandomValues&&(s=function(e){return u.getRandomValues(e)}),tt.options.usePureJavaScript||!tt.util.isNodejs&&!s){if(a.collectInt(+new Date,32),"undefined"!=typeof navigator){var c="";for(var l in navigator)try{"string"==typeof navigator[l]&&(c+=navigator[l])}catch(e){}a.collect(c),c=null}e&&(e().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),e().keypress((function(e){a.collectInt(e.charCode,8)})))}if(tt.random)for(var l in a)tt.random[l]=a[l];else tt.random=a;tt.random.createInstance=i,tt.random}("undefined"!=typeof jQuery?jQuery:null);var rt=S,nt=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],it=[1,2,3,5],at=function(e,t){return e<<t&65535|(65535&e)>>16-t},st=function(e,t){return(65535&e)>>t|e<<16-t&65535};rt.rc2=rt.rc2||{},rt.rc2.expandKey=function(e,t){"string"==typeof e&&(e=rt.util.createBuffer(e)),t=t||128;var r,n=e,i=e.length(),a=t,s=Math.ceil(a/8),o=255>>(7&a);for(r=i;r<128;r++)n.putByte(nt[n.at(r-1)+n.at(r-i)&255]);for(n.setAt(128-s,nt[n.at(128-s)&o]),r=127-s;r>=0;r--)n.setAt(r,nt[n.at(r+1)^n.at(r+s)]);return n};var ot=function(e,t,r){var n,i,a,s,o=!1,u=null,c=null,l=null,h=[];for(e=rt.rc2.expandKey(e,t),a=0;a<64;a++)h.push(e.getInt16Le());r?(n=function(e){for(a=0;a<4;a++)e[a]+=h[s]+(e[(a+3)%4]&e[(a+2)%4])+(~e[(a+3)%4]&e[(a+1)%4]),e[a]=at(e[a],it[a]),s++},i=function(e){for(a=0;a<4;a++)e[a]+=h[63&e[(a+3)%4]]}):(n=function(e){for(a=3;a>=0;a--)e[a]=st(e[a],it[a]),e[a]-=h[s]+(e[(a+3)%4]&e[(a+2)%4])+(~e[(a+3)%4]&e[(a+1)%4]),s--},i=function(e){for(a=3;a>=0;a--)e[a]-=h[63&e[(a+3)%4]]});var f=function(e){var t=[];for(a=0;a<4;a++){var n=u.getInt16Le();null!==l&&(r?n^=l.getInt16Le():l.putInt16Le(n)),t.push(65535&n)}s=r?0:63;for(var i=0;i<e.length;i++)for(var o=0;o<e[i][0];o++)e[i][1](t);for(a=0;a<4;a++)null!==l&&(r?l.putInt16Le(t[a]):t[a]^=l.getInt16Le()),c.putInt16Le(t[a])},d=null;return d={start:function(e,t){e&&"string"==typeof e&&(e=rt.util.createBuffer(e)),o=!1,u=rt.util.createBuffer(),c=t||new rt.util.createBuffer,l=e,d.output=c},update:function(e){for(o||u.putBuffer(e);u.length()>=8;)f([[5,n],[1,i],[6,n],[1,i],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,u,!r);else{var n=8===u.length()?8:8-u.length();u.fillWithByte(n,n)}if(t&&(o=!0,d.update()),!r&&(t=0===u.length()))if(e)t=e(8,c,!r);else{var i=c.length(),a=c.at(i-1);a>i?t=!1:c.truncate(a)}return t}}};rt.rc2.startEncrypting=function(e,t,r){var n=rt.rc2.createEncryptionCipher(e,128);return n.start(t,r),n},rt.rc2.createEncryptionCipher=function(e,t){return ot(e,t,!0)},rt.rc2.startDecrypting=function(e,t,r){var n=rt.rc2.createDecryptionCipher(e,128);return n.start(t,r),n},rt.rc2.createDecryptionCipher=function(e,t){return ot(e,t,!1)};var ut,ct=S;function lt(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function ht(){return new lt(null)}function ft(e,t,r,n,i,a){for(var s=16383&t,o=t>>14;--a>=0;){var u=16383&this.data[e],c=this.data[e++]>>14,l=o*u+c*s;i=((u=s*u+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+o*c,r.data[n++]=268435455&u}return i}ct.jsbn=ct.jsbn||{},ct.jsbn.BigInteger=lt,"undefined"==typeof navigator?(lt.prototype.am=ft,ut=28):"Microsoft Internet Explorer"==navigator.appName?(lt.prototype.am=function(e,t,r,n,i,a){for(var s=32767&t,o=t>>15;--a>=0;){var u=32767&this.data[e],c=this.data[e++]>>15,l=o*u+c*s;i=((u=s*u+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+o*c+(i>>>30),r.data[n++]=1073741823&u}return i},ut=30):"Netscape"!=navigator.appName?(lt.prototype.am=function(e,t,r,n,i,a){for(;--a>=0;){var s=t*this.data[e++]+r.data[n]+i;i=Math.floor(s/67108864),r.data[n++]=67108863&s}return i},ut=26):(lt.prototype.am=ft,ut=28),lt.prototype.DB=ut,lt.prototype.DM=(1<<ut)-1,lt.prototype.DV=1<<ut;lt.prototype.FV=Math.pow(2,52),lt.prototype.F1=52-ut,lt.prototype.F2=2*ut-52;var dt,pt,gt="0123456789abcdefghijklmnopqrstuvwxyz",yt=new Array;for(dt="0".charCodeAt(0),pt=0;pt<=9;++pt)yt[dt++]=pt;for(dt="a".charCodeAt(0),pt=10;pt<36;++pt)yt[dt++]=pt;for(dt="A".charCodeAt(0),pt=10;pt<36;++pt)yt[dt++]=pt;function mt(e){return gt.charAt(e)}function vt(e,t){var r=yt[e.charCodeAt(t)];return null==r?-1:r}function Ct(e){var t=ht();return t.fromInt(e),t}function Et(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function bt(e){this.m=e}function St(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function Tt(e,t){return e&t}function _t(e,t){return e|t}function wt(e,t){return e^t}function It(e,t){return e&~t}function At(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function Bt(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function kt(){}function Nt(e){return e}function Rt(e){this.r2=ht(),this.q3=ht(),lt.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}bt.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},bt.prototype.revert=function(e){return e},bt.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},bt.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},bt.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},St.prototype.convert=function(e){var t=ht();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(lt.ZERO)>0&&this.m.subTo(t,t),t},St.prototype.revert=function(e){var t=ht();return e.copyTo(t),this.reduce(t),t},St.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},St.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},St.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},lt.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},lt.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},lt.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,a=0;--n>=0;){var s=8==r?255&e[n]:vt(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==a?this.data[this.t++]=s:a+r>this.DB?(this.data[this.t-1]|=(s&(1<<this.DB-a)-1)<<a,this.data[this.t++]=s>>this.DB-a):this.data[this.t-1]|=s<<a,(a+=r)>=this.DB&&(a-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),i&<.ZERO.subTo(this,this)},lt.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},lt.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},lt.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},lt.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,a=(1<<i)-1,s=Math.floor(e/this.DB),o=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+s+1]=this.data[r]>>i|o,o=(this.data[r]&a)<<n;for(r=s-1;r>=0;--r)t.data[r]=0;t.data[s]=o,t.t=this.t+s+1,t.s=this.s,t.clamp()},lt.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,a=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var s=r+1;s<this.t;++s)t.data[s-r-1]|=(this.data[s]&a)<<i,t.data[s-r]=this.data[s]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&a)<<i),t.t=this.t-r,t.clamp()}},lt.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},lt.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i<n.t;++i)t.data[i+r.t]=r.am(0,n.data[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&<.ZERO.subTo(t,t)},lt.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},lt.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=ht());var a=ht(),s=this.s,o=e.s,u=this.DB-Et(n.data[n.t-1]);u>0?(n.lShiftTo(u,a),i.lShiftTo(u,r)):(n.copyTo(a),i.copyTo(r));var c=a.t,l=a.data[c-1];if(0!=l){var h=l*(1<<this.F1)+(c>1?a.data[c-2]>>this.F2:0),f=this.FV/h,d=(1<<this.F1)/h,p=1<<this.F2,g=r.t,y=g-c,m=null==t?ht():t;for(a.dlShiftTo(y,m),r.compareTo(m)>=0&&(r.data[r.t++]=1,r.subTo(m,r)),lt.ONE.dlShiftTo(c,m),m.subTo(a,a);a.t<c;)a.data[a.t++]=0;for(;--y>=0;){var v=r.data[--g]==l?this.DM:Math.floor(r.data[g]*f+(r.data[g-1]+p)*d);if((r.data[g]+=a.am(0,v,r,y,0,c))<v)for(a.dlShiftTo(y,m),r.subTo(m,r);r.data[g]<--v;)r.subTo(m,r)}null!=t&&(r.drShiftTo(c,t),s!=o&<.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&<.ZERO.subTo(r,r)}}},lt.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},lt.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},lt.prototype.exp=function(e,t){if(e>4294967295||e<1)return lt.ONE;var r=ht(),n=ht(),i=t.convert(this),a=Et(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<<a)>0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)},lt.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,a="",s=this.t,o=this.DB-s*this.DB%t;if(s-- >0)for(o<this.DB&&(r=this.data[s]>>o)>0&&(i=!0,a=mt(r));s>=0;)o<t?(r=(this.data[s]&(1<<o)-1)<<t-o,r|=this.data[--s]>>(o+=this.DB-t)):(r=this.data[s]>>(o-=t)&n,o<=0&&(o+=this.DB,--s)),r>0&&(i=!0),i&&(a+=mt(r));return i?a:"0"},lt.prototype.negate=function(){var e=ht();return lt.ZERO.subTo(this,e),e},lt.prototype.abs=function(){return this.s<0?this.negate():this},lt.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},lt.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+Et(this.data[this.t-1]^this.s&this.DM)},lt.prototype.mod=function(e){var t=ht();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(lt.ZERO)>0&&e.subTo(t,t),t},lt.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new bt(t):new St(t),this.exp(e,r)},lt.ZERO=Ct(0),lt.ONE=Ct(1),kt.prototype.convert=Nt,kt.prototype.revert=Nt,kt.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},kt.prototype.sqrTo=function(e,t){e.squareTo(t)},Rt.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=ht();return e.copyTo(t),this.reduce(t),t},Rt.prototype.revert=function(e){return e},Rt.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},Rt.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Rt.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var Lt=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],Dt=(1<<26)/Lt[Lt.length-1];lt.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},lt.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=Ct(r),i=ht(),a=ht(),s="";for(this.divRemTo(n,i,a);i.signum()>0;)s=(r+a.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,a);return a.intValue().toString(e)+s},lt.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,s=0,o=0;o<e.length;++o){var u=vt(e,o);u<0?"-"==e.charAt(o)&&0==this.signum()&&(i=!0):(s=t*s+u,++a>=r&&(this.dMultiply(n),this.dAddOffset(s,0),a=0,s=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),i&<.ZERO.subTo(this,this)},lt.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(lt.ONE.shiftLeft(e-1),_t,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(lt.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},lt.prototype.bitwiseTo=function(e,t,r){var n,i,a=Math.min(e.t,this.t);for(n=0;n<a;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=a;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=a;n<e.t;++n)r.data[n]=t(i,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},lt.prototype.changeBit=function(e,t){var r=lt.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},lt.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},lt.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},lt.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},lt.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i<n;++i)r.data[i+this.t]=this.am(0,e.data[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e.data[i],r,i,0,t-i);r.clamp()},lt.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},lt.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},lt.prototype.millerRabin=function(e){var t=this.subtract(lt.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),a={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},s=0;s<e;++s){do{n=new lt(this.bitLength(),a)}while(n.compareTo(lt.ONE)<=0||n.compareTo(t)>=0);var o=n.modPow(i,this);if(0!=o.compareTo(lt.ONE)&&0!=o.compareTo(t)){for(var u=1;u++<r&&0!=o.compareTo(t);)if(0==(o=o.modPowInt(2,this)).compareTo(lt.ONE))return!1;if(0!=o.compareTo(t))return!1}}return!0},lt.prototype.clone=function(){var e=ht();return this.copyTo(e),e},lt.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},lt.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},lt.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},lt.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},lt.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},lt.prototype.equals=function(e){return 0==this.compareTo(e)},lt.prototype.min=function(e){return this.compareTo(e)<0?this:e},lt.prototype.max=function(e){return this.compareTo(e)>0?this:e},lt.prototype.and=function(e){var t=ht();return this.bitwiseTo(e,Tt,t),t},lt.prototype.or=function(e){var t=ht();return this.bitwiseTo(e,_t,t),t},lt.prototype.xor=function(e){var t=ht();return this.bitwiseTo(e,wt,t),t},lt.prototype.andNot=function(e){var t=ht();return this.bitwiseTo(e,It,t),t},lt.prototype.not=function(){for(var e=ht(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},lt.prototype.shiftLeft=function(e){var t=ht();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},lt.prototype.shiftRight=function(e){var t=ht();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},lt.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+At(this.data[e]);return this.s<0?this.t*this.DB:-1},lt.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=Bt(this.data[r]^t);return e},lt.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this.data[t]&1<<e%this.DB)},lt.prototype.setBit=function(e){return this.changeBit(e,_t)},lt.prototype.clearBit=function(e){return this.changeBit(e,It)},lt.prototype.flipBit=function(e){return this.changeBit(e,wt)},lt.prototype.add=function(e){var t=ht();return this.addTo(e,t),t},lt.prototype.subtract=function(e){var t=ht();return this.subTo(e,t),t},lt.prototype.multiply=function(e){var t=ht();return this.multiplyTo(e,t),t},lt.prototype.divide=function(e){var t=ht();return this.divRemTo(e,t,null),t},lt.prototype.remainder=function(e){var t=ht();return this.divRemTo(e,null,t),t},lt.prototype.divideAndRemainder=function(e){var t=ht(),r=ht();return this.divRemTo(e,t,r),new Array(t,r)},lt.prototype.modPow=function(e,t){var r,n,i=e.bitLength(),a=Ct(1);if(i<=0)return a;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new bt(t):t.isEven()?new Rt(t):new St(t);var s=new Array,o=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=ht();for(n.sqrTo(s[1],l);o<=c;)s[o]=ht(),n.mulTo(l,s[o-2],s[o]),o+=2}var h,f,d=e.t-1,p=!0,g=ht();for(i=Et(e.data[d])-1;d>=0;){for(i>=u?h=e.data[d]>>i-u&c:(h=(e.data[d]&(1<<i+1)-1)<<u-i,d>0&&(h|=e.data[d-1]>>this.DB+i-u)),o=r;0==(1&h);)h>>=1,--o;if((i-=o)<0&&(i+=this.DB,--d),p)s[h].copyTo(a),p=!1;else{for(;o>1;)n.sqrTo(a,g),n.sqrTo(g,a),o-=2;o>0?n.sqrTo(a,g):(f=a,a=g,g=f),n.mulTo(g,s[h],a)}for(;d>=0&&0==(e.data[d]&1<<i);)n.sqrTo(a,g),f=a,a=g,g=f,--i<0&&(i=this.DB-1,--d)}return n.revert(a)},lt.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return lt.ZERO;for(var r=e.clone(),n=this.clone(),i=Ct(1),a=Ct(0),s=Ct(0),o=Ct(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&a.isEven()||(i.addTo(this,i),a.subTo(e,a)),i.rShiftTo(1,i)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(e,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),a.subTo(o,a)):(n.subTo(r,n),t&&s.subTo(i,s),o.subTo(a,o))}return 0!=n.compareTo(lt.ONE)?lt.ZERO:o.compareTo(e)>=0?o.subtract(e):o.signum()<0?(o.addTo(e,o),o.signum()<0?o.add(e):o):o},lt.prototype.pow=function(e){return this.exp(e,new kt)},lt.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),a=r.getLowestSetBit();if(a<0)return t;for(i<a&&(a=i),a>0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r},lt.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=Lt[Lt.length-1]){for(t=0;t<Lt.length;++t)if(r.data[0]==Lt[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<Lt.length;){for(var n=Lt[t],i=t+1;i<Lt.length&&n<Dt;)n*=Lt[i++];for(n=r.modInt(n);t<i;)if(n%Lt[t++]==0)return!1}return r.millerRabin(e)};var Ut=S,xt=Ut.sha1=Ut.sha1||{};Ut.md.sha1=Ut.md.algorithms.sha1=xt,xt.create=function(){Pt||(Ot=String.fromCharCode(128),Ot+=Ut.util.fillString(String.fromCharCode(0),64),Pt=!0);var e=null,t=Ut.util.createBuffer(),r=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var r=n.messageLengthSize/4,i=0;i<r;++i)n.fullMessageLength.push(0);return t=Ut.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n}};return n.start(),n.update=function(i,a){"utf8"===a&&(i=Ut.util.encodeUtf8(i));var s=i.length;n.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=s[1],s[1]=s[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(i),Vt(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var i=Ut.util.createBuffer();i.putBytes(t.bytes());var a,s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;i.putBytes(Ot.substr(0,n.blockLength-s));for(var o=8*n.fullMessageLength[0],u=0;u<n.fullMessageLength.length-1;++u)o+=(a=8*n.fullMessageLength[u+1])/4294967296>>>0,i.putInt32(o>>>0),o=a>>>0;i.putInt32(o);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};Vt(c,r,i);var l=Ut.util.createBuffer();return l.putInt32(c.h0),l.putInt32(c.h1),l.putInt32(c.h2),l.putInt32(c.h3),l.putInt32(c.h4),l},n};var Ot=null,Pt=!1;function Vt(e,t,r){for(var n,i,a,s,o,u,c,l=r.length();l>=64;){for(i=e.h0,a=e.h1,s=e.h2,o=e.h3,u=e.h4,c=0;c<16;++c)n=r.getInt32(),t[c]=n,n=(i<<5|i>>>27)+(o^a&(s^o))+u+1518500249+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<20;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(o^a&(s^o))+u+1518500249+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<32;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(a^s^o)+u+1859775393+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<40;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(a^s^o)+u+1859775393+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<60;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(a&s|o&(a^s))+u+2400959708+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;c<80;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(a^s^o)+u+3395469782+n,u=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+a|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,e.h4=e.h4+u|0,l-=64}}var Kt=S,Mt=Kt.pkcs1=Kt.pkcs1||{};function Ft(e,t,r){r||(r=Kt.md.sha1.create());for(var n="",i=Math.ceil(t/r.digestLength),a=0;a<i;++a){var s=String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a);r.start(),r.update(e+s),n+=r.digest().getBytes()}return n.substring(0,t)}Mt.encode_rsa_oaep=function(e,t,r){var n,i,a,s;"string"==typeof r?(n=r,i=arguments[3]||void 0,a=arguments[4]||void 0):r&&(n=r.label||void 0,i=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md)),a?a.start():a=Kt.md.sha1.create(),s||(s=a);var o=Math.ceil(e.n.bitLength()/8),u=o-2*a.digestLength-2;if(t.length>u)throw(p=new Error("RSAES-OAEP input message length is too long.")).length=t.length,p.maxLength=u,p;n||(n=""),a.update(n,"raw");for(var c=a.digest(),l="",h=u-t.length,f=0;f<h;f++)l+="\0";var d=c.getBytes()+l+""+t;if(i){if(i.length!==a.digestLength){var p;throw(p=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=i.length,p.digestLength=a.digestLength,p}}else i=Kt.random.getBytes(a.digestLength);var g=Ft(i,o-a.digestLength-1,s),y=Kt.util.xorBytes(d,g,d.length),m=Ft(y,a.digestLength,s);return"\0"+Kt.util.xorBytes(i,m,i.length)+y},Mt.decode_rsa_oaep=function(e,t,r){var n,i,a;"string"==typeof r?(n=r,i=arguments[3]||void 0):r&&(n=r.label||void 0,i=r.md||void 0,r.mgf1&&r.mgf1.md&&(a=r.mgf1.md));var s=Math.ceil(e.n.bitLength()/8);if(t.length!==s)throw(g=new Error("RSAES-OAEP encoded message length is invalid.")).length=t.length,g.expectedLength=s,g;if(void 0===i?i=Kt.md.sha1.create():i.start(),a||(a=i),s<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),i.update(n,"raw");for(var o=i.digest().getBytes(),u=t.charAt(0),c=t.substring(1,i.digestLength+1),l=t.substring(1+i.digestLength),h=Ft(l,i.digestLength,a),f=Ft(Kt.util.xorBytes(c,h,c.length),s-i.digestLength-1,a),d=Kt.util.xorBytes(l,f,l.length),p=d.substring(0,i.digestLength),g="\0"!==u,y=0;y<i.digestLength;++y)g|=o.charAt(y)!==p.charAt(y);for(var m=1,v=i.digestLength,C=i.digestLength;C<d.length;C++){var E=d.charCodeAt(C);g|=E&(m?65534:0),v+=m&=1&E^1}if(g||1!==d.charCodeAt(v))throw new Error("Invalid RSAES-OAEP padding.");return d.substring(v+1)};var zt=S;!function(){if(zt.prime)zt.prime;else{var e=zt.prime=zt.prime||{},t=zt.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new t(null);n.fromInt(30);var i=function(e,t){return e|t};e.generateProbablePrime=function(e,r,n){"function"==typeof r&&(n=r,r={});var i=(r=r||{}).algorithm||"PRIMEINC";"string"==typeof i&&(i={name:i}),i.options=i.options||{};var s=r.prng||zt.random,u={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===i.name)return function(e,r,n,i){if("workers"in n)return function(e,r,n,i){if("undefined"==typeof Worker)return a(e,r,n,i);var s=o(e,r),u=n.workers,c=n.workLoad||100,l=30*c/8,h=n.workerScript||"forge/prime.worker.js";if(-1===u)return zt.util.estimateCores((function(e,t){e&&(t=2),u=t-1,f()}));function f(){u=Math.max(1,u);for(var n=[],a=0;a<u;++a)n[a]=new Worker(h);for(a=0;a<u;++a)n[a].addEventListener("message",d);var f=!1;function d(a){if(!f){var u=a.data;if(u.found){for(var h=0;h<n.length;++h)n[h].terminate();return f=!0,i(null,new t(u.prime,16))}s.bitLength()>e&&(s=o(e,r));var d=s.toString(16);a.target.postMessage({hex:d,workLoad:c}),s.dAddOffset(l,0)}}}f()}(e,r,n,i);return a(e,r,n,i)}(e,u,i.options,n);throw new Error("Invalid prime generation algorithm: "+i.name)}}function a(e,t,r,n){var i=o(e,t),a=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var u=10;"maxBlockTime"in r&&(u=r.maxBlockTime),s(i,e,t,0,a,u,n)}function s(e,t,n,i,a,u,c){var l=+new Date;do{if(e.bitLength()>t&&(e=o(t,n)),e.isProbablePrime(a))return c(null,e);e.dAddOffset(r[i++%8],0)}while(u<0||+new Date-l<u);zt.util.setImmediate((function(){s(e,t,n,i,a,u,c)}))}function o(e,r){var a=new t(e,r),s=e-1;return a.testBit(s)||a.bitwiseTo(t.ONE.shiftLeft(s),i,a),a.dAddOffset(31-a.mod(n).byteValue(),0),a}}();var jt=S;if(void 0===qt)var qt=jt.jsbn.BigInteger;var Ht=jt.util.isNodejs?s:null,Gt=jt.asn1,Wt=jt.util;jt.pki=jt.pki||{},jt.pki.rsa=jt.rsa=jt.rsa||{};var Qt=jt.pki,Yt=[6,4,2,4,2,4,6,2],Zt={name:"PrivateKeyInfo",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},Xt={name:"RSAPrivateKey",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},$t={name:"RSAPublicKey",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},Jt=jt.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:Gt.Class.UNIVERSAL,type:Gt.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},er=function(e){var t;if(!(e.algorithm in Qt.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=Qt.oids[e.algorithm];var n=Gt.oidToDer(t).getBytes(),i=Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[]),a=Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[]);a.value.push(Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OID,!1,n)),a.value.push(Gt.create(Gt.Class.UNIVERSAL,Gt.Type.NULL,!1,""));var s=Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(a),i.value.push(s),Gt.toDer(i).getBytes()},tr=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var n;t.dP||(t.dP=t.d.mod(t.p.subtract(qt.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(qt.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{n=new qt(jt.util.bytesToHex(jt.random.getBytes(t.n.bitLength()/8)),16)}while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(qt.ONE));for(var i=(e=e.multiply(n.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);i.compareTo(a)<0;)i=i.add(t.p);var s=i.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return s=s.multiply(n.modInverse(t.n)).mod(t.n)};function rr(e,t,r){var n=jt.util.createBuffer(),i=Math.ceil(t.n.bitLength()/8);if(e.length>i-11){var a=new Error("Message is too long for PKCS#1 v1.5 padding.");throw a.length=e.length,a.max=i-11,a}n.putByte(0),n.putByte(r);var s,o=i-3-e.length;if(0===r||1===r){s=0===r?0:255;for(var u=0;u<o;++u)n.putByte(s)}else for(;o>0;){var c=0,l=jt.random.getBytes(o);for(u=0;u<o;++u)0===(s=l.charCodeAt(u))?++c:n.putByte(s);o=c}return n.putByte(0),n.putBytes(e),n}function nr(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8),a=jt.util.createBuffer(e),s=a.getByte(),o=a.getByte();if(0!==s||r&&0!==o&&1!==o||!r&&2!=o||r&&0===o&&void 0===n)throw new Error("Encryption block is invalid.");var u=0;if(0===o){u=i-3-n;for(var c=0;c<u;++c)if(0!==a.getByte())throw new Error("Encryption block is invalid.")}else if(1===o)for(u=0;a.length()>1;){if(255!==a.getByte()){--a.read;break}++u}else if(2===o)for(u=0;a.length()>1;){if(0===a.getByte()){--a.read;break}++u}if(0!==a.getByte()||u!==i-3-a.length())throw new Error("Encryption block is invalid.");return a.getBytes()}function ir(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=jt.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function ar(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function sr(e){return jt.util.isNodejs&&"function"==typeof Ht[e]}function or(e){return void 0!==Wt.globalScope&&"object"==typeof Wt.globalScope.crypto&&"object"==typeof Wt.globalScope.crypto.subtle&&"function"==typeof Wt.globalScope.crypto.subtle[e]}function ur(e){return void 0!==Wt.globalScope&&"object"==typeof Wt.globalScope.msCrypto&&"object"==typeof Wt.globalScope.msCrypto.subtle&&"function"==typeof Wt.globalScope.msCrypto.subtle[e]}function cr(e){for(var t=jt.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}Qt.rsa.encrypt=function(e,t,r){var n,i=r,a=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(i=2===r,n=rr(e,t,r)):(n=jt.util.createBuffer()).putBytes(e);for(var s=new qt(n.toHex(),16),o=tr(s,t,i).toString(16),u=jt.util.createBuffer(),c=a-Math.ceil(o.length/2);c>0;)u.putByte(0),--c;return u.putBytes(jt.util.hexToBytes(o)),u.getBytes()},Qt.rsa.decrypt=function(e,t,r,n){var i=Math.ceil(t.n.bitLength()/8);if(e.length!==i){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=i,a}var s=new qt(jt.util.createBuffer(e).toHex(),16);if(s.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var o=tr(s,t,r).toString(16),u=jt.util.createBuffer(),c=i-Math.ceil(o.length/2);c>0;)u.putByte(0),--c;return u.putBytes(jt.util.hexToBytes(o)),!1!==n?nr(u.getBytes(),t,r):u.getBytes()},Qt.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var n,i=(r=r||{}).prng||jt.random,a={nextBytes:function(e){for(var t=i.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},s=r.algorithm||"PRIMEINC";if("PRIMEINC"!==s)throw new Error("Invalid key generation algorithm: "+s);return(n={algorithm:s,state:0,bits:e,rng:a,eInt:t||65537,e:new qt(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},Qt.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new qt(null);r.fromInt(30);for(var n,i=0,a=function(e,t){return e|t},s=+new Date,o=0;null===e.keys&&(t<=0||o<t);){if(0===e.state){var u=null===e.p?e.pBits:e.qBits,c=u-1;0===e.pqState?(e.num=new qt(u,e.rng),e.num.testBit(c)||e.num.bitwiseTo(qt.ONE.shiftLeft(c),a,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),i=0,++e.pqState):1===e.pqState?e.num.bitLength()>u?e.pqState=0:e.num.isProbablePrime(ar(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(Yt[i++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(qt.ONE).gcd(e.e).compareTo(qt.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(qt.ONE),e.q1=e.q.subtract(qt.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(qt.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var l=e.e.modInverse(e.phi);e.keys={privateKey:Qt.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:Qt.rsa.setPublicKey(e.n,e.e)}}o+=(n=+new Date)-s,s=n}return null!==e.keys},Qt.rsa.generateKeyPair=function(e,t,r,n){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(n=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(n=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!jt.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(n){if(sr("generateKeyPair"))return Ht.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return n(e);n(null,{privateKey:Qt.privateKeyFromPem(r),publicKey:Qt.publicKeyFromPem(t)})}));if(or("generateKey")&&or("exportKey"))return Wt.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:cr(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return Wt.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){n(e)})).then((function(e){if(e){var t=Qt.privateKeyFromAsn1(Gt.fromDer(jt.util.createBuffer(e)));n(null,{privateKey:t,publicKey:Qt.setRsaPublicKey(t.n,t.e)})}}));if(ur("generateKey")&&ur("exportKey")){var i=Wt.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:cr(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return i.oncomplete=function(e){var t=e.target.result,r=Wt.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=Qt.privateKeyFromAsn1(Gt.fromDer(jt.util.createBuffer(t)));n(null,{privateKey:r,publicKey:Qt.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){n(e)}},void(i.onerror=function(e){n(e)})}}else if(sr("generateKeyPairSync")){var a=Ht.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:Qt.privateKeyFromPem(a.privateKey),publicKey:Qt.publicKeyFromPem(a.publicKey)}}var s=Qt.rsa.createKeyPairGenerationState(e,t,r);if(!n)return Qt.rsa.stepKeyPairGenerationState(s,0),s.keys;!function(e,t,r){"function"==typeof t&&(r=t,t={});t=t||{};var n={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(n.prng=t.prng);function i(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?s(t,e.q):void a(e.qBits,s))}))}function a(e,t){jt.prime.generateProbablePrime(e,n,t)}function s(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var o=e.p;e.p=e.q,e.q=o}if(0!==e.p.subtract(qt.ONE).gcd(e.e).compareTo(qt.ONE))return e.p=null,void i();if(0!==e.q.subtract(qt.ONE).gcd(e.e).compareTo(qt.ONE))return e.q=null,void a(e.qBits,s);if(e.p1=e.p.subtract(qt.ONE),e.q1=e.q.subtract(qt.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(qt.ONE))return e.p=e.q=null,void i();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,s);var u=e.e.modInverse(e.phi);e.keys={privateKey:Qt.rsa.setPrivateKey(e.n,e.e,u,e.p,e.q,u.mod(e.p1),u.mod(e.q1),e.q.modInverse(e.p)),publicKey:Qt.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}i()}(s,r,n)},Qt.setRsaPublicKey=Qt.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return rr(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return jt.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var i=t.encode(e,r,!0);return Qt.rsa.encrypt(i,r,!0)},verify:function(e,t,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=nr(t,r,!0),e===Gt.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===(t=nr(t,r,!0))}});var i=Qt.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},Qt.setRsaPrivateKey=Qt.rsa.setPrivateKey=function(e,t,r,n,i,a,s,o){var u={n:e,e:t,d:r,p:n,q:i,dP:a,dQ:s,qInv:o,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var n=Qt.rsa.decrypt(e,u,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:nr};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return jt.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,u,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:er},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,u.n.bitLength());return Qt.rsa.encrypt(n,u,r)}};return u},Qt.wrapRsaPrivateKey=function(e){return Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,Gt.integerToDer(0).getBytes()),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OID,!1,Gt.oidToDer(Qt.oids.rsaEncryption).getBytes()),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.NULL,!1,"")]),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OCTETSTRING,!1,Gt.toDer(e).getBytes())])},Qt.privateKeyFromAsn1=function(e){var t,r,n,i,a,s,o,u,c={},l=[];if(Gt.validate(e,Zt,c,l)&&(e=Gt.fromDer(jt.util.createBuffer(c.privateKey))),c={},l=[],!Gt.validate(e,Xt,c,l)){var h=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw h.errors=l,h}return t=jt.util.createBuffer(c.privateKeyModulus).toHex(),r=jt.util.createBuffer(c.privateKeyPublicExponent).toHex(),n=jt.util.createBuffer(c.privateKeyPrivateExponent).toHex(),i=jt.util.createBuffer(c.privateKeyPrime1).toHex(),a=jt.util.createBuffer(c.privateKeyPrime2).toHex(),s=jt.util.createBuffer(c.privateKeyExponent1).toHex(),o=jt.util.createBuffer(c.privateKeyExponent2).toHex(),u=jt.util.createBuffer(c.privateKeyCoefficient).toHex(),Qt.setRsaPrivateKey(new qt(t,16),new qt(r,16),new qt(n,16),new qt(i,16),new qt(a,16),new qt(s,16),new qt(o,16),new qt(u,16))},Qt.privateKeyToAsn1=Qt.privateKeyToRSAPrivateKey=function(e){return Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,Gt.integerToDer(0).getBytes()),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.n)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.e)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.d)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.p)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.q)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.dP)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.dQ)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.qInv))])},Qt.publicKeyFromAsn1=function(e){var t={},r=[];if(Gt.validate(e,Jt,t,r)){var n,i=Gt.derToOid(t.publicKeyOid);if(i!==Qt.oids.rsaEncryption)throw(n=new Error("Cannot read public key. Unknown OID.")).oid=i,n;e=t.rsaPublicKey}if(r=[],!Gt.validate(e,$t,t,r))throw(n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,n;var a=jt.util.createBuffer(t.publicKeyModulus).toHex(),s=jt.util.createBuffer(t.publicKeyExponent).toHex();return Qt.setRsaPublicKey(new qt(a,16),new qt(s,16))},Qt.publicKeyToAsn1=Qt.publicKeyToSubjectPublicKeyInfo=function(e){return Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.OID,!1,Gt.oidToDer(Qt.oids.rsaEncryption).getBytes()),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.NULL,!1,"")]),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.BITSTRING,!1,[Qt.publicKeyToRSAPublicKey(e)])])},Qt.publicKeyToRSAPublicKey=function(e){return Gt.create(Gt.Class.UNIVERSAL,Gt.Type.SEQUENCE,!0,[Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.n)),Gt.create(Gt.Class.UNIVERSAL,Gt.Type.INTEGER,!1,ir(e.e))])};var lr=S;if(void 0===hr)var hr=lr.jsbn.BigInteger;var fr=lr.asn1,dr=lr.pki=lr.pki||{};dr.pbe=lr.pbe=lr.pbe||{};var pr=dr.oids,gr={name:"EncryptedPrivateKeyInfo",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},yr={name:"PBES2Algorithms",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:fr.Class.UNIVERSAL,type:fr.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:fr.Class.UNIVERSAL,type:fr.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},mr={name:"pkcs-12PbeParams",tagClass:fr.Class.UNIVERSAL,type:fr.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:fr.Class.UNIVERSAL,type:fr.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:fr.Class.UNIVERSAL,type:fr.Type.INTEGER,constructed:!1,capture:"iterations"}]};function vr(e,t){return e.start().update(t).digest().getBytes()}function Cr(e){var t;if(e){if(!(t=dr.oids[fr.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return Er(t)}function Er(e){var t=lr.md;switch(e){case"hmacWithSHA224":t=lr.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}dr.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n,i,a,s=lr.random.getBytesSync(r.saltSize),o=r.count,u=fr.integerToDer(o);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var c,l,h;switch(r.algorithm){case"aes128":n=16,c=16,l=pr["aes128-CBC"],h=lr.aes.createEncryptionCipher;break;case"aes192":n=24,c=16,l=pr["aes192-CBC"],h=lr.aes.createEncryptionCipher;break;case"aes256":n=32,c=16,l=pr["aes256-CBC"],h=lr.aes.createEncryptionCipher;break;case"des":n=8,c=8,l=pr.desCBC,h=lr.des.createEncryptionCipher;break;default:throw(m=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,m}var f="hmacWith"+r.prfAlgorithm.toUpperCase(),d=Er(f),p=lr.pkcs5.pbkdf2(t,s,o,n,d),g=lr.random.getBytesSync(c);(v=h(p)).start(g),v.update(fr.toDer(e)),v.finish(),a=v.output.getBytes();var y=function(e,t,r,n){var i=fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OCTETSTRING,!1,e),fr.create(fr.Class.UNIVERSAL,fr.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==n&&i.value.push(fr.create(fr.Class.UNIVERSAL,fr.Type.INTEGER,!1,lr.util.hexToBytes(r.toString(16))),fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(dr.oids[n]).getBytes()),fr.create(fr.Class.UNIVERSAL,fr.Type.NULL,!1,"")]));return i}(s,u,n,f);i=fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(pr.pkcs5PBES2).getBytes()),fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(pr.pkcs5PBKDF2).getBytes()),y]),fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(l).getBytes()),fr.create(fr.Class.UNIVERSAL,fr.Type.OCTETSTRING,!1,g)])])])}else{var m;if("3des"!==r.algorithm)throw(m=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,m;n=24;var v,C=new lr.util.ByteBuffer(s);p=dr.pbe.generatePkcs12Key(t,C,1,o,n),g=dr.pbe.generatePkcs12Key(t,C,2,o,n);(v=lr.des.createEncryptionCipher(p)).start(g),v.update(fr.toDer(e)),v.finish(),a=v.output.getBytes(),i=fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OID,!1,fr.oidToDer(pr["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[fr.create(fr.Class.UNIVERSAL,fr.Type.OCTETSTRING,!1,s),fr.create(fr.Class.UNIVERSAL,fr.Type.INTEGER,!1,u.getBytes())])])}return fr.create(fr.Class.UNIVERSAL,fr.Type.SEQUENCE,!0,[i,fr.create(fr.Class.UNIVERSAL,fr.Type.OCTETSTRING,!1,a)])},dr.decryptPrivateKeyInfo=function(e,t){var r=null,n={},i=[];if(!fr.validate(e,gr,n,i)){var a=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=i,a}var s=fr.derToOid(n.encryptionOid),o=dr.pbe.getCipher(s,n.encryptionParams,t),u=lr.util.createBuffer(n.encryptedData);return o.update(u),o.finish()&&(r=fr.fromDer(o.output)),r},dr.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:fr.toDer(e).getBytes()};return lr.pem.encode(r,{maxline:t})},dr.encryptedPrivateKeyFromPem=function(e){var t=lr.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return fr.fromDer(t.body)},dr.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var n=dr.wrapRsaPrivateKey(dr.privateKeyToAsn1(e));return n=dr.encryptPrivateKeyInfo(n,t,r),dr.encryptedPrivateKeyToPem(n)}var i,a,s,o;switch(r.algorithm){case"aes128":i="AES-128-CBC",s=16,a=lr.random.getBytesSync(16),o=lr.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",s=24,a=lr.random.getBytesSync(16),o=lr.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",s=32,a=lr.random.getBytesSync(16),o=lr.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",s=24,a=lr.random.getBytesSync(8),o=lr.des.createEncryptionCipher;break;case"des":i="DES-CBC",s=8,a=lr.random.getBytesSync(8),o=lr.des.createEncryptionCipher;break;default:var u=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw u.algorithm=r.algorithm,u}var c=o(lr.pbe.opensslDeriveBytes(t,a.substr(0,8),s));c.start(a),c.update(fr.toDer(dr.privateKeyToAsn1(e))),c.finish();var l={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:lr.util.bytesToHex(a).toUpperCase()},body:c.output.getBytes()};return lr.pem.encode(l)},dr.decryptRsaPrivateKey=function(e,t){var r=null,n=lr.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw(s=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=s,s;if(n.procType&&"ENCRYPTED"===n.procType.type){var i,a;switch(n.dekInfo.algorithm){case"DES-CBC":i=8,a=lr.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,a=lr.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,a=lr.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,a=lr.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,a=lr.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,a=function(e){return lr.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":i=8,a=function(e){return lr.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":i=16,a=function(e){return lr.rc2.createDecryptionCipher(e,128)};break;default:var s;throw(s=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".')).algorithm=n.dekInfo.algorithm,s}var o=lr.util.hexToBytes(n.dekInfo.parameters),u=a(lr.pbe.opensslDeriveBytes(t,o.substr(0,8),i));if(u.start(o),u.update(lr.util.createBuffer(n.body)),!u.finish())return r;r=u.output.getBytes()}else r=n.body;return null!==(r="ENCRYPTED PRIVATE KEY"===n.type?dr.decryptPrivateKeyInfo(fr.fromDer(r),t):fr.fromDer(r))&&(r=dr.privateKeyFromAsn1(r)),r},dr.pbe.generatePkcs12Key=function(e,t,r,n,i,a){var s,o;if(null==a){if(!("sha1"in lr.md))throw new Error('"sha1" hash algorithm unavailable.');a=lr.md.sha1.create()}var u=a.digestLength,c=a.blockLength,l=new lr.util.ByteBuffer,h=new lr.util.ByteBuffer;if(null!=e){for(o=0;o<e.length;o++)h.putInt16(e.charCodeAt(o));h.putInt16(0)}var f=h.length(),d=t.length(),p=new lr.util.ByteBuffer;p.fillWithByte(r,c);var g=c*Math.ceil(d/c),y=new lr.util.ByteBuffer;for(o=0;o<g;o++)y.putByte(t.at(o%d));var m=c*Math.ceil(f/c),v=new lr.util.ByteBuffer;for(o=0;o<m;o++)v.putByte(h.at(o%f));var C=y;C.putBuffer(v);for(var E=Math.ceil(i/u),b=1;b<=E;b++){var S=new lr.util.ByteBuffer;S.putBytes(p.bytes()),S.putBytes(C.bytes());for(var T=0;T<n;T++)a.start(),a.update(S.getBytes()),S=a.digest();var _=new lr.util.ByteBuffer;for(o=0;o<c;o++)_.putByte(S.at(o%u));var w=Math.ceil(d/c)+Math.ceil(f/c),I=new lr.util.ByteBuffer;for(s=0;s<w;s++){var A=new lr.util.ByteBuffer(C.getBytes(c)),B=511;for(o=_.length()-1;o>=0;o--)B>>=8,B+=_.at(o)+A.at(o),A.setAt(o,255&B);I.putBuffer(A)}C=I,l.putBuffer(S)}return l.truncate(l.length()-i),l},dr.pbe.getCipher=function(e,t,r){switch(e){case dr.oids.pkcs5PBES2:return dr.pbe.getCipherForPBES2(e,t,r);case dr.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case dr.oids["pbewithSHAAnd40BitRC2-CBC"]:return dr.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},dr.pbe.getCipherForPBES2=function(e,t,r){var n,i={},a=[];if(!fr.validate(t,yr,i,a))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,n;if((e=fr.derToOid(i.kdfOid))!==dr.oids.pkcs5PBKDF2)throw(n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,n.supportedOids=["pkcs5PBKDF2"],n;if((e=fr.derToOid(i.encOid))!==dr.oids["aes128-CBC"]&&e!==dr.oids["aes192-CBC"]&&e!==dr.oids["aes256-CBC"]&&e!==dr.oids["des-EDE3-CBC"]&&e!==dr.oids.desCBC)throw(n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n;var s,o,u=i.kdfSalt,c=lr.util.createBuffer(i.kdfIterationCount);switch(c=c.getInt(c.length()<<3),dr.oids[e]){case"aes128-CBC":s=16,o=lr.aes.createDecryptionCipher;break;case"aes192-CBC":s=24,o=lr.aes.createDecryptionCipher;break;case"aes256-CBC":s=32,o=lr.aes.createDecryptionCipher;break;case"des-EDE3-CBC":s=24,o=lr.des.createDecryptionCipher;break;case"desCBC":s=8,o=lr.des.createDecryptionCipher}var l=Cr(i.prfOid),h=lr.pkcs5.pbkdf2(r,u,c,s,l),f=i.encIv,d=o(h);return d.start(f),d},dr.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},i=[];if(!fr.validate(t,mr,n,i))throw(l=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=i,l;var a,s,o,u=lr.util.createBuffer(n.salt),c=lr.util.createBuffer(n.iterations);switch(c=c.getInt(c.length()<<3),e){case dr.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:a=24,s=8,o=lr.des.startDecrypting;break;case dr.oids["pbewithSHAAnd40BitRC2-CBC"]:a=5,s=8,o=function(e,t){var r=lr.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var l;throw(l=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,l}var h=Cr(n.prfOid),f=dr.pbe.generatePkcs12Key(r,u,1,c,a,h);return h.start(),o(f,dr.pbe.generatePkcs12Key(r,u,2,c,s,h))},dr.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!("md5"in lr.md))throw new Error('"md5" hash algorithm unavailable.');n=lr.md.md5.create()}null===t&&(t="");for(var i=[vr(n,e+t)],a=16,s=1;a<r;++s,a+=16)i.push(vr(n,i[s-1]+e+t));return i.join("").substr(0,r)};var br=S,Sr=br.asn1,Tr=br.pkcs7asn1=br.pkcs7asn1||{};br.pkcs7=br.pkcs7||{},br.pkcs7.asn1=Tr;var _r={name:"ContentInfo",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};Tr.contentInfoValidator=_r;var wr={name:"EncryptedContentInfo",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:Sr.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};Tr.envelopedDataValidator={name:"EnvelopedData",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(wr)},Tr.encryptedDataValidator={name:"EncryptedData",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"version"}].concat(wr)};var Ir={name:"SignerInfo",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:Sr.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};Tr.signedDataValidator={name:"SignedData",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},_r,{name:"SignedData.Certificates",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:Sr.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SET,capture:"signerInfos",optional:!0,value:[Ir]}]},Tr.recipientInfoValidator={name:"RecipientInfo",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:Sr.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:Sr.Class.UNIVERSAL,type:Sr.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]};var Ar=S;Ar.mgf=Ar.mgf||{},(Ar.mgf.mgf1=Ar.mgf1=Ar.mgf1||{}).create=function(e){var t={generate:function(t,r){for(var n=new Ar.util.ByteBuffer,i=Math.ceil(r/e.digestLength),a=0;a<i;a++){var s=new Ar.util.ByteBuffer;s.putInt32(a),e.start(),e.update(t+s.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}};return t};var Br=S;Br.mgf=Br.mgf||{},Br.mgf.mgf1=Br.mgf1;var kr=S;(kr.pss=kr.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,n=e.mgf,i=r.digestLength,a=e.salt||null;if("string"==typeof a&&(a=kr.util.createBuffer(a)),"saltLength"in e)t=e.saltLength;else{if(null===a)throw new Error("Salt length not specified or specific salt not given.");t=a.length()}if(null!==a&&a.length()!==t)throw new Error("Given salt length does not match length of given salt.");var s=e.prng||kr.random,o={encode:function(e,o){var u,c,l=o-1,h=Math.ceil(l/8),f=e.digest().getBytes();if(h<i+t+2)throw new Error("Message is too long to encrypt.");c=null===a?s.getBytesSync(t):a.bytes();var d=new kr.util.ByteBuffer;d.fillWithByte(0,8),d.putBytes(f),d.putBytes(c),r.start(),r.update(d.getBytes());var p=r.digest().getBytes(),g=new kr.util.ByteBuffer;g.fillWithByte(0,h-t-i-2),g.putByte(1),g.putBytes(c);var y=g.getBytes(),m=h-i-1,v=n.generate(p,m),C="";for(u=0;u<m;u++)C+=String.fromCharCode(y.charCodeAt(u)^v.charCodeAt(u));var E=65280>>8*h-l&255;return(C=String.fromCharCode(C.charCodeAt(0)&~E)+C.substr(1))+p+String.fromCharCode(188)},verify:function(e,a,s){var o,u=s-1,c=Math.ceil(u/8);if(a=a.substr(-c),c<i+t+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==a.charCodeAt(c-1))throw new Error("Encoded message does not end in 0xBC.");var l=c-i-1,h=a.substr(0,l),f=a.substr(l,i),d=65280>>8*c-u&255;if(0!=(h.charCodeAt(0)&d))throw new Error("Bits beyond keysize not zero as expected.");var p=n.generate(f,l),g="";for(o=0;o<l;o++)g+=String.fromCharCode(h.charCodeAt(o)^p.charCodeAt(o));g=String.fromCharCode(g.charCodeAt(0)&~d)+g.substr(1);var y=c-i-t-2;for(o=0;o<y;o++)if(0!==g.charCodeAt(o))throw new Error("Leftmost octets not zero as expected");if(1!==g.charCodeAt(y))throw new Error("Inconsistent PSS signature, 0x01 marker not found");var m=g.substr(-t),v=new kr.util.ByteBuffer;return v.fillWithByte(0,8),v.putBytes(e),v.putBytes(m),r.start(),r.update(v.getBytes()),f===r.digest().getBytes()}};return o};var Nr=S,Rr=Nr.asn1,Lr=Nr.pki=Nr.pki||{},Dr=Lr.oids,Ur={};Ur.CN=Dr.commonName,Ur.commonName="CN",Ur.C=Dr.countryName,Ur.countryName="C",Ur.L=Dr.localityName,Ur.localityName="L",Ur.ST=Dr.stateOrProvinceName,Ur.stateOrProvinceName="ST",Ur.O=Dr.organizationName,Ur.organizationName="O",Ur.OU=Dr.organizationalUnitName,Ur.organizationalUnitName="OU",Ur.E=Dr.emailAddress,Ur.emailAddress="E";var xr=Nr.pki.rsa.publicKeyValidator,Or={name:"Certificate",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:Rr.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},xr,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:Rr.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},Pr={name:"rsapss",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:Rr.Class.UNIVERSAL,type:Rr.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:Rr.Class.UNIVERSAL,type:Rr.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:Rr.Class.UNIVERSAL,type:Rr.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:Rr.Class.UNIVERSAL,type:Rr.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},Vr={name:"CertificationRequestInfo",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},xr,{name:"CertificationRequestInfo.attributes",tagClass:Rr.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SET,constructed:!0}]}]}]},Kr={name:"CertificationRequest",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[Vr,{name:"CertificationRequest.signatureAlgorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:Rr.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:Rr.Class.UNIVERSAL,type:Rr.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function Mr(e,t){"string"==typeof t&&(t={shortName:t});for(var r,n=null,i=0;null===n&&i<e.attributes.length;++i)r=e.attributes[i],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(n=r);return n}Lr.RDNAttributesAsArray=function(e,t){for(var r,n,i,a=[],s=0;s<e.value.length;++s){r=e.value[s];for(var o=0;o<r.value.length;++o)i={},n=r.value[o],i.type=Rr.derToOid(n.value[0].value),i.value=n.value[1].value,i.valueTagClass=n.value[1].type,i.type in Dr&&(i.name=Dr[i.type],i.name in Ur&&(i.shortName=Ur[i.name])),t&&(t.update(i.type),t.update(i.value)),a.push(i)}return a},Lr.CRIAttributesAsArray=function(e){for(var t=[],r=0;r<e.length;++r)for(var n=e[r],i=Rr.derToOid(n.value[0].value),a=n.value[1].value,s=0;s<a.length;++s){var o={};if(o.type=i,o.value=a[s].value,o.valueTagClass=a[s].type,o.type in Dr&&(o.name=Dr[o.type],o.name in Ur&&(o.shortName=Ur[o.name])),o.type===Dr.extensionRequest){o.extensions=[];for(var u=0;u<o.value.length;++u)o.extensions.push(Lr.certificateExtensionFromAsn1(o.value[u]))}t.push(o)}return t};var Fr=function(e,t,r){var n={};if(e!==Dr["RSASSA-PSS"])return n;r&&(n={hash:{algorithmOid:Dr.sha1},mgf:{algorithmOid:Dr.mgf1,hash:{algorithmOid:Dr.sha1}},saltLength:20});var i={},a=[];if(!Rr.validate(t,Pr,i,a)){var s=new Error("Cannot read RSASSA-PSS parameter block.");throw s.errors=a,s}return void 0!==i.hashOid&&(n.hash=n.hash||{},n.hash.algorithmOid=Rr.derToOid(i.hashOid)),void 0!==i.maskGenOid&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=Rr.derToOid(i.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=Rr.derToOid(i.maskGenHashOid)),void 0!==i.saltLength&&(n.saltLength=i.saltLength.charCodeAt(0)),n};function zr(e){for(var t,r,n=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]),i=e.attributes,a=0;a<i.length;++a){var s=(t=i[a]).value,o=Rr.Type.PRINTABLESTRING;"valueTagClass"in t&&(o=t.valueTagClass)===Rr.Type.UTF8&&(s=Nr.util.encodeUtf8(s)),r=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SET,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(t.type).getBytes()),Rr.create(Rr.Class.UNIVERSAL,o,!1,s)])]),n.value.push(r)}return n}function jr(e){for(var t,r=0;r<e.length;++r){if(void 0===(t=e[r]).name&&(t.type&&t.type in Lr.oids?t.name=Lr.oids[t.type]:t.shortName&&t.shortName in Ur&&(t.name=Lr.oids[Ur[t.shortName]])),void 0===t.type){if(!t.name||!(t.name in Lr.oids))throw(i=new Error("Attribute type not specified.")).attribute=t,i;t.type=Lr.oids[t.name]}if(void 0===t.shortName&&t.name&&t.name in Ur&&(t.shortName=Ur[t.name]),t.type===Dr.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=Rr.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var n=0;n<t.extensions.length;++n)t.value.push(Lr.certificateExtensionToAsn1(qr(t.extensions[n])))}var i;if(void 0===t.value)throw(i=new Error("Attribute value not specified.")).attribute=t,i}}function qr(e,t){if(t=t||{},void 0===e.name&&e.id&&e.id in Lr.oids&&(e.name=Lr.oids[e.id]),void 0===e.id){if(!e.name||!(e.name in Lr.oids))throw(y=new Error("Extension ID not specified.")).extension=e,y;e.id=Lr.oids[e.name]}if(void 0!==e.value)return e;if("keyUsage"===e.name){var r=0,n=0,i=0;e.digitalSignature&&(n|=128,r=7),e.nonRepudiation&&(n|=64,r=6),e.keyEncipherment&&(n|=32,r=5),e.dataEncipherment&&(n|=16,r=4),e.keyAgreement&&(n|=8,r=3),e.keyCertSign&&(n|=4,r=2),e.cRLSign&&(n|=2,r=1),e.encipherOnly&&(n|=1,r=0),e.decipherOnly&&(i|=128,r=7);var a=String.fromCharCode(r);0!==i?a+=String.fromCharCode(n)+String.fromCharCode(i):0!==n&&(a+=String.fromCharCode(n)),e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,a)}else if("basicConstraints"===e.name)e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Rr.integerToDer(e.pathLenConstraint).getBytes()));else if("extKeyUsage"===e.name){e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);var s=e.value.value;for(var o in e)!0===e[o]&&(o in Dr?s.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(Dr[o]).getBytes())):-1!==o.indexOf(".")&&s.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(o).getBytes())))}else if("nsCertType"===e.name){r=0,n=0;e.client&&(n|=128,r=7),e.server&&(n|=64,r=6),e.email&&(n|=32,r=5),e.objsign&&(n|=16,r=4),e.reserved&&(n|=8,r=3),e.sslCA&&(n|=4,r=2),e.emailCA&&(n|=2,r=1),e.objCA&&(n|=1,r=0);a=String.fromCharCode(r);0!==n&&(a+=String.fromCharCode(n)),e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,a)}else if("subjectAltName"===e.name||"issuerAltName"===e.name){e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);for(var u=0;u<e.altNames.length;++u){a=(d=e.altNames[u]).value;if(7===d.type&&d.ip){if(null===(a=Nr.util.bytesFromIP(d.ip)))throw(y=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,y}else 8===d.type&&(a=d.oid?Rr.oidToDer(Rr.oidToDer(d.oid)):Rr.oidToDer(a));e.value.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,d.type,!1,a))}}else if("nsComment"===e.name&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&t.cert){var c=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=c.toHex(),e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OCTETSTRING,!1,c.getBytes())}else if("authorityKeyIdentifier"===e.name&&t.cert){e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);s=e.value.value;if(e.keyIdentifier){var l=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;s.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!1,l))}if(e.authorityCertIssuer){var h=[Rr.create(Rr.Class.CONTEXT_SPECIFIC,4,!0,[zr(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];s.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,1,!0,h))}if(e.serialNumber){var f=Nr.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);s.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,2,!1,f))}}else if("cRLDistributionPoints"===e.name){e.value=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);s=e.value.value;var d,p=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]),g=Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[]);for(u=0;u<e.altNames.length;++u){a=(d=e.altNames[u]).value;if(7===d.type&&d.ip){if(null===(a=Nr.util.bytesFromIP(d.ip)))throw(y=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,y}else 8===d.type&&(a=d.oid?Rr.oidToDer(Rr.oidToDer(d.oid)):Rr.oidToDer(a));g.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,d.type,!1,a))}p.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[g])),s.push(p)}var y;if(void 0===e.value)throw(y=new Error("Extension value not specified.")).extension=e,y;return e}function Hr(e,t){if(e===Dr["RSASSA-PSS"]){var r=[];return void 0!==t.hash.algorithmOid&&r.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(t.hash.algorithmOid).getBytes()),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.NULL,!1,"")])])),void 0!==t.mgf.algorithmOid&&r.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,1,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(t.mgf.algorithmOid).getBytes()),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(t.mgf.hash.algorithmOid).getBytes()),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.NULL,!1,"")])])])),void 0!==t.saltLength&&r.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,2,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Rr.integerToDer(t.saltLength).getBytes())])),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,r)}return Rr.create(Rr.Class.UNIVERSAL,Rr.Type.NULL,!1,"")}function Gr(e){var t=Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===e.attributes.length)return t;for(var r=e.attributes,n=0;n<r.length;++n){var i=r[n],a=i.value,s=Rr.Type.UTF8;"valueTagClass"in i&&(s=i.valueTagClass),s===Rr.Type.UTF8&&(a=Nr.util.encodeUtf8(a));var o=!1;"valueConstructed"in i&&(o=i.valueConstructed);var u=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(i.type).getBytes()),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SET,!0,[Rr.create(Rr.Class.UNIVERSAL,s,o,a)])]);t.value.push(u)}return t}Lr.certificateFromPem=function(e,t,r){var n=Nr.pem.decode(e)[0];if("CERTIFICATE"!==n.type&&"X509 CERTIFICATE"!==n.type&&"TRUSTED CERTIFICATE"!==n.type){var i=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var a=Rr.fromDer(n.body,r);return Lr.certificateFromAsn1(a,t)},Lr.certificateToPem=function(e,t){var r={type:"CERTIFICATE",body:Rr.toDer(Lr.certificateToAsn1(e)).getBytes()};return Nr.pem.encode(r,{maxline:t})},Lr.publicKeyFromPem=function(e){var t=Nr.pem.decode(e)[0];if("PUBLIC KEY"!==t.type&&"RSA PUBLIC KEY"!==t.type){var r=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert public key from PEM; PEM is encrypted.");var n=Rr.fromDer(t.body);return Lr.publicKeyFromAsn1(n)},Lr.publicKeyToPem=function(e,t){var r={type:"PUBLIC KEY",body:Rr.toDer(Lr.publicKeyToAsn1(e)).getBytes()};return Nr.pem.encode(r,{maxline:t})},Lr.publicKeyToRSAPublicKeyPem=function(e,t){var r={type:"RSA PUBLIC KEY",body:Rr.toDer(Lr.publicKeyToRSAPublicKey(e)).getBytes()};return Nr.pem.encode(r,{maxline:t})},Lr.getPublicKeyFingerprint=function(e,t){var r,n=(t=t||{}).md||Nr.md.sha1.create();switch(t.type||"RSAPublicKey"){case"RSAPublicKey":r=Rr.toDer(Lr.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":r=Rr.toDer(Lr.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+t.type+'".')}n.start(),n.update(r);var i=n.digest();if("hex"===t.encoding){var a=i.toHex();return t.delimiter?a.match(/.{2}/g).join(t.delimiter):a}if("binary"===t.encoding)return i.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return i},Lr.certificationRequestFromPem=function(e,t,r){var n=Nr.pem.decode(e)[0];if("CERTIFICATE REQUEST"!==n.type){var i=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var a=Rr.fromDer(n.body,r);return Lr.certificationRequestFromAsn1(a,t)},Lr.certificationRequestToPem=function(e,t){var r={type:"CERTIFICATE REQUEST",body:Rr.toDer(Lr.certificationRequestToAsn1(e)).getBytes()};return Nr.pem.encode(r,{maxline:t})},Lr.createCertificate=function(){var e={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return Mr(e.issuer,t)},e.issuer.addField=function(t){jr([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return Mr(e.subject,t)},e.subject.addField=function(t){jr([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,r){jr(t),e.subject.attributes=t,delete e.subject.uniqueId,r&&(e.subject.uniqueId=r),e.subject.hash=null},e.setIssuer=function(t,r){jr(t),e.issuer.attributes=t,delete e.issuer.uniqueId,r&&(e.issuer.uniqueId=r),e.issuer.hash=null},e.setExtensions=function(t){for(var r=0;r<t.length;++r)qr(t[r],{cert:e});e.extensions=t},e.getExtension=function(t){"string"==typeof t&&(t={name:t});for(var r,n=null,i=0;null===n&&i<e.extensions.length;++i)r=e.extensions[i],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(n=r);return n},e.sign=function(t,r){e.md=r||Nr.md.sha1.create();var n=Dr[e.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw i.algorithm=e.md.algorithm,i}e.signatureOid=e.siginfo.algorithmOid=n,e.tbsCertificate=Lr.getTBSCertificate(e);var a=Rr.toDer(e.tbsCertificate);e.md.update(a.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var r=!1;if(!e.issued(t)){var n=t.issuer,i=e.subject;throw(h=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.")).expectedIssuer=n.attributes,h.actualIssuer=i.attributes,h}var a=t.md;if(null===a){if(t.signatureOid in Dr)switch(Dr[t.signatureOid]){case"sha1WithRSAEncryption":a=Nr.md.sha1.create();break;case"md5WithRSAEncryption":a=Nr.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":a=Nr.md.sha256.create();break;case"sha384WithRSAEncryption":a=Nr.md.sha384.create();break;case"sha512WithRSAEncryption":a=Nr.md.sha512.create()}if(null===a)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=t.signatureOid,h;var s=t.tbsCertificate||Lr.getTBSCertificate(t),o=Rr.toDer(s);a.update(o.getBytes())}if(null!==a){var u;switch(t.signatureOid){case Dr.sha1WithRSAEncryption:u=void 0;break;case Dr["RSASSA-PSS"]:var c,l,h;if(void 0===(c=Dr[t.signatureParameters.mgf.hash.algorithmOid])||void 0===Nr.md[c])throw(h=new Error("Unsupported MGF hash function.")).oid=t.signatureParameters.mgf.hash.algorithmOid,h.name=c,h;if(void 0===(l=Dr[t.signatureParameters.mgf.algorithmOid])||void 0===Nr.mgf[l])throw(h=new Error("Unsupported MGF function.")).oid=t.signatureParameters.mgf.algorithmOid,h.name=l,h;if(l=Nr.mgf[l].create(Nr.md[c].create()),void 0===(c=Dr[t.signatureParameters.hash.algorithmOid])||void 0===Nr.md[c])throw{message:"Unsupported RSASSA-PSS hash function.",oid:t.signatureParameters.hash.algorithmOid,name:c};u=Nr.pss.create(Nr.md[c].create(),l,t.signatureParameters.saltLength)}r=e.publicKey.verify(a.digest().getBytes(),t.signature,u)}return r},e.isIssuer=function(t){var r=!1,n=e.issuer,i=t.subject;if(n.hash&&i.hash)r=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){var a,s;r=!0;for(var o=0;r&&o<n.attributes.length;++o)a=n.attributes[o],s=i.attributes[o],a.type===s.type&&a.value===s.value||(r=!1)}return r},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return Lr.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=Dr.subjectKeyIdentifier,r=0;r<e.extensions.length;++r){var n=e.extensions[r];if(n.id===t){var i=e.generateSubjectKeyIdentifier().getBytes();return Nr.util.hexToBytes(n.subjectKeyIdentifier)===i}}return!1},e},Lr.certificateFromAsn1=function(e,t){var r={},n=[];if(!Rr.validate(e,Or,r,n))throw(o=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.")).errors=n,o;if(Rr.derToOid(r.publicKeyOid)!==Lr.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=Lr.createCertificate();i.version=r.certVersion?r.certVersion.charCodeAt(0):0;var a=Nr.util.createBuffer(r.certSerialNumber);i.serialNumber=a.toHex(),i.signatureOid=Nr.asn1.derToOid(r.certSignatureOid),i.signatureParameters=Fr(i.signatureOid,r.certSignatureParams,!0),i.siginfo.algorithmOid=Nr.asn1.derToOid(r.certinfoSignatureOid),i.siginfo.parameters=Fr(i.siginfo.algorithmOid,r.certinfoSignatureParams,!1),i.signature=r.certSignature;var s=[];if(void 0!==r.certValidity1UTCTime&&s.push(Rr.utcTimeToDate(r.certValidity1UTCTime)),void 0!==r.certValidity2GeneralizedTime&&s.push(Rr.generalizedTimeToDate(r.certValidity2GeneralizedTime)),void 0!==r.certValidity3UTCTime&&s.push(Rr.utcTimeToDate(r.certValidity3UTCTime)),void 0!==r.certValidity4GeneralizedTime&&s.push(Rr.generalizedTimeToDate(r.certValidity4GeneralizedTime)),s.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(s.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(i.validity.notBefore=s[0],i.validity.notAfter=s[1],i.tbsCertificate=r.tbsCertificate,t){var o;if(i.md=null,i.signatureOid in Dr)switch(Dr[i.signatureOid]){case"sha1WithRSAEncryption":i.md=Nr.md.sha1.create();break;case"md5WithRSAEncryption":i.md=Nr.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":i.md=Nr.md.sha256.create();break;case"sha384WithRSAEncryption":i.md=Nr.md.sha384.create();break;case"sha512WithRSAEncryption":i.md=Nr.md.sha512.create()}if(null===i.md)throw(o=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=i.signatureOid,o;var u=Rr.toDer(i.tbsCertificate);i.md.update(u.getBytes())}var c=Nr.md.sha1.create();i.issuer.getField=function(e){return Mr(i.issuer,e)},i.issuer.addField=function(e){jr([e]),i.issuer.attributes.push(e)},i.issuer.attributes=Lr.RDNAttributesAsArray(r.certIssuer,c),r.certIssuerUniqueId&&(i.issuer.uniqueId=r.certIssuerUniqueId),i.issuer.hash=c.digest().toHex();var l=Nr.md.sha1.create();return i.subject.getField=function(e){return Mr(i.subject,e)},i.subject.addField=function(e){jr([e]),i.subject.attributes.push(e)},i.subject.attributes=Lr.RDNAttributesAsArray(r.certSubject,l),r.certSubjectUniqueId&&(i.subject.uniqueId=r.certSubjectUniqueId),i.subject.hash=l.digest().toHex(),r.certExtensions?i.extensions=Lr.certificateExtensionsFromAsn1(r.certExtensions):i.extensions=[],i.publicKey=Lr.publicKeyFromAsn1(r.subjectPublicKeyInfo),i},Lr.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r<e.value.length;++r)for(var n=e.value[r],i=0;i<n.value.length;++i)t.push(Lr.certificateExtensionFromAsn1(n.value[i]));return t},Lr.certificateExtensionFromAsn1=function(e){var t={};if(t.id=Rr.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===Rr.Type.BOOLEAN?(t.critical=0!==e.value[1].value.charCodeAt(0),t.value=e.value[2].value):t.value=e.value[1].value,t.id in Dr)if(t.name=Dr[t.id],"keyUsage"===t.name){var r=0,n=0;(a=Rr.fromDer(t.value)).value.length>1&&(r=a.value.charCodeAt(1),n=a.value.length>2?a.value.charCodeAt(2):0),t.digitalSignature=128==(128&r),t.nonRepudiation=64==(64&r),t.keyEncipherment=32==(32&r),t.dataEncipherment=16==(16&r),t.keyAgreement=8==(8&r),t.keyCertSign=4==(4&r),t.cRLSign=2==(2&r),t.encipherOnly=1==(1&r),t.decipherOnly=128==(128&n)}else if("basicConstraints"===t.name){(a=Rr.fromDer(t.value)).value.length>0&&a.value[0].type===Rr.Type.BOOLEAN?t.cA=0!==a.value[0].value.charCodeAt(0):t.cA=!1;var i=null;a.value.length>0&&a.value[0].type===Rr.Type.INTEGER?i=a.value[0].value:a.value.length>1&&(i=a.value[1].value),null!==i&&(t.pathLenConstraint=Rr.derToInteger(i))}else if("extKeyUsage"===t.name)for(var a=Rr.fromDer(t.value),s=0;s<a.value.length;++s){var o=Rr.derToOid(a.value[s].value);o in Dr?t[Dr[o]]=!0:t[o]=!0}else if("nsCertType"===t.name){r=0;(a=Rr.fromDer(t.value)).value.length>1&&(r=a.value.charCodeAt(1)),t.client=128==(128&r),t.server=64==(64&r),t.email=32==(32&r),t.objsign=16==(16&r),t.reserved=8==(8&r),t.sslCA=4==(4&r),t.emailCA=2==(2&r),t.objCA=1==(1&r)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){var u;t.altNames=[];a=Rr.fromDer(t.value);for(var c=0;c<a.value.length;++c){var l={type:(u=a.value[c]).type,value:u.value};switch(t.altNames.push(l),u.type){case 1:case 2:case 6:break;case 7:l.ip=Nr.util.bytesToIP(u.value);break;case 8:l.oid=Rr.derToOid(u.value)}}}else if("subjectKeyIdentifier"===t.name){a=Rr.fromDer(t.value);t.subjectKeyIdentifier=Nr.util.bytesToHex(a.value)}return t},Lr.certificationRequestFromAsn1=function(e,t){var r={},n=[];if(!Rr.validate(e,Kr,r,n))throw(a=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.")).errors=n,a;if(Rr.derToOid(r.publicKeyOid)!==Lr.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=Lr.createCertificationRequest();if(i.version=r.csrVersion?r.csrVersion.charCodeAt(0):0,i.signatureOid=Nr.asn1.derToOid(r.csrSignatureOid),i.signatureParameters=Fr(i.signatureOid,r.csrSignatureParams,!0),i.siginfo.algorithmOid=Nr.asn1.derToOid(r.csrSignatureOid),i.siginfo.parameters=Fr(i.siginfo.algorithmOid,r.csrSignatureParams,!1),i.signature=r.csrSignature,i.certificationRequestInfo=r.certificationRequestInfo,t){var a;if(i.md=null,i.signatureOid in Dr)switch(Dr[i.signatureOid]){case"sha1WithRSAEncryption":i.md=Nr.md.sha1.create();break;case"md5WithRSAEncryption":i.md=Nr.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":i.md=Nr.md.sha256.create();break;case"sha384WithRSAEncryption":i.md=Nr.md.sha384.create();break;case"sha512WithRSAEncryption":i.md=Nr.md.sha512.create()}if(null===i.md)throw(a=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=i.signatureOid,a;var s=Rr.toDer(i.certificationRequestInfo);i.md.update(s.getBytes())}var o=Nr.md.sha1.create();return i.subject.getField=function(e){return Mr(i.subject,e)},i.subject.addField=function(e){jr([e]),i.subject.attributes.push(e)},i.subject.attributes=Lr.RDNAttributesAsArray(r.certificationRequestInfoSubject,o),i.subject.hash=o.digest().toHex(),i.publicKey=Lr.publicKeyFromAsn1(r.subjectPublicKeyInfo),i.getAttribute=function(e){return Mr(i,e)},i.addAttribute=function(e){jr([e]),i.attributes.push(e)},i.attributes=Lr.CRIAttributesAsArray(r.certificationRequestInfoAttributes||[]),i},Lr.createCertificationRequest=function(){var e={version:0,signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return Mr(e.subject,t)},e.subject.addField=function(t){jr([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return Mr(e,t)},e.addAttribute=function(t){jr([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){jr(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){jr(t),e.attributes=t},e.sign=function(t,r){e.md=r||Nr.md.sha1.create();var n=Dr[e.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw i.algorithm=e.md.algorithm,i}e.signatureOid=e.siginfo.algorithmOid=n,e.certificationRequestInfo=Lr.getCertificationRequestInfo(e);var a=Rr.toDer(e.certificationRequestInfo);e.md.update(a.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,r=e.md;if(null===r){if(e.signatureOid in Dr)switch(Dr[e.signatureOid]){case"sha1WithRSAEncryption":r=Nr.md.sha1.create();break;case"md5WithRSAEncryption":r=Nr.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":r=Nr.md.sha256.create();break;case"sha384WithRSAEncryption":r=Nr.md.sha384.create();break;case"sha512WithRSAEncryption":r=Nr.md.sha512.create()}if(null===r)throw(u=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=e.signatureOid,u;var n=e.certificationRequestInfo||Lr.getCertificationRequestInfo(e),i=Rr.toDer(n);r.update(i.getBytes())}if(null!==r){var a;switch(e.signatureOid){case Dr.sha1WithRSAEncryption:break;case Dr["RSASSA-PSS"]:var s,o,u;if(void 0===(s=Dr[e.signatureParameters.mgf.hash.algorithmOid])||void 0===Nr.md[s])throw(u=new Error("Unsupported MGF hash function.")).oid=e.signatureParameters.mgf.hash.algorithmOid,u.name=s,u;if(void 0===(o=Dr[e.signatureParameters.mgf.algorithmOid])||void 0===Nr.mgf[o])throw(u=new Error("Unsupported MGF function.")).oid=e.signatureParameters.mgf.algorithmOid,u.name=o,u;if(o=Nr.mgf[o].create(Nr.md[s].create()),void 0===(s=Dr[e.signatureParameters.hash.algorithmOid])||void 0===Nr.md[s])throw(u=new Error("Unsupported RSASSA-PSS hash function.")).oid=e.signatureParameters.hash.algorithmOid,u.name=s,u;a=Nr.pss.create(Nr.md[s].create(),o,e.signatureParameters.saltLength)}t=e.publicKey.verify(r.digest().getBytes(),e.signature,a)}return t},e};var Wr=new Date("1950-01-01T00:00:00Z"),Qr=new Date("2050-01-01T00:00:00Z");function Yr(e){return e>=Wr&&e<Qr?Rr.create(Rr.Class.UNIVERSAL,Rr.Type.UTCTIME,!1,Rr.dateToUtcTime(e)):Rr.create(Rr.Class.UNIVERSAL,Rr.Type.GENERALIZEDTIME,!1,Rr.dateToGeneralizedTime(e))}Lr.getTBSCertificate=function(e){var t=Yr(e.validity.notBefore),r=Yr(e.validity.notAfter),n=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.CONTEXT_SPECIFIC,0,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Rr.integerToDer(e.version).getBytes())]),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Nr.util.hexToBytes(e.serialNumber)),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(e.siginfo.algorithmOid).getBytes()),Hr(e.siginfo.algorithmOid,e.siginfo.parameters)]),zr(e.issuer),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[t,r]),zr(e.subject),Lr.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&n.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,1,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&n.value.push(Rr.create(Rr.Class.CONTEXT_SPECIFIC,2,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&n.value.push(Lr.certificateExtensionsToAsn1(e.extensions)),n},Lr.getCertificationRequestInfo=function(e){return Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.INTEGER,!1,Rr.integerToDer(e.version).getBytes()),zr(e.subject),Lr.publicKeyToAsn1(e.publicKey),Gr(e)])},Lr.distinguishedNameToAsn1=function(e){return zr(e)},Lr.certificateToAsn1=function(e){var t=e.tbsCertificate||Lr.getTBSCertificate(e);return Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[t,Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(e.signatureOid).getBytes()),Hr(e.signatureOid,e.signatureParameters)]),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},Lr.certificateExtensionsToAsn1=function(e){var t=Rr.create(Rr.Class.CONTEXT_SPECIFIC,3,!0,[]),r=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);t.value.push(r);for(var n=0;n<e.length;++n)r.value.push(Lr.certificateExtensionToAsn1(e[n]));return t},Lr.certificateExtensionToAsn1=function(e){var t=Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[]);t.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(e.id).getBytes())),e.critical&&t.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BOOLEAN,!1,String.fromCharCode(255)));var r=e.value;return"string"!=typeof e.value&&(r=Rr.toDer(r).getBytes()),t.value.push(Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OCTETSTRING,!1,r)),t},Lr.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||Lr.getCertificationRequestInfo(e);return Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[t,Rr.create(Rr.Class.UNIVERSAL,Rr.Type.SEQUENCE,!0,[Rr.create(Rr.Class.UNIVERSAL,Rr.Type.OID,!1,Rr.oidToDer(e.signatureOid).getBytes()),Hr(e.signatureOid,e.signatureParameters)]),Rr.create(Rr.Class.UNIVERSAL,Rr.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},Lr.createCaStore=function(e){var t={certs:{}};function r(e){return n(e),t.certs[e.hash]||null}function n(e){if(!e.hash){var t=Nr.md.sha1.create();e.attributes=Lr.RDNAttributesAsArray(zr(e),t),e.hash=t.digest().toHex()}}if(t.getIssuer=function(e){return r(e.issuer)},t.addCertificate=function(e){if("string"==typeof e&&(e=Nr.pki.certificateFromPem(e)),n(e.subject),!t.hasCertificate(e))if(e.subject.hash in t.certs){var r=t.certs[e.subject.hash];Nr.util.isArray(r)||(r=[r]),r.push(e),t.certs[e.subject.hash]=r}else t.certs[e.subject.hash]=e},t.hasCertificate=function(e){"string"==typeof e&&(e=Nr.pki.certificateFromPem(e));var t=r(e.subject);if(!t)return!1;Nr.util.isArray(t)||(t=[t]);for(var n=Rr.toDer(Lr.certificateToAsn1(e)).getBytes(),i=0;i<t.length;++i){if(n===Rr.toDer(Lr.certificateToAsn1(t[i])).getBytes())return!0}return!1},t.listAllCertificates=function(){var e=[];for(var r in t.certs)if(t.certs.hasOwnProperty(r)){var n=t.certs[r];if(Nr.util.isArray(n))for(var i=0;i<n.length;++i)e.push(n[i]);else e.push(n)}return e},t.removeCertificate=function(e){var i;if("string"==typeof e&&(e=Nr.pki.certificateFromPem(e)),n(e.subject),!t.hasCertificate(e))return null;var a=r(e.subject);if(!Nr.util.isArray(a))return i=t.certs[e.subject.hash],delete t.certs[e.subject.hash],i;for(var s=Rr.toDer(Lr.certificateToAsn1(e)).getBytes(),o=0;o<a.length;++o){s===Rr.toDer(Lr.certificateToAsn1(a[o])).getBytes()&&(i=a[o],a.splice(o,1))}return 0===a.length&&delete t.certs[e.subject.hash],i},e)for(var i=0;i<e.length;++i){var a=e[i];t.addCertificate(a)}return t},Lr.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},Lr.verifyCertificateChain=function(e,t,r){"function"==typeof r&&(r={verify:r}),r=r||{};var n=(t=t.slice(0)).slice(0),i=r.validityCheckDate;void 0===i&&(i=new Date);var a=!0,s=null,o=0;do{var u=t.shift(),c=null,l=!1;if(i&&(i<u.validity.notBefore||i>u.validity.notAfter)&&(s={message:"Certificate is not valid yet or has expired.",error:Lr.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:i}),null===s){if(null===(c=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(l=!0,c=u),c){var h=c;Nr.util.isArray(h)||(h=[h]);for(var f=!1;!f&&h.length>0;){c=h.shift();try{f=c.verify(u)}catch(e){}}f||(s={message:"Certificate signature is invalid.",error:Lr.certificateError.bad_certificate})}null!==s||c&&!l||e.hasCertificate(u)||(s={message:"Certificate is not trusted.",error:Lr.certificateError.unknown_ca})}if(null===s&&c&&!u.isIssuer(c)&&(s={message:"Certificate issuer is invalid.",error:Lr.certificateError.bad_certificate}),null===s)for(var d={keyUsage:!0,basicConstraints:!0},p=0;null===s&&p<u.extensions.length;++p){var g=u.extensions[p];g.critical&&!(g.name in d)&&(s={message:"Certificate has an unsupported critical extension.",error:Lr.certificateError.unsupported_certificate})}if(null===s&&(!a||0===t.length&&(!c||l))){var y=u.getExtension("basicConstraints"),m=u.getExtension("keyUsage");if(null!==m&&(m.keyCertSign&&null!==y||(s={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:Lr.certificateError.bad_certificate})),null!==s||null===y||y.cA||(s={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:Lr.certificateError.bad_certificate}),null===s&&null!==m&&"pathLenConstraint"in y)o-1>y.pathLenConstraint&&(s={message:"Certificate basicConstraints pathLenConstraint violated.",error:Lr.certificateError.bad_certificate})}var v=null===s||s.error,C=r.verify?r.verify(v,o,n):v;if(!0!==C)throw!0===v&&(s={message:"The application rejected the certificate.",error:Lr.certificateError.bad_certificate}),(C||0===C)&&("object"!=typeof C||Nr.util.isArray(C)?"string"==typeof C&&(s.error=C):(C.message&&(s.message=C.message),C.error&&(s.error=C.error))),s;s=null,a=!1,++o}while(t.length>0);return!0};var Zr=S,Xr=Zr.asn1,$r=Zr.pki,Jr=Zr.pkcs12=Zr.pkcs12||{},en={name:"ContentInfo",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:Xr.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},tn={name:"PFX",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.INTEGER,constructed:!1,capture:"version"},en,{name:"PFX.macData",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:Xr.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},rn={name:"SafeBag",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:Xr.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},nn={name:"Attribute",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SET,constructed:!0,capture:"values"}]},an={name:"CertBag",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:Xr.Class.UNIVERSAL,type:Xr.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:Xr.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:Xr.Class.UNIVERSAL,type:Xr.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function sn(e,t,r,n){for(var i=[],a=0;a<e.length;a++)for(var s=0;s<e[a].safeBags.length;s++){var o=e[a].safeBags[s];void 0!==n&&o.type!==n||(null!==t?void 0!==o.attributes[t]&&o.attributes[t].indexOf(r)>=0&&i.push(o):i.push(o))}return i}function on(e){if(e.composed||e.constructed){for(var t=Zr.util.createBuffer(),r=0;r<e.value.length;++r)t.putBytes(e.value[r].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function un(e,t){var r={},n=[];if(!Xr.validate(e,Zr.pkcs7.asn1.encryptedDataValidator,r,n))throw(i=new Error("Cannot read EncryptedContentInfo.")).errors=n,i;var i,a=Xr.derToOid(r.contentType);if(a!==$r.oids.data)throw(i=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=a,i;a=Xr.derToOid(r.encAlgorithm);var s=$r.pbe.getCipher(a,r.encParameter,t),o=on(r.encryptedContentAsn1),u=Zr.util.createBuffer(o.value);if(s.update(u),!s.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return s.output.getBytes()}function cn(e,t,r){if(!t&&0===e.length)return[];if((e=Xr.fromDer(e,t)).tagClass!==Xr.Class.UNIVERSAL||e.type!==Xr.Type.SEQUENCE||!0!==e.constructed)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var n=[],i=0;i<e.value.length;i++){var a=e.value[i],s={},o=[];if(!Xr.validate(a,rn,s,o))throw(f=new Error("Cannot read SafeBag.")).errors=o,f;var u,c,l={type:Xr.derToOid(s.bagId),attributes:ln(s.bagAttributes)};n.push(l);var h=s.bagValue.value[0];switch(l.type){case $r.oids.pkcs8ShroudedKeyBag:if(null===(h=$r.decryptPrivateKeyInfo(h,r)))throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case $r.oids.keyBag:try{l.key=$r.privateKeyFromAsn1(h)}catch(e){l.key=null,l.asn1=h}continue;case $r.oids.certBag:u=an,c=function(){if(Xr.derToOid(s.certId)!==$r.oids.x509Certificate){var e=new Error("Unsupported certificate type, only X.509 supported.");throw e.oid=Xr.derToOid(s.certId),e}var r=Xr.fromDer(s.cert,t);try{l.cert=$r.certificateFromAsn1(r,!0)}catch(e){l.cert=null,l.asn1=r}};break;default:var f;throw(f=new Error("Unsupported PKCS#12 SafeBag type.")).oid=l.type,f}if(void 0!==u&&!Xr.validate(h,u,s,o))throw(f=new Error("Cannot read PKCS#12 "+u.name)).errors=o,f;c()}return n}function ln(e){var t={};if(void 0!==e)for(var r=0;r<e.length;++r){var n={},i=[];if(!Xr.validate(e[r],nn,n,i)){var a=new Error("Cannot read PKCS#12 BagAttribute.");throw a.errors=i,a}var s=Xr.derToOid(n.oid);if(void 0!==$r.oids[s]){t[$r.oids[s]]=[];for(var o=0;o<n.values.length;++o)t[$r.oids[s]].push(n.values[o].value)}}return t}Jr.pkcs12FromAsn1=function(e,t,r){"string"==typeof t?(r=t,t=!0):void 0===t&&(t=!0);var n={};if(!Xr.validate(e,tn,n,[]))throw(i=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.")).errors=i,i;var i,a={version:n.version.charCodeAt(0),safeContents:[],getBags:function(e){var t,r={};return"localKeyId"in e?t=e.localKeyId:"localKeyIdHex"in e&&(t=Zr.util.hexToBytes(e.localKeyIdHex)),void 0===t&&!("friendlyName"in e)&&"bagType"in e&&(r[e.bagType]=sn(a.safeContents,null,null,e.bagType)),void 0!==t&&(r.localKeyId=sn(a.safeContents,"localKeyId",t,e.bagType)),"friendlyName"in e&&(r.friendlyName=sn(a.safeContents,"friendlyName",e.friendlyName,e.bagType)),r},getBagsByFriendlyName:function(e,t){return sn(a.safeContents,"friendlyName",e,t)},getBagsByLocalKeyId:function(e,t){return sn(a.safeContents,"localKeyId",e,t)}};if(3!==n.version.charCodeAt(0))throw(i=new Error("PKCS#12 PFX of version other than 3 not supported.")).version=n.version.charCodeAt(0),i;if(Xr.derToOid(n.contentType)!==$r.oids.data)throw(i=new Error("Only PKCS#12 PFX in password integrity mode supported.")).oid=Xr.derToOid(n.contentType),i;var s=n.content.value[0];if(s.tagClass!==Xr.Class.UNIVERSAL||s.type!==Xr.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(s=on(s),n.mac){var o=null,u=0,c=Xr.derToOid(n.macAlgorithm);switch(c){case $r.oids.sha1:o=Zr.md.sha1.create(),u=20;break;case $r.oids.sha256:o=Zr.md.sha256.create(),u=32;break;case $r.oids.sha384:o=Zr.md.sha384.create(),u=48;break;case $r.oids.sha512:o=Zr.md.sha512.create(),u=64;break;case $r.oids.md5:o=Zr.md.md5.create(),u=16}if(null===o)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+c);var l=new Zr.util.ByteBuffer(n.macSalt),h="macIterations"in n?parseInt(Zr.util.bytesToHex(n.macIterations),16):1,f=Jr.generateKey(r,l,3,h,u,o),d=Zr.hmac.create();if(d.start(o,f),d.update(s.value),d.getMac().getBytes()!==n.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,t,r,n){if(t=Xr.fromDer(t,r),t.tagClass!==Xr.Class.UNIVERSAL||t.type!==Xr.Type.SEQUENCE||!0!==t.constructed)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var i=0;i<t.value.length;i++){var a=t.value[i],s={},o=[];if(!Xr.validate(a,en,s,o))throw(h=new Error("Cannot read ContentInfo.")).errors=o,h;var u={encrypted:!1},c=null,l=s.content.value[0];switch(Xr.derToOid(s.contentType)){case $r.oids.data:if(l.tagClass!==Xr.Class.UNIVERSAL||l.type!==Xr.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");c=on(l).value;break;case $r.oids.encryptedData:c=un(l,n),u.encrypted=!0;break;default:var h;throw(h=new Error("Unsupported PKCS#12 contentType.")).contentType=Xr.derToOid(s.contentType),h}u.safeBags=cn(c,r,n),e.safeContents.push(u)}}(a,s.value,t,r),a},Jr.toPkcs12Asn1=function(e,t,r,n){(n=n||{}).saltSize=n.saltSize||8,n.count=n.count||2048,n.algorithm=n.algorithm||n.encAlgorithm||"aes128","useMac"in n||(n.useMac=!0),"localKeyId"in n||(n.localKeyId=null),"generateLocalKeyId"in n||(n.generateLocalKeyId=!0);var i,a=n.localKeyId;if(null!==a)a=Zr.util.hexToBytes(a);else if(n.generateLocalKeyId)if(t){var s=Zr.util.isArray(t)?t[0]:t;"string"==typeof s&&(s=$r.certificateFromPem(s)),(T=Zr.md.sha1.create()).update(Xr.toDer($r.certificateToAsn1(s)).getBytes()),a=T.digest().getBytes()}else a=Zr.random.getBytes(20);var o=[];null!==a&&o.push(Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.localKeyId).getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SET,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,a)])])),"friendlyName"in n&&o.push(Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.friendlyName).getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SET,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.BMPSTRING,!1,n.friendlyName)])])),o.length>0&&(i=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SET,!0,o));var u=[],c=[];null!==t&&(c=Zr.util.isArray(t)?t:[t]);for(var l=[],h=0;h<c.length;++h){"string"==typeof(t=c[h])&&(t=$r.certificateFromPem(t));var f=0===h?i:void 0,d=$r.certificateToAsn1(t),p=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.certBag).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.x509Certificate).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,Xr.toDer(d).getBytes())])])]),f]);l.push(p)}if(l.length>0){var g=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,l),y=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.data).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,Xr.toDer(g).getBytes())])]);u.push(y)}var m=null;if(null!==e){var v=$r.wrapRsaPrivateKey($r.privateKeyToAsn1(e));m=null===r?Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.keyBag).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[v]),i]):Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.pkcs8ShroudedKeyBag).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[$r.encryptPrivateKeyInfo(v,r,n)]),i]);var C=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[m]),E=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.data).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,Xr.toDer(C).getBytes())])]);u.push(E)}var b,S=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,u);if(n.useMac){var T=Zr.md.sha1.create(),_=new Zr.util.ByteBuffer(Zr.random.getBytes(n.saltSize)),w=n.count,I=(e=Jr.generateKey(r,_,3,w,20),Zr.hmac.create());I.start(T,e),I.update(Xr.toDer(S).getBytes());var A=I.getMac();b=Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.sha1).getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.NULL,!1,"")]),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,A.getBytes())]),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,_.getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.INTEGER,!1,Xr.integerToDer(w).getBytes())])}return Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.INTEGER,!1,Xr.integerToDer(3).getBytes()),Xr.create(Xr.Class.UNIVERSAL,Xr.Type.SEQUENCE,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OID,!1,Xr.oidToDer($r.oids.data).getBytes()),Xr.create(Xr.Class.CONTEXT_SPECIFIC,0,!0,[Xr.create(Xr.Class.UNIVERSAL,Xr.Type.OCTETSTRING,!1,Xr.toDer(S).getBytes())])]),b])},Jr.generateKey=Zr.pbe.generatePkcs12Key;var hn=S,fn=hn.asn1,dn=hn.pki=hn.pki||{};dn.pemToDer=function(e){var t=hn.pem.decode(e)[0];if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return hn.util.createBuffer(t.body)},dn.privateKeyFromPem=function(e){var t=hn.pem.decode(e)[0];if("PRIVATE KEY"!==t.type&&"RSA PRIVATE KEY"!==t.type){var r=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var n=fn.fromDer(t.body);return dn.privateKeyFromAsn1(n)},dn.privateKeyToPem=function(e,t){var r={type:"RSA PRIVATE KEY",body:fn.toDer(dn.privateKeyToAsn1(e)).getBytes()};return hn.pem.encode(r,{maxline:t})},dn.privateKeyInfoToPem=function(e,t){var r={type:"PRIVATE KEY",body:fn.toDer(e).getBytes()};return hn.pem.encode(r,{maxline:t})};var pn=S,gn=function(e,t,r,n){var i=pn.util.createBuffer(),a=e.length>>1,s=a+(1&e.length),o=e.substr(0,s),u=e.substr(a,s),c=pn.util.createBuffer(),l=pn.hmac.create();r=t+r;var h=Math.ceil(n/16),f=Math.ceil(n/20);l.start("MD5",o);var d=pn.util.createBuffer();c.putBytes(r);for(var p=0;p<h;++p)l.start(null,null),l.update(c.getBytes()),c.putBuffer(l.digest()),l.start(null,null),l.update(c.bytes()+r),d.putBuffer(l.digest());l.start("SHA1",u);var g=pn.util.createBuffer();c.clear(),c.putBytes(r);for(p=0;p<f;++p)l.start(null,null),l.update(c.getBytes()),c.putBuffer(l.digest()),l.start(null,null),l.update(c.bytes()+r),g.putBuffer(l.digest());return i.putBytes(pn.util.xorBytes(d.getBytes(),g.getBytes(),n)),i},yn=function(e,t,r){var n=!1;try{var i=e.deflate(t.fragment.getBytes());t.fragment=pn.util.createBuffer(i),t.length=i.length,n=!0}catch(e){}return n},mn=function(e,t,r){var n=!1;try{var i=e.inflate(t.fragment.getBytes());t.fragment=pn.util.createBuffer(i),t.length=i.length,n=!0}catch(e){}return n},vn=function(e,t){var r=0;switch(t){case 1:r=e.getByte();break;case 2:r=e.getInt16();break;case 3:r=e.getInt24();break;case 4:r=e.getInt32()}return pn.util.createBuffer(e.getBytes(r))},Cn=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},En={Versions:{TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}}};En.SupportedVersions=[En.Versions.TLS_1_1,En.Versions.TLS_1_0],En.Version=En.SupportedVersions[0],En.MaxFragment=15360,En.ConnectionEnd={server:0,client:1},En.PRFAlgorithm={tls_prf_sha256:0},En.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},En.CipherType={stream:0,block:1,aead:2},En.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},En.CompressionMethod={none:0,deflate:1},En.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},En.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},En.Alert={},En.Alert.Level={warning:1,fatal:2},En.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},En.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},En.CipherSuites={},En.getCipherSuite=function(e){var t=null;for(var r in En.CipherSuites){var n=En.CipherSuites[r];if(n.id[0]===e.charCodeAt(0)&&n.id[1]===e.charCodeAt(1)){t=n;break}}return t},En.handleUnexpected=function(e,t){!e.open&&e.entity===En.ConnectionEnd.client||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.unexpected_message}})},En.handleHelloRequest=function(e,t,r){!e.handshaking&&e.handshakes>0&&(En.queue(e,En.createAlert(e,{level:En.Alert.Level.warning,description:En.Alert.Description.no_renegotiation})),En.flush(e)),e.process()},En.parseHelloMessage=function(e,t,r){var n=null,i=e.entity===En.ConnectionEnd.client;if(r<38)e.error(e,{message:i?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});else{var a=t.fragment,s=a.length();if(n={version:{major:a.getByte(),minor:a.getByte()},random:pn.util.createBuffer(a.getBytes(32)),session_id:vn(a,1),extensions:[]},i?(n.cipher_suite=a.getBytes(2),n.compression_method=a.getByte()):(n.cipher_suites=vn(a,2),n.compression_methods=vn(a,1)),(s=r-(s-a.length()))>0){for(var o=vn(a,2);o.length()>0;)n.extensions.push({type:[o.getByte(),o.getByte()],data:vn(o,2)});if(!i)for(var u=0;u<n.extensions.length;++u){var c=n.extensions[u];if(0===c.type[0]&&0===c.type[1])for(var l=vn(c.data,2);l.length()>0;){if(0!==l.getByte())break;e.session.extensions.server_name.serverNameList.push(vn(l,2).getBytes())}}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.protocol_version}});if(i)e.session.cipherSuite=En.getCipherSuite(n.cipher_suite);else for(var h=pn.util.createBuffer(n.cipher_suites.bytes());h.length()>0&&(e.session.cipherSuite=En.getCipherSuite(h.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.handshake_failure},cipherSuite:pn.util.bytesToHex(n.cipher_suite)});e.session.compressionMethod=i?n.compression_method:En.CompressionMethod.none}return n},En.createSecurityParameters=function(e,t){var r=e.entity===En.ConnectionEnd.client,n=t.random.bytes(),i=r?e.session.sp.client_random:n,a=r?n:En.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:En.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:i,server_random:a}},En.handleServerHello=function(e,t,r){var n=En.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var i=n.session_id.bytes();i.length>0&&i===e.session.id?(e.expect=wn,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=bn,e.session.resuming=!1,En.createSecurityParameters(e,n)),e.session.id=i,e.process()}},En.handleClientHello=function(e,t,r){var n=En.parseHelloMessage(e,t,r);if(!e.fail){var i=n.session_id.bytes(),a=null;if(e.sessionCache&&(null===(a=e.sessionCache.getSession(i))?i="":(a.version.major!==n.version.major||a.version.minor>n.version.minor)&&(a=null,i="")),0===i.length&&(i=pn.random.getBytes(32)),e.session.id=i,e.session.clientHelloVersion=n.version,e.session.sp={},a)e.version=e.session.version=a.version,e.session.sp=a.sp;else{for(var s,o=1;o<En.SupportedVersions.length&&!((s=En.SupportedVersions[o]).minor<=n.version.minor);++o);e.version={major:s.major,minor:s.minor},e.session.version=e.version}null!==a?(e.expect=Ln,e.session.resuming=!0,e.session.sp.client_random=n.random.bytes()):(e.expect=!1!==e.verifyClient?kn:Nn,e.session.resuming=!1,En.createSecurityParameters(e,n)),e.open=!0,En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createServerHello(e)})),e.session.resuming?(En.queue(e,En.createRecord(e,{type:En.ContentType.change_cipher_spec,data:En.createChangeCipherSpec()})),e.state.pending=En.createConnectionState(e),e.state.current.write=e.state.pending.write,En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createFinished(e)}))):(En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createCertificate(e)})),e.fail||(En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createServerKeyExchange(e)})),!1!==e.verifyClient&&En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createCertificateRequest(e)})),En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createServerHelloDone(e)})))),En.flush(e),e.process()}},En.handleCertificate=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});var n,i,a=t.fragment,s={certificate_list:vn(a,3)},o=[];try{for(;s.certificate_list.length()>0;)n=vn(s.certificate_list,3),i=pn.asn1.fromDer(n),n=pn.pki.certificateFromAsn1(i,!0),o.push(n)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.bad_certificate}})}var u=e.entity===En.ConnectionEnd.client;!u&&!0!==e.verifyClient||0!==o.length?0===o.length?e.expect=u?Sn:Nn:(u?e.session.serverCertificate=o[0]:e.session.clientCertificate=o[0],En.verifyCertificateChain(e,o)&&(e.expect=u?Sn:Nn)):e.error(e,{message:u?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}}),e.process()},En.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.unsupported_certificate}});e.expect=Tn,e.process()},En.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.unsupported_certificate}});var n=t.fragment,i={enc_pre_master_secret:vn(n,2).getBytes()},a=null;if(e.getPrivateKey)try{a=e.getPrivateKey(e,e.session.serverCertificate),a=pn.pki.privateKeyFromPem(a)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}})}if(null===a)return e.error(e,{message:"No private key set.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}});try{var s=e.session.sp;s.pre_master_secret=a.decrypt(i.enc_pre_master_secret);var o=e.session.clientHelloVersion;if(o.major!==s.pre_master_secret.charCodeAt(0)||o.minor!==s.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){s.pre_master_secret=pn.random.getBytes(48)}e.expect=Ln,null!==e.session.clientCertificate&&(e.expect=Rn),e.process()},En.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});var n=t.fragment,i={certificate_types:vn(n,1),certificate_authorities:vn(n,2)};e.session.certificateRequest=i,e.expect=_n,e.process()},En.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var a={signature:vn(n,2).getBytes()},s=pn.util.createBuffer();s.putBuffer(e.session.md5.digest()),s.putBuffer(e.session.sha1.digest()),s=s.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(s,a.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(i),e.session.sha1.update(i)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.handshake_failure}})}e.expect=Ln,e.process()},En.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.record_overflow}});if(null===e.serverCertificate){var n={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.insufficient_security}},i=e.verify(e,n.alert.description,0,[]);if(!0!==i)return(i||0===i)&&("object"!=typeof i||pn.util.isArray(i)?"number"==typeof i&&(n.alert.description=i):(i.message&&(n.message=i.message),i.alert&&(n.alert.description=i.alert))),e.error(e,n)}null!==e.session.certificateRequest&&(t=En.createRecord(e,{type:En.ContentType.handshake,data:En.createCertificate(e)}),En.queue(e,t)),t=En.createRecord(e,{type:En.ContentType.handshake,data:En.createClientKeyExchange(e)}),En.queue(e,t),e.expect=Bn;var a=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createCertificateVerify(e,t)})),En.queue(e,En.createRecord(e,{type:En.ContentType.change_cipher_spec,data:En.createChangeCipherSpec()})),e.state.pending=En.createConnectionState(e),e.state.current.write=e.state.pending.write,En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createFinished(e)})),e.expect=wn,En.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return a(e,null);En.getClientSignature(e,a)},En.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.illegal_parameter}});var r=e.entity===En.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=En.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?In:Dn,e.process()},En.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var a=t.fragment.getBytes();(n=pn.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var s=e.entity===En.ConnectionEnd.client,o=s?"server finished":"client finished",u=e.session.sp;if((n=gn(u.master_secret,o,n.getBytes(),12)).getBytes()!==a)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.decrypt_error}});e.session.md5.update(i),e.session.sha1.update(i),(e.session.resuming&&s||!e.session.resuming&&!s)&&(En.queue(e,En.createRecord(e,{type:En.ContentType.change_cipher_spec,data:En.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,En.queue(e,En.createRecord(e,{type:En.ContentType.handshake,data:En.createFinished(e)}))),e.expect=s?An:Un,e.handshaking=!1,++e.handshakes,e.peerCertificate=s?e.session.serverCertificate:e.session.clientCertificate,En.flush(e),e.isConnected=!0,e.connected(e),e.process()},En.handleAlert=function(e,t){var r,n=t.fragment,i={level:n.getByte(),description:n.getByte()};switch(i.description){case En.Alert.Description.close_notify:r="Connection closed.";break;case En.Alert.Description.unexpected_message:r="Unexpected message.";break;case En.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case En.Alert.Description.decryption_failed:r="Decryption failed.";break;case En.Alert.Description.record_overflow:r="Record overflow.";break;case En.Alert.Description.decompression_failure:r="Decompression failed.";break;case En.Alert.Description.handshake_failure:r="Handshake failure.";break;case En.Alert.Description.bad_certificate:r="Bad certificate.";break;case En.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case En.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case En.Alert.Description.certificate_expired:r="Certificate expired.";break;case En.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case En.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case En.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case En.Alert.Description.access_denied:r="Access denied.";break;case En.Alert.Description.decode_error:r="Decode error.";break;case En.Alert.Description.decrypt_error:r="Decrypt error.";break;case En.Alert.Description.export_restriction:r="Export restriction.";break;case En.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case En.Alert.Description.insufficient_security:r="Insufficient security.";break;case En.Alert.Description.internal_error:r="Internal error.";break;case En.Alert.Description.user_canceled:r="User canceled.";break;case En.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(i.description===En.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===En.ConnectionEnd.client?"server":"client",alert:i}),e.process()},En.handleHandshake=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt24();if(i>r.length())return e.fragmented=t,t.fragment=pn.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var a=r.bytes(i+4);r.read+=4,n in Yn[e.entity][e.expect]?(e.entity!==En.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:pn.md.md5.create(),sha1:pn.md.sha1.create()}),n!==En.HandshakeType.hello_request&&n!==En.HandshakeType.certificate_verify&&n!==En.HandshakeType.finished&&(e.session.md5.update(a),e.session.sha1.update(a)),Yn[e.entity][e.expect][n](e,t,i)):En.handleUnexpected(e,t)},En.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},En.handleHeartbeat=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt16(),a=r.getBytes(i);if(n===En.HeartbeatMessageType.heartbeat_request){if(e.handshaking||i>a.length)return e.process();En.queue(e,En.createRecord(e,{type:En.ContentType.heartbeat,data:En.createHeartbeat(En.HeartbeatMessageType.heartbeat_response,a)})),En.flush(e)}else if(n===En.HeartbeatMessageType.heartbeat_response){if(a!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,pn.util.createBuffer(a))}e.process()};var bn=1,Sn=2,Tn=3,_n=4,wn=5,In=6,An=7,Bn=8,kn=1,Nn=2,Rn=3,Ln=4,Dn=5,Un=6,xn=En.handleUnexpected,On=En.handleChangeCipherSpec,Pn=En.handleAlert,Vn=En.handleHandshake,Kn=En.handleApplicationData,Mn=En.handleHeartbeat,Fn=[];Fn[En.ConnectionEnd.client]=[[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[On,Pn,xn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,Kn,Mn],[xn,Pn,Vn,xn,Mn]],Fn[En.ConnectionEnd.server]=[[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,xn,Mn],[On,Pn,xn,xn,Mn],[xn,Pn,Vn,xn,Mn],[xn,Pn,Vn,Kn,Mn],[xn,Pn,Vn,xn,Mn]];var zn=En.handleHelloRequest,jn=En.handleServerHello,qn=En.handleCertificate,Hn=En.handleServerKeyExchange,Gn=En.handleCertificateRequest,Wn=En.handleServerHelloDone,Qn=En.handleFinished,Yn=[];Yn[En.ConnectionEnd.client]=[[xn,xn,jn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,qn,Hn,Gn,Wn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Hn,Gn,Wn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Gn,Wn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Wn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Qn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn]];var Zn=En.handleClientHello,Xn=En.handleClientKeyExchange,$n=En.handleCertificateVerify;Yn[En.ConnectionEnd.server]=[[xn,Zn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,qn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,$n,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,Qn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn],[xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn,xn]],En.generateKeys=function(e,t){var r=gn,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var i=2*t.mac_key_length+2*t.enc_key_length,a=e.version.major===En.Versions.TLS_1_0.major&&e.version.minor===En.Versions.TLS_1_0.minor;a&&(i+=2*t.fixed_iv_length);var s=r(t.master_secret,"key expansion",n,i),o={client_write_MAC_key:s.getBytes(t.mac_key_length),server_write_MAC_key:s.getBytes(t.mac_key_length),client_write_key:s.getBytes(t.enc_key_length),server_write_key:s.getBytes(t.enc_key_length)};return a&&(o.client_write_IV=s.getBytes(t.fixed_iv_length),o.server_write_IV=s.getBytes(t.fixed_iv_length)),o},En.createConnectionState=function(e){var t=e.entity===En.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},n={read:r(),write:r()};if(n.read.update=function(e,t){return n.read.cipherFunction(t,n.read)?n.read.compressFunction(e,t,n.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.bad_record_mac}}),!e.fail},n.write.update=function(e,t){return n.write.compressFunction(e,t,n.write)?n.write.cipherFunction(t,n.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}}),!e.fail},e.session){var i=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(i),i.keys=En.generateKeys(e,i),n.read.macKey=t?i.keys.server_write_MAC_key:i.keys.client_write_MAC_key,n.write.macKey=t?i.keys.client_write_MAC_key:i.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,i),i.compression_algorithm){case En.CompressionMethod.none:break;case En.CompressionMethod.deflate:n.read.compressFunction=mn,n.write.compressFunction=yn;break;default:throw new Error("Unsupported compression algorithm.")}}return n},En.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=pn.util.createBuffer();return r.putInt32(t),r.putBytes(pn.random.getBytes(28)),r},En.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},En.createAlert=function(e,t){var r=pn.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),En.createRecord(e,{type:En.ContentType.alert,data:r})},En.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=pn.util.createBuffer(),r=0;r<e.cipherSuites.length;++r){var n=e.cipherSuites[r];t.putByte(n.id[0]),t.putByte(n.id[1])}var i=t.length(),a=pn.util.createBuffer();a.putByte(En.CompressionMethod.none);var s=a.length(),o=pn.util.createBuffer();if(e.virtualHost){var u=pn.util.createBuffer();u.putByte(0),u.putByte(0);var c=pn.util.createBuffer();c.putByte(0),Cn(c,2,pn.util.createBuffer(e.virtualHost));var l=pn.util.createBuffer();Cn(l,2,c),Cn(u,2,l),o.putBuffer(u)}var h=o.length();h>0&&(h+=2);var f=e.session.id,d=f.length+1+2+4+28+2+i+1+s+h,p=pn.util.createBuffer();return p.putByte(En.HandshakeType.client_hello),p.putInt24(d),p.putByte(e.version.major),p.putByte(e.version.minor),p.putBytes(e.session.sp.client_random),Cn(p,1,pn.util.createBuffer(f)),Cn(p,2,t),Cn(p,1,a),h>0&&Cn(p,2,o),p},En.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,n=pn.util.createBuffer();return n.putByte(En.HandshakeType.server_hello),n.putInt24(r),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),Cn(n,1,pn.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n},En.createCertificate=function(e){var t,r=e.entity===En.ConnectionEnd.client,n=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,n=e.getCertificate(e,t));var i=pn.util.createBuffer();if(null!==n)try{pn.util.isArray(n)||(n=[n]);for(var a=null,s=0;s<n.length;++s){var o=pn.pem.decode(n[s])[0];if("CERTIFICATE"!==o.type&&"X509 CERTIFICATE"!==o.type&&"TRUSTED CERTIFICATE"!==o.type){var u=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw u.headerType=o.type,u}if(o.procType&&"ENCRYPTED"===o.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var c=pn.util.createBuffer(o.body);null===a&&(a=pn.asn1.fromDer(c.bytes(),!1));var l=pn.util.createBuffer();Cn(l,3,c),i.putBuffer(l)}n=pn.pki.certificateFromAsn1(a),r?e.session.clientCertificate=n:e.session.serverCertificate=n}catch(t){return e.error(e,{message:"Could not send certificate list.",cause:t,send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.bad_certificate}})}var h=3+i.length(),f=pn.util.createBuffer();return f.putByte(En.HandshakeType.certificate),f.putInt24(h),Cn(f,3,i),f},En.createClientKeyExchange=function(e){var t=pn.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(pn.random.getBytes(46));var r=e.session.sp;r.pre_master_secret=t.getBytes();var n=(t=e.session.serverCertificate.publicKey.encrypt(r.pre_master_secret)).length+2,i=pn.util.createBuffer();return i.putByte(En.HandshakeType.client_key_exchange),i.putInt24(n),i.putInt16(t.length),i.putBytes(t),i},En.createServerKeyExchange=function(e){return pn.util.createBuffer()},En.getClientSignature=function(e,t){var r=pn.util.createBuffer();r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest()),r=r.getBytes(),e.getSignature=e.getSignature||function(e,t,r){var n=null;if(e.getPrivateKey)try{n=e.getPrivateKey(e,e.session.clientCertificate),n=pn.pki.privateKeyFromPem(n)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}})}null===n?e.error(e,{message:"No private key set.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.internal_error}}):t=n.sign(t,null),r(e,t)},e.getSignature(e,r,t)},En.createCertificateVerify=function(e,t){var r=t.length+2,n=pn.util.createBuffer();return n.putByte(En.HandshakeType.certificate_verify),n.putInt24(r),n.putInt16(t.length),n.putBytes(t),n},En.createCertificateRequest=function(e){var t=pn.util.createBuffer();t.putByte(1);var r=pn.util.createBuffer();for(var n in e.caStore.certs){var i=e.caStore.certs[n],a=pn.pki.distinguishedNameToAsn1(i.subject),s=pn.asn1.toDer(a);r.putInt16(s.length()),r.putBuffer(s)}var o=1+t.length()+2+r.length(),u=pn.util.createBuffer();return u.putByte(En.HandshakeType.certificate_request),u.putInt24(o),Cn(u,1,t),Cn(u,2,r),u},En.createServerHelloDone=function(e){var t=pn.util.createBuffer();return t.putByte(En.HandshakeType.server_hello_done),t.putInt24(0),t},En.createChangeCipherSpec=function(){var e=pn.util.createBuffer();return e.putByte(1),e},En.createFinished=function(e){var t=pn.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var r=e.entity===En.ConnectionEnd.client,n=e.session.sp,i=r?"client finished":"server finished";t=gn(n.master_secret,i,t.getBytes(),12);var a=pn.util.createBuffer();return a.putByte(En.HandshakeType.finished),a.putInt24(t.length()),a.putBuffer(t),a},En.createHeartbeat=function(e,t,r){void 0===r&&(r=t.length);var n=pn.util.createBuffer();n.putByte(e),n.putInt16(r),n.putBytes(t);var i=n.length(),a=Math.max(16,i-r-3);return n.putBytes(pn.random.getBytes(a)),n},En.queue=function(e,t){if(t&&(0!==t.fragment.length()||t.type!==En.ContentType.handshake&&t.type!==En.ContentType.alert&&t.type!==En.ContentType.change_cipher_spec)){if(t.type===En.ContentType.handshake){var r=t.fragment.bytes();e.session.md5.update(r),e.session.sha1.update(r),r=null}var n;if(t.fragment.length()<=En.MaxFragment)n=[t];else{n=[];for(var i=t.fragment.bytes();i.length>En.MaxFragment;)n.push(En.createRecord(e,{type:t.type,data:pn.util.createBuffer(i.slice(0,En.MaxFragment))})),i=i.slice(En.MaxFragment);i.length>0&&n.push(En.createRecord(e,{type:t.type,data:pn.util.createBuffer(i)}))}for(var a=0;a<n.length&&!e.fail;++a){var s=n[a];e.state.current.write.update(e,s)&&e.records.push(s)}}},En.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var Jn=function(e){switch(e){case!0:return!0;case pn.pki.certificateError.bad_certificate:return En.Alert.Description.bad_certificate;case pn.pki.certificateError.unsupported_certificate:return En.Alert.Description.unsupported_certificate;case pn.pki.certificateError.certificate_revoked:return En.Alert.Description.certificate_revoked;case pn.pki.certificateError.certificate_expired:return En.Alert.Description.certificate_expired;case pn.pki.certificateError.certificate_unknown:return En.Alert.Description.certificate_unknown;case pn.pki.certificateError.unknown_ca:return En.Alert.Description.unknown_ca;default:return En.Alert.Description.bad_certificate}};for(var ei in En.verifyCertificateChain=function(e,t){try{var r={};for(var n in e.verifyOptions)r[n]=e.verifyOptions[n];r.verify=function(t,r,n){Jn(t);var i=e.verify(e,t,r,n);if(!0!==i){if("object"==typeof i&&!pn.util.isArray(i)){var a=new Error("The application rejected the certificate.");throw a.send=!0,a.alert={level:En.Alert.Level.fatal,description:En.Alert.Description.bad_certificate},i.message&&(a.message=i.message),i.alert&&(a.alert.description=i.alert),a}i!==t&&(i=function(e){switch(e){case!0:return!0;case En.Alert.Description.bad_certificate:return pn.pki.certificateError.bad_certificate;case En.Alert.Description.unsupported_certificate:return pn.pki.certificateError.unsupported_certificate;case En.Alert.Description.certificate_revoked:return pn.pki.certificateError.certificate_revoked;case En.Alert.Description.certificate_expired:return pn.pki.certificateError.certificate_expired;case En.Alert.Description.certificate_unknown:return pn.pki.certificateError.certificate_unknown;case En.Alert.Description.unknown_ca:return pn.pki.certificateError.unknown_ca;default:return pn.pki.certificateError.bad_certificate}}(i))}return i},pn.pki.verifyCertificateChain(e.caStore,t,r)}catch(t){var i=t;("object"!=typeof i||pn.util.isArray(i))&&(i={send:!0,alert:{level:En.Alert.Level.fatal,description:Jn(t)}}),"send"in i||(i.send=!0),"alert"in i||(i.alert={level:En.Alert.Level.fatal,description:Jn(i.error)}),e.error(e,i)}return!e.fail},En.createSessionCache=function(e,t){var r=null;if(e&&e.getSession&&e.setSession&&e.order)r=e;else{for(var n in(r={}).cache=e||{},r.capacity=Math.max(t||100,1),r.order=[],e)r.order.length<=t?r.order.push(n):delete e[n];r.getSession=function(e){var t=null,n=null;if(e?n=pn.util.bytesToHex(e):r.order.length>0&&(n=r.order[0]),null!==n&&n in r.cache)for(var i in t=r.cache[n],delete r.cache[n],r.order)if(r.order[i]===n){r.order.splice(i,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var n=r.order.shift();delete r.cache[n]}n=pn.util.bytesToHex(e);r.order.push(n),r.cache[n]=t}}return r},En.createConnection=function(e){var t=null;t=e.caStore?pn.util.isArray(e.caStore)?pn.pki.createCaStore(e.caStore):e.caStore:pn.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var n in r=[],En.CipherSuites)r.push(En.CipherSuites[n]);var i=e.server?En.ConnectionEnd.server:En.ConnectionEnd.client,a=e.sessionCache?En.createSessionCache(e.sessionCache):null,s={version:{major:En.Version.major,minor:En.Version.minor},entity:i,sessionId:e.sessionId,caStore:t,sessionCache:a,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,n){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:pn.util.createBuffer(),tlsData:pn.util.createBuffer(),data:pn.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===En.ConnectionEnd.client?"client":"server"),r.send&&(En.queue(t,En.createAlert(t,r.alert)),En.flush(t));var n=!1!==r.fatal;n&&(t.fail=!0),e.error(t,r),n&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){s.version={major:En.Version.major,minor:En.Version.minor},s.record=null,s.session=null,s.peerCertificate=null,s.state={pending:null,current:null},s.expect=(s.entity,En.ConnectionEnd.client,0),s.fragmented=null,s.records=[],s.open=!1,s.handshakes=0,s.handshaking=!1,s.isConnected=!1,s.fail=!(e||void 0===e),s.input.clear(),s.tlsData.clear(),s.data.clear(),s.state.current=En.createConnectionState(s)}};s.reset();return s.handshake=function(e){if(s.entity!==En.ConnectionEnd.client)s.error(s,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(s.handshaking)s.error(s,{message:"Handshake already in progress.",fatal:!1});else{s.fail&&!s.open&&0===s.handshakes&&(s.fail=!1),s.handshaking=!0;var t=null;(e=e||"").length>0&&(s.sessionCache&&(t=s.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&s.sessionCache&&null!==(t=s.sessionCache.getSession())&&(e=t.id),s.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:pn.md.md5.create(),sha1:pn.md.sha1.create()},t&&(s.version=t.version,s.session.sp=t.sp),s.session.sp.client_random=En.createRandom().getBytes(),s.open=!0,En.queue(s,En.createRecord(s,{type:En.ContentType.handshake,data:En.createClientHello(s)})),En.flush(s)}},s.process=function(e){var t=0;return e&&s.input.putBytes(e),s.fail||(null!==s.record&&s.record.ready&&s.record.fragment.isEmpty()&&(s.record=null),null===s.record&&(t=function(e){var t=0,r=e.input,n=r.length();if(n<5)t=5-n;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:pn.util.createBuffer(),ready:!1};var i=e.record.version.major===e.version.major;i&&e.session&&e.session.version&&(i=e.record.version.minor===e.version.minor),i||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.protocol_version}})}return t}(s)),s.fail||null===s.record||s.record.ready||(t=function(e){var t=0,r=e.input,n=r.length();return n<e.record.length?t=e.record.length-n:(e.record.fragment.putBytes(r.getBytes(e.record.length)),r.compact(),e.state.current.read.update(e,e.record)&&(null!==e.fragmented&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:"Invalid fragmented record.",send:!0,alert:{level:En.Alert.Level.fatal,description:En.Alert.Description.unexpected_message}})),e.record.ready=!0)),t}(s)),!s.fail&&null!==s.record&&s.record.ready&&function(e,t){var r=t.type-En.ContentType.change_cipher_spec,n=Fn[e.entity][e.expect];r in n?n[r](e,t):En.handleUnexpected(e,t)}(s,s.record)),t},s.prepare=function(e){return En.queue(s,En.createRecord(s,{type:En.ContentType.application_data,data:pn.util.createBuffer(e)})),En.flush(s)},s.prepareHeartbeatRequest=function(e,t){return e instanceof pn.util.ByteBuffer&&(e=e.bytes()),void 0===t&&(t=e.length),s.expectedHeartbeatPayload=e,En.queue(s,En.createRecord(s,{type:En.ContentType.heartbeat,data:En.createHeartbeat(En.HeartbeatMessageType.heartbeat_request,e,t)})),En.flush(s)},s.close=function(e){if(!s.fail&&s.sessionCache&&s.session){var t={id:s.session.id,version:s.session.version,sp:s.session.sp};t.sp.keys=null,s.sessionCache.setSession(t.id,t)}s.open&&(s.open=!1,s.input.clear(),(s.isConnected||s.handshaking)&&(s.isConnected=s.handshaking=!1,En.queue(s,En.createAlert(s,{level:En.Alert.Level.warning,description:En.Alert.Description.close_notify})),En.flush(s)),s.closed(s)),s.reset(e)},s},pn.tls=pn.tls||{},En)"function"!=typeof En[ei]&&(pn.tls[ei]=En[ei]);pn.tls.prf_tls1=gn,pn.tls.hmac_sha1=function(e,t,r){var n=pn.hmac.create();n.start("SHA1",e);var i=pn.util.createBuffer();return i.putInt32(t[0]),i.putInt32(t[1]),i.putByte(r.type),i.putByte(r.version.major),i.putByte(r.version.minor),i.putInt16(r.length),i.putBytes(r.fragment.bytes()),n.update(i.getBytes()),n.digest().getBytes()},pn.tls.createSessionCache=En.createSessionCache,pn.tls.createConnection=En.createConnection;var ti=S,ri=ti.tls;function ni(e,t,r){var n=t.entity===ti.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:ti.cipher.createDecipher("AES-CBC",n?r.keys.server_write_key:r.keys.client_write_key),iv:n?r.keys.server_write_IV:r.keys.client_write_IV},e.write.cipherState={init:!1,cipher:ti.cipher.createCipher("AES-CBC",n?r.keys.client_write_key:r.keys.server_write_key),iv:n?r.keys.client_write_IV:r.keys.server_write_IV},e.read.cipherFunction=oi,e.write.cipherFunction=ii,e.read.macLength=e.write.macLength=r.mac_length,e.read.macFunction=e.write.macFunction=ri.hmac_sha1}function ii(e,t){var r,n=!1,i=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(i),t.updateSequenceNumber(),r=e.version.minor===ri.Versions.TLS_1_0.minor?t.cipherState.init?null:t.cipherState.iv:ti.random.getBytesSync(16),t.cipherState.init=!0;var a=t.cipherState.cipher;return a.start({iv:r}),e.version.minor>=ri.Versions.TLS_1_1.minor&&a.output.putBytes(r),a.update(e.fragment),a.finish(ai)&&(e.fragment=a.output,e.length=e.fragment.length(),n=!0),n}function ai(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function si(e,t,r){var n=!0;if(r){for(var i=t.length(),a=t.last(),s=i-1-a;s<i-1;++s)n=n&&t.at(s)==a;n&&t.truncate(a+1)}return n}function oi(e,t){var r,n=!1;r=e.version.minor===ri.Versions.TLS_1_0.minor?t.cipherState.init?null:t.cipherState.iv:e.fragment.getBytes(16),t.cipherState.init=!0;var i=t.cipherState.cipher;i.start({iv:r}),i.update(e.fragment),n=i.finish(si);var a=t.macLength,s=ti.random.getBytesSync(a),o=i.output.length();o>=a?(e.fragment=i.output.getBytes(o-a),s=i.output.getBytes(a)):e.fragment=i.output.getBytes(),e.fragment=ti.util.createBuffer(e.fragment),e.length=e.fragment.length();var u=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),n=function(e,t,r){var n=ti.hmac.create();return n.start("SHA1",e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(r),r=n.digest().getBytes(),t===r}(t.macKey,s,u)&&n,n}ri.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=ri.BulkCipherAlgorithm.aes,e.cipher_type=ri.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=ri.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:ni},ri.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=ri.BulkCipherAlgorithm.aes,e.cipher_type=ri.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=ri.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:ni};var ui=S;ui.debug=ui.debug||{},ui.debug.storage={},ui.debug.get=function(e,t){var r;return void 0===e?r=ui.debug.storage:e in ui.debug.storage&&(r=void 0===t?ui.debug.storage[e]:ui.debug.storage[e][t]),r},ui.debug.set=function(e,t,r){e in ui.debug.storage||(ui.debug.storage[e]={}),ui.debug.storage[e][t]=r},ui.debug.clear=function(e,t){void 0===e?ui.debug.storage={}:e in ui.debug.storage&&(void 0===t?delete ui.debug.storage[e]:delete ui.debug.storage[e][t])};var ci=S,li=ci.sha512=ci.sha512||{};ci.md.sha512=ci.md.algorithms.sha512=li;var hi=ci.sha384=ci.sha512.sha384=ci.sha512.sha384||{};hi.create=function(){return li.create("SHA-384")},ci.md.sha384=ci.md.algorithms.sha384=hi,ci.sha512.sha256=ci.sha512.sha256||{create:function(){return li.create("SHA-512/256")}},ci.md["sha512/256"]=ci.md.algorithms["sha512/256"]=ci.sha512.sha256,ci.sha512.sha224=ci.sha512.sha224||{create:function(){return li.create("SHA-512/224")}},ci.md["sha512/224"]=ci.md.algorithms["sha512/224"]=ci.sha512.sha224,li.create=function(e){if(di||(fi=String.fromCharCode(128),fi+=ci.util.fillString(String.fromCharCode(0),128),pi=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(gi={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],gi["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],gi["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],gi["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],di=!0),void 0===e&&(e="SHA-512"),!(e in gi))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=gi[e],r=null,n=ci.util.createBuffer(),i=new Array(80),a=0;a<80;++a)i[a]=new Array(2);var s=64;switch(e){case"SHA-384":s=48;break;case"SHA-512/256":s=32;break;case"SHA-512/224":s=28}var o={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:s,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){o.messageLength=0,o.fullMessageLength=o.messageLength128=[];for(var e=o.messageLengthSize/4,i=0;i<e;++i)o.fullMessageLength.push(0);n=ci.util.createBuffer(),r=new Array(t.length);for(i=0;i<t.length;++i)r[i]=t[i].slice(0);return o}};return o.start(),o.update=function(e,t){"utf8"===t&&(e=ci.util.encodeUtf8(e));var a=e.length;o.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var s=o.fullMessageLength.length-1;s>=0;--s)o.fullMessageLength[s]+=a[1],a[1]=a[0]+(o.fullMessageLength[s]/4294967296>>>0),o.fullMessageLength[s]=o.fullMessageLength[s]>>>0,a[0]=a[1]/4294967296>>>0;return n.putBytes(e),yi(r,i,n),(n.read>2048||0===n.length())&&n.compact(),o},o.digest=function(){var t=ci.util.createBuffer();t.putBytes(n.bytes());var a,s=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;t.putBytes(fi.substr(0,o.blockLength-s));for(var u=8*o.fullMessageLength[0],c=0;c<o.fullMessageLength.length-1;++c)u+=(a=8*o.fullMessageLength[c+1])/4294967296>>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var l=new Array(r.length);for(c=0;c<r.length;++c)l[c]=r[c].slice(0);yi(l,i,t);var h,f=ci.util.createBuffer();h="SHA-512"===e?l.length:"SHA-384"===e?l.length-2:l.length-4;for(c=0;c<h;++c)f.putInt32(l[c][0]),c===h-1&&"SHA-512/224"===e||f.putInt32(l[c][1]);return f},o};var fi=null,di=!1,pi=null,gi=null;function yi(e,t,r){for(var n,i,a,s,o,u,c,l,h,f,d,p,g,y,m,v,C,E,b,S,T,_,w,I,A,B,k,N,R,L,D,U,x,O=r.length();O>=128;){for(k=0;k<16;++k)t[k][0]=r.getInt32()>>>0,t[k][1]=r.getInt32()>>>0;for(;k<80;++k)n=(((N=(L=t[k-2])[0])>>>19|(R=L[1])<<13)^(R>>>29|N<<3)^N>>>6)>>>0,i=((N<<13|R>>>19)^(R<<3|N>>>29)^(N<<26|R>>>6))>>>0,a=(((N=(U=t[k-15])[0])>>>1|(R=U[1])<<31)^(N>>>8|R<<24)^N>>>7)>>>0,s=((N<<31|R>>>1)^(N<<24|R>>>8)^(N<<25|R>>>7))>>>0,D=t[k-7],x=t[k-16],R=i+D[1]+s+x[1],t[k][0]=n+D[0]+a+x[0]+(R/4294967296>>>0)>>>0,t[k][1]=R>>>0;for(d=e[0][0],p=e[0][1],g=e[1][0],y=e[1][1],m=e[2][0],v=e[2][1],C=e[3][0],E=e[3][1],b=e[4][0],S=e[4][1],T=e[5][0],_=e[5][1],w=e[6][0],I=e[6][1],A=e[7][0],B=e[7][1],k=0;k<80;++k)c=((b>>>14|S<<18)^(b>>>18|S<<14)^(S>>>9|b<<23))>>>0,l=(w^b&(T^w))>>>0,o=((d>>>28|p<<4)^(p>>>2|d<<30)^(p>>>7|d<<25))>>>0,u=((d<<4|p>>>28)^(p<<30|d>>>2)^(p<<25|d>>>7))>>>0,h=(d&g|m&(d^g))>>>0,f=(p&y|v&(p^y))>>>0,R=B+(((b<<18|S>>>14)^(b<<14|S>>>18)^(S<<23|b>>>9))>>>0)+((I^S&(_^I))>>>0)+pi[k][1]+t[k][1],n=A+c+l+pi[k][0]+t[k][0]+(R/4294967296>>>0)>>>0,i=R>>>0,a=o+h+((R=u+f)/4294967296>>>0)>>>0,s=R>>>0,A=w,B=I,w=T,I=_,T=b,_=S,b=C+n+((R=E+i)/4294967296>>>0)>>>0,S=R>>>0,C=m,E=v,m=g,v=y,g=d,y=p,d=n+a+((R=i+s)/4294967296>>>0)>>>0,p=R>>>0;R=e[0][1]+p,e[0][0]=e[0][0]+d+(R/4294967296>>>0)>>>0,e[0][1]=R>>>0,R=e[1][1]+y,e[1][0]=e[1][0]+g+(R/4294967296>>>0)>>>0,e[1][1]=R>>>0,R=e[2][1]+v,e[2][0]=e[2][0]+m+(R/4294967296>>>0)>>>0,e[2][1]=R>>>0,R=e[3][1]+E,e[3][0]=e[3][0]+C+(R/4294967296>>>0)>>>0,e[3][1]=R>>>0,R=e[4][1]+S,e[4][0]=e[4][0]+b+(R/4294967296>>>0)>>>0,e[4][1]=R>>>0,R=e[5][1]+_,e[5][0]=e[5][0]+T+(R/4294967296>>>0)>>>0,e[5][1]=R>>>0,R=e[6][1]+I,e[6][0]=e[6][0]+w+(R/4294967296>>>0)>>>0,e[6][1]=R>>>0,R=e[7][1]+B,e[7][0]=e[7][0]+A+(R/4294967296>>>0)>>>0,e[7][1]=R>>>0,O-=128}}var mi={},vi=S.asn1;mi.privateKeyValidator={name:"PrivateKeyInfo",tagClass:vi.Class.UNIVERSAL,type:vi.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:vi.Class.UNIVERSAL,type:vi.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:vi.Class.UNIVERSAL,type:vi.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:vi.Class.UNIVERSAL,type:vi.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:vi.Class.UNIVERSAL,type:vi.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},mi.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:vi.Class.UNIVERSAL,type:vi.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:vi.Class.UNIVERSAL,type:vi.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:vi.Class.UNIVERSAL,type:vi.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:vi.Class.UNIVERSAL,type:vi.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]};var Ci=S,Ei=mi,bi=Ei.publicKeyValidator,Si=Ei.privateKeyValidator;if(void 0===Ti)var Ti=Ci.jsbn.BigInteger;var _i=Ci.util.ByteBuffer,wi="undefined"==typeof Buffer?Uint8Array:Buffer;Ci.pki=Ci.pki||{},Ci.pki.ed25519=Ci.ed25519=Ci.ed25519||{};var Ii=Ci.ed25519;function Ai(e){var t=e.message;if(t instanceof Uint8Array||t instanceof wi)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if("undefined"!=typeof Buffer)return Buffer.from(t,r);t=new _i(t,r)}else if(!(t instanceof _i))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new wi(t.length()),i=0;i<n.length;++i)n[i]=t.at(i);return n}Ii.constants={},Ii.constants.PUBLIC_KEY_BYTE_LENGTH=32,Ii.constants.PRIVATE_KEY_BYTE_LENGTH=64,Ii.constants.SEED_BYTE_LENGTH=32,Ii.constants.SIGN_BYTE_LENGTH=64,Ii.constants.HASH_BYTE_LENGTH=64,Ii.generateKeyPair=function(e){var t=(e=e||{}).seed;if(void 0===t)t=Ci.random.getBytesSync(Ii.constants.SEED_BYTE_LENGTH);else if("string"==typeof t){if(t.length!==Ii.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+Ii.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=Ai({message:t,encoding:"binary"});for(var r=new wi(Ii.constants.PUBLIC_KEY_BYTE_LENGTH),n=new wi(Ii.constants.PRIVATE_KEY_BYTE_LENGTH),i=0;i<32;++i)n[i]=t[i];return function(e,t){var r,n=[Xi(),Xi(),Xi(),Xi()],i=Oi(t,32);for(i[0]&=248,i[31]&=127,i[31]|=64,Wi(n,i),Fi(e,n),r=0;r<32;++r)t[r+32]=e[r]}(r,n),{publicKey:r,privateKey:n}},Ii.privateKeyFromAsn1=function(e){var t={},r=[];if(!Ci.asn1.validate(e,Si,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=Ci.asn1.derToOid(t.privateKeyOid),a=Ci.oids.EdDSA25519;if(i!==a)throw new Error('Invalid OID "'+i+'"; OID must be "'+a+'".');var s=t.privateKey;return{privateKeyBytes:Ai({message:Ci.asn1.fromDer(s).value,encoding:"binary"})}},Ii.publicKeyFromAsn1=function(e){var t={},r=[];if(!Ci.asn1.validate(e,bi,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var i=Ci.asn1.derToOid(t.publicKeyOid),a=Ci.oids.EdDSA25519;if(i!==a)throw new Error('Invalid OID "'+i+'"; OID must be "'+a+'".');var s=t.ed25519PublicKey;if(s.length!==Ii.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return Ai({message:s,encoding:"binary"})},Ii.publicKeyFromPrivateKey=function(e){var t=Ai({message:(e=e||{}).privateKey,encoding:"binary"});if(t.length!==Ii.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+Ii.constants.PRIVATE_KEY_BYTE_LENGTH);for(var r=new wi(Ii.constants.PUBLIC_KEY_BYTE_LENGTH),n=0;n<r.length;++n)r[n]=t[32+n];return r},Ii.sign=function(e){var t=Ai(e=e||{}),r=Ai({message:e.privateKey,encoding:"binary"});if(r.length===Ii.constants.SEED_BYTE_LENGTH)r=Ii.generateKeyPair({seed:r}).privateKey;else if(r.length!==Ii.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+Ii.constants.SEED_BYTE_LENGTH+" or "+Ii.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new wi(Ii.constants.SIGN_BYTE_LENGTH+t.length);!function(e,t,r,n){var i,a,s=new Float64Array(64),o=[Xi(),Xi(),Xi(),Xi()],u=Oi(n,32);u[0]&=248,u[31]&=127,u[31]|=64;var c=r+64;for(i=0;i<r;++i)e[64+i]=t[i];for(i=0;i<32;++i)e[32+i]=u[32+i];var l=Oi(e.subarray(32),r+32);for(Vi(l),Wi(o,l),Fi(e,o),i=32;i<64;++i)e[i]=n[i];var h=Oi(e,r+64);for(Vi(h),i=32;i<64;++i)s[i]=0;for(i=0;i<32;++i)s[i]=l[i];for(i=0;i<32;++i)for(a=0;a<32;a++)s[i+a]+=h[i]*u[a];Pi(e.subarray(32),s)}(n,t,t.length,r);for(var i=new wi(Ii.constants.SIGN_BYTE_LENGTH),a=0;a<i.length;++a)i[a]=n[a];return i},Ii.verify=function(e){var t=Ai(e=e||{});if(void 0===e.signature)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var r=Ai({message:e.signature,encoding:"binary"});if(r.length!==Ii.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+Ii.constants.SIGN_BYTE_LENGTH);var n=Ai({message:e.publicKey,encoding:"binary"});if(n.length!==Ii.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+Ii.constants.PUBLIC_KEY_BYTE_LENGTH);var i,a=new wi(Ii.constants.SIGN_BYTE_LENGTH+t.length),s=new wi(Ii.constants.SIGN_BYTE_LENGTH+t.length);for(i=0;i<Ii.constants.SIGN_BYTE_LENGTH;++i)a[i]=r[i];for(i=0;i<t.length;++i)a[i+Ii.constants.SIGN_BYTE_LENGTH]=t[i];return function(e,t,r,n){var i,a=new wi(32),s=[Xi(),Xi(),Xi(),Xi()],o=[Xi(),Xi(),Xi(),Xi()];if(-1,r<64)return-1;if(function(e,t){var r=Xi(),n=Xi(),i=Xi(),a=Xi(),s=Xi(),o=Xi(),u=Xi();Qi(e[2],ki),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),ea(i,e[1]),ta(a,i,Ni),Ji(i,i,e[2]),$i(a,e[2],a),ea(s,a),ea(o,s),ta(u,o,s),ta(r,u,i),ta(r,r,a),function(e,t){var r,n=Xi();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)ea(n,n),1!==r&&ta(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),ta(r,r,i),ta(r,r,a),ta(r,r,a),ta(e[0],r,a),ea(n,e[0]),ta(n,n,a),ji(n,i)&&ta(e[0],e[0],xi);if(ea(n,e[0]),ta(n,n,a),ji(n,i))return-1;Hi(e[0])===t[31]>>7&&Ji(e[0],Bi,e[0]);return ta(e[3],e[0],e[1]),0}(o,n))return-1;for(i=0;i<r;++i)e[i]=t[i];for(i=0;i<32;++i)e[i+32]=n[i];var u=Oi(e,r);if(Vi(u),Gi(s,o,u),Wi(o,t.subarray(32)),Ki(s,o),Fi(a,s),r-=64,qi(t,0,a,0)){for(i=0;i<r;++i)e[i]=0;return-1}for(i=0;i<r;++i)e[i]=t[i+64];return r}(s,a,a.length,n)>=0};var Bi=Xi(),ki=Xi([1]),Ni=Xi([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),Ri=Xi([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Li=Xi([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Di=Xi([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Ui=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),xi=Xi([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Oi(e,t){var r=Ci.md.sha512.create(),n=new _i(e);r.update(n.getBytes(t),"binary");var i=r.digest().getBytes();if("undefined"!=typeof Buffer)return Buffer.from(i,"binary");for(var a=new wi(Ii.constants.HASH_BYTE_LENGTH),s=0;s<64;++s)a[s]=i.charCodeAt(s);return a}function Pi(e,t){var r,n,i,a;for(n=63;n>=32;--n){for(r=0,i=n-32,a=n-12;i<a;++i)t[i]+=r-16*t[n]*Ui[i-(n-32)],r=t[i]+128>>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;++i)t[i]+=r-(t[31]>>4)*Ui[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=r*Ui[i];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function Vi(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;Pi(e,t)}function Ki(e,t){var r=Xi(),n=Xi(),i=Xi(),a=Xi(),s=Xi(),o=Xi(),u=Xi(),c=Xi(),l=Xi();Ji(r,e[1],e[0]),Ji(l,t[1],t[0]),ta(r,r,l),$i(n,e[0],e[1]),$i(l,t[0],t[1]),ta(n,n,l),ta(i,e[3],t[3]),ta(i,i,Ri),ta(a,e[2],t[2]),$i(a,a,a),Ji(s,n,r),Ji(o,a,i),$i(u,a,i),$i(c,n,r),ta(e[0],s,o),ta(e[1],c,u),ta(e[2],u,o),ta(e[3],s,c)}function Mi(e,t,r){for(var n=0;n<4;++n)Zi(e[n],t[n],r)}function Fi(e,t){var r=Xi(),n=Xi(),i=Xi();!function(e,t){var r,n=Xi();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)ea(n,n),2!==r&&4!==r&&ta(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(i,t[2]),ta(r,t[0],i),ta(n,t[1],i),zi(e,n),e[31]^=Hi(r)<<7}function zi(e,t){var r,n,i,a=Xi(),s=Xi();for(r=0;r<16;++r)s[r]=t[r];for(Yi(s),Yi(s),Yi(s),n=0;n<2;++n){for(a[0]=s[0]-65517,r=1;r<15;++r)a[r]=s[r]-65535-(a[r-1]>>16&1),a[r-1]&=65535;a[15]=s[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,Zi(s,a,1-i)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function ji(e,t){var r=new wi(32),n=new wi(32);return zi(r,e),zi(n,t),qi(r,0,n,0)}function qi(e,t,r,n){return function(e,t,r,n,i){var a,s=0;for(a=0;a<i;++a)s|=e[t+a]^r[n+a];return(1&s-1>>>8)-1}(e,t,r,n,32)}function Hi(e){var t=new wi(32);return zi(t,e),1&t[0]}function Gi(e,t,r){var n,i;for(Qi(e[0],Bi),Qi(e[1],ki),Qi(e[2],ki),Qi(e[3],Bi),i=255;i>=0;--i)Mi(e,t,n=r[i/8|0]>>(7&i)&1),Ki(t,e),Ki(e,e),Mi(e,t,n)}function Wi(e,t){var r=[Xi(),Xi(),Xi(),Xi()];Qi(r[0],Li),Qi(r[1],Di),Qi(r[2],ki),ta(r[3],Li,Di),Gi(e,r,t)}function Qi(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function Yi(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function Zi(e,t,r){for(var n,i=~(r-1),a=0;a<16;++a)n=i&(e[a]^t[a]),e[a]^=n,t[a]^=n}function Xi(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;++t)r[t]=e[t];return r}function $i(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]+r[n]}function Ji(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]-r[n]}function ea(e,t){ta(e,t,t)}function ta(e,t,r){var n,i,a=0,s=0,o=0,u=0,c=0,l=0,h=0,f=0,d=0,p=0,g=0,y=0,m=0,v=0,C=0,E=0,b=0,S=0,T=0,_=0,w=0,I=0,A=0,B=0,k=0,N=0,R=0,L=0,D=0,U=0,x=0,O=r[0],P=r[1],V=r[2],K=r[3],M=r[4],F=r[5],z=r[6],j=r[7],q=r[8],H=r[9],G=r[10],W=r[11],Q=r[12],Y=r[13],Z=r[14],X=r[15];a+=(n=t[0])*O,s+=n*P,o+=n*V,u+=n*K,c+=n*M,l+=n*F,h+=n*z,f+=n*j,d+=n*q,p+=n*H,g+=n*G,y+=n*W,m+=n*Q,v+=n*Y,C+=n*Z,E+=n*X,s+=(n=t[1])*O,o+=n*P,u+=n*V,c+=n*K,l+=n*M,h+=n*F,f+=n*z,d+=n*j,p+=n*q,g+=n*H,y+=n*G,m+=n*W,v+=n*Q,C+=n*Y,E+=n*Z,b+=n*X,o+=(n=t[2])*O,u+=n*P,c+=n*V,l+=n*K,h+=n*M,f+=n*F,d+=n*z,p+=n*j,g+=n*q,y+=n*H,m+=n*G,v+=n*W,C+=n*Q,E+=n*Y,b+=n*Z,S+=n*X,u+=(n=t[3])*O,c+=n*P,l+=n*V,h+=n*K,f+=n*M,d+=n*F,p+=n*z,g+=n*j,y+=n*q,m+=n*H,v+=n*G,C+=n*W,E+=n*Q,b+=n*Y,S+=n*Z,T+=n*X,c+=(n=t[4])*O,l+=n*P,h+=n*V,f+=n*K,d+=n*M,p+=n*F,g+=n*z,y+=n*j,m+=n*q,v+=n*H,C+=n*G,E+=n*W,b+=n*Q,S+=n*Y,T+=n*Z,_+=n*X,l+=(n=t[5])*O,h+=n*P,f+=n*V,d+=n*K,p+=n*M,g+=n*F,y+=n*z,m+=n*j,v+=n*q,C+=n*H,E+=n*G,b+=n*W,S+=n*Q,T+=n*Y,_+=n*Z,w+=n*X,h+=(n=t[6])*O,f+=n*P,d+=n*V,p+=n*K,g+=n*M,y+=n*F,m+=n*z,v+=n*j,C+=n*q,E+=n*H,b+=n*G,S+=n*W,T+=n*Q,_+=n*Y,w+=n*Z,I+=n*X,f+=(n=t[7])*O,d+=n*P,p+=n*V,g+=n*K,y+=n*M,m+=n*F,v+=n*z,C+=n*j,E+=n*q,b+=n*H,S+=n*G,T+=n*W,_+=n*Q,w+=n*Y,I+=n*Z,A+=n*X,d+=(n=t[8])*O,p+=n*P,g+=n*V,y+=n*K,m+=n*M,v+=n*F,C+=n*z,E+=n*j,b+=n*q,S+=n*H,T+=n*G,_+=n*W,w+=n*Q,I+=n*Y,A+=n*Z,B+=n*X,p+=(n=t[9])*O,g+=n*P,y+=n*V,m+=n*K,v+=n*M,C+=n*F,E+=n*z,b+=n*j,S+=n*q,T+=n*H,_+=n*G,w+=n*W,I+=n*Q,A+=n*Y,B+=n*Z,k+=n*X,g+=(n=t[10])*O,y+=n*P,m+=n*V,v+=n*K,C+=n*M,E+=n*F,b+=n*z,S+=n*j,T+=n*q,_+=n*H,w+=n*G,I+=n*W,A+=n*Q,B+=n*Y,k+=n*Z,N+=n*X,y+=(n=t[11])*O,m+=n*P,v+=n*V,C+=n*K,E+=n*M,b+=n*F,S+=n*z,T+=n*j,_+=n*q,w+=n*H,I+=n*G,A+=n*W,B+=n*Q,k+=n*Y,N+=n*Z,R+=n*X,m+=(n=t[12])*O,v+=n*P,C+=n*V,E+=n*K,b+=n*M,S+=n*F,T+=n*z,_+=n*j,w+=n*q,I+=n*H,A+=n*G,B+=n*W,k+=n*Q,N+=n*Y,R+=n*Z,L+=n*X,v+=(n=t[13])*O,C+=n*P,E+=n*V,b+=n*K,S+=n*M,T+=n*F,_+=n*z,w+=n*j,I+=n*q,A+=n*H,B+=n*G,k+=n*W,N+=n*Q,R+=n*Y,L+=n*Z,D+=n*X,C+=(n=t[14])*O,E+=n*P,b+=n*V,S+=n*K,T+=n*M,_+=n*F,w+=n*z,I+=n*j,A+=n*q,B+=n*H,k+=n*G,N+=n*W,R+=n*Q,L+=n*Y,D+=n*Z,U+=n*X,E+=(n=t[15])*O,s+=38*(S+=n*V),o+=38*(T+=n*K),u+=38*(_+=n*M),c+=38*(w+=n*F),l+=38*(I+=n*z),h+=38*(A+=n*j),f+=38*(B+=n*q),d+=38*(k+=n*H),p+=38*(N+=n*G),g+=38*(R+=n*W),y+=38*(L+=n*Q),m+=38*(D+=n*Y),v+=38*(U+=n*Z),C+=38*(x+=n*X),a=(n=(a+=38*(b+=n*P))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),E=(n=E+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=(a+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),E=(n=E+i+65535)-65536*(i=Math.floor(n/65536)),a+=i-1+37*(i-1),e[0]=a,e[1]=s,e[2]=o,e[3]=u,e[4]=c,e[5]=l,e[6]=h,e[7]=f,e[8]=d,e[9]=p,e[10]=g,e[11]=y,e[12]=m,e[13]=v,e[14]=C,e[15]=E}var ra=S;ra.kem=ra.kem||{};var na=ra.jsbn.BigInteger;function ia(e,t,r,n){e.generate=function(e,i){for(var a=new ra.util.ByteBuffer,s=Math.ceil(i/n)+r,o=new ra.util.ByteBuffer,u=r;u<s;++u){o.putInt32(u),t.start(),t.update(e+o.getBytes());var c=t.digest();a.putBytes(c.getBytes(n))}return a.truncate(a.length()-i),a.getBytes()}}ra.kem.rsa={},ra.kem.rsa.create=function(e,t){var r=(t=t||{}).prng||ra.random,n={encrypt:function(t,n){var i,a=Math.ceil(t.n.bitLength()/8);do{i=new na(ra.util.bytesToHex(r.getBytesSync(a)),16).mod(t.n)}while(i.compareTo(na.ONE)<=0);var s=a-(i=ra.util.hexToBytes(i.toString(16))).length;return s>0&&(i=ra.util.fillString(String.fromCharCode(0),s)+i),{encapsulation:t.encrypt(i,"NONE"),key:e.generate(i,n)}},decrypt:function(t,r,n){var i=t.decrypt(r,"NONE");return e.generate(i,n)}};return n},ra.kem.kdf1=function(e,t){ia(this,e,0,t||e.digestLength)},ra.kem.kdf2=function(e,t){ia(this,e,1,t||e.digestLength)};var aa=S;aa.log=aa.log||{},aa.log.levels=["none","error","warning","info","debug","verbose","max"];var sa={},oa=[],ua=null;aa.log.LEVEL_LOCKED=2,aa.log.NO_LEVEL_CHECK=4,aa.log.INTERPOLATE=8;for(var ca=0;ca<aa.log.levels.length;++ca){var la=aa.log.levels[ca];sa[la]={index:ca,name:la.toUpperCase()}}aa.log.logMessage=function(e){for(var t=sa[e.level].index,r=0;r<oa.length;++r){var n=oa[r];if(n.flags&aa.log.NO_LEVEL_CHECK)n.f(e);else t<=sa[n.level].index&&n.f(n,e)}},aa.log.prepareStandard=function(e){"standard"in e||(e.standard=sa[e.level].name+" ["+e.category+"] "+e.message)},aa.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]||e.arguments),e.full=aa.util.format.apply(this,t)}},aa.log.prepareStandardFull=function(e){"standardFull"in e||(aa.log.prepareStandard(e),e.standardFull=e.standard)};var ha=["error","warning","info","debug","verbose"];for(ca=0;ca<ha.length;++ca)!function(e){aa.log[e]=function(t,r){var n=Array.prototype.slice.call(arguments).slice(2),i={timestamp:new Date,level:e,category:t,message:r,arguments:n};aa.log.logMessage(i)}}(ha[ca]);if(aa.log.makeLogger=function(e){var t={flags:0,f:e};return aa.log.setLevel(t,"none"),t},aa.log.setLevel=function(e,t){var r=!1;if(e&&!(e.flags&aa.log.LEVEL_LOCKED))for(var n=0;n<aa.log.levels.length;++n){if(t==aa.log.levels[n]){e.level=t,r=!0;break}}return r},aa.log.lock=function(e,t){void 0===t||t?e.flags|=aa.log.LEVEL_LOCKED:e.flags&=~aa.log.LEVEL_LOCKED},aa.log.addLogger=function(e){oa.push(e)},"undefined"!=typeof console&&"log"in console){var fa;if(console.error&&console.warn&&console.info&&console.debug){var da={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},pa=function(e,t){aa.log.prepareStandard(t);var r=da[t.level],n=[t.standard];n=n.concat(t.arguments.slice()),r.apply(console,n)};fa=aa.log.makeLogger(pa)}else{pa=function(e,t){aa.log.prepareStandardFull(t),console.log(t.standardFull)};fa=aa.log.makeLogger(pa)}aa.log.setLevel(fa,"debug"),aa.log.addLogger(fa),ua=fa}else console={log:function(){}};if(null!==ua){var ga=aa.util.getQueryVariables();if("console.level"in ga&&aa.log.setLevel(ua,ga["console.level"].slice(-1)[0]),"console.lock"in ga)"true"==ga["console.lock"].slice(-1)[0]&&aa.log.lock(ua)}aa.log.consoleLogger=ua;var ya={};({get exports(){return ya},set exports(e){ya=e}}).exports=ve;var ma=S,va=ma.asn1,Ca=ma.pkcs7=ma.pkcs7||{};function Ea(e){var t={},r=[];if(!va.validate(e,Ca.asn1.recipientInfoValidator,t,r)){var n=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw n.errors=r,n}return{version:t.version.charCodeAt(0),issuer:ma.pki.RDNAttributesAsArray(t.issuer),serialNumber:ma.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:va.derToOid(t.encAlgorithm),parameter:t.encParameter.value,content:t.encKey}}}function ba(e){for(var t,r=[],n=0;n<e.length;++n)r.push((t=e[n],va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,va.integerToDer(t.version).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[ma.pki.distinguishedNameToAsn1({attributes:t.issuer}),va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,ma.util.hexToBytes(t.serialNumber))]),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(t.encryptedContent.algorithm).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.NULL,!1,"")]),va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,t.encryptedContent.content)])));return r}function Sa(e){var t=va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,va.integerToDer(e.version).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[ma.pki.distinguishedNameToAsn1({attributes:e.issuer}),va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,ma.util.hexToBytes(e.serialNumber))]),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.digestAlgorithm).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.signatureAlgorithm).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.NULL,!1,"")])),t.value.push(va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var r=va.create(va.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<e.unauthenticatedAttributes.length;++n){var i=e.unauthenticatedAttributes[n];r.values.push(Ta(i))}t.value.push(r)}return t}function Ta(e){var t;if(e.type===ma.pki.oids.contentType)t=va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.value).getBytes());else if(e.type===ma.pki.oids.messageDigest)t=va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===ma.pki.oids.signingTime){var r=new Date("1950-01-01T00:00:00Z"),n=new Date("2050-01-01T00:00:00Z"),i=e.value;if("string"==typeof i){var a=Date.parse(i);i=isNaN(a)?13===i.length?va.utcTimeToDate(i):va.generalizedTimeToDate(i):new Date(a)}t=i>=r&&i<n?va.create(va.Class.UNIVERSAL,va.Type.UTCTIME,!1,va.dateToUtcTime(i)):va.create(va.Class.UNIVERSAL,va.Type.GENERALIZEDTIME,!1,va.dateToGeneralizedTime(i))}return va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.type).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SET,!0,[t])])}function _a(e,t,r){var n={};if(!va.validate(t,r,n,[])){var i=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw i.errors=i,i}if(va.derToOid(n.contentType)!==ma.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var a="";if(ma.util.isArray(n.encryptedContent))for(var s=0;s<n.encryptedContent.length;++s){if(n.encryptedContent[s].type!==va.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");a+=n.encryptedContent[s].value}else a=n.encryptedContent;e.encryptedContent={algorithm:va.derToOid(n.encAlgorithm),parameter:ma.util.createBuffer(n.encParameter.value),content:ma.util.createBuffer(a)}}if(n.content){a="";if(ma.util.isArray(n.content))for(s=0;s<n.content.length;++s){if(n.content[s].type!==va.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");a+=n.content[s].value}else a=n.content;e.content=ma.util.createBuffer(a)}return e.version=n.version.charCodeAt(0),e.rawCapture=n,n}function wa(e){if(void 0===e.encryptedContent.key)throw new Error("Symmetric key not available.");if(void 0===e.content){var t;switch(e.encryptedContent.algorithm){case ma.pki.oids["aes128-CBC"]:case ma.pki.oids["aes192-CBC"]:case ma.pki.oids["aes256-CBC"]:t=ma.aes.createDecryptionCipher(e.encryptedContent.key);break;case ma.pki.oids.desCBC:case ma.pki.oids["des-EDE3-CBC"]:t=ma.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}Ca.messageFromPem=function(e){var t=ma.pem.decode(e)[0];if("PKCS7"!==t.type){var r=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var n=va.fromDer(t.body);return Ca.messageFromAsn1(n)},Ca.messageToPem=function(e,t){var r={type:"PKCS7",body:va.toDer(e.toAsn1()).getBytes()};return ma.pem.encode(r,{maxline:t})},Ca.messageFromAsn1=function(e){var t={},r=[];if(!va.validate(e,Ca.asn1.contentInfoValidator,t,r)){var n=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw n.errors=r,n}var i,a=va.derToOid(t.contentType);switch(a){case ma.pki.oids.envelopedData:i=Ca.createEnvelopedData();break;case ma.pki.oids.encryptedData:i=Ca.createEncryptedData();break;case ma.pki.oids.signedData:i=Ca.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+a+" is not (yet) supported.")}return i.fromAsn1(t.content.value[0]),i},Ca.createSignedData=function(){var e=null;return e={type:ma.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){if(_a(e,t,Ca.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var r=e.rawCapture.certificates.value,n=0;n<r.length;++n)e.certificates.push(ma.pki.certificateFromAsn1(r[n]))},toAsn1:function(){e.contentInfo||e.sign();for(var t=[],r=0;r<e.certificates.length;++r)t.push(ma.pki.certificateToAsn1(e.certificates[r]));var n=[],i=va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,va.integerToDer(e.version).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return t.length>0&&i.value[0].value.push(va.create(va.Class.CONTEXT_SPECIFIC,0,!0,t)),n.length>0&&i.value[0].value.push(va.create(va.Class.CONTEXT_SPECIFIC,1,!0,n)),i.value[0].value.push(va.create(va.Class.UNIVERSAL,va.Type.SET,!0,e.signerInfos)),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.type).getBytes()),i])},addSigner:function(t){var r=t.issuer,n=t.serialNumber;if(t.certificate){var i=t.certificate;"string"==typeof i&&(i=ma.pki.certificateFromPem(i)),r=i.issuer.attributes,n=i.serialNumber}var a=t.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof a&&(a=ma.pki.privateKeyFromPem(a));var s=t.digestAlgorithm||ma.pki.oids.sha1;switch(s){case ma.pki.oids.sha1:case ma.pki.oids.sha256:case ma.pki.oids.sha384:case ma.pki.oids.sha512:case ma.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+s)}var o=t.authenticatedAttributes||[];if(o.length>0){for(var u=!1,c=!1,l=0;l<o.length;++l){var h=o[l];if(u||h.type!==ma.pki.oids.contentType){if(c||h.type!==ma.pki.oids.messageDigest);else if(c=!0,u)break}else if(u=!0,c)break}if(!u||!c)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:a,version:1,issuer:r,serialNumber:n,digestAlgorithm:s,signatureAlgorithm:ma.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:o,unauthenticatedAttributes:[]})},sign:function(t){var r;(t=t||{},"object"!=typeof e.content||null===e.contentInfo)&&(e.contentInfo=va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(ma.pki.oids.data).getBytes())]),"content"in e&&(e.content instanceof ma.util.ByteBuffer?r=e.content.bytes():"string"==typeof e.content&&(r=ma.util.encodeUtf8(e.content)),t.detached?e.detachedContent=va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,r):e.contentInfo.value.push(va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,r)]))));if(0!==e.signers.length){var n=function(){for(var t={},r=0;r<e.signers.length;++r){var n=e.signers[r];(i=n.digestAlgorithm)in t||(t[i]=ma.md[ma.pki.oids[i]].create()),0===n.authenticatedAttributes.length?n.md=t[i]:n.md=ma.md[ma.pki.oids[i]].create()}for(var i in e.digestAlgorithmIdentifiers=[],t)e.digestAlgorithmIdentifiers.push(va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(i).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.NULL,!1,"")]));return t}();!function(t){var r;r=e.detachedContent?e.detachedContent:(r=e.contentInfo.value[1]).value[0];if(!r)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var n=va.derToOid(e.contentInfo.value[0].value),i=va.toDer(r);for(var a in i.getByte(),va.getBerValueLength(i),i=i.getBytes(),t)t[a].start().update(i);for(var s=new Date,o=0;o<e.signers.length;++o){var u=e.signers[o];if(0===u.authenticatedAttributes.length){if(n!==ma.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{u.authenticatedAttributesAsn1=va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var c=va.create(va.Class.UNIVERSAL,va.Type.SET,!0,[]),l=0;l<u.authenticatedAttributes.length;++l){var h=u.authenticatedAttributes[l];h.type===ma.pki.oids.messageDigest?h.value=t[u.digestAlgorithm].digest():h.type===ma.pki.oids.signingTime&&(h.value||(h.value=s)),c.value.push(Ta(h)),u.authenticatedAttributesAsn1.value.push(Ta(h))}i=va.toDer(c).getBytes(),u.md.start().update(i)}u.signature=u.key.sign(u.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(Sa(e[r]));return t}(e.signers)}(n)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(t){"string"==typeof t&&(t=ma.pki.certificateFromPem(t)),e.certificates.push(t)},addCertificateRevokationList:function(e){throw new Error("PKCS#7 CRL support not yet implemented.")}},e},Ca.createEncryptedData=function(){var e=null;return e={type:ma.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:ma.pki.oids["aes256-CBC"]},fromAsn1:function(t){_a(e,t,Ca.asn1.encryptedDataValidator)},decrypt:function(t){void 0!==t&&(e.encryptedContent.key=t),wa(e)}},e},Ca.createEnvelopedData=function(){var e=null;return e={type:ma.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:ma.pki.oids["aes256-CBC"]},fromAsn1:function(t){var r=_a(e,t,Ca.asn1.envelopedDataValidator);e.recipients=function(e){for(var t=[],r=0;r<e.length;++r)t.push(Ea(e[r]));return t}(r.recipientInfos.value)},toAsn1:function(){return va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(e.type).getBytes()),va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.INTEGER,!1,va.integerToDer(e.version).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SET,!0,ba(e.recipients)),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,(t=e.encryptedContent,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(ma.pki.oids.data).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.SEQUENCE,!0,[va.create(va.Class.UNIVERSAL,va.Type.OID,!1,va.oidToDer(t.algorithm).getBytes()),va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,t.parameter.getBytes())]),va.create(va.Class.CONTEXT_SPECIFIC,0,!0,[va.create(va.Class.UNIVERSAL,va.Type.OCTETSTRING,!1,t.content.getBytes())])]))])])]);var t},findRecipient:function(t){for(var r=t.issuer.attributes,n=0;n<e.recipients.length;++n){var i=e.recipients[n],a=i.issuer;if(i.serialNumber===t.serialNumber&&a.length===r.length){for(var s=!0,o=0;o<r.length;++o)if(a[o].type!==r[o].type||a[o].value!==r[o].value){s=!1;break}if(s)return i}}return null},decrypt:function(t,r){if(void 0===e.encryptedContent.key&&void 0!==t&&void 0!==r)switch(t.encryptedContent.algorithm){case ma.pki.oids.rsaEncryption:case ma.pki.oids.desCBC:var n=r.decrypt(t.encryptedContent.content);e.encryptedContent.key=ma.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}wa(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:ma.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(void 0===e.encryptedContent.content){var n,i,a;switch(r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key,r){case ma.pki.oids["aes128-CBC"]:n=16,i=16,a=ma.aes.createEncryptionCipher;break;case ma.pki.oids["aes192-CBC"]:n=24,i=16,a=ma.aes.createEncryptionCipher;break;case ma.pki.oids["aes256-CBC"]:n=32,i=16,a=ma.aes.createEncryptionCipher;break;case ma.pki.oids["des-EDE3-CBC"]:n=24,i=8,a=ma.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(void 0===t)t=ma.util.createBuffer(ma.random.getBytes(n));else if(t.length()!=n)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+n+".");e.encryptedContent.algorithm=r,e.encryptedContent.key=t,e.encryptedContent.parameter=ma.util.createBuffer(ma.random.getBytes(i));var s=a(t);if(s.start(e.encryptedContent.parameter.copy()),s.update(e.content),!s.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=s.output}for(var o=0;o<e.recipients.length;++o){var u=e.recipients[o];if(void 0===u.encryptedContent.content){if(u.encryptedContent.algorithm!==ma.pki.oids.rsaEncryption)throw new Error("Unsupported asymmetric cipher, OID "+u.encryptedContent.algorithm);u.encryptedContent.content=u.encryptedContent.key.encrypt(e.encryptedContent.key.data)}}}},e};var Ia=S,Aa=Ia.ssh=Ia.ssh||{};function Ba(e,t){var r=t.toString(16);r[0]>="8"&&(r="00"+r);var n=Ia.util.hexToBytes(r);e.putInt32(n.length),e.putBytes(n)}function ka(e,t){e.putInt32(t.length),e.putString(t)}function Na(){for(var e=Ia.md.sha1.create(),t=arguments.length,r=0;r<t;++r)e.update(arguments[r]);return e.digest()}Aa.privateKeyToPutty=function(e,t,r){var n="ssh-rsa",i=""===(t=t||"")?"none":"aes256-cbc",a="PuTTY-User-Key-File-2: "+n+"\r\n";a+="Encryption: "+i+"\r\n",a+="Comment: "+(r=r||"")+"\r\n";var s=Ia.util.createBuffer();ka(s,n),Ba(s,e.e),Ba(s,e.n);var o=Ia.util.encode64(s.bytes(),64),u=Math.floor(o.length/66)+1;a+="Public-Lines: "+u+"\r\n",a+=o;var c,l=Ia.util.createBuffer();if(Ba(l,e.d),Ba(l,e.p),Ba(l,e.q),Ba(l,e.qInv),t){var h=l.length()+16-1;h-=h%16;var f=Na(l.bytes());f.truncate(f.length()-h+l.length()),l.putBuffer(f);var d=Ia.util.createBuffer();d.putBuffer(Na("\0\0\0\0",t)),d.putBuffer(Na("\0\0\0",t));var p=Ia.aes.createEncryptionCipher(d.truncate(8),"CBC");p.start(Ia.util.createBuffer().fillWithByte(0,16)),p.update(l.copy()),p.finish();var g=p.output;g.truncate(16),c=Ia.util.encode64(g.bytes(),64)}else c=Ia.util.encode64(l.bytes(),64);a+="\r\nPrivate-Lines: "+(u=Math.floor(c.length/66)+1)+"\r\n",a+=c;var y=Na("putty-private-key-file-mac-key",t),m=Ia.util.createBuffer();ka(m,n),ka(m,i),ka(m,r),m.putInt32(s.length()),m.putBuffer(s),m.putInt32(l.length()),m.putBuffer(l);var v=Ia.hmac.create();return v.start("sha1",y),v.update(m.bytes()),a+="\r\nPrivate-MAC: "+v.digest().toHex()+"\r\n"},Aa.publicKeyToOpenSSH=function(e,t){var r="ssh-rsa";t=t||"";var n=Ia.util.createBuffer();return ka(n,r),Ba(n,e.e),Ba(n,e.n),r+" "+Ia.util.encode64(n.bytes())+" "+t},Aa.privateKeyToOpenSSH=function(e,t){return t?Ia.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):Ia.pki.privateKeyToPem(e)},Aa.getPublicKeyFingerprint=function(e,t){var r=(t=t||{}).md||Ia.md.md5.create(),n=Ia.util.createBuffer();ka(n,"ssh-rsa"),Ba(n,e.e),Ba(n,e.n),r.start(),r.update(n.getBytes());var i=r.digest();if("hex"===t.encoding){var a=i.toHex();return t.delimiter?a.match(/.{2}/g).join(t.delimiter):a}if("binary"===t.encoding)return i.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return i};var Ra=S,La="forge.task",Da={},Ua=0;Ra.debug.set(La,"tasks",Da);var xa={};Ra.debug.set(La,"queues",xa);var Oa="ready",Pa="running",Va="blocked",Ka="sleeping",Ma="done",Fa="error",za="stop",ja="start",qa="block",Ha="unblock",Ga="sleep",Wa="wakeup",Qa="cancel",Ya="fail",Za={};Za[Oa]={},Za[Oa][za]=Oa,Za[Oa][ja]=Pa,Za[Oa][Qa]=Ma,Za[Oa][Ya]=Fa,Za[Pa]={},Za[Pa][za]=Oa,Za[Pa][ja]=Pa,Za[Pa][qa]=Va,Za[Pa][Ha]=Pa,Za[Pa][Ga]=Ka,Za[Pa][Wa]=Pa,Za[Pa][Qa]=Ma,Za[Pa][Ya]=Fa,Za[Va]={},Za[Va][za]=Va,Za[Va][ja]=Va,Za[Va][qa]=Va,Za[Va][Ha]=Va,Za[Va][Ga]=Va,Za[Va][Wa]=Va,Za[Va][Qa]=Ma,Za[Va][Ya]=Fa,Za[Ka]={},Za[Ka][za]=Ka,Za[Ka][ja]=Ka,Za[Ka][qa]=Ka,Za[Ka][Ha]=Ka,Za[Ka][Ga]=Ka,Za[Ka][Wa]=Ka,Za[Ka][Qa]=Ma,Za[Ka][Ya]=Fa,Za[Ma]={},Za[Ma][za]=Ma,Za[Ma][ja]=Ma,Za[Ma][qa]=Ma,Za[Ma][Ha]=Ma,Za[Ma][Ga]=Ma,Za[Ma][Wa]=Ma,Za[Ma][Qa]=Ma,Za[Ma][Ya]=Fa,Za[Fa]={},Za[Fa][za]=Fa,Za[Fa][ja]=Fa,Za[Fa][qa]=Fa,Za[Fa][Ha]=Fa,Za[Fa][Ga]=Fa,Za[Fa][Wa]=Fa,Za[Fa][Qa]=Fa,Za[Fa][Ya]=Fa;var Xa=function(e){this.id=-1,this.name=e.name||"?",this.parent=e.parent||null,this.run=e.run,this.subtasks=[],this.error=!1,this.state=Oa,this.blocks=0,this.timeoutId=null,this.swapTime=null,this.userData=null,this.id=Ua++,Da[this.id]=this};Xa.prototype.debug=function(e){e=e||"",Ra.log.debug(La,e,"[%s][%s] task:",this.id,this.name,this,"subtasks:",this.subtasks.length,"queue:",xa)},Xa.prototype.next=function(e,t){"function"==typeof e&&(t=e,e=this.name);var r=new Xa({run:t,name:e,parent:this});return r.state=Pa,r.type=this.type,r.successCallback=this.successCallback||null,r.failureCallback=this.failureCallback||null,this.subtasks.push(r),this},Xa.prototype.parallel=function(e,t){return Ra.util.isArray(e)&&(t=e,e=this.name),this.next(e,(function(r){var n=r;n.block(t.length);for(var i=function(e,r){Ra.task.start({type:e,run:function(e){t[r](e)},success:function(e){n.unblock()},failure:function(e){n.unblock()}})},a=0;a<t.length;a++){i(e+"__parallel-"+r.id+"-"+a,a)}}))},Xa.prototype.stop=function(){this.state=Za[this.state][za]},Xa.prototype.start=function(){this.error=!1,this.state=Za[this.state][ja],this.state===Pa&&(this.start=new Date,this.run(this),$a(this,0))},Xa.prototype.block=function(e){e=void 0===e?1:e,this.blocks+=e,this.blocks>0&&(this.state=Za[this.state][qa])},Xa.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==Ma&&(this.state=Pa,$a(this,0)),this.blocks},Xa.prototype.sleep=function(e){e=void 0===e?0:e,this.state=Za[this.state][Ga];var t=this;this.timeoutId=setTimeout((function(){t.timeoutId=null,t.state=Pa,$a(t,0)}),e)},Xa.prototype.wait=function(e){e.wait(this)},Xa.prototype.wakeup=function(){this.state===Ka&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=Pa,$a(this,0))},Xa.prototype.cancel=function(){this.state=Za[this.state][Qa],this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},Xa.prototype.fail=function(e){if(this.error=!0,Ja(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,$a(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;Ja(t,!0)}this.failureCallback&&this.failureCallback(this)}};var $a=function(e,t){var r=t>30||+new Date-e.swapTime>20,n=function(t){if(t++,e.state===Pa)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var n=e.subtasks.shift();n.error=e.error,n.swapTime=e.swapTime,n.userData=e.userData,n.run(n),n.error||$a(n,t)}else Ja(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,$a(e.parent,t))};r?setTimeout(n,0):n(t)},Ja=function(e,t){e.state=Ma,delete Da[e.id],null===e.parent&&(e.type in xa?0===xa[e.type].length?Ra.log.error(La,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):xa[e.type][0]!==e?Ra.log.error(La,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(xa[e.type].shift(),0===xa[e.type].length?delete xa[e.type]:xa[e.type][0].start()):Ra.log.error(La,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};Ra.task=Ra.task||{},Ra.task.start=function(e){var t=new Xa({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in xa?xa[e.type].push(t):(xa[t.type]=[t],function(e){e.error=!1,e.state=Za[e.state][ja],setTimeout((function(){e.state===Pa&&(e.swapTime=+new Date,e.run(e),$a(e,0))}),0)}(t))},Ra.task.cancel=function(e){e in xa&&(xa[e]=[xa[e][0]])},Ra.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e},b.exports=S;var es=C(E);class ts{crt;key;csr;detail;expires;constructor(e){this.crt=e.crt,this.key=e.key,this.csr=e.csr;const{detail:t,expires:r}=this.getCrtDetail(this.crt);this.detail=t,this.expires=r.getTime()}toCertInfo(){return{crt:this.crt,key:this.key,csr:this.csr}}getCrtDetail(e){const t=es.pki.certificateFromPem(e.toString());return{detail:t,expires:t.validity.notAfter}}saveToFile(e,t){null==t&&(t=o.join(a.tmpdir(),"/certd/tmp/",Math.floor(1e6*Math.random())+"",`cert.${e}`));const r=o.dirname(t);return i.existsSync(r)||i.mkdirSync(r,{recursive:!0}),i.writeFileSync(t,this[e]),t}}var rs,ns,is,as={},ss={},os={},us={},cs={get exports(){return us},set exports(e){us=e}},ls={},hs={get exports(){return ls},set exports(e){ls=e}};function fs(){if(rs)return ls;return rs=1,"undefined"==typeof process||!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?hs.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,a,s=arguments.length;switch(s){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick((function(){e.call(null,t)}));case 3:return process.nextTick((function(){e.call(null,t,r)}));case 4:return process.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),a=0;a<i.length;)i[a++]=arguments[a];return process.nextTick((function(){e.apply(null,i)}))}}}:hs.exports=process,ls}var ds,ps={},gs={get exports(){return ps},set exports(e){ps=e}};function ys(){return ds||(ds=1,gs.exports=u),ps}var ms,vs={},Cs={get exports(){return vs},set exports(e){vs=e}};function Es(){return ms||(ms=1,function(e,t){var r=l,n=r.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=a),i(n,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(Cs,vs)),vs}var bs,Ss={};function Ts(){if(bs)return Ss;function e(e){return Object.prototype.toString.call(e)}return bs=1,Ss.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===e(t)},Ss.isBoolean=function(e){return"boolean"==typeof e},Ss.isNull=function(e){return null===e},Ss.isNullOrUndefined=function(e){return null==e},Ss.isNumber=function(e){return"number"==typeof e},Ss.isString=function(e){return"string"==typeof e},Ss.isSymbol=function(e){return"symbol"==typeof e},Ss.isUndefined=function(e){return void 0===e},Ss.isRegExp=function(t){return"[object RegExp]"===e(t)},Ss.isObject=function(e){return"object"==typeof e&&null!==e},Ss.isDate=function(t){return"[object Date]"===e(t)},Ss.isError=function(t){return"[object Error]"===e(t)||t instanceof Error},Ss.isFunction=function(e){return"function"==typeof e},Ss.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Ss.isBuffer=l.Buffer.isBuffer,Ss}var _s,ws,Is={},As={get exports(){return Is},set exports(e){Is=e}},Bs={},ks={get exports(){return Bs},set exports(e){Bs=e}};function Ns(){return ws||(ws=1,function(e){try{var t=require("util");if("function"!=typeof t.inherits)throw"";e.exports=t.inherits}catch(t){e.exports=(_s||(_s=1,"function"==typeof Object.create?ks.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ks.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}),Bs)}}(As)),Is}var Rs,Ls,Ds,Us,xs,Os,Ps,Vs,Ks,Ms={},Fs={get exports(){return Ms},set exports(e){Ms=e}};function zs(){return Rs||(Rs=1,function(e){var t=Es().Buffer,r=h;e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return t.alloc(0);for(var r,n,i,a=t.allocUnsafe(e>>>0),s=this.head,o=0;s;)r=s.data,n=a,i=o,r.copy(n,i),o+=s.data.length,s=s.next;return a},e}(),r&&r.inspect&&r.inspect.custom&&(e.exports.prototype[r.inspect.custom]=function(){var e=r.inspect({length:this.length});return this.constructor.name+" "+e})}(Fs)),Ms}function js(){if(Ds)return Ls;Ds=1;var e=fs();function t(e,t){e.emit("error",t)}return Ls={destroy:function(r,n){var i=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(n?n(r):r&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(t,this,r)):e.nextTick(t,this,r)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(r||null,(function(r){!n&&r?i._writableState?i._writableState.errorEmitted||(i._writableState.errorEmitted=!0,e.nextTick(t,i,r)):e.nextTick(t,i,r):n&&n(r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}},Ls}function qs(){if(Ps)return Os;Ps=1;var e=fs();function t(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}(t,e)}}Os=p;var r,n=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:e.nextTick;p.WritableState=d;var i=Object.create(Ts());i.inherits=Ns();var a={deprecate:xs?Us:(xs=1,Us=h.deprecate)},s=ys(),o=Es().Buffer,u=(void 0!==v?v:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,l=js();function f(){}function d(i,a){r=r||Hs(),i=i||{};var s=a instanceof r;this.objectMode=!!i.objectMode,s&&(this.objectMode=this.objectMode||!!i.writableObjectMode);var o=i.highWaterMark,u=i.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:s&&(u||0===u)?u:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===i.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=i.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,r){var i=t._writableState,a=i.sync,s=i.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(i),r)!function(t,r,n,i,a){--r.pendingcb,n?(e.nextTick(a,i),e.nextTick(b,t,r),t._writableState.errorEmitted=!0,t.emit("error",i)):(a(i),t._writableState.errorEmitted=!0,t.emit("error",i),b(t,r))}(t,i,a,r,s);else{var o=C(i);o||i.corked||i.bufferProcessing||!i.bufferedRequest||m(t,i),a?n(y,t,i,o,s):y(t,i,o,s)}}(a,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}function p(e){if(r=r||Hs(),!(c.call(p,this)||this instanceof r))return new p(e);this._writableState=new d(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),s.call(this)}function g(e,t,r,n,i,a,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function y(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),b(e,t)}function m(e,r){r.bufferProcessing=!0;var n=r.bufferedRequest;if(e._writev&&n&&n.next){var i=r.bufferedRequestCount,a=new Array(i),s=r.corkedRequestsFree;s.entry=n;for(var o=0,u=!0;n;)a[o]=n,n.isBuf||(u=!1),n=n.next,o+=1;a.allBuffers=u,g(e,r,!0,r.length,a,"",s.finish),r.pendingcb++,r.lastBufferedRequest=null,s.next?(r.corkedRequestsFree=s.next,s.next=null):r.corkedRequestsFree=new t(r),r.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,h=n.callback;if(g(e,r,!1,r.objectMode?1:c.length,c,l,h),n=n.next,r.bufferedRequestCount--,r.writing)break}null===n&&(r.lastBufferedRequest=null)}r.bufferedRequest=n,r.bufferProcessing=!1}function C(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),b(e,t)}))}function b(t,r){var n=C(r);return n&&(!function(t,r){r.prefinished||r.finalCalled||("function"==typeof t._final?(r.pendingcb++,r.finalCalled=!0,e.nextTick(E,t,r)):(r.prefinished=!0,t.emit("prefinish")))}(t,r),0===r.pendingcb&&(r.finished=!0,t.emit("finish"))),n}return i.inherits(p,s),d.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(d.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(c=Function.prototype[Symbol.hasInstance],Object.defineProperty(p,Symbol.hasInstance,{value:function(e){return!!c.call(this,e)||this===p&&(e&&e._writableState instanceof d)}})):c=function(e){return e instanceof this},p.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},p.prototype.write=function(t,r,n){var i,a=this._writableState,s=!1,c=!a.objectMode&&(i=t,o.isBuffer(i)||i instanceof u);return c&&!o.isBuffer(t)&&(t=function(e){return o.from(e)}(t)),"function"==typeof r&&(n=r,r=null),c?r="buffer":r||(r=a.defaultEncoding),"function"!=typeof n&&(n=f),a.ended?function(t,r){var n=new Error("write after end");t.emit("error",n),e.nextTick(r,n)}(this,n):(c||function(t,r,n,i){var a=!0,s=!1;return null===n?s=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||r.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),e.nextTick(i,s),a=!1),a}(this,a,t,n))&&(a.pendingcb++,s=function(e,t,r,n,i,a){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=o.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var u=t.objectMode?1:n.length;t.length+=u;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:a,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else g(e,t,!1,u,n,i,a);return c}(this,a,c,t,r,n)),s},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||m(this,e))},p.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(p.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),p.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},p.prototype._writev=null,p.prototype.end=function(t,r,n){var i=this._writableState;"function"==typeof t?(n=t,t=null,r=null):"function"==typeof r&&(n=r,r=null),null!=t&&this.write(t,r),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,r,n){r.ending=!0,b(t,r),n&&(r.finished?e.nextTick(n):t.once("finish",n));r.ended=!0,t.writable=!1}(this,i,n)},Object.defineProperty(p.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),p.prototype.destroy=l.destroy,p.prototype._undestroy=l.undestroy,p.prototype._destroy=function(e,t){this.end(),t(e)},Os}function Hs(){if(Ks)return Vs;Ks=1;var e=fs(),t=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Vs=u;var r=Object.create(Ts());r.inherits=Ns();var n=ro(),i=qs();r.inherits(u,n);for(var a=t(i.prototype),s=0;s<a.length;s++){var o=a[s];u.prototype[o]||(u.prototype[o]=i.prototype[o])}function u(e){if(!(this instanceof u))return new u(e);n.call(this,e),i.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",c)}function c(){this.allowHalfOpen||this._writableState.ended||e.nextTick(l,this)}function l(e){e.end()}return Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),u.prototype._destroy=function(t,r){this.push(null),this.end(),e.nextTick(r,t)},Vs}var Gs,Ws,Qs,Ys,Zs,Xs,$s,Js,eo={};function to(){if(Gs)return eo;Gs=1;var e=Es().Buffer,t=e.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(r){var n;switch(this.encoding=function(r){var n=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(r);if("string"!=typeof n&&(e.isEncoding===t||!t(r)))throw new Error("Unknown encoding: "+r);return n||r}(r),this.encoding){case"utf16le":this.text=a,this.end=s,n=4;break;case"utf8":this.fillLast=i,n=4;break;case"base64":this.text=o,this.end=u,n=3;break;default:return this.write=c,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=e.allocUnsafe(n)}function n(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function i(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function s(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function o(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function c(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}return eo.StringDecoder=r,r.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},r.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},r.prototype.text=function(e,t){var r=function(e,t,r){var i=t.length-1;if(i<r)return 0;var a=n(t[i]);if(a>=0)return a>0&&(e.lastNeed=a-1),a;if(--i<r||-2===a)return 0;if(a=n(t[i]),a>=0)return a>0&&(e.lastNeed=a-2),a;if(--i<r||-2===a)return 0;if(a=n(t[i]),a>=0)return a>0&&(2===a?a=0:e.lastNeed=a-3),a;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},r.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length},eo}function ro(){if(Qs)return Ws;Qs=1;var e=fs();Ws=m;var t,r=function(){if(is)return ns;is=1;var e={}.toString;return ns=Array.isArray||function(t){return"[object Array]"==e.call(t)}}();m.ReadableState=y,c.EventEmitter;var n=function(e,t){return e.listeners(t).length},i=ys(),a=Es().Buffer,s=(void 0!==v?v:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var o=Object.create(Ts());o.inherits=Ns();var u=h,l=void 0;l=u&&u.debuglog?u.debuglog("stream"):function(){};var f,d=zs(),p=js();o.inherits(m,i);var g=["error","close","destroy","pause","resume"];function y(e,r){e=e||{};var n=r instanceof(t=t||Hs());this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,a=e.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(a||0===a)?a:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=to().StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function m(e){if(t=t||Hs(),!(this instanceof m))return new m(e);this._readableState=new y(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),i.call(this)}function C(e,t,r,n,i){var o,u=e._readableState;null===t?(u.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,T(e)}(e,u)):(i||(o=function(e,t){var r;n=t,a.isBuffer(n)||n instanceof s||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(u,t)),o?e.emit("error",o):u.objectMode||t&&t.length>0?("string"==typeof t||u.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),n?u.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):E(e,u,t,!0):u.ended?e.emit("error",new Error("stream.push() after EOF")):(u.reading=!1,u.decoder&&!r?(t=u.decoder.write(t),u.objectMode||0!==t.length?E(e,u,t,!1):w(e,u)):E(e,u,t,!1))):n||(u.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(u)}function E(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&T(e)),w(e,t)}Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.push(null),t(e)},m.prototype.push=function(e,t){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof e&&((t=t||n.defaultEncoding)!==n.encoding&&(e=a.from(e,t),t=""),r=!0),C(this,e,t,!1,r)},m.prototype.unshift=function(e){return C(this,e,null,!0,!1)},m.prototype.isPaused=function(){return!1===this._readableState.flowing},m.prototype.setEncoding=function(e){return f||(f=to().StringDecoder),this._readableState.decoder=new f(e),this._readableState.encoding=e,this};var b=8388608;function S(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=b?e=b:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function T(t){var r=t._readableState;r.needReadable=!1,r.emittedReadable||(l("emitReadable",r.flowing),r.emittedReadable=!0,r.sync?e.nextTick(_,t):_(t))}function _(e){l("emit readable"),e.emit("readable"),k(e)}function w(t,r){r.readingMore||(r.readingMore=!0,e.nextTick(I,t,r))}function I(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(l("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}function A(e){l("readable nexttick read 0"),e.read(0)}function B(e,t){t.reading||(l("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),k(e),t.flowing&&!t.reading&&e.read(0)}function k(e){var t=e._readableState;for(l("flow",t.flowing);t.flowing&&null!==e.read(););}function N(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):n=e===t.head.data.length?t.shift():r?function(e,t){var r=t.head,n=1,i=r.data;e-=i.length;for(;r=r.next;){var a=r.data,s=e>a.length?a.length:e;if(s===a.length?i+=a:i+=a.slice(0,e),0===(e-=s)){s===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=a.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var s=n.data,o=e>s.length?s.length:e;if(s.copy(r,r.length-e,0,o),0===(e-=o)){o===s.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(o));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function R(t){var r=t._readableState;if(r.length>0)throw new Error('"endReadable()" called on non-empty stream');r.endEmitted||(r.ended=!0,e.nextTick(L,r,t))}function L(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function D(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}return m.prototype.read=function(e){l("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return l("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):T(this),null;if(0===(e=S(e,t))&&t.ended)return 0===t.length&&R(this),null;var n,i=t.needReadable;return l("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&l("length less than watermark",i=!0),t.ended||t.reading?l("reading or ended",i=!1):i&&(l("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=S(r,t))),null===(n=e>0?N(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&R(this)),null!==n&&this.emit("data",n),n},m.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(t,i){var a=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,l("pipe count=%d opts=%j",s.pipesCount,i);var o=(!i||!1!==i.end)&&t!==process.stdout&&t!==process.stderr?c:v;function u(e,r){l("onunpipe"),e===a&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",y),t.removeListener("finish",m),t.removeListener("drain",h),t.removeListener("error",g),t.removeListener("unpipe",u),a.removeListener("end",c),a.removeListener("end",v),a.removeListener("data",p),f=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function c(){l("onend"),t.end()}s.endEmitted?e.nextTick(o):a.once("end",o),t.on("unpipe",u);var h=function(e){return function(){var t=e._readableState;l("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&n(e,"data")&&(t.flowing=!0,k(e))}}(a);t.on("drain",h);var f=!1;var d=!1;function p(e){l("ondata"),d=!1,!1!==t.write(e)||d||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==D(s.pipes,t))&&!f&&(l("false write response, pause",s.awaitDrain),s.awaitDrain++,d=!0),a.pause())}function g(e){l("onerror",e),v(),t.removeListener("error",g),0===n(t,"error")&&t.emit("error",e)}function y(){t.removeListener("finish",m),v()}function m(){l("onfinish"),t.removeListener("close",y),v()}function v(){l("unpipe"),a.unpipe(t)}return a.on("data",p),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?r(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(t,"error",g),t.once("close",y),t.once("finish",m),t.emit("pipe",a),s.flowing||(l("pipe resume"),a.resume()),t},m.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<i;a++)n[a].emit("unpipe",this,{hasUnpiped:!1});return this}var s=D(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},m.prototype.on=function(t,r){var n=i.prototype.on.call(this,t,r);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var a=this._readableState;a.endEmitted||a.readableListening||(a.readableListening=a.needReadable=!0,a.emittedReadable=!1,a.reading?a.length&&T(this):e.nextTick(A,this))}return n},m.prototype.addListener=m.prototype.on,m.prototype.resume=function(){var t=this._readableState;return t.flowing||(l("resume"),t.flowing=!0,function(t,r){r.resumeScheduled||(r.resumeScheduled=!0,e.nextTick(B,t,r))}(this,t)),this},m.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this},m.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(l("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(l("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var a=0;a<g.length;a++)e.on(g[a],this.emit.bind(this,g[a]));return this._read=function(t){l("wrapped _read",t),n&&(n=!1,e.resume())},this},Object.defineProperty(m.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),m._fromList=N,Ws}function no(){if(Zs)return Ys;Zs=1,Ys=n;var e=Hs(),t=Object.create(Ts());function r(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function n(t){if(!(this instanceof n))return new n(t);e.call(this,t),this._transformState={afterTransform:r.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",i)}function i(){var e=this;"function"==typeof this._flush?this._flush((function(t,r){a(e,t,r)})):a(this,null,null)}function a(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}return t.inherits=Ns(),t.inherits(n,e),n.prototype.push=function(t,r){return this._transformState.needTransform=!1,e.prototype.push.call(this,t,r)},n.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")},n.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},n.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},n.prototype._destroy=function(t,r){var n=this;e.prototype._destroy.call(this,t,(function(e){r(e),n.emit("close")}))},Ys}function io(){return Js||(Js=1,function(e,t){var r=u;"disable"===process.env.READABLE_STREAM&&r?(e.exports=r,(t=e.exports=r.Readable).Readable=r.Readable,t.Writable=r.Writable,t.Duplex=r.Duplex,t.Transform=r.Transform,t.PassThrough=r.PassThrough,t.Stream=r):((t=e.exports=ro()).Stream=r||t,t.Readable=t,t.Writable=qs(),t.Duplex=Hs(),t.Transform=no(),t.PassThrough=function(){if($s)return Xs;$s=1,Xs=r;var e=no(),t=Object.create(Ts());function r(t){if(!(this instanceof r))return new r(t);e.call(this,t)}return t.inherits=Ns(),t.inherits(r,e),r.prototype._transform=function(e,t,r){r(null,e)},Xs}())}(cs,us)),us}if(os.base64=!0,os.array=!0,os.string=!0,os.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,os.nodebuffer="undefined"!=typeof Buffer,os.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)os.blob=!1;else{var ao=new ArrayBuffer(0);try{os.blob=0===new Blob([ao],{type:"application/zip"}).size}catch(e){try{var so=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);so.append(ao),os.blob=0===so.getBlob("application/zip").size}catch(e){os.blob=!1}}}try{os.nodestream=!!io().Readable}catch(e){os.nodestream=!1}var oo,uo={};function co(){if(oo)return uo;oo=1;var e=Co(),t=os,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return uo.encode=function(t){for(var n,i,a,s,o,u,c,l=[],h=0,f=t.length,d=f,p="string"!==e.getTypeOf(t);h<t.length;)d=f-h,p?(n=t[h++],i=h<f?t[h++]:0,a=h<f?t[h++]:0):(n=t.charCodeAt(h++),i=h<f?t.charCodeAt(h++):0,a=h<f?t.charCodeAt(h++):0),s=n>>2,o=(3&n)<<4|i>>4,u=d>1?(15&i)<<2|a>>6:64,c=d>2?63&a:64,l.push(r.charAt(s)+r.charAt(o)+r.charAt(u)+r.charAt(c));return l.join("")},uo.decode=function(e){var n,i,a,s,o,u,c=0,l=0,h="data:";if(e.substr(0,5)===h)throw new Error("Invalid base64 input, it looks like a data url.");var f,d=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===r.charAt(64)&&d--,e.charAt(e.length-2)===r.charAt(64)&&d--,d%1!=0)throw new Error("Invalid base64 input, bad content length.");for(f=t.uint8array?new Uint8Array(0|d):new Array(0|d);c<e.length;)n=r.indexOf(e.charAt(c++))<<2|(s=r.indexOf(e.charAt(c++)))>>4,i=(15&s)<<4|(o=r.indexOf(e.charAt(c++)))>>2,a=(3&o)<<6|(u=r.indexOf(e.charAt(c++))),f[l++]=n,64!==o&&(f[l++]=i),64!==u&&(f[l++]=a);return f},uo}var lo,ho,fo,po,go={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}};var yo=null;yo="undefined"!=typeof Promise?Promise:function(){if(po)return fo;po=1;var e=function(){if(ho)return lo;ho=1;var e,t,r=v.MutationObserver||v.WebKitMutationObserver;if(process.browser)if(r){var n=0,i=new r(u),a=v.document.createTextNode("");i.observe(a,{characterData:!0}),e=function(){a.data=n=++n%2}}else if(v.setImmediate||void 0===v.MessageChannel)e="document"in v&&"onreadystatechange"in v.document.createElement("script")?function(){var e=v.document.createElement("script");e.onreadystatechange=function(){u(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},v.document.documentElement.appendChild(e)}:function(){setTimeout(u,0)};else{var s=new v.MessageChannel;s.port1.onmessage=u,e=function(){s.port2.postMessage(0)}}else e=function(){process.nextTick(u)};var o=[];function u(){var e,r;t=!0;for(var n=o.length;n;){for(r=o,o=[],e=-1;++e<n;)r[e]();n=o.length}t=!1}return lo=function(r){1!==o.push(r)||t||e()}}();function t(){}var r={},n=["REJECTED"],i=["FULFILLED"],a=["PENDING"];if(!process.browser)var s=["UNHANDLED"];function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=a,this.queue=[],this.outcome=void 0,process.browser||(this.handled=s),e!==t&&h(this,e)}function u(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function c(t,n,i){e((function(){var e;try{e=n(i)}catch(e){return r.reject(t,e)}e===t?r.reject(t,new TypeError("Cannot resolve promise with itself")):r.resolve(t,e)}))}function l(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function i(t){n||(n=!0,r.reject(e,t))}function a(t){n||(n=!0,r.resolve(e,t))}var s=f((function(){t(a,i)}));"error"===s.status&&i(s.value)}function f(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}return fo=o,o.prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then((function(r){return t.resolve(e()).then((function(){return r}))}),(function(r){return t.resolve(e()).then((function(){throw r}))}))},o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,r){if("function"!=typeof e&&this.state===i||"function"!=typeof r&&this.state===n)return this;var o=new this.constructor(t);return process.browser||this.handled===s&&(this.handled=null),this.state!==a?c(o,this.state===i?e:r,this.outcome):this.queue.push(new u(o,e,r)),o},u.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},u.prototype.otherCallFulfilled=function(e){c(this.promise,this.onFulfilled,e)},u.prototype.callRejected=function(e){r.reject(this.promise,e)},u.prototype.otherCallRejected=function(e){c(this.promise,this.onRejected,e)},r.resolve=function(e,t){var n=f(l,t);if("error"===n.status)return r.reject(e,n.value);var a=n.value;if(a)h(e,a);else{e.state=i,e.outcome=t;for(var s=-1,o=e.queue.length;++s<o;)e.queue[s].callFulfilled(t)}return e},r.reject=function(t,r){t.state=n,t.outcome=r,process.browser||t.handled===s&&e((function(){t.handled===s&&process.emit("unhandledRejection",r,t)}));for(var i=-1,a=t.queue.length;++i<a;)t.queue[i].callRejected(r);return t},o.resolve=function(e){return e instanceof this?e:r.resolve(new this(t),e)},o.reject=function(e){var n=new this(t);return r.reject(n,e)},o.all=function(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var i=e.length,a=!1;if(!i)return this.resolve([]);for(var s=new Array(i),o=0,u=-1,c=new this(t);++u<i;)l(e[u],u);return c;function l(e,t){n.resolve(e).then((function(e){s[t]=e,++o!==i||a||(a=!0,r.resolve(c,s))}),(function(e){a||(a=!0,r.reject(c,e))}))}},o.race=function(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var i=e.length,a=!1;if(!i)return this.resolve([]);for(var s,o=-1,u=new this(t);++o<i;)s=e[o],n.resolve(s).then((function(e){a||(a=!0,r.resolve(u,e))}),(function(e){a||(a=!0,r.reject(u,e))}));return u},fo}();var mo,vo={Promise:yo};function Co(){return mo||(mo=1,function(e){var t=os,r=co(),n=go,i=vo;function a(e){return e}function s(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}e.newBlob=function(t,r){e.checkSupport("blob");try{return new Blob([t],{type:r})}catch(e){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return n.append(t),n.getBlob(r)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var o={stringifyByChunk:function(e,t,r){var n=[],i=0,a=e.length;if(a<=r)return String.fromCharCode.apply(null,e);for(;i<a;)"array"===t||"nodebuffer"===t?n.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+r,a)))):n.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+r,a)))),i+=r;return n.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return t.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return t.nodebuffer&&1===String.fromCharCode.apply(null,n.allocBuffer(1)).length}catch(e){return!1}}()}};function u(t){var r=65536,n=e.getTypeOf(t),i=!0;if("uint8array"===n?i=o.applyCanBeUsed.uint8array:"nodebuffer"===n&&(i=o.applyCanBeUsed.nodebuffer),i)for(;r>1;)try{return o.stringifyByChunk(t,n,r)}catch(e){r=Math.floor(r/2)}return o.stringifyByChar(t)}function c(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}e.applyFromCharCode=u;var l={};l.string={string:a,array:function(e){return s(e,new Array(e.length))},arraybuffer:function(e){return l.string.uint8array(e).buffer},uint8array:function(e){return s(e,new Uint8Array(e.length))},nodebuffer:function(e){return s(e,n.allocBuffer(e.length))}},l.array={string:u,array:a,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return n.newBufferFrom(e)}},l.arraybuffer={string:function(e){return u(new Uint8Array(e))},array:function(e){return c(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:a,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return n.newBufferFrom(new Uint8Array(e))}},l.uint8array={string:u,array:function(e){return c(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:a,nodebuffer:function(e){return n.newBufferFrom(e)}},l.nodebuffer={string:u,array:function(e){return c(e,new Array(e.length))},arraybuffer:function(e){return l.nodebuffer.uint8array(e).buffer},uint8array:function(e){return c(e,new Uint8Array(e.length))},nodebuffer:a},e.transformTo=function(t,r){if(r||(r=""),!t)return r;e.checkSupport(t);var n=e.getTypeOf(r);return l[n][t](r)},e.resolve=function(e){for(var t=e.split("/"),r=[],n=0;n<t.length;n++){var i=t[n];"."===i||""===i&&0!==n&&n!==t.length-1||(".."===i?r.pop():r.push(i))}return r.join("/")},e.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":t.nodebuffer&&n.isBuffer(e)?"nodebuffer":t.uint8array&&e instanceof Uint8Array?"uint8array":t.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},e.checkSupport=function(e){if(!t[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},e.MAX_VALUE_16BITS=65535,e.MAX_VALUE_32BITS=-1,e.pretty=function(e){var t,r,n="";for(r=0;r<(e||"").length;r++)n+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return n},e.delay=function(e,t,r){setImmediate((function(){e.apply(r||null,t||[])}))},e.inherits=function(e,t){var r=function(){};r.prototype=t.prototype,e.prototype=new r},e.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},e.prepareContent=function(n,a,o,u,c){return i.Promise.resolve(a).then((function(e){return t.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new i.Promise((function(t,r){var n=new FileReader;n.onload=function(e){t(e.target.result)},n.onerror=function(e){r(e.target.error)},n.readAsArrayBuffer(e)})):e})).then((function(a){var l,h=e.getTypeOf(a);return h?("arraybuffer"===h?a=e.transformTo("uint8array",a):"string"===h&&(c?a=r.decode(a):o&&!0!==u&&(a=s(l=a,t.uint8array?new Uint8Array(l.length):new Array(l.length)))),a):i.Promise.reject(new Error("Can't read the data of '"+n+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))}))}}(ss)),ss}function Eo(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}!function(e,t){if(!e.setImmediate){var r,n,i,a,s,o=1,u={},c=!1,l=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){process.nextTick((function(){d(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){d(e.data)},r=function(e){i.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(n=l.documentElement,r=function(e){var t=l.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,n.removeChild(t),t=null},n.appendChild(t)}):r=function(e){setTimeout(d,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&d(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),r=function(t){e.postMessage(a+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var i={callback:e,args:t};return u[o]=i,r(o),o++},h.clearImmediate=f}function f(e){delete u[e]}function d(e){if(c)setTimeout(d,0,e);else{var r=u[e];if(r){c=!0;try{!function(e){var r=e.callback,n=e.args;switch(n.length){case 0:r();break;case 1:r(n[0]);break;case 2:r(n[0],n[1]);break;case 3:r(n[0],n[1],n[2]);break;default:r.apply(t,n)}}(r)}finally{f(e),c=!1}}}}}("undefined"==typeof self?v:self),Eo.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r<this._listeners[e].length;r++)this._listeners[e][r].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",(function(e){t.processChunk(e)})),e.on("end",(function(){t.end()})),e.on("error",(function(e){t.error(e)})),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var e=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}};var bo=Eo;!function(e){for(var t=Co(),r=os,n=go,i=bo,a=new Array(256),s=0;s<256;s++)a[s]=s>=252?6:s>=248?5:s>=240?4:s>=224?3:s>=192?2:1;a[254]=a[254]=1;function o(){i.call(this,"utf-8 decode"),this.leftOver=null}function u(){i.call(this,"utf-8 encode")}e.utf8encode=function(e){return r.nodebuffer?n.newBufferFrom(e,"utf-8"):function(e){var t,n,i,a,s,o=e.length,u=0;for(a=0;a<o;a++)55296==(64512&(n=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(i=e.charCodeAt(a+1)))&&(n=65536+(n-55296<<10)+(i-56320),a++),u+=n<128?1:n<2048?2:n<65536?3:4;for(t=r.uint8array?new Uint8Array(u):new Array(u),s=0,a=0;s<u;a++)55296==(64512&(n=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(i=e.charCodeAt(a+1)))&&(n=65536+(n-55296<<10)+(i-56320),a++),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t}(e)},e.utf8decode=function(e){return r.nodebuffer?t.transformTo("nodebuffer",e).toString("utf-8"):function(e){var r,n,i,s,o=e.length,u=new Array(2*o);for(n=0,r=0;r<o;)if((i=e[r++])<128)u[n++]=i;else if((s=a[i])>4)u[n++]=65533,r+=s-1;else{for(i&=2===s?31:3===s?15:7;s>1&&r<o;)i=i<<6|63&e[r++],s--;s>1?u[n++]=65533:i<65536?u[n++]=i:(i-=65536,u[n++]=55296|i>>10&1023,u[n++]=56320|1023&i)}return u.length!==n&&(u.subarray?u=u.subarray(0,n):u.length=n),t.applyFromCharCode(u)}(e=t.transformTo(r.uint8array?"uint8array":"array",e))},t.inherits(o,i),o.prototype.processChunk=function(n){var i=t.transformTo(r.uint8array?"uint8array":"array",n.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var s=i;(i=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),i.set(s,this.leftOver.length)}else i=this.leftOver.concat(i);this.leftOver=null}var o=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}(i),u=i;o!==i.length&&(r.uint8array?(u=i.subarray(0,o),this.leftOver=i.subarray(o,i.length)):(u=i.slice(0,o),this.leftOver=i.slice(o,i.length))),this.push({data:e.utf8decode(u),meta:n.meta})},o.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:e.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},e.Utf8DecodeWorker=o,t.inherits(u,i),u.prototype.processChunk=function(t){this.push({data:e.utf8encode(t.data),meta:t.meta})},e.Utf8EncodeWorker=u}(as);var So=bo,To=Co();function _o(e){So.call(this,"ConvertWorker to "+e),this.destType=e}To.inherits(_o,So),_o.prototype.processChunk=function(e){this.push({data:To.transformTo(this.destType,e.data),meta:e.meta})};var wo,Io,Ao=_o;var Bo=Co(),ko=Ao,No=bo,Ro=co(),Lo=vo,Do=null;if(os.nodestream)try{Do=function(){if(Io)return wo;Io=1;var e=io().Readable;function t(t,r,n){e.call(this,r),this._helper=t;var i=this;t.on("data",(function(e,t){i.push(e)||i._helper.pause(),n&&n(t)})).on("error",(function(e){i.emit("error",e)})).on("end",(function(){i.push(null)}))}return Co().inherits(t,e),t.prototype._read=function(){this._helper.resume()},wo=t}()}catch(e){}function Uo(e,t){return new Lo.Promise((function(r,n){var i=[],a=e._internalType,s=e._outputType,o=e._mimeType;e.on("data",(function(e,r){i.push(e),t&&t(r)})).on("error",(function(e){i=[],n(e)})).on("end",(function(){try{var e=function(e,t,r){switch(e){case"blob":return Bo.newBlob(Bo.transformTo("arraybuffer",t),r);case"base64":return Ro.encode(t);default:return Bo.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,a=0;for(r=0;r<t.length;r++)a+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(a),r=0;r<t.length;r++)i.set(t[r],n),n+=t[r].length;return i;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(a,i),o);r(e)}catch(e){n(e)}i=[]})).resume()}))}function xo(e,t,r){var n=t;switch(t){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string"}try{this._internalType=n,this._outputType=t,this._mimeType=r,Bo.checkSupport(n),this._worker=e.pipe(new ko(n)),e.lock()}catch(e){this._worker=new No("error"),this._worker.error(e)}}xo.prototype={accumulate:function(e){return Uo(this,e)},on:function(e,t){var r=this;return"data"===e?this._worker.on(e,(function(e){t.call(r,e.data,e.meta)})):this._worker.on(e,(function(){Bo.delay(t,arguments,r)})),this},resume:function(){return Bo.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(Bo.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new Do(this,{objectMode:"nodebuffer"!==this._outputType},e)}};var Oo=xo,Po={base64:!1,binary:!1,dir:!1,createFolders:!0,date:null,compression:null,compressionOptions:null,comment:null,unixPermissions:null,dosPermissions:null},Vo=Co(),Ko=bo;function Mo(e){Ko.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=Vo.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}Vo.inherits(Mo,Ko),Mo.prototype.cleanUp=function(){Ko.prototype.cleanUp.call(this),this.data=null},Mo.prototype.resume=function(){return!!Ko.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,Vo.delay(this._tickAndRepeat,[],this)),!0)},Mo.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(Vo.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},Mo.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})};var Fo=Mo,zo=Co();var jo=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var qo=function(e,t){return void 0!==e&&e.length?"string"!==zo.getTypeOf(e)?function(e,t,r,n){var i=jo,a=n+r;e^=-1;for(var s=n;s<a;s++)e=e>>>8^i[255&(e^t[s])];return-1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=jo,a=n+r;e^=-1;for(var s=n;s<a;s++)e=e>>>8^i[255&(e^t.charCodeAt(s))];return-1^e}(0|t,e,e.length,0):0},Ho=bo,Go=qo;function Wo(){Ho.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}Co().inherits(Wo,Ho),Wo.prototype.processChunk=function(e){this.streamInfo.crc32=Go(e.data,this.streamInfo.crc32||0),this.push(e)};var Qo=Wo,Yo=Co(),Zo=bo;function Xo(e){Zo.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}Yo.inherits(Xo,Zo),Xo.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}Zo.prototype.processChunk.call(this,e)};var $o=vo,Jo=Fo,eu=Qo,tu=Xo;function ru(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}ru.prototype={getContentWorker:function(){var e=new Jo($o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new tu("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new Jo($o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},ru.createWorkerFrom=function(e,t,r){return e.pipe(new eu).pipe(new tu("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new tu("compressedSize")).withStreamInfo("compression",t)};var nu=ru,iu=Oo,au=Fo,su=as,ou=nu,uu=bo,cu=function(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}};cu.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var n="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var i=!this._dataBinary;i&&!n&&(t=t.pipe(new su.Utf8EncodeWorker)),!i&&n&&(t=t.pipe(new su.Utf8DecodeWorker))}catch(e){(t=new uu("error")).error(e)}return new iu(t,r,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof ou&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new su.Utf8EncodeWorker)),ou.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof ou?this._data.getContentWorker():this._data instanceof uu?this._data:new au(this._data)}};for(var lu=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],hu=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},fu=0;fu<lu.length;fu++)cu.prototype[lu[fu]]=hu;var du=cu,pu={},gu={},yu={},mu={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.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,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var a=0;a<n;a++)e[i+a]=t[r+a]},flattenChunks:function(e){var t,r,n,i,a,s;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(s=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)a=e[t],s.set(a,i),i+=a.length;return s}},i={arraySet:function(e,t,r,n,i){for(var a=0;a<n;a++)e[i+a]=t[r+a]},flattenChunks:function(e){return[].concat.apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(mu);var vu={},Cu={},Eu={},bu=mu,Su=0,Tu=1;function _u(e){for(var t=e.length;--t>=0;)e[t]=0}var wu=0,Iu=29,Au=256,Bu=Au+1+Iu,ku=30,Nu=19,Ru=2*Bu+1,Lu=15,Du=16,Uu=7,xu=256,Ou=16,Pu=17,Vu=18,Ku=[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],Mu=[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],Fu=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],zu=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ju=new Array(2*(Bu+2));_u(ju);var qu=new Array(2*ku);_u(qu);var Hu=new Array(512);_u(Hu);var Gu=new Array(256);_u(Gu);var Wu=new Array(Iu);_u(Wu);var Qu,Yu,Zu,Xu=new Array(ku);function $u(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function Ju(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function ec(e){return e<256?Hu[e]:Hu[256+(e>>>7)]}function tc(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function rc(e,t,r){e.bi_valid>Du-r?(e.bi_buf|=t<<e.bi_valid&65535,tc(e,e.bi_buf),e.bi_buf=t>>Du-e.bi_valid,e.bi_valid+=r-Du):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function nc(e,t,r){rc(e,r[2*t],r[2*t+1])}function ic(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function ac(e,t,r){var n,i,a=new Array(Lu+1),s=0;for(n=1;n<=Lu;n++)a[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=ic(a[o]++,o))}}function sc(e){var t;for(t=0;t<Bu;t++)e.dyn_ltree[2*t]=0;for(t=0;t<ku;t++)e.dyn_dtree[2*t]=0;for(t=0;t<Nu;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*xu]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function oc(e){e.bi_valid>8?tc(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 uc(e,t,r,n){var i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]}function cc(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&uc(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!uc(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function lc(e,t,r){var n,i,a,s,o=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?nc(e,i,t):(nc(e,(a=Gu[i])+Au+1,t),0!==(s=Ku[a])&&rc(e,i-=Wu[a],s),nc(e,a=ec(--n),r),0!==(s=Mu[a])&&rc(e,n-=Xu[a],s))}while(o<e.last_lit);nc(e,xu,t)}function hc(e,t){var r,n,i,a=t.dyn_tree,s=t.stat_desc.static_tree,o=t.stat_desc.has_stree,u=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=Ru,r=0;r<u;r++)0!==a[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=s[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)cc(e,a,r);i=u;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],cc(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,cc(e,a,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,a,s,o,u=t.dyn_tree,c=t.max_code,l=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(a=0;a<=Lu;a++)e.bl_count[a]=0;for(u[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<Ru;r++)(a=u[2*u[2*(n=e.heap[r])+1]+1]+1)>p&&(a=p,g++),u[2*n+1]=a,n>c||(e.bl_count[a]++,s=0,n>=d&&(s=f[n-d]),o=u[2*n],e.opt_len+=o*(a+s),h&&(e.static_len+=o*(l[2*n+1]+s)));if(0!==g){do{for(a=p-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(a=p;0!==a;a--)for(n=e.bl_count[a];0!==n;)(i=e.heap[--r])>c||(u[2*i+1]!==a&&(e.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),n--)}}(e,t),ac(a,c,e.bl_count)}function fc(e,t,r){var n,i,a=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=t[2*(n+1)+1],++o<u&&i===s||(o<c?e.bl_tree[2*i]+=o:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[2*Ou]++):o<=10?e.bl_tree[2*Pu]++:e.bl_tree[2*Vu]++,o=0,a=i,0===s?(u=138,c=3):i===s?(u=6,c=3):(u=7,c=4))}function dc(e,t,r){var n,i,a=-1,s=t[1],o=0,u=7,c=4;for(0===s&&(u=138,c=3),n=0;n<=r;n++)if(i=s,s=t[2*(n+1)+1],!(++o<u&&i===s)){if(o<c)do{nc(e,i,e.bl_tree)}while(0!=--o);else 0!==i?(i!==a&&(nc(e,i,e.bl_tree),o--),nc(e,Ou,e.bl_tree),rc(e,o-3,2)):o<=10?(nc(e,Pu,e.bl_tree),rc(e,o-3,3)):(nc(e,Vu,e.bl_tree),rc(e,o-11,7));o=0,a=i,0===s?(u=138,c=3):i===s?(u=6,c=3):(u=7,c=4)}}_u(Xu);var pc=!1;function gc(e,t,r,n){rc(e,(wu<<1)+(n?1:0),3),function(e,t,r,n){oc(e),n&&(tc(e,r),tc(e,~r)),bu.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}Eu._tr_init=function(e){pc||(!function(){var e,t,r,n,i,a=new Array(Lu+1);for(r=0,n=0;n<Iu-1;n++)for(Wu[n]=r,e=0;e<1<<Ku[n];e++)Gu[r++]=n;for(Gu[r-1]=n,i=0,n=0;n<16;n++)for(Xu[n]=i,e=0;e<1<<Mu[n];e++)Hu[i++]=n;for(i>>=7;n<ku;n++)for(Xu[n]=i<<7,e=0;e<1<<Mu[n]-7;e++)Hu[256+i++]=n;for(t=0;t<=Lu;t++)a[t]=0;for(e=0;e<=143;)ju[2*e+1]=8,e++,a[8]++;for(;e<=255;)ju[2*e+1]=9,e++,a[9]++;for(;e<=279;)ju[2*e+1]=7,e++,a[7]++;for(;e<=287;)ju[2*e+1]=8,e++,a[8]++;for(ac(ju,Bu+1,a),e=0;e<ku;e++)qu[2*e+1]=5,qu[2*e]=ic(e,5);Qu=new $u(ju,Ku,Au+1,Bu,Lu),Yu=new $u(qu,Mu,0,ku,Lu),Zu=new $u(new Array(0),Fu,0,Nu,Uu)}(),pc=!0),e.l_desc=new Ju(e.dyn_ltree,Qu),e.d_desc=new Ju(e.dyn_dtree,Yu),e.bl_desc=new Ju(e.bl_tree,Zu),e.bi_buf=0,e.bi_valid=0,sc(e)},Eu._tr_stored_block=gc,Eu._tr_flush_block=function(e,t,r,n){var i,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 Su;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return Tu;for(t=32;t<Au;t++)if(0!==e.dyn_ltree[2*t])return Tu;return Su}(e)),hc(e,e.l_desc),hc(e,e.d_desc),s=function(e){var t;for(fc(e,e.dyn_ltree,e.l_desc.max_code),fc(e,e.dyn_dtree,e.d_desc.max_code),hc(e,e.bl_desc),t=Nu-1;t>=3&&0===e.bl_tree[2*zu[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?gc(e,t,r,n):4===e.strategy||a===i?(rc(e,2+(n?1:0),3),lc(e,ju,qu)):(rc(e,4+(n?1:0),3),function(e,t,r,n){var i;for(rc(e,t-257,5),rc(e,r-1,5),rc(e,n-4,4),i=0;i<n;i++)rc(e,e.bl_tree[2*zu[i]+1],3);dc(e,e.dyn_ltree,t-1),dc(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),lc(e,e.dyn_ltree,e.dyn_dtree)),sc(e),n&&oc(e)},Eu._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*(Gu[r]+Au+1)]++,e.dyn_dtree[2*ec(t)]++),e.last_lit===e.lit_bufsize-1},Eu._tr_align=function(e){rc(e,2,3),nc(e,xu,ju),function(e){16===e.bi_valid?(tc(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)};var yc=function(e,t,r,n){for(var i=65535&e|0,a=e>>>16&65535|0,s=0;0!==r;){r-=s=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--s);i%=65521,a%=65521}return i|a<<16|0};var mc=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var vc,Cc=function(e,t,r,n){var i=mc,a=n+r;e^=-1;for(var s=n;s<a;s++)e=e>>>8^i[255&(e^t[s])];return-1^e},Ec={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"},bc=mu,Sc=Eu,Tc=yc,_c=Cc,wc=Ec,Ic=0,Ac=4,Bc=0,kc=-2,Nc=-1,Rc=4,Lc=2,Dc=8,Uc=9,xc=286,Oc=30,Pc=19,Vc=2*xc+1,Kc=15,Mc=3,Fc=258,zc=Fc+Mc+1,jc=42,qc=103,Hc=113,Gc=666,Wc=1,Qc=2,Yc=3,Zc=4;function Xc(e,t){return e.msg=wc[t],t}function $c(e){return(e<<1)-(e>4?9:0)}function Jc(e){for(var t=e.length;--t>=0;)e[t]=0}function el(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(bc.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 tl(e,t){Sc._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,el(e.strm)}function rl(e,t){e.pending_buf[e.pending++]=t}function nl(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function il(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,bc.arraySet(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=Tc(e.adler,t,i,r):2===e.state.wrap&&(e.adler=_c(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function al(e,t){var r,n,i=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match,u=e.strstart>e.w_size-zc?e.strstart-(e.w_size-zc):0,c=e.window,l=e.w_mask,h=e.prev,f=e.strstart+Fc,d=c[a+s-1],p=c[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(c[(r=t)+s]===p&&c[r+s-1]===d&&c[r]===c[a]&&c[++r]===c[a+1]){a+=2,r++;do{}while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&a<f);if(n=Fc-(f-a),a=f-Fc,n>s){if(e.match_start=t,s=n,n>=o)break;d=c[a+s-1],p=c[a+s]}}}while((t=h[t&l])>u&&0!=--i);return s<=e.lookahead?s:e.lookahead}function sl(e){var t,r,n,i,a,s=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-zc)){bc.arraySet(e.window,e.window,s,s,0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=s?n-s:0}while(--r);t=r=s;do{n=e.prev[--t],e.prev[t]=n>=s?n-s:0}while(--r);i+=s}if(0===e.strm.avail_in)break;if(r=il(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=Mc)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+Mc-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<Mc)););}while(e.lookahead<zc&&0!==e.strm.avail_in)}function ol(e,t){for(var r,n;;){if(e.lookahead<zc){if(sl(e),e.lookahead<zc&&t===Ic)return Wc;if(0===e.lookahead)break}if(r=0,e.lookahead>=Mc&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Mc-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-zc&&(e.match_length=al(e,r)),e.match_length>=Mc)if(n=Sc._tr_tally(e,e.strstart-e.match_start,e.match_length-Mc),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Mc){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Mc-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 n=Sc._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(tl(e,!1),0===e.strm.avail_out))return Wc}return e.insert=e.strstart<Mc-1?e.strstart:Mc-1,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):e.last_lit&&(tl(e,!1),0===e.strm.avail_out)?Wc:Qc}function ul(e,t){for(var r,n,i;;){if(e.lookahead<zc){if(sl(e),e.lookahead<zc&&t===Ic)return Wc;if(0===e.lookahead)break}if(r=0,e.lookahead>=Mc&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Mc-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=Mc-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-zc&&(e.match_length=al(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===Mc&&e.strstart-e.match_start>4096)&&(e.match_length=Mc-1)),e.prev_length>=Mc&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Mc,n=Sc._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Mc),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Mc-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=Mc-1,e.strstart++,n&&(tl(e,!1),0===e.strm.avail_out))return Wc}else if(e.match_available){if((n=Sc._tr_tally(e,0,e.window[e.strstart-1]))&&tl(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return Wc}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Sc._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Mc-1?e.strstart:Mc-1,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):e.last_lit&&(tl(e,!1),0===e.strm.avail_out)?Wc:Qc}function cl(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function ll(){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=Dc,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 bc.Buf16(2*Vc),this.dyn_dtree=new bc.Buf16(2*(2*Oc+1)),this.bl_tree=new bc.Buf16(2*(2*Pc+1)),Jc(this.dyn_ltree),Jc(this.dyn_dtree),Jc(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new bc.Buf16(Kc+1),this.heap=new bc.Buf16(2*xc+1),Jc(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new bc.Buf16(2*xc+1),Jc(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 hl(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=Lc,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?jc:Hc,e.adler=2===t.wrap?0:1,t.last_flush=Ic,Sc._tr_init(t),Bc):Xc(e,kc)}function fl(e){var t=hl(e);return t===Bc&&function(e){e.window_size=2*e.w_size,Jc(e.head),e.max_lazy_match=vc[e.level].max_lazy,e.good_match=vc[e.level].good_length,e.nice_match=vc[e.level].nice_length,e.max_chain_length=vc[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Mc-1,e.match_available=0,e.ins_h=0}(e.state),t}function dl(e,t,r,n,i,a){if(!e)return kc;var s=1;if(t===Nc&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>Uc||r!==Dc||n<8||n>15||t<0||t>9||a<0||a>Rc)return Xc(e,kc);8===n&&(n=9);var o=new ll;return e.state=o,o.strm=e,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+Mc-1)/Mc),o.window=new bc.Buf8(2*o.w_size),o.head=new bc.Buf16(o.hash_size),o.prev=new bc.Buf16(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new bc.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=a,o.method=r,fl(e)}vc=[new cl(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(sl(e),0===e.lookahead&&t===Ic)return Wc;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,tl(e,!1),0===e.strm.avail_out))return Wc;if(e.strstart-e.block_start>=e.w_size-zc&&(tl(e,!1),0===e.strm.avail_out))return Wc}return e.insert=0,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):(e.strstart>e.block_start&&(tl(e,!1),e.strm.avail_out),Wc)})),new cl(4,4,8,4,ol),new cl(4,5,16,8,ol),new cl(4,6,32,32,ol),new cl(4,4,16,16,ul),new cl(8,16,32,32,ul),new cl(8,16,128,128,ul),new cl(8,32,128,256,ul),new cl(32,128,258,1024,ul),new cl(32,258,258,4096,ul)],Cu.deflateInit=function(e,t){return dl(e,t,Dc,15,8,0)},Cu.deflateInit2=dl,Cu.deflateReset=fl,Cu.deflateResetKeep=hl,Cu.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?kc:(e.state.gzhead=t,Bc):kc},Cu.deflate=function(e,t){var r,n,i,a;if(!e||!e.state||t>5||t<0)return e?Xc(e,kc):kc;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===Gc&&t!==Ac)return Xc(e,0===e.avail_out?-5:kc);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===jc)if(2===n.wrap)e.adler=0,rl(n,31),rl(n,139),rl(n,8),n.gzhead?(rl(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)),rl(n,255&n.gzhead.time),rl(n,n.gzhead.time>>8&255),rl(n,n.gzhead.time>>16&255),rl(n,n.gzhead.time>>24&255),rl(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),rl(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(rl(n,255&n.gzhead.extra.length),rl(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=_c(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(rl(n,0),rl(n,0),rl(n,0),rl(n,0),rl(n,0),rl(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),rl(n,3),n.status=Hc);else{var s=Dc+(n.w_bits-8<<4)<<8;s|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(s|=32),s+=31-s%31,n.status=Hc,nl(n,s),0!==n.strstart&&(nl(n,e.adler>>>16),nl(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),el(e),i=n.pending,n.pending!==n.pending_buf_size));)rl(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),el(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,rl(n,a)}while(0!==a);n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),el(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,rl(n,a)}while(0!==a);n.gzhead.hcrc&&n.pending>i&&(e.adler=_c(e.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.status=qc)}else n.status=qc;if(n.status===qc&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&el(e),n.pending+2<=n.pending_buf_size&&(rl(n,255&e.adler),rl(n,e.adler>>8&255),e.adler=0,n.status=Hc)):n.status=Hc),0!==n.pending){if(el(e),0===e.avail_out)return n.last_flush=-1,Bc}else if(0===e.avail_in&&$c(t)<=$c(r)&&t!==Ac)return Xc(e,-5);if(n.status===Gc&&0!==e.avail_in)return Xc(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==Ic&&n.status!==Gc){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(sl(e),0===e.lookahead)){if(t===Ic)return Wc;break}if(e.match_length=0,r=Sc._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(tl(e,!1),0===e.strm.avail_out))return Wc}return e.insert=0,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):e.last_lit&&(tl(e,!1),0===e.strm.avail_out)?Wc:Qc}(n,t):3===n.strategy?function(e,t){for(var r,n,i,a,s=e.window;;){if(e.lookahead<=Fc){if(sl(e),e.lookahead<=Fc&&t===Ic)return Wc;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=Mc&&e.strstart>0&&(n=s[i=e.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=e.strstart+Fc;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);e.match_length=Fc-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Mc?(r=Sc._tr_tally(e,1,e.match_length-Mc),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Sc._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(tl(e,!1),0===e.strm.avail_out))return Wc}return e.insert=0,t===Ac?(tl(e,!0),0===e.strm.avail_out?Yc:Zc):e.last_lit&&(tl(e,!1),0===e.strm.avail_out)?Wc:Qc}(n,t):vc[n.level].func(n,t);if(o!==Yc&&o!==Zc||(n.status=Gc),o===Wc||o===Yc)return 0===e.avail_out&&(n.last_flush=-1),Bc;if(o===Qc&&(1===t?Sc._tr_align(n):5!==t&&(Sc._tr_stored_block(n,0,0,!1),3===t&&(Jc(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),el(e),0===e.avail_out))return n.last_flush=-1,Bc}return t!==Ac?Bc:n.wrap<=0?1:(2===n.wrap?(rl(n,255&e.adler),rl(n,e.adler>>8&255),rl(n,e.adler>>16&255),rl(n,e.adler>>24&255),rl(n,255&e.total_in),rl(n,e.total_in>>8&255),rl(n,e.total_in>>16&255),rl(n,e.total_in>>24&255)):(nl(n,e.adler>>>16),nl(n,65535&e.adler)),el(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Bc:1)},Cu.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==jc&&69!==t&&73!==t&&91!==t&&t!==qc&&t!==Hc&&t!==Gc?Xc(e,kc):(e.state=null,t===Hc?Xc(e,-3):Bc):kc},Cu.deflateSetDictionary=function(e,t){var r,n,i,a,s,o,u,c,l=t.length;if(!e||!e.state)return kc;if(2===(a=(r=e.state).wrap)||1===a&&r.status!==jc||r.lookahead)return kc;for(1===a&&(e.adler=Tc(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===a&&(Jc(r.head),r.strstart=0,r.block_start=0,r.insert=0),c=new bc.Buf8(r.w_size),bc.arraySet(c,t,l-r.w_size,r.w_size,0),t=c,l=r.w_size),s=e.avail_in,o=e.next_in,u=e.input,e.avail_in=l,e.next_in=0,e.input=t,sl(r);r.lookahead>=Mc;){n=r.strstart,i=r.lookahead-(Mc-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+Mc-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=Mc-1,sl(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Mc-1,r.match_available=0,e.next_in=o,e.input=u,e.avail_in=s,r.wrap=a,Bc},Cu.deflateInfo="pako deflate (from Nodeca project)";var pl={},gl=mu,yl=!0,ml=!0;try{String.fromCharCode.apply(null,[0])}catch(xn){yl=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(xn){ml=!1}for(var vl=new gl.Buf8(256),Cl=0;Cl<256;Cl++)vl[Cl]=Cl>=252?6:Cl>=248?5:Cl>=240?4:Cl>=224?3:Cl>=192?2:1;function El(e,t){if(t<65534&&(e.subarray&&ml||!e.subarray&&yl))return String.fromCharCode.apply(null,gl.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}vl[254]=vl[254]=1,pl.string2buf=function(e){var t,r,n,i,a,s=e.length,o=0;for(i=0;i<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<s&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new gl.Buf8(o),a=0,i=0;a<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<s&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),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},pl.buf2binstring=function(e){return El(e,e.length)},pl.binstring2buf=function(e){for(var t=new gl.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},pl.buf2string=function(e,t){var r,n,i,a,s=t||e.length,o=new Array(2*s);for(n=0,r=0;r<s;)if((i=e[r++])<128)o[n++]=i;else if((a=vl[i])>4)o[n++]=65533,r+=a-1;else{for(i&=2===a?31:3===a?15:7;a>1&&r<s;)i=i<<6|63&e[r++],a--;a>1?o[n++]=65533:i<65536?o[n++]=i:(i-=65536,o[n++]=55296|i>>10&1023,o[n++]=56320|1023&i)}return El(o,n)},pl.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+vl[e[r]]>t?r:t};var bl=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},Sl=Cu,Tl=mu,_l=pl,wl=Ec,Il=bl,Al=Object.prototype.toString,Bl=0,kl=-1,Nl=0,Rl=8;function Ll(e){if(!(this instanceof Ll))return new Ll(e);this.options=Tl.assign({level:kl,method:Rl,chunkSize:16384,windowBits:15,memLevel:8,strategy:Nl,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 Il,this.strm.avail_out=0;var r=Sl.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Bl)throw new Error(wl[r]);if(t.header&&Sl.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?_l.string2buf(t.dictionary):"[object ArrayBuffer]"===Al.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=Sl.deflateSetDictionary(this.strm,n))!==Bl)throw new Error(wl[r]);this._dict_set=!0}}function Dl(e,t){var r=new Ll(t);if(r.push(e,!0),r.err)throw r.msg||wl[r.err];return r.result}Ll.prototype.push=function(e,t){var r,n,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=_l.string2buf(e):"[object ArrayBuffer]"===Al.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new Tl.Buf8(a),i.next_out=0,i.avail_out=a),1!==(r=Sl.deflate(i,n))&&r!==Bl)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(_l.buf2binstring(Tl.shrinkBuf(i.output,i.next_out))):this.onData(Tl.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=Sl.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Bl):2!==n||(this.onEnd(Bl),i.avail_out=0,!0)},Ll.prototype.onData=function(e){this.chunks.push(e)},Ll.prototype.onEnd=function(e){e===Bl&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Tl.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},vu.Deflate=Ll,vu.deflate=Dl,vu.deflateRaw=function(e,t){return(t=t||{}).raw=!0,Dl(e,t)},vu.gzip=function(e,t){return(t=t||{}).gzip=!0,Dl(e,t)};var Ul={},xl={},Ol=mu,Pl=15,Vl=[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],Kl=[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],Ml=[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],Fl=[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],zl=mu,jl=yc,ql=Cc,Hl=function(e,t){var r,n,i,a,s,o,u,c,l,h,f,d,p,g,y,m,v,C,E,b,S,T,_,w,I;r=e.state,n=e.next_in,w=e.input,i=n+(e.avail_in-5),a=e.next_out,I=e.output,s=a-(t-e.avail_out),o=a+(e.avail_out-257),u=r.dmax,c=r.wsize,l=r.whave,h=r.wnext,f=r.window,d=r.hold,p=r.bits,g=r.lencode,y=r.distcode,m=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;e:do{p<15&&(d+=w[n++]<<p,p+=8,d+=w[n++]<<p,p+=8),C=g[d&m];t:for(;;){if(d>>>=E=C>>>24,p-=E,0===(E=C>>>16&255))I[a++]=65535&C;else{if(!(16&E)){if(0==(64&E)){C=g[(65535&C)+(d&(1<<E)-1)];continue t}if(32&E){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&C,(E&=15)&&(p<E&&(d+=w[n++]<<p,p+=8),b+=d&(1<<E)-1,d>>>=E,p-=E),p<15&&(d+=w[n++]<<p,p+=8,d+=w[n++]<<p,p+=8),C=y[d&v];r:for(;;){if(d>>>=E=C>>>24,p-=E,!(16&(E=C>>>16&255))){if(0==(64&E)){C=y[(65535&C)+(d&(1<<E)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(S=65535&C,p<(E&=15)&&(d+=w[n++]<<p,(p+=8)<E&&(d+=w[n++]<<p,p+=8)),(S+=d&(1<<E)-1)>u){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=E,p-=E,S>(E=a-s)){if((E=S-E)>l&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(T=0,_=f,0===h){if(T+=c-E,E<b){b-=E;do{I[a++]=f[T++]}while(--E);T=a-S,_=I}}else if(h<E){if(T+=c+h-E,(E-=h)<b){b-=E;do{I[a++]=f[T++]}while(--E);if(T=0,h<b){b-=E=h;do{I[a++]=f[T++]}while(--E);T=a-S,_=I}}}else if(T+=h-E,E<b){b-=E;do{I[a++]=f[T++]}while(--E);T=a-S,_=I}for(;b>2;)I[a++]=_[T++],I[a++]=_[T++],I[a++]=_[T++],b-=3;b&&(I[a++]=_[T++],b>1&&(I[a++]=_[T++]))}else{T=a-S;do{I[a++]=I[T++],I[a++]=I[T++],I[a++]=I[T++],b-=3}while(b>2);b&&(I[a++]=I[T++],b>1&&(I[a++]=I[T++]))}break}}break}}while(n<i&&a<o);n-=b=p>>3,d&=(1<<(p-=b<<3))-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=a<o?o-a+257:257-(a-o),r.hold=d,r.bits=p},Gl=function(e,t,r,n,i,a,s,o){var u,c,l,h,f,d,p,g,y,m=o.bits,v=0,C=0,E=0,b=0,S=0,T=0,_=0,w=0,I=0,A=0,B=null,k=0,N=new Ol.Buf16(16),R=new Ol.Buf16(16),L=null,D=0;for(v=0;v<=Pl;v++)N[v]=0;for(C=0;C<n;C++)N[t[r+C]]++;for(S=m,b=Pl;b>=1&&0===N[b];b--);if(S>b&&(S=b),0===b)return i[a++]=20971520,i[a++]=20971520,o.bits=1,0;for(E=1;E<b&&0===N[E];E++);for(S<E&&(S=E),w=1,v=1;v<=Pl;v++)if(w<<=1,(w-=N[v])<0)return-1;if(w>0&&(0===e||1!==b))return-1;for(R[1]=0,v=1;v<Pl;v++)R[v+1]=R[v]+N[v];for(C=0;C<n;C++)0!==t[r+C]&&(s[R[t[r+C]]++]=C);if(0===e?(B=L=s,d=19):1===e?(B=Vl,k-=257,L=Kl,D-=257,d=256):(B=Ml,L=Fl,d=-1),A=0,C=0,v=E,f=a,T=S,_=0,l=-1,h=(I=1<<S)-1,1===e&&I>852||2===e&&I>592)return 1;for(;;){p=v-_,s[C]<d?(g=0,y=s[C]):s[C]>d?(g=L[D+s[C]],y=B[k+s[C]]):(g=96,y=0),u=1<<v-_,E=c=1<<T;do{i[f+(A>>_)+(c-=u)]=p<<24|g<<16|y|0}while(0!==c);for(u=1<<v-1;A&u;)u>>=1;if(0!==u?(A&=u-1,A+=u):A=0,C++,0==--N[v]){if(v===b)break;v=t[r+s[C]]}if(v>S&&(A&h)!==l){for(0===_&&(_=S),f+=E,w=1<<(T=v-_);T+_<b&&!((w-=N[T+_])<=0);)T++,w<<=1;if(I+=1<<T,1===e&&I>852||2===e&&I>592)return 1;i[l=A&h]=S<<24|T<<16|f-a|0}}return 0!==A&&(i[f+A]=v-_<<24|64<<16|0),o.bits=S,0},Wl=1,Ql=2,Yl=0,Zl=-2,Xl=1,$l=12,Jl=30,eh=852,th=592;function rh(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function nh(){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 zl.Buf16(320),this.work=new zl.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ih(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=Xl,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new zl.Buf32(eh),t.distcode=t.distdyn=new zl.Buf32(th),t.sane=1,t.back=-1,Yl):Zl}function ah(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,ih(e)):Zl}function sh(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Zl:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ah(e))):Zl}function oh(e,t){var r,n;return e?(n=new nh,e.state=n,n.window=null,(r=sh(e,t))!==Yl&&(e.state=null),r):Zl}var uh,ch,lh=!0;function hh(e){if(lh){var t;for(uh=new zl.Buf32(512),ch=new zl.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(Gl(Wl,e.lens,0,288,uh,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Gl(Ql,e.lens,0,32,ch,0,e.work,{bits:5}),lh=!1}e.lencode=uh,e.lenbits=9,e.distcode=ch,e.distbits=5}function fh(e,t,r,n){var i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new zl.Buf8(a.wsize)),n>=a.wsize?(zl.arraySet(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),zl.arraySet(a.window,t,r-n,i,a.wnext),(n-=i)?(zl.arraySet(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}xl.inflateReset=ah,xl.inflateReset2=sh,xl.inflateResetKeep=ih,xl.inflateInit=function(e){return oh(e,15)},xl.inflateInit2=oh,xl.inflate=function(e,t){var r,n,i,a,s,o,u,c,l,h,f,d,p,g,y,m,v,C,E,b,S,T,_,w,I=0,A=new zl.Buf8(4),B=[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 Zl;(r=e.state).mode===$l&&(r.mode=13),s=e.next_out,i=e.output,u=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,c=r.hold,l=r.bits,h=o,f=u,T=Yl;e:for(;;)switch(r.mode){case Xl:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(2&r.wrap&&35615===c){r.check=0,A[0]=255&c,A[1]=c>>>8&255,r.check=ql(r.check,A,2,0),c=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=Jl;break}if(8!=(15&c)){e.msg="unknown compression method",r.mode=Jl;break}if(l-=4,S=8+(15&(c>>>=4)),0===r.wbits)r.wbits=S;else if(S>r.wbits){e.msg="invalid window size",r.mode=Jl;break}r.dmax=1<<S,e.adler=r.check=1,r.mode=512&c?10:$l,c=0,l=0;break;case 2:for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(r.flags=c,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=Jl;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=Jl;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&(A[0]=255&c,A[1]=c>>>8&255,r.check=ql(r.check,A,2,0)),c=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.head&&(r.head.time=c),512&r.flags&&(A[0]=255&c,A[1]=c>>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,r.check=ql(r.check,A,4,0)),c=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&(A[0]=255&c,A[1]=c>>>8&255,r.check=ql(r.check,A,2,0)),c=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&(A[0]=255&c,A[1]=c>>>8&255,r.check=ql(r.check,A,2,0)),c=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>o&&(d=o),d&&(r.head&&(S=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),zl.arraySet(r.head.extra,n,a,d,S)),512&r.flags&&(r.check=ql(r.check,n,d,a)),o-=d,a+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;d=0;do{S=n[a+d++],r.head&&S&&r.length<65536&&(r.head.name+=String.fromCharCode(S))}while(S&&d<o);if(512&r.flags&&(r.check=ql(r.check,n,d,a)),o-=d,a+=d,S)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break e;d=0;do{S=n[a+d++],r.head&&S&&r.length<65536&&(r.head.comment+=String.fromCharCode(S))}while(S&&d<o);if(512&r.flags&&(r.check=ql(r.check,n,d,a)),o-=d,a+=d,S)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Jl;break}c=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=$l;break;case 10:for(;l<32;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}e.adler=r.check=rh(c),c=0,l=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=l,2;e.adler=r.check=1,r.mode=$l;case $l:if(5===t||6===t)break e;case 13:if(r.last){c>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}switch(r.last=1&c,l-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(hh(r),r.mode=20,6===t){c>>>=2,l-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=Jl}c>>>=2,l-=2;break;case 14:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Jl;break}if(r.length=65535&c,c=0,l=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>o&&(d=o),d>u&&(d=u),0===d)break e;zl.arraySet(i,n,a,d,s),o-=d,a+=d,u-=d,s+=d,r.length-=d;break}r.mode=$l;break;case 17:for(;l<14;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(r.nlen=257+(31&c),c>>>=5,l-=5,r.ndist=1+(31&c),c>>>=5,l-=5,r.ncode=4+(15&c),c>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Jl;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.lens[B[r.have++]]=7&c,c>>>=3,l-=3}for(;r.have<19;)r.lens[B[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,_={bits:r.lenbits},T=Gl(0,r.lens,0,19,r.lencode,0,r.work,_),r.lenbits=_.bits,T){e.msg="invalid code lengths set",r.mode=Jl;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(I=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,v=65535&I,!((y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(v<16)c>>>=y,l-=y,r.lens[r.have++]=v;else{if(16===v){for(w=y+2;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(c>>>=y,l-=y,0===r.have){e.msg="invalid bit length repeat",r.mode=Jl;break}S=r.lens[r.have-1],d=3+(3&c),c>>>=2,l-=2}else if(17===v){for(w=y+3;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}l-=y,S=0,d=3+(7&(c>>>=y)),c>>>=3,l-=3}else{for(w=y+7;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}l-=y,S=0,d=11+(127&(c>>>=y)),c>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Jl;break}for(;d--;)r.lens[r.have++]=S}}if(r.mode===Jl)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Jl;break}if(r.lenbits=9,_={bits:r.lenbits},T=Gl(Wl,r.lens,0,r.nlen,r.lencode,0,r.work,_),r.lenbits=_.bits,T){e.msg="invalid literal/lengths set",r.mode=Jl;break}if(r.distbits=6,r.distcode=r.distdyn,_={bits:r.distbits},T=Gl(Ql,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,_),r.distbits=_.bits,T){e.msg="invalid distances set",r.mode=Jl;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(o>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=l,Hl(e,f),s=e.next_out,i=e.output,u=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,c=r.hold,l=r.bits,r.mode===$l&&(r.back=-1);break}for(r.back=0;m=(I=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,v=65535&I,!((y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(m&&0==(240&m)){for(C=y,E=m,b=v;m=(I=r.lencode[b+((c&(1<<C+E)-1)>>C)])>>>16&255,v=65535&I,!(C+(y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}c>>>=C,l-=C,r.back+=C}if(c>>>=y,l-=y,r.back+=y,r.length=v,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=$l;break}if(64&m){e.msg="invalid literal/length code",r.mode=Jl;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(w=r.extra;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(I=r.distcode[c&(1<<r.distbits)-1])>>>16&255,v=65535&I,!((y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(0==(240&m)){for(C=y,E=m,b=v;m=(I=r.distcode[b+((c&(1<<C+E)-1)>>C)])>>>16&255,v=65535&I,!(C+(y=I>>>24)<=l);){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}c>>>=C,l-=C,r.back+=C}if(c>>>=y,l-=y,r.back+=y,64&m){e.msg="invalid distance code",r.mode=Jl;break}r.offset=v,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(w=r.extra;l<w;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Jl;break}r.mode=25;case 25:if(0===u)break e;if(d=f-u,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Jl;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),g=r.window}else g=i,p=s-r.offset,d=r.length;d>u&&(d=u),u-=d,r.length-=d;do{i[s++]=g[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===u)break e;i[s++]=r.length,u--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===o)break e;o--,c|=n[a++]<<l,l+=8}if(f-=u,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?ql(r.check,i,f,s-f):jl(r.check,i,f,s-f)),f=u,(r.flags?c:rh(c))!==r.check){e.msg="incorrect data check",r.mode=Jl;break}c=0,l=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===o)break e;o--,c+=n[a++]<<l,l+=8}if(c!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Jl;break}c=0,l=0}r.mode=29;case 29:T=1;break e;case Jl:T=-3;break e;case 31:return-4;default:return Zl}return e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=l,(r.wsize||f!==e.avail_out&&r.mode<Jl&&(r.mode<27||4!==t))&&fh(e,e.output,e.next_out,f-e.avail_out),h-=e.avail_in,f-=e.avail_out,e.total_in+=h,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?ql(r.check,i,f,e.next_out-f):jl(r.check,i,f,e.next_out-f)),e.data_type=r.bits+(r.last?64:0)+(r.mode===$l?128:0)+(20===r.mode||15===r.mode?256:0),(0===h&&0===f||4===t)&&T===Yl&&(T=-5),T},xl.inflateEnd=function(e){if(!e||!e.state)return Zl;var t=e.state;return t.window&&(t.window=null),e.state=null,Yl},xl.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?Zl:(r.head=t,t.done=!1,Yl):Zl},xl.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?Zl:11===r.mode&&jl(1,t,n,0)!==r.check?-3:fh(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,Yl):Zl},xl.inflateInfo="pako inflate (from Nodeca project)";var dh={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};var ph=xl,gh=mu,yh=pl,mh=dh,vh=Ec,Ch=bl,Eh=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},bh=Object.prototype.toString;function Sh(e){if(!(this instanceof Sh))return new Sh(e);this.options=gh.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 Ch,this.strm.avail_out=0;var r=ph.inflateInit2(this.strm,t.windowBits);if(r!==mh.Z_OK)throw new Error(vh[r]);if(this.header=new Eh,ph.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=yh.string2buf(t.dictionary):"[object ArrayBuffer]"===bh.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=ph.inflateSetDictionary(this.strm,t.dictionary))!==mh.Z_OK))throw new Error(vh[r])}function Th(e,t){var r=new Sh(t);if(r.push(e,!0),r.err)throw r.msg||vh[r.err];return r.result}Sh.prototype.push=function(e,t){var r,n,i,a,s,o=this.strm,u=this.options.chunkSize,c=this.options.dictionary,l=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?mh.Z_FINISH:mh.Z_NO_FLUSH,"string"==typeof e?o.input=yh.binstring2buf(e):"[object ArrayBuffer]"===bh.call(e)?o.input=new Uint8Array(e):o.input=e,o.next_in=0,o.avail_in=o.input.length;do{if(0===o.avail_out&&(o.output=new gh.Buf8(u),o.next_out=0,o.avail_out=u),(r=ph.inflate(o,mh.Z_NO_FLUSH))===mh.Z_NEED_DICT&&c&&(r=ph.inflateSetDictionary(this.strm,c)),r===mh.Z_BUF_ERROR&&!0===l&&(r=mh.Z_OK,l=!1),r!==mh.Z_STREAM_END&&r!==mh.Z_OK)return this.onEnd(r),this.ended=!0,!1;o.next_out&&(0!==o.avail_out&&r!==mh.Z_STREAM_END&&(0!==o.avail_in||n!==mh.Z_FINISH&&n!==mh.Z_SYNC_FLUSH)||("string"===this.options.to?(i=yh.utf8border(o.output,o.next_out),a=o.next_out-i,s=yh.buf2string(o.output,i),o.next_out=a,o.avail_out=u-a,a&&gh.arraySet(o.output,o.output,i,a,0),this.onData(s)):this.onData(gh.shrinkBuf(o.output,o.next_out)))),0===o.avail_in&&0===o.avail_out&&(l=!0)}while((o.avail_in>0||0===o.avail_out)&&r!==mh.Z_STREAM_END);return r===mh.Z_STREAM_END&&(n=mh.Z_FINISH),n===mh.Z_FINISH?(r=ph.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===mh.Z_OK):n!==mh.Z_SYNC_FLUSH||(this.onEnd(mh.Z_OK),o.avail_out=0,!0)},Sh.prototype.onData=function(e){this.chunks.push(e)},Sh.prototype.onEnd=function(e){e===mh.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=gh.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Ul.Inflate=Sh,Ul.inflate=Th,Ul.inflateRaw=function(e,t){return(t=t||{}).raw=!0,Th(e,t)},Ul.ungzip=Th;var _h={};(0,mu.assign)(_h,vu,Ul,dh);var wh="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,Ih=_h,Ah=Co(),Bh=bo,kh=wh?"uint8array":"array";function Nh(e,t){Bh.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}yu.magic="\b\0",Ah.inherits(Nh,Bh),Nh.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(Ah.transformTo(kh,e.data),!1)},Nh.prototype.flush=function(){Bh.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},Nh.prototype.cleanUp=function(){Bh.prototype.cleanUp.call(this),this._pako=null},Nh.prototype._createPako=function(){this._pako=new Ih[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},yu.compressWorker=function(e){return new Nh("Deflate",e)},yu.uncompressWorker=function(){return new Nh("Inflate",{})};var Rh=bo;gu.STORE={magic:"\0\0",compressWorker:function(){return new Rh("STORE compression")},uncompressWorker:function(){return new Rh("STORE decompression")}},gu.DEFLATE=yu;var Lh={LOCAL_FILE_HEADER:"PK",CENTRAL_FILE_HEADER:"PK",CENTRAL_DIRECTORY_END:"PK",ZIP64_CENTRAL_DIRECTORY_LOCATOR:"PK",ZIP64_CENTRAL_DIRECTORY_END:"PK",DATA_DESCRIPTOR:"PK\b"},Dh=Co(),Uh=bo,xh=as,Oh=qo,Ph=Lh,Vh=function(e,t){var r,n="";for(r=0;r<t;r++)n+=String.fromCharCode(255&e),e>>>=8;return n},Kh=function(e,t,r,n,i,a){var s,o,u=e.file,c=e.compression,l=a!==xh.utf8encode,h=Dh.transformTo("string",a(u.name)),f=Dh.transformTo("string",xh.utf8encode(u.name)),d=u.comment,p=Dh.transformTo("string",a(d)),g=Dh.transformTo("string",xh.utf8encode(d)),y=f.length!==u.name.length,m=g.length!==d.length,v="",C="",E="",b=u.dir,S=u.date,T={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(T.crc32=e.crc32,T.compressedSize=e.compressedSize,T.uncompressedSize=e.uncompressedSize);var _=0;t&&(_|=8),l||!y&&!m||(_|=2048);var w,I,A,B=0,k=0;b&&(B|=16),"UNIX"===i?(k=798,B|=(w=u.unixPermissions,I=b,A=w,w||(A=I?16893:33204),(65535&A)<<16)):(k=20,B|=63&(u.dosPermissions||0)),s=S.getUTCHours(),s<<=6,s|=S.getUTCMinutes(),s<<=5,s|=S.getUTCSeconds()/2,o=S.getUTCFullYear()-1980,o<<=4,o|=S.getUTCMonth()+1,o<<=5,o|=S.getUTCDate(),y&&(C=Vh(1,1)+Vh(Oh(h),4)+f,v+="up"+Vh(C.length,2)+C),m&&(E=Vh(1,1)+Vh(Oh(p),4)+g,v+="uc"+Vh(E.length,2)+E);var N="";return N+="\n\0",N+=Vh(_,2),N+=c.magic,N+=Vh(s,2),N+=Vh(o,2),N+=Vh(T.crc32,4),N+=Vh(T.compressedSize,4),N+=Vh(T.uncompressedSize,4),N+=Vh(h.length,2),N+=Vh(v.length,2),{fileRecord:Ph.LOCAL_FILE_HEADER+N+h+v,dirRecord:Ph.CENTRAL_FILE_HEADER+Vh(k,2)+N+Vh(p.length,2)+"\0\0\0\0"+Vh(B,4)+Vh(n,4)+h+v+p}},Mh=function(e){return Ph.DATA_DESCRIPTOR+Vh(e.crc32,4)+Vh(e.compressedSize,4)+Vh(e.uncompressedSize,4)};function Fh(e,t,r,n){Uh.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}Dh.inherits(Fh,Uh),Fh.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,Uh.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},Fh.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=Kh(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},Fh.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=Kh(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:Mh(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},Fh.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var r=this.bytesWritten-e,n=function(e,t,r,n,i){var a=Dh.transformTo("string",i(n));return Ph.CENTRAL_DIRECTORY_END+"\0\0\0\0"+Vh(e,2)+Vh(e,2)+Vh(t,4)+Vh(r,4)+Vh(a.length,2)+a}(this.dirRecords.length,r,e,this.zipComment,this.encodeFileName);this.push({data:n,meta:{percent:100}})},Fh.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},Fh.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",(function(e){t.processChunk(e)})),e.on("end",(function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()})),e.on("error",(function(e){t.error(e)})),this},Fh.prototype.resume=function(){return!!Uh.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},Fh.prototype.error=function(e){var t=this._sources;if(!Uh.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(e){}return!0},Fh.prototype.lock=function(){Uh.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()};var zh=gu,jh=Fh;pu.generateWorker=function(e,t,r){var n=new jh(t.streamFiles,r,t.platform,t.encodeFileName),i=0;try{e.forEach((function(e,r){i++;var a=function(e,t){var r=e||t,n=zh[r];if(!n)throw new Error(r+" is not a valid compression method !");return n}(r.options.compression,t.compression),s=r.options.compressionOptions||t.compressionOptions||{},o=r.dir,u=r.date;r._compressWorker(a,s).withStreamInfo("file",{name:e,dir:o,date:u,comment:r.comment||"",unixPermissions:r.unixPermissions,dosPermissions:r.dosPermissions}).pipe(n)})),n.entriesCount=i}catch(e){n.error(e)}return n};var qh=Co(),Hh=bo;function Gh(e,t){Hh.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}qh.inherits(Gh,Hh),Gh.prototype._bindStream=function(e){var t=this;this._stream=e,e.pause(),e.on("data",(function(e){t.push({data:e,meta:{percent:0}})})).on("error",(function(e){t.isPaused?this.generatedError=e:t.error(e)})).on("end",(function(){t.isPaused?t._upstreamEnded=!0:t.end()}))},Gh.prototype.pause=function(){return!!Hh.prototype.pause.call(this)&&(this._stream.pause(),!0)},Gh.prototype.resume=function(){return!!Hh.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)};var Wh=Gh,Qh=as,Yh=Co(),Zh=bo,Xh=Oo,$h=Po,Jh=nu,ef=du,tf=pu,rf=go,nf=Wh,af=function(e,t,r){var n,i=Yh.getTypeOf(t),a=Yh.extend(r||{},$h);a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),"string"==typeof a.unixPermissions&&(a.unixPermissions=parseInt(a.unixPermissions,8)),a.unixPermissions&&16384&a.unixPermissions&&(a.dir=!0),a.dosPermissions&&16&a.dosPermissions&&(a.dir=!0),a.dir&&(e=of(e)),a.createFolders&&(n=sf(e))&&uf.call(this,n,!0);var s="string"===i&&!1===a.binary&&!1===a.base64;r&&void 0!==r.binary||(a.binary=!s),(t instanceof Jh&&0===t.uncompressedSize||a.dir||!t||0===t.length)&&(a.base64=!1,a.binary=!0,t="",a.compression="STORE",i="string");var o=null;o=t instanceof Jh||t instanceof Zh?t:rf.isNode&&rf.isStream(t)?new nf(e,t):Yh.prepareContent(e,t,a.binary,a.optimizedBinaryString,a.base64);var u=new ef(e,o,a);this.files[e]=u},sf=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return t>0?e.substring(0,t):""},of=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},uf=function(e,t){return t=void 0!==t?t:$h.createFolders,e=of(e),this.files[e]||af.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function cf(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var lf={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,r,n;for(t in this.files)n=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,n)},filter:function(e){var t=[];return this.forEach((function(r,n){e(r,n)&&t.push(n)})),t},file:function(e,t,r){if(1===arguments.length){if(cf(e)){var n=e;return this.filter((function(e,t){return!t.dir&&n.test(e)}))}var i=this.files[this.root+e];return i&&!i.dir?i:null}return e=this.root+e,af.call(this,e,t,r),this},folder:function(e){if(!e)return this;if(cf(e))return this.filter((function(t,r){return r.dir&&e.test(t)}));var t=this.root+e,r=uf.call(this,t),n=this.clone();return n.root=r.name,n},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!==e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var r=this.filter((function(t,r){return r.name.slice(0,e.length)===e})),n=0;n<r.length;n++)delete this.files[r[n].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,r={};try{if((r=Yh.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:Qh.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");Yh.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var n=r.comment||this.comment||"";t=tf.generateWorker(this,r,n)}catch(e){(t=new Zh("error")).error(e)}return new Xh(t,r.type||"string",r.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}},hf=lf,ff=Co();function df(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}df.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return ff.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}};var pf=df,gf=pf;function yf(e){gf.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}Co().inherits(yf,gf),yf.prototype.byteAt=function(e){return this.data[this.zero+e]},yf.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),a=this.length-4;a>=0;--a)if(this.data[a]===t&&this.data[a+1]===r&&this.data[a+2]===n&&this.data[a+3]===i)return a-this.zero;return-1},yf.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),a=this.readData(4);return t===a[0]&&r===a[1]&&n===a[2]&&i===a[3]},yf.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};var mf=yf,vf=pf;function Cf(e){vf.call(this,e)}Co().inherits(Cf,vf),Cf.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},Cf.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},Cf.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},Cf.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};var Ef=Cf,bf=mf;function Sf(e){bf.call(this,e)}Co().inherits(Sf,bf),Sf.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};var Tf=Sf,_f=Tf;function wf(e){_f.call(this,e)}Co().inherits(wf,_f),wf.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};var If=wf,Af=Co(),Bf=os,kf=mf,Nf=Ef,Rf=If,Lf=Tf,Df=function(e){var t=Af.getTypeOf(e);return Af.checkSupport(t),"string"!==t||Bf.uint8array?"nodebuffer"===t?new Rf(e):Bf.uint8array?new Lf(Af.transformTo("uint8array",e)):new kf(Af.transformTo("array",e)):new Nf(e)},Uf=Df,xf=Co(),Of=nu,Pf=qo,Vf=as,Kf=gu,Mf=os;function Ff(e,t){this.options=e,this.loadOptions=t}Ff.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(e){var t,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in Kf)if(Object.prototype.hasOwnProperty.call(Kf,t)&&Kf[t].magic===e)return Kf[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+xf.pretty(this.compressionMethod)+" unknown (inner file : "+xf.transformTo("string",this.fileName)+")");this.decompressed=new Of(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0===e&&(this.dosPermissions=63&this.externalFileAttributes),3===e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=Uf(this.extraFields[1].value);this.uncompressedSize===xf.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===xf.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===xf.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===xf.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),r=e.readInt(2),n=e.readData(r),this.extraFields[t]={id:t,length:r,value:n};e.setIndex(i)},handleUTF8:function(){var e=Mf.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=Vf.utf8decode(this.fileName),this.fileCommentStr=Vf.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var r=xf.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var n=this.findExtraFieldUnicodeComment();if(null!==n)this.fileCommentStr=n;else{var i=xf.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(i)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=Uf(e.value);return 1!==t.readInt(1)||Pf(this.fileName)!==t.readInt(4)?null:Vf.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=Uf(e.value);return 1!==t.readInt(1)||Pf(this.fileComment)!==t.readInt(4)?null:Vf.utf8decode(t.readData(e.length-5))}return null}};var zf=Ff,jf=Df,qf=Co(),Hf=Lh,Gf=zf,Wf=os;function Qf(e){this.files=[],this.loadOptions=e}Qf.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+qf.pretty(t)+", expected "+qf.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var n=this.reader.readString(4)===t;return this.reader.setIndex(r),n},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=Wf.uint8array?"uint8array":"array",r=qf.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,r,n=this.zip64EndOfCentralSize-44;0<n;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(Hf.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(Hf.CENTRAL_FILE_HEADER);)(e=new Gf({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(Hf.CENTRAL_DIRECTORY_END);if(e<0)throw!this.isSignature(0,Hf.LOCAL_FILE_HEADER)?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory");this.reader.setIndex(e);var t=e;if(this.checkSignature(Hf.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===qf.MAX_VALUE_16BITS||this.diskWithCentralDirStart===qf.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===qf.MAX_VALUE_16BITS||this.centralDirRecords===qf.MAX_VALUE_16BITS||this.centralDirSize===qf.MAX_VALUE_32BITS||this.centralDirOffset===qf.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(Hf.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(Hf.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,Hf.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(Hf.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(Hf.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var n=t-r;if(n>0)this.isSignature(t,Hf.CENTRAL_FILE_HEADER)||(this.reader.zero=n);else if(n<0)throw new Error("Corrupted zip: missing "+Math.abs(n)+" bytes.")},prepareReader:function(e){this.reader=jf(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};var Yf=Qf,Zf=Co(),Xf=vo,$f=as,Jf=Yf,ed=Qo,td=go;function rd(e){return new Xf.Promise((function(t,r){var n=e.decompressed.getContentWorker().pipe(new ed);n.on("error",(function(e){r(e)})).on("end",(function(){n.streamInfo.crc32!==e.decompressed.crc32?r(new Error("Corrupted zip : CRC32 mismatch")):t()})).resume()}))}function nd(){if(!(this instanceof nd))return new nd;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new nd;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}nd.prototype=hf,nd.prototype.loadAsync=function(e,t){var r=this;return t=Zf.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:$f.utf8decode}),td.isNode&&td.isStream(e)?Xf.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):Zf.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then((function(e){var r=new Jf(t);return r.load(e),r})).then((function(e){var r=[Xf.Promise.resolve(e)],n=e.files;if(t.checkCRC32)for(var i=0;i<n.length;i++)r.push(rd(n[i]));return Xf.Promise.all(r)})).then((function(e){for(var n=e.shift(),i=n.files,a=0;a<i.length;a++){var s=i[a],o=s.fileNameStr,u=Zf.resolve(s.fileNameStr);r.file(u,s.decompressed,{binary:!0,optimizedBinaryString:!0,date:s.date,dir:s.dir,comment:s.fileCommentStr.length?s.fileCommentStr:null,unixPermissions:s.unixPermissions,dosPermissions:s.dosPermissions,createFolders:t.createFolders}),s.dir||(r.file(u).unsafeOriginalName=o)}return n.zipComment.length&&(r.comment=n.zipComment),r}))},nd.support=os,nd.defaults=Po,nd.version="3.10.1",nd.loadAsync=function(e,t){return(new nd).loadAsync(e,t)},nd.external=vo;var id=nd;exports.CertApplyPlugin=class extends e.AbstractTaskPlugin{domains;email;dnsProviderType;dnsProviderAccess;renewDays;forceUpdate;csrInfo;acme;logger;userContext;accessService;http;lastStatus;cert;async onInstance(){this.accessService=this.ctx.accessService,this.logger=this.ctx.logger,this.userContext=this.ctx.userContext,this.http=this.ctx.http,this.lastStatus=this.ctx.lastStatus,this.acme=new g({userContext:this.userContext,logger:this.logger})}async execute(){const e=await this.condition();if(null!=e)return await this.output(e.toCertInfo());const t=await this.doCertApply();if(null==t)throw new Error("申请证书失败");await this.output(t.toCertInfo()),this.clearLastStatus()}async output(e){this.cert=e,await this.zipCert(e)}async zipCert(e){const t=new id;t.file("cert.crt",e.crt),t.file("cert.key",e.key);const r=await t.generateAsync({type:"nodebuffer"});this.saveFile("cert.zip",r)}async condition(){if(this.forceUpdate)return null;let e=!1;let r;JSON.stringify(this.lastStatus?.input?.domains)!==JSON.stringify(this.domains)&&(e=!0);try{r=await this.readLastCert()}catch(e){this.logger.warn("读取cert失败:",e)}if(null==r)return this.logger.info("还未申请过,准备申请新证书"),null;if(e)return this.logger.info("输入参数变更,申请新证书"),null;const n=this.isWillExpire(r.expires,this.renewDays);return n.isWillExpire?(this.logger.info("即将过期,开始更新证书"),null):(this.logger.info(`证书还未过期:过期时间${t(r.expires).format("YYYY-MM-DD HH:mm:ss")},剩余${n.leftDays}天`),r)}async doCertApply(){const t=this.email,r=this.domains,i=this.dnsProviderType,a=this.dnsProviderAccess,s=n.merge({country:"CN",state:"GuangDong",locality:"ShengZhen",organization:"CertD Org.",organizationUnit:"IT Department",emailAddress:t},this.csrInfo);this.logger.info("开始申请证书,",t,r);const o=y.get(i),u=o.target,c=o.define,l=await this.accessService.getById(a),h=new u,f={access:l,logger:this.logger,http:this.http};e.Decorator.inject(c.autowire,h,f),await h.onInstance();const d=await this.acme.order({email:t,domains:r,dnsProvider:h,csrInfo:s,isTest:!1}),p=this.formatCerts(d);return new ts(p)}formatCert(e){return e=(e=(e=e.replace(/\r/g,"")).replace(/\n\n/g,"\n")).replace(/\n$/g,"")}formatCerts(e){return{crt:this.formatCert(e.crt),key:this.formatCert(e.key),csr:this.formatCert(e.csr)}}async readLastCert(){const e=this.lastStatus?.status?.output?.cert;if(null!=e)return new ts(e)}isWillExpire(e,r=20){if(null==e)throw new Error("过期时间不能为空");const n=t(e).diff(t(),"day");return{isWillExpire:n<r,leftDays:n}}},p([e.TaskInput({title:"域名",component:{name:"a-select",vModel:"value",mode:"tags",open:!1},required:!0,col:{span:24},helper:"支持通配符域名,例如: *.foo.com、foo.com、*.test.handsfree.work\n支持多个域名、多个子域名、多个通配符域名打到一个证书上(域名必须是在同一个DNS提供商解析)\n多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com、foo.com)\n输入一个回车之后,再输入下一个"})],exports.CertApplyPlugin.prototype,"domains",void 0),p([e.TaskInput({title:"邮箱",component:{name:"a-input",vModel:"value"},required:!0,helper:"请输入邮箱"})],exports.CertApplyPlugin.prototype,"email",void 0),p([e.TaskInput({title:"DNS提供商",component:{name:"pi-dns-provider-selector"},required:!0,helper:"请选择dns解析提供商"})],exports.CertApplyPlugin.prototype,"dnsProviderType",void 0),p([e.TaskInput({title:"DNS解析授权",component:{name:"pi-access-selector"},required:!0,helper:"请选择dns解析提供商授权",reference:[{src:"form.dnsProviderType",dest:"component.type",type:"computed"}]})],exports.CertApplyPlugin.prototype,"dnsProviderAccess",void 0),p([e.TaskInput({title:"更新天数",component:{name:"a-input-number",vModel:"value"},required:!0,helper:"到期前多少天后更新证书"})],exports.CertApplyPlugin.prototype,"renewDays",void 0),p([e.TaskInput({title:"强制更新",component:{name:"a-switch",vModel:"checked"},helper:"是否强制重新申请证书"})],exports.CertApplyPlugin.prototype,"forceUpdate",void 0),p([e.TaskInput({title:"CsrInfo"})],exports.CertApplyPlugin.prototype,"csrInfo",void 0),p([e.TaskOutput({title:"域名证书"})],exports.CertApplyPlugin.prototype,"cert",void 0),exports.CertApplyPlugin=p([e.IsTaskPlugin({name:"CertApply",title:"证书申请",desc:"免费通配符域名证书申请,支持多个域名打到同一个证书上",default:{input:{renewDays:20,forceUpdate:!1},strategy:{runStrategy:e.RunStrategy.AlwaysRun}}})],exports.CertApplyPlugin),new exports.CertApplyPlugin,exports.CertReader=ts,exports.DNS_PROVIDER_CLASS_KEY=m,exports.IsDnsProvider=function(t){return r=>{r=e.Decorator.target(r);const i={},a=e.Decorator.getClassProperties(r);for(const t in a){const n=Reflect.getMetadata(e.AUTOWIRE_KEY,r,t);n&&(i[t]=n)}n.merge(t,{autowire:i}),Reflect.defineMetadata(m,t,r),r.define=t,y.register(t.name,{define:t,target:r})}},exports.dnsProviderRegistry=y;
|