UNPKG

poly-crypto

Version:

High-level cryptographic functions that are interoperable between NodeJS and PHP 7.1+.

4 lines 95.8 kB
var ir=Object.create;var Ae=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,cr=Object.prototype.hasOwnProperty;var z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),hr=(e,t)=>{for(var a in t)Ae(e,a,{get:t[a],enumerable:!0})},rt=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of sr(t))!cr.call(e,n)&&n!==a&&Ae(e,n,{get:()=>t[n],enumerable:!(r=fr(t,n))||r.enumerable});return e};var se=(e,t,a)=>(a=e!=null?ir(or(e)):{},rt(t||!e||!e.__esModule?Ae(a,"default",{value:e,enumerable:!0}):a,e)),ur=e=>rt(Ae({},"__esModule",{value:!0}),e);var $=z((Fr,at)=>{at.exports={options:{usePureJavaScript:!1}}});var ft=z((kr,it)=>{var Ue={};it.exports=Ue;var nt={};Ue.encode=function(e,t,a){if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');if(a!==void 0&&typeof a!="number")throw new TypeError('"maxline" must be a number.');var r="";if(!(e instanceof Uint8Array))r=xr(e,t);else{var n=0,i=t.length,s=t.charAt(0),f=[0];for(n=0;n<e.length;++n){for(var h=0,o=e[n];h<f.length;++h)o+=f[h]<<8,f[h]=o%i,o=o/i|0;for(;o>0;)f.push(o%i),o=o/i|0}for(n=0;e[n]===0&&n<e.length-1;++n)r+=s;for(n=f.length-1;n>=0;--n)r+=t[f[n]]}if(a){var c=new RegExp(".{1,"+a+"}","g");r=r.match(c).join(`\r `)}return r};Ue.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var a=nt[t];if(!a){a=nt[t]=[];for(var r=0;r<t.length;++r)a[t.charCodeAt(r)]=r}e=e.replace(/\s/g,"");for(var n=t.length,i=t.charAt(0),s=[0],r=0;r<e.length;r++){var f=a[e.charCodeAt(r)];if(f===void 0)return;for(var h=0,o=f;h<s.length;++h)o+=s[h]*n,s[h]=o&255,o>>=8;for(;o>0;)s.push(o&255),o>>=8}for(var c=0;e[c]===i&&c<e.length-1;++c)s.push(0);return typeof Buffer<"u"?Buffer.from(s.reverse()):new Uint8Array(s.reverse())};function xr(e,t){var a=0,r=t.length,n=t.charAt(0),i=[0];for(a=0;a<e.length();++a){for(var s=0,f=e.at(a);s<i.length;++s)f+=i[s]<<8,i[s]=f%r,f=f/r|0;for(;f>0;)i.push(f%r),f=f/r|0}var h="";for(a=0;e.at(a)===0&&a<e.length()-1;++a)h+=n;for(a=i.length-1;a>=0;--a)h+=t[i[a]];return h}});var K=z((Lr,ht)=>{var st=$(),ot=ft(),u=ht.exports=st.util=st.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){u.nextTick=process.nextTick,typeof setImmediate=="function"?u.setImmediate=setImmediate:u.setImmediate=u.nextTick;return}if(typeof setImmediate=="function"){u.setImmediate=function(){return setImmediate.apply(void 0,arguments)},u.nextTick=function(f){return setImmediate(f)};return}if(u.setImmediate=function(f){setTimeout(f,0)},typeof window<"u"&&typeof window.postMessage=="function"){let f=function(h){if(h.source===window&&h.data===e){h.stopPropagation();var o=t.slice();t.length=0,o.forEach(function(c){c()})}};var s=f,e="forge.setImmediate",t=[];u.setImmediate=function(h){t.push(h),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",f,!0)}if(typeof MutationObserver<"u"){var a=Date.now(),r=!0,n=document.createElement("div"),t=[];new MutationObserver(function(){var h=t.slice();t.length=0,h.forEach(function(o){o()})}).observe(n,{attributes:!0});var i=u.setImmediate;u.setImmediate=function(h){Date.now()-a>15?(a=Date.now(),i(h)):(t.push(h),t.length===1&&n.setAttribute("a",r=!r))}}u.nextTick=u.setImmediate})();u.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;u.globalScope=function(){return u.isNodejs?global:typeof self>"u"?window:self}();u.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};u.isArrayBuffer=function(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer};u.isArrayBufferView=function(e){return e&&u.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function Be(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}u.ByteBuffer=Re;function Re(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(u.isArrayBuffer(e)||u.isArrayBufferView(e))if(typeof Buffer<"u"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var a=0;a<t.length;++a)this.putByte(t[a])}}else(e instanceof Re||typeof e=="object"&&typeof e.data=="string"&&typeof e.read=="number")&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}u.ByteStringBuffer=Re;var dr=4096;u.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>dr&&(this.data.substr(0,1),this._constructedStringLength=0)};u.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};u.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};u.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))};u.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var a=this.data;t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return this.data=a,this._optimizeConstructedString(t),this};u.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this};u.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(u.encodeUtf8(e))};u.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};u.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};u.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(e&255))};u.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))};u.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))};u.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))};u.ByteStringBuffer.prototype.putInt=function(e,t){Be(t);var a="";do t-=8,a+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(a)};u.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)};u.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())};u.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};u.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e};u.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};u.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};u.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e};u.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};u.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};u.ByteStringBuffer.prototype.getInt=function(e){Be(e);var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t};u.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t};u.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):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};u.ByteStringBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};u.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)};u.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};u.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};u.ByteStringBuffer.prototype.copy=function(){var e=u.createBuffer(this.data);return e.read=this.read,e};u.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};u.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};u.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};u.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var a=this.data.charCodeAt(t);a<16&&(e+="0"),e+=a.toString(16)}return e};u.ByteStringBuffer.prototype.toString=function(){return u.decodeUtf8(this.bytes())};function lr(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var a=u.isArrayBuffer(e),r=u.isArrayBufferView(e);if(a||r){a?this.data=new DataView(e):this.data=new DataView(e.buffer,e.byteOffset,e.byteLength),this.write="writeOffset"in t?t.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,e!=null&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)}u.DataBuffer=lr;u.DataBuffer.prototype.length=function(){return this.write-this.read};u.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};u.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var a=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),r=new Uint8Array(this.length()+t);return r.set(a),this.data=new DataView(r.buffer),this};u.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this};u.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var a=0;a<t;++a)this.data.setUint8(e);return this};u.DataBuffer.prototype.putBytes=function(e,t){if(u.isArrayBufferView(e)){var a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=a.byteLength-a.byteOffset;this.accommodate(r);var n=new Uint8Array(this.data.buffer,this.write);return n.set(a),this.write+=r,this}if(u.isArrayBuffer(e)){var a=new Uint8Array(e);this.accommodate(a.byteLength);var n=new Uint8Array(this.data.buffer);return n.set(a,this.write),this.write+=a.byteLength,this}if(e instanceof u.DataBuffer||typeof e=="object"&&typeof e.read=="number"&&typeof e.write=="number"&&u.isArrayBufferView(e.data)){var a=new Uint8Array(e.data.byteLength,e.read,e.length());this.accommodate(a.byteLength);var n=new Uint8Array(e.data.byteLength,this.write);return n.set(a),this.write+=a.byteLength,this}if(e instanceof u.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary",typeof e=="string"){var i;if(t==="hex")return this.accommodate(Math.ceil(e.length/2)),i=new Uint8Array(this.data.buffer,this.write),this.write+=u.binary.hex.decode(e,i,this.write),this;if(t==="base64")return this.accommodate(Math.ceil(e.length/4)*3),i=new Uint8Array(this.data.buffer,this.write),this.write+=u.binary.base64.decode(e,i,this.write),this;if(t==="utf8"&&(e=u.encodeUtf8(e),t="binary"),t==="binary"||t==="raw")return this.accommodate(e.length),i=new Uint8Array(this.data.buffer,this.write),this.write+=u.binary.raw.decode(i),this;if(t==="utf16")return this.accommodate(e.length*2),i=new Uint16Array(this.data.buffer,this.write),this.write+=u.text.utf16.encode(i),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)};u.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this};u.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")};u.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this};u.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};u.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this};u.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this};u.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};u.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this};u.DataBuffer.prototype.putInt=function(e,t){Be(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this};u.DataBuffer.prototype.putSignedInt=function(e,t){return Be(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)};u.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};u.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e};u.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e};u.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e};u.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e};u.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e};u.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e};u.DataBuffer.prototype.getInt=function(e){Be(e);var t=0;do t=(t<<8)+this.data.getInt8(this.read++),e-=8;while(e>0);return t};u.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t};u.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):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};u.DataBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};u.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)};u.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this};u.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};u.DataBuffer.prototype.copy=function(){return new u.DataBuffer(this)};u.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};u.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};u.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this};u.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var a=this.data.getUint8(t);a<16&&(e+="0"),e+=a.toString(16)}return e};u.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if(e=e||"utf8",e==="binary"||e==="raw")return u.binary.raw.encode(t);if(e==="hex")return u.binary.hex.encode(t);if(e==="base64")return u.binary.base64.encode(t);if(e==="utf8")return u.text.utf8.decode(t);if(e==="utf16")return u.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)};u.createBuffer=function(e,t){return t=t||"raw",e!==void 0&&t==="utf8"&&(e=u.encodeUtf8(e)),new u.ByteBuffer(e)};u.fillString=function(e,t){for(var a="";t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return a};u.xorBytes=function(e,t,a){for(var r="",n="",i="",s=0,f=0;a>0;--a,++s)n=e.charCodeAt(s)^t.charCodeAt(s),f>=10&&(r+=i,i="",f=0),i+=String.fromCharCode(n),++f;return r+=i,r};u.hexToBytes=function(e){var t="",a=0;for(e.length&!0&&(a=1,t+=String.fromCharCode(parseInt(e[0],16)));a<e.length;a+=2)t+=String.fromCharCode(parseInt(e.substr(a,2),16));return t};u.bytesToHex=function(e){return u.createBuffer(e).toHex()};u.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ce=[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],ct="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";u.encode64=function(e,t){for(var a="",r="",n,i,s,f=0;f<e.length;)n=e.charCodeAt(f++),i=e.charCodeAt(f++),s=e.charCodeAt(f++),a+=oe.charAt(n>>2),a+=oe.charAt((n&3)<<4|i>>4),isNaN(i)?a+="==":(a+=oe.charAt((i&15)<<2|s>>6),a+=isNaN(s)?"=":oe.charAt(s&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r `,a=a.substr(t));return r+=a,r};u.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t="",a,r,n,i,s=0;s<e.length;)a=ce[e.charCodeAt(s++)-43],r=ce[e.charCodeAt(s++)-43],n=ce[e.charCodeAt(s++)-43],i=ce[e.charCodeAt(s++)-43],t+=String.fromCharCode(a<<2|r>>4),n!==64&&(t+=String.fromCharCode((r&15)<<4|n>>2),i!==64&&(t+=String.fromCharCode((n&3)<<6|i)));return t};u.encodeUtf8=function(e){return unescape(encodeURIComponent(e))};u.decodeUtf8=function(e){return decodeURIComponent(escape(e))};u.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:ot.encode,decode:ot.decode}};u.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)};u.binary.raw.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,i=0;i<e.length;++i)r[n++]=e.charCodeAt(i);return t?n-a:r};u.binary.hex.encode=u.bytesToHex;u.binary.hex.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/2))),a=a||0;var n=0,i=a;for(e.length&1&&(n=1,r[i++]=parseInt(e[0],16));n<e.length;n+=2)r[i++]=parseInt(e.substr(n,2),16);return t?i-a:r};u.binary.base64.encode=function(e,t){for(var a="",r="",n,i,s,f=0;f<e.byteLength;)n=e[f++],i=e[f++],s=e[f++],a+=oe.charAt(n>>2),a+=oe.charAt((n&3)<<4|i>>4),isNaN(i)?a+="==":(a+=oe.charAt((i&15)<<2|s>>6),a+=isNaN(s)?"=":oe.charAt(s&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r `,a=a.substr(t));return r+=a,r};u.binary.base64.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/4)*3)),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),a=a||0;for(var n,i,s,f,h=0,o=a;h<e.length;)n=ce[e.charCodeAt(h++)-43],i=ce[e.charCodeAt(h++)-43],s=ce[e.charCodeAt(h++)-43],f=ce[e.charCodeAt(h++)-43],r[o++]=n<<2|i>>4,s!==64&&(r[o++]=(i&15)<<4|s>>2,f!==64&&(r[o++]=(s&3)<<6|f));return t?o-a:r.subarray(0,o)};u.binary.base58.encode=function(e,t){return u.binary.baseN.encode(e,ct,t)};u.binary.base58.decode=function(e,t){return u.binary.baseN.decode(e,ct,t)};u.text={utf8:{},utf16:{}};u.text.utf8.encode=function(e,t,a){e=u.encodeUtf8(e);var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,i=0;i<e.length;++i)r[n++]=e.charCodeAt(i);return t?n-a:r};u.text.utf8.decode=function(e){return u.decodeUtf8(String.fromCharCode.apply(null,e))};u.text.utf16.encode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length*2));var n=new Uint16Array(r.buffer);a=a||0;for(var i=a,s=a,f=0;f<e.length;++f)n[s++]=e.charCodeAt(f),i+=2;return t?i-a:r};u.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))};u.deflate=function(e,t,a){if(t=u.decode64(e.deflate(u.encode64(t)).rval),a){var r=2,n=t.charCodeAt(1);n&32&&(r=6),t=t.substring(r,t.length-4)}return t};u.inflate=function(e,t,a){var r=e.inflate(u.encode64(t)).rval;return r===null?null:u.decode64(r)};var ze=function(e,t,a){if(!e)throw new Error("WebStorage not available.");var r;if(a===null?r=e.removeItem(t):(a=u.encode64(JSON.stringify(a)),r=e.setItem(t,a)),typeof r<"u"&&r.rval!==!0){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}},Ne=function(e,t){if(!e)throw new Error("WebStorage not available.");var a=e.getItem(t);if(e.init)if(a.rval===null){if(a.error){var r=new Error(a.error.message);throw r.id=a.error.id,r.name=a.error.name,r}a=null}else a=a.rval;return a!==null&&(a=JSON.parse(u.decode64(a))),a},gr=function(e,t,a,r){var n=Ne(e,t);n===null&&(n={}),n[a]=r,ze(e,t,n)},br=function(e,t,a){var r=Ne(e,t);return r!==null&&(r=a in r?r[a]:null),r},pr=function(e,t,a){var r=Ne(e,t);if(r!==null&&a in r){delete r[a];var n=!0;for(var i in r){n=!1;break}n&&(r=null),ze(e,t,r)}},yr=function(e,t){ze(e,t,null)},Ce=function(e,t,a){var r=null;typeof a>"u"&&(a=["web","flash"]);var n,i=!1,s=null;for(var f in a){n=a[f];try{if(n==="flash"||n==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");r=e.apply(this,t),i=n==="flash"}(n==="web"||n==="both")&&(t[0]=localStorage,r=e.apply(this,t),i=!0)}catch(h){s=h}if(i)break}if(!i)throw s;return r};u.setItem=function(e,t,a,r,n){Ce(gr,arguments,n)};u.getItem=function(e,t,a,r){return Ce(br,arguments,r)};u.removeItem=function(e,t,a,r){Ce(pr,arguments,r)};u.clearItems=function(e,t,a){Ce(yr,arguments,a)};u.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0};u.format=function(e){for(var t=/%./g,a,r,n=0,i=[],s=0;a=t.exec(e);){r=e.substring(s,t.lastIndex-2),r.length>0&&i.push(r),s=t.lastIndex;var f=a[0][1];switch(f){case"s":case"o":n<arguments.length?i.push(arguments[n+++1]):i.push("<?>");break;case"%":i.push("%");break;default:i.push("<%"+f+"?>")}}return i.push(e.substring(s)),i.join("")};u.formatNumber=function(e,t,a,r){var n=e,i=isNaN(t=Math.abs(t))?2:t,s=a===void 0?",":a,f=r===void 0?".":r,h=n<0?"-":"",o=parseInt(n=Math.abs(+n||0).toFixed(i),10)+"",c=o.length>3?o.length%3:0;return h+(c?o.substr(0,c)+f:"")+o.substr(c).replace(/(\d{3})(?=\d)/g,"$1"+f)+(i?s+Math.abs(n-o).toFixed(i).slice(2):"")};u.formatSize=function(e){return e>=1073741824?e=u.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?e=u.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?e=u.formatNumber(e/1024,0)+" KiB":e=u.formatNumber(e,0)+" bytes",e};u.bytesFromIP=function(e){return e.indexOf(".")!==-1?u.bytesFromIPv4(e):e.indexOf(":")!==-1?u.bytesFromIPv6(e):null};u.bytesFromIPv4=function(e){if(e=e.split("."),e.length!==4)return null;for(var t=u.createBuffer(),a=0;a<e.length;++a){var r=parseInt(e[a],10);if(isNaN(r))return null;t.putByte(r)}return t.getBytes()};u.bytesFromIPv6=function(e){var t=0;e=e.split(":").filter(function(s){return s.length===0&&++t,!0});for(var a=(8-e.length+t)*2,r=u.createBuffer(),n=0;n<8;++n){if(!e[n]||e[n].length===0){r.fillWithByte(0,a),a=0;continue}var i=u.hexToBytes(e[n]);i.length<2&&r.putByte(0),r.putBytes(i)}return r.getBytes()};u.bytesToIP=function(e){return e.length===4?u.bytesToIPv4(e):e.length===16?u.bytesToIPv6(e):null};u.bytesToIPv4=function(e){if(e.length!==4)return null;for(var t=[],a=0;a<e.length;++a)t.push(e.charCodeAt(a));return t.join(".")};u.bytesToIPv6=function(e){if(e.length!==16)return null;for(var t=[],a=[],r=0,n=0;n<e.length;n+=2){for(var i=u.bytesToHex(e[n]+e[n+1]);i[0]==="0"&&i!=="0";)i=i.substr(1);if(i==="0"){var s=a[a.length-1],f=t.length;!s||f!==s.end+1?a.push({start:f,end:f}):(s.end=f,s.end-s.start>a[r].end-a[r].start&&(r=a.length-1))}t.push(i)}if(a.length>0){var h=a[r];h.end-h.start>0&&(t.splice(h.start,h.end-h.start+1,""),h.start===0&&t.unshift(""),h.end===7&&t.push(""))}return t.join(":")};u.estimateCores=function(e,t){if(typeof e=="function"&&(t=e,e={}),e=e||{},"cores"in u&&!e.update)return t(null,u.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return u.cores=navigator.hardwareConcurrency,t(null,u.cores);if(typeof Worker>"u")return u.cores=1,t(null,u.cores);if(typeof Blob>"u")return u.cores=2,t(null,u.cores);var a=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(s){for(var f=Date.now(),h=f+4;Date.now()<h;);self.postMessage({st:f,et:h})})}.toString(),")()"],{type:"application/javascript"}));r([],5,16);function r(s,f,h){if(f===0){var o=Math.floor(s.reduce(function(c,l){return c+l},0)/s.length);return u.cores=Math.max(1,o),URL.revokeObjectURL(a),t(null,u.cores)}n(h,function(c,l){s.push(i(h,l)),r(s,f-1,h)})}function n(s,f){for(var h=[],o=[],c=0;c<s;++c){var l=new Worker(a);l.addEventListener("message",function(v){if(o.push(v.data),o.length===s){for(var _=0;_<s;++_)h[_].terminate();f(null,o)}}),h.push(l)}for(var c=0;c<s;++c)h[c].postMessage(c)}function i(s,f){for(var h=[],o=0;o<s;++o)for(var c=f[o],l=h[o]=[],v=0;v<s;++v)if(o!==v){var _=f[v];(c.st>_.st&&c.st<_.et||_.st>c.st&&_.st<c.et)&&l.push(v)}return h.reduce(function(S,I){return Math.max(S,I.length)},0)}}});var He=z((Er,ut)=>{var N=$();K();ut.exports=N.cipher=N.cipher||{};N.cipher.algorithms=N.cipher.algorithms||{};N.cipher.createCipher=function(e,t){var a=e;if(typeof a=="string"&&(a=N.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new N.cipher.BlockCipher({algorithm:a,key:t,decrypt:!1})};N.cipher.createDecipher=function(e,t){var a=e;if(typeof a=="string"&&(a=N.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new N.cipher.BlockCipher({algorithm:a,key:t,decrypt:!0})};N.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),N.cipher.algorithms[e]=t};N.cipher.getAlgorithm=function(e){return e=e.toUpperCase(),e in N.cipher.algorithms?N.cipher.algorithms[e]:null};var qe=N.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)};qe.prototype.start=function(e){e=e||{};var t={};for(var a in e)t[a]=e[a];t.decrypt=this._decrypt,this._finish=!1,this._input=N.util.createBuffer(),this.output=e.output||N.util.createBuffer(),this.mode.start(t)};qe.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()};qe.prototype.finish=function(e){e&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(a){return e(this.blockSize,a,!1)},this.mode.unpad=function(a){return e(this.blockSize,a,!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 he=z((Tr,xt)=>{var Fe=$();xt.exports=Fe.md=Fe.md||{};Fe.md.algorithms=Fe.md.algorithms||{}});var lt=z((Dr,dt)=>{var ne=$();he();K();var vr=dt.exports=ne.hmac=ne.hmac||{};vr.create=function(){var e=null,t=null,a=null,r=null,n={};return n.start=function(i,s){if(i!==null)if(typeof i=="string")if(i=i.toLowerCase(),i in ne.md.algorithms)t=ne.md.algorithms[i].create();else throw new Error('Unknown hash algorithm "'+i+'"');else t=i;if(s===null)s=e;else{if(typeof s=="string")s=ne.util.createBuffer(s);else if(ne.util.isArray(s)){var f=s;s=ne.util.createBuffer();for(var h=0;h<f.length;++h)s.putByte(f[h])}var o=s.length();o>t.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),a=ne.util.createBuffer(),r=ne.util.createBuffer(),o=s.length();for(var h=0;h<o;++h){var f=s.at(h);a.putByte(54^f),r.putByte(92^f)}if(o<t.blockLength)for(var f=t.blockLength-o,h=0;h<f;++h)a.putByte(54),r.putByte(92);e=s,a=a.bytes(),r=r.bytes()}t.start(),t.update(a)},n.update=function(i){t.update(i)},n.getMac=function(){var i=t.digest().bytes();return t.start(),t.update(r),t.update(i),t.digest()},n.digest=n.getMac,n}});var bt=z((Or,gt)=>{var V=$();lt();he();K();var Br=V.pkcs5=V.pkcs5||{},ie;V.util.isNodejs&&!V.options.usePureJavaScript&&(ie=require("crypto"));gt.exports=V.pbkdf2=Br.pbkdf2=function(e,t,a,r,n,i){if(typeof n=="function"&&(i=n,n=null),V.util.isNodejs&&!V.options.usePureJavaScript&&ie.pbkdf2&&(n===null||typeof n!="object")&&(ie.pbkdf2Sync.length>4||!n||n==="sha1"))return typeof n!="string"&&(n="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),i?ie.pbkdf2Sync.length===4?ie.pbkdf2(e,t,a,r,function(U,M){if(U)return i(U);i(null,M.toString("binary"))}):ie.pbkdf2(e,t,a,r,n,function(U,M){if(U)return i(U);i(null,M.toString("binary"))}):ie.pbkdf2Sync.length===4?ie.pbkdf2Sync(e,t,a,r).toString("binary"):ie.pbkdf2Sync(e,t,a,r,n).toString("binary");if((typeof n>"u"||n===null)&&(n="sha1"),typeof n=="string"){if(!(n in V.md.algorithms))throw new Error("Unknown hash algorithm: "+n);n=V.md[n].create()}var s=n.digestLength;if(r>4294967295*s){var f=new Error("Derived key is too long.");if(i)return i(f);throw f}var h=Math.ceil(r/s),o=r-(h-1)*s,c=V.hmac.create();c.start(n,e);var l="",v,_,S;if(!i){for(var I=1;I<=h;++I){c.start(null,null),c.update(t),c.update(V.util.int32ToBytes(I)),v=S=c.digest().getBytes();for(var A=2;A<=a;++A)c.start(null,null),c.update(S),_=c.digest().getBytes(),v=V.util.xorBytes(v,_,s),S=_;l+=I<h?v:v.substr(0,o)}return l}var I=1,A;function C(){if(I>h)return i(null,l);c.start(null,null),c.update(t),c.update(V.util.int32ToBytes(I)),v=S=c.digest().getBytes(),A=2,E()}function E(){if(A<=a)return c.start(null,null),c.update(S),_=c.digest().getBytes(),v=V.util.xorBytes(v,_,s),S=_,++A,V.util.setImmediate(E);l+=I<h?v:v.substr(0,o),++I,C()}C()}});var yt=z((Mr,pt)=>{var q=$();K();q.cipher=q.cipher||{};var k=pt.exports=q.cipher.modes=q.cipher.modes||{};k.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)};k.ecb.prototype.start=function(e){};k.ecb.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])};k.ecb.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])};k.ecb.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0};k.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)};k.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)};k.cbc.prototype.start=function(e){if(e.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in e)this._iv=ke(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};k.cbc.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=this._prev[r]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r]);this._prev=this._outBlock};k.cbc.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._prev[r]^this._outBlock[r]);this._prev=this._inBlock.slice(0)};k.cbc.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0};k.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)};k.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};k.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=ke(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};k.cfb.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32()^this._outBlock[n],t.putInt32(this._inBlock[n]);return}var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32()^this._outBlock[n],this._partialOutput.putInt32(this._partialBlock[n]);if(i>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};k.cfb.prototype.decrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32(),t.putInt32(this._inBlock[n]^this._outBlock[n]);return}var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[n]^this._outBlock[n]);if(i>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};k.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};k.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=ke(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};k.ofb.prototype.encrypt=function(e,t,a){var r=e.length();if(e.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]),this._inBlock[n]=this._outBlock[n];return}var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(i>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._outBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};k.ofb.prototype.decrypt=k.ofb.prototype.encrypt;k.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};k.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=ke(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};k.ctr.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize)for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]);else{var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(i>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}Le(this._inBlock)};k.ctr.prototype.decrypt=k.ctr.prototype.encrypt;k.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};k.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=q.util.createBuffer(e.iv);this._cipherLength=0;var a;if("additionalData"in e?a=q.util.createBuffer(e.additionalData):a=q.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._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 r=t.length();if(r===12)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(je(r*8)))}this._inBlock=this._j0.slice(0),Le(this._inBlock),this._partialBytes=0,a=q.util.createBuffer(a),this._aDataLength=je(a.length()*8);var n=a.length()%this.blockSize;for(n&&a.fillWithByte(0,this.blockSize-n),this._s=[0,0,0,0];a.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()])};k.gcm.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^=e.getInt32());this._cipherLength+=this.blockSize}else{var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(i<=0||a){if(a){var s=r%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(var n=0;n<this._ints;++n)this._outBlock[n]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),Le(this._inBlock)};k.gcm.prototype.decrypt=function(e,t,a){var r=e.length();if(r<this.blockSize&&!(a&&r>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),Le(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 n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^this._hashBlock[n]);r<this.blockSize?this._cipherLength+=r%this.blockSize:this._cipherLength+=this.blockSize};k.gcm.prototype.afterFinish=function(e,t){var a=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=q.util.createBuffer();var r=this._aDataLength.concat(je(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,r);var n=[];this.cipher.encrypt(this._j0,n);for(var i=0;i<this._ints;++i)this.tag.putInt32(this._s[i]^n[i]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(a=!1),a};k.gcm.prototype.multiply=function(e,t){for(var a=[0,0,0,0],r=t.slice(0),n=0;n<128;++n){var i=e[n/32|0]&1<<31-n%32;i&&(a[0]^=r[0],a[1]^=r[1],a[2]^=r[2],a[3]^=r[3]),this.pow(r,r)}return a};k.gcm.prototype.pow=function(e,t){for(var a=e[3]&1,r=3;r>0;--r)t[r]=e[r]>>>1|(e[r-1]&1)<<31;t[0]=e[0]>>>1,a&&(t[0]^=this._R)};k.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],a=0;a<32;++a){var r=a/8|0,n=e[r]>>>(7-a%8)*4&15,i=this._m[a][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t};k.gcm.prototype.ghash=function(e,t,a){return t[0]^=a[0],t[1]^=a[1],t[2]^=a[2],t[3]^=a[3],this.tableMultiply(t)};k.gcm.prototype.generateHashTable=function(e,t){for(var a=8/t,r=4*a,n=16*a,i=new Array(n),s=0;s<n;++s){var f=[0,0,0,0],h=s/r|0,o=(r-1-s%r)*t;f[h]=1<<t-1<<o,i[s]=this.generateSubHashTable(this.multiply(f,e),t)}return i};k.gcm.prototype.generateSubHashTable=function(e,t){var a=1<<t,r=a>>>1,n=new Array(a);n[r]=e.slice(0);for(var i=r>>>1;i>0;)this.pow(n[2*i],n[i]=[]),i>>=1;for(i=2;i<r;){for(var s=1;s<i;++s){var f=n[i],h=n[s];n[i+s]=[f[0]^h[0],f[1]^h[1],f[2]^h[2],f[3]^h[3]]}i*=2}for(n[0]=[0,0,0,0],i=r+1;i<a;++i){var o=n[i^r];n[i]=[e[0]^o[0],e[1]^o[1],e[2]^o[2],e[3]^o[3]]}return n};function ke(e,t){if(typeof e=="string"&&(e=q.util.createBuffer(e)),q.util.isArray(e)&&e.length>4){var a=e;e=q.util.createBuffer();for(var r=0;r<a.length;++r)e.putByte(a[r])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!q.util.isArray(e)){for(var n=[],i=t/4,r=0;r<i;++r)n.push(e.getInt32());e=n}return e}function Le(e){e[e.length-1]=e[e.length-1]+1&4294967295}function je(e){return[e/4294967296|0,e&4294967295]}});var It=z((Ur,_t)=>{var T=$();He();yt();K();_t.exports=T.aes=T.aes||{};T.aes.startEncrypting=function(e,t,a,r){var n=Ee({key:e,output:a,decrypt:!1,mode:r});return n.start(t),n};T.aes.createEncryptionCipher=function(e,t){return Ee({key:e,output:null,decrypt:!1,mode:t})};T.aes.startDecrypting=function(e,t,a,r){var n=Ee({key:e,output:a,decrypt:!0,mode:r});return n.start(t),n};T.aes.createDecryptionCipher=function(e,t){return Ee({key:e,output:null,decrypt:!0,mode:t})};T.aes.Algorithm=function(e,t){Ge||Bt();var a=this;a.name=e,a.mode=new t({blockSize:16,cipher:{encrypt:function(r,n){return Pe(a._w,r,n,!1)},decrypt:function(r,n){return Pe(a._w,r,n,!0)}}}),a._init=!1};T.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t=e.key,a;if(typeof t=="string"&&(t.length===16||t.length===24||t.length===32))t=T.util.createBuffer(t);else if(T.util.isArray(t)&&(t.length===16||t.length===24||t.length===32)){a=t,t=T.util.createBuffer();for(var r=0;r<a.length;++r)t.putByte(a[r])}if(!T.util.isArray(t)){a=t,t=[];var n=a.length();if(n===16||n===24||n===32){n=n>>>2;for(var r=0;r<n;++r)t.push(a.getInt32())}}if(!T.util.isArray(t)||!(t.length===4||t.length===6||t.length===8))throw new Error("Invalid key parameter.");var i=this.mode.name,s=["CFB","OFB","CTR","GCM"].indexOf(i)!==-1;this._w=mt(t,e.decrypt&&!s),this._init=!0}};T.aes._expandKey=function(e,t){return Ge||Bt(),mt(e,t)};T.aes._updateBlock=Pe;pe("AES-ECB",T.cipher.modes.ecb);pe("AES-CBC",T.cipher.modes.cbc);pe("AES-CFB",T.cipher.modes.cfb);pe("AES-OFB",T.cipher.modes.ofb);pe("AES-CTR",T.cipher.modes.ctr);pe("AES-GCM",T.cipher.modes.gcm);function pe(e,t){var a=function(){return new T.aes.Algorithm(e,t)};T.cipher.registerAlgorithm(e,a)}var Ge=!1,be=4,P,Ve,vt,de,X;function Bt(){Ge=!0,vt=[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;P=new Array(256),Ve=new Array(256),de=new Array(4),X=new Array(4);for(var t=0;t<4;++t)de[t]=new Array(256),X[t]=new Array(256);for(var a=0,r=0,n,i,s,f,h,o,c,t=0;t<256;++t){f=r^r<<1^r<<2^r<<3^r<<4,f=f>>8^f&255^99,P[a]=f,Ve[f]=a,h=e[f],n=e[a],i=e[n],s=e[i],o=h<<24^f<<16^f<<8^(f^h),c=(n^i^s)<<24^(a^s)<<16^(a^i^s)<<8^(a^n^s);for(var l=0;l<4;++l)de[l][a]=o,X[l][f]=c,o=o<<24|o>>>8,c=c<<24|c>>>8;a===0?a=r=1:(a=n^e[e[e[n^s]]],r^=e[e[r]])}}function mt(e,t){for(var a=e.slice(0),r,n=1,i=a.length,s=i+6+1,f=be*s,h=i;h<f;++h)r=a[h-1],h%i===0?(r=P[r>>>16&255]<<24^P[r>>>8&255]<<16^P[r&255]<<8^P[r>>>24]^vt[n]<<24,n++):i>6&&h%i===4&&(r=P[r>>>24]<<24^P[r>>>16&255]<<16^P[r>>>8&255]<<8^P[r&255]),a[h]=a[h-i]^r;if(t){var o,c=X[0],l=X[1],v=X[2],_=X[3],S=a.slice(0);f=a.length;for(var h=0,I=f-be;h<f;h+=be,I-=be)if(h===0||h===f-be)S[h]=a[I],S[h+1]=a[I+3],S[h+2]=a[I+2],S[h+3]=a[I+1];else for(var A=0;A<be;++A)o=a[I+A],S[h+(3&-A)]=c[P[o>>>24]]^l[P[o>>>16&255]]^v[P[o>>>8&255]]^_[P[o&255]];a=S}return a}function Pe(e,t,a,r){var n=e.length/4-1,i,s,f,h,o;r?(i=X[0],s=X[1],f=X[2],h=X[3],o=Ve):(i=de[0],s=de[1],f=de[2],h=de[3],o=P);var c,l,v,_,S,I,A;c=t[0]^e[0],l=t[r?3:1]^e[1],v=t[2]^e[2],_=t[r?1:3]^e[3];for(var C=3,E=1;E<n;++E)S=i[c>>>24]^s[l>>>16&255]^f[v>>>8&255]^h[_&255]^e[++C],I=i[l>>>24]^s[v>>>16&255]^f[_>>>8&255]^h[c&255]^e[++C],A=i[v>>>24]^s[_>>>16&255]^f[c>>>8&255]^h[l&255]^e[++C],_=i[_>>>24]^s[c>>>16&255]^f[l>>>8&255]^h[v&255]^e[++C],c=S,l=I,v=A;a[0]=o[c>>>24]<<24^o[l>>>16&255]<<16^o[v>>>8&255]<<8^o[_&255]^e[++C],a[r?3:1]=o[l>>>24]<<24^o[v>>>16&255]<<16^o[_>>>8&255]<<8^o[c&255]^e[++C],a[2]=o[v>>>24]<<24^o[_>>>16&255]<<16^o[c>>>8&255]<<8^o[l&255]^e[++C],a[r?1:3]=o[_>>>24]<<24^o[c>>>16&255]<<16^o[l>>>8&255]<<8^o[v&255]^e[++C]}function Ee(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="AES-"+t,r;e.decrypt?r=T.cipher.createDecipher(a,e.key):r=T.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(i,s){var f=null;s instanceof T.util.ByteBuffer&&(f=s,s={}),s=s||{},s.output=f,s.iv=i,n.call(r,s)},r}});var $e=z((Rr,Ft)=>{var J=$();he();K();var wt=Ft.exports=J.sha256=J.sha256||{};J.md.sha256=J.md.algorithms.sha256=wt;wt.create=function(){At||mr();var e=null,t=J.util.createBuffer(),a=new Array(64),r={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,i=0;i<n;++i)r.fullMessageLength.push(0);return t=J.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},r},r.start(),r.update=function(n,i){i==="utf8"&&(n=J.util.encodeUtf8(n));var s=n.length;r.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var f=r.fullMessageLength.length-1;f>=0;--f)r.fullMessageLength[f]+=s[1],s[1]=s[0]+(r.fullMessageLength[f]/4294967296>>>0),r.fullMessageLength[f]=r.fullMessageLength[f]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(n),St(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=J.util.createBuffer();n.putBytes(t.bytes());var i=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,s=i&r.blockLength-1;n.putBytes(Ye.substr(0,r.blockLength-s));for(var f,h,o=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)f=r.fullMessageLength[c+1]*8,h=f/4294967296>>>0,o+=h,n.putInt32(o>>>0),o=f>>>0;n.putInt32(o);var l={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};St(l,a,n);var v=J.util.createBuffer();return v.putInt32(l.h0),v.putInt32(l.h1),v.putInt32(l.h2),v.putInt32(l.h3),v.putInt32(l.h4),v.putInt32(l.h5),v.putInt32(l.h6),v.putInt32(l.h7),v},r};var Ye=null,At=!1,Ct=null;function mr(){Ye="\x80",Ye+=J.util.fillString("\0",64),Ct=[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],At=!0}function St(e,t,a){for(var r,n,i,s,f,h,o,c,l,v,_,S,I,A,C,E=a.length();E>=64;){for(o=0;o<16;++o)t[o]=a.getInt32();for(;o<64;++o)r=t[o-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,n=t[o-15],n=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[o]=r+t[o-7]+n+t[o-16]|0;for(c=e.h0,l=e.h1,v=e.h2,_=e.h3,S=e.h4,I=e.h5,A=e.h6,C=e.h7,o=0;o<64;++o)s=(S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7),f=A^S&(I^A),i=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),h=c&l|v&(c^l),r=C+s+f+Ct[o]+t[o],n=i+h,C=A,A=I,I=S,S=_+r>>>0,_=v,v=l,l=c,c=r+n>>>0;e.h0=e.h0+c|0,e.h1=e.h1+l|0,e.h2=e.h2+v|0,e.h3=e.h3+_|0,e.h4=e.h4+S|0,e.h5=e.h5+I|0,e.h6=e.h6+A|0,e.h7=e.h7+C|0,E-=64}}});var Lt=z((zr,kt)=>{var Z=$();K();var Te=null;Z.util.isNodejs&&!Z.options.usePureJavaScript&&!process.versions["node-webkit"]&&(Te=require("crypto"));var _r=kt.exports=Z.prng=Z.prng||{};_r.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},a=e.md,r=new Array(32),n=0;n<32;++n)r[n]=a.create();t.pools=r,t.pool=0,t.generate=function(o,c){if(!c)return t.generateSync(o);var l=t.plugin.cipher,v=t.plugin.increment,_=t.plugin.formatKey,S=t.plugin.formatSeed,I=Z.