s3db.js 3.1.0 → 3.2.0
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/dist/s3db.cjs.js +11 -1
- package/dist/s3db.cjs.min.js +4 -4
- package/dist/s3db.es.js +11 -1
- package/dist/s3db.es.min.js +4 -4
- package/dist/s3db.iife.js +11 -1
- package/dist/s3db.iife.min.js +4 -4
- package/package.json +1 -1
package/dist/s3db.cjs.min.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
|
-
"use strict";var ni=require("nanoid"),O=require("lodash-es"),ue=require("@supercharge/promise-pool"),de=require("@aws-sdk/client-s3"),At=require("flat"),Za=require("fastest-validator"),rr=require("node:stream/web");function ai(e,t){for(var r=0,i=e.length-1;i>=0;i--){var n=e[i];n==="."?e.splice(i,1):n===".."?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var ja=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,ir=function(e){return ja.exec(e).slice(1)};function nr(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var i=r>=0?arguments[r]:"/";if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)continue;e=i+"/"+e,t=i.charAt(0)==="/"}return e=ai(ar(e.split("/"),function(n){return!!n}),!t).join("/"),(t?"/":"")+e||"."}function oi(e){var t=si(e),r=Ga(e,-1)==="/";return e=ai(ar(e.split("/"),function(i){return!!i}),!t).join("/"),!e&&!t&&(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function si(e){return e.charAt(0)==="/"}function
|
|
2
|
+
"use strict";var ni=require("nanoid"),O=require("lodash-es"),ue=require("@supercharge/promise-pool"),de=require("@aws-sdk/client-s3"),At=require("flat"),Za=require("fastest-validator"),rr=require("node:stream/web");function ai(e,t){for(var r=0,i=e.length-1;i>=0;i--){var n=e[i];n==="."?e.splice(i,1):n===".."?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var ja=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,ir=function(e){return ja.exec(e).slice(1)};function nr(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var i=r>=0?arguments[r]:"/";if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)continue;e=i+"/"+e,t=i.charAt(0)==="/"}return e=ai(ar(e.split("/"),function(n){return!!n}),!t).join("/"),(t?"/":"")+e||"."}function oi(e){var t=si(e),r=Ga(e,-1)==="/";return e=ai(ar(e.split("/"),function(i){return!!i}),!t).join("/"),!e&&!t&&(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function si(e){return e.charAt(0)==="/"}function W(){var e=Array.prototype.slice.call(arguments,0);return oi(ar(e,function(t,r){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function $a(e,t){e=nr(e).substr(1),t=nr(t).substr(1);function r(f){for(var l=0;l<f.length&&f[l]==="";l++);for(var d=f.length-1;d>=0&&f[d]==="";d--);return l>d?[]:f.slice(l,d-l+1)}for(var i=r(e.split("/")),n=r(t.split("/")),a=Math.min(i.length,n.length),o=a,s=0;s<a;s++)if(i[s]!==n[s]){o=s;break}for(var h=[],s=o;s<i.length;s++)h.push("..");return h=h.concat(n.slice(o)),h.join("/")}var Ha="/",Ka=":";function Wa(e){var t=ir(e),r=t[0],i=t[1];return!r&&!i?".":(i&&(i=i.substr(0,i.length-1)),r+i)}function Ya(e,t){var r=ir(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r}function qa(e){return ir(e)[3]}var ne={extname:qa,basename:Ya,dirname:Wa,sep:Ha,delimiter:Ka,relative:$a,join:W,isAbsolute:si,normalize:oi,resolve:nr};function ar(e,t){if(e.filter)return e.filter(t);for(var r=[],i=0;i<e.length;i++)t(e[i],i,e)&&r.push(e[i]);return r}var Ga="ab".substr(-1)==="b"?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)},Va;function pe(){}pe.prototype=Object.create(null);function b(){b.init.call(this)}b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&Va.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new pe,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this};function fi(e){return e._maxListeners===void 0?b.defaultMaxListeners:e._maxListeners}b.prototype.getMaxListeners=function(){return fi(this)};function Xa(e,t,r){if(t)e.call(r);else for(var i=e.length,n=nt(e,i),a=0;a<i;++a)n[a].call(r)}function Ja(e,t,r,i){if(t)e.call(r,i);else for(var n=e.length,a=nt(e,n),o=0;o<n;++o)a[o].call(r,i)}function Qa(e,t,r,i,n){if(t)e.call(r,i,n);else for(var a=e.length,o=nt(e,a),s=0;s<a;++s)o[s].call(r,i,n)}function eo(e,t,r,i,n,a){if(t)e.call(r,i,n,a);else for(var o=e.length,s=nt(e,o),h=0;h<o;++h)s[h].call(r,i,n,a)}function to(e,t,r,i){if(t)e.apply(r,i);else for(var n=e.length,a=nt(e,n),o=0;o<n;++o)a[o].apply(r,i)}b.prototype.emit=function(t){var r,i,n,a,o,s,h,f=t==="error";if(s=this._events,s)f=f&&s.error==null;else if(!f)return!1;if(h=this.domain,f){if(r=arguments[1],h)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=h,r.domainThrown=!1,h.emit("error",r);else{if(r instanceof Error)throw r;var l=new Error('Uncaught, unspecified "error" event. ('+r+")");throw l.context=r,l}return!1}if(i=s[t],!i)return!1;var d=typeof i=="function";switch(n=arguments.length,n){case 1:Xa(i,d,this);break;case 2:Ja(i,d,this,arguments[1]);break;case 3:Qa(i,d,this,arguments[1],arguments[2]);break;case 4:eo(i,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(n-1),o=1;o<n;o++)a[o-1]=arguments[o];to(i,d,this,a)}return!0};function li(e,t,r,i){var n,a,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),o=a[t]):(a=e._events=new pe,e._eventsCount=0),!o)o=a[t]=r,++e._eventsCount;else if(typeof o=="function"?o=a[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),!o.warned&&(n=fi(e),n&&n>0&&o.length>n)){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,ro(s)}return e}function ro(e){typeof console.warn=="function"?console.warn(e):console.log(e)}b.prototype.addListener=function(t,r){return li(this,t,r,!1)},b.prototype.on=b.prototype.addListener,b.prototype.prependListener=function(t,r){return li(this,t,r,!0)};function hi(e,t,r){var i=!1;function n(){e.removeListener(t,n),i||(i=!0,r.apply(e,arguments))}return n.listener=r,n}b.prototype.once=function(t,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(t,hi(this,t,r)),this},b.prototype.prependOnceListener=function(t,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(t,hi(this,t,r)),this},b.prototype.removeListener=function(t,r){var i,n,a,o,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(n=this._events,!n)return this;if(i=n[t],!i)return this;if(i===r||i.listener&&i.listener===r)--this._eventsCount===0?this._events=new pe:(delete n[t],n.removeListener&&this.emit("removeListener",t,i.listener||r));else if(typeof i!="function"){for(a=-1,o=i.length;o-- >0;)if(i[o]===r||i[o].listener&&i[o].listener===r){s=i[o].listener,a=o;break}if(a<0)return this;if(i.length===1){if(i[0]=void 0,--this._eventsCount===0)return this._events=new pe,this;delete n[t]}else io(i,a);n.removeListener&&this.emit("removeListener",t,s||r)}return this},b.prototype.off=function(e,t){return this.removeListener(e,t)},b.prototype.removeAllListeners=function(t){var r,i;if(i=this._events,!i)return this;if(!i.removeListener)return arguments.length===0?(this._events=new pe,this._eventsCount=0):i[t]&&(--this._eventsCount===0?this._events=new pe:delete i[t]),this;if(arguments.length===0){for(var n=Object.keys(i),a=0,o;a<n.length;++a)o=n[a],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=new pe,this._eventsCount=0,this}if(r=i[t],typeof r=="function")this.removeListener(t,r);else if(r)do this.removeListener(t,r[r.length-1]);while(r[0]);return this},b.prototype.listeners=function(t){var r,i,n=this._events;return n?(r=n[t],r?typeof r=="function"?i=[r.listener||r]:i=no(r):i=[]):i=[],i},b.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):ci.call(e,t)},b.prototype.listenerCount=ci;function ci(e){var t=this._events;if(t){var r=t[e];if(typeof r=="function")return 1;if(r)return r.length}return 0}b.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function io(e,t){for(var r=t,i=r+1,n=e.length;i<n;r+=1,i+=1)e[r]=e[i];e.pop()}function nt(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}function no(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}class We extends Error{constructor({verbose:t,bucket:r,message:i,...n}){t&&(i=i+`
|
|
3
3
|
|
|
4
4
|
Verbose:
|
|
5
5
|
|
|
6
6
|
${JSON.stringify(n,null,2)}`),super(i),typeof Error.captureStackTrace=="function"?Error.captureStackTrace(this,this.constructor):this.stack=new Error(i).stack,super.name=this.constructor.name,this.name=this.constructor.name,this.bucket=r,this.thrownAt=new Date}toJson(){return{...this}}toString(){return`${this.name} | ${this.message}`}}class ui extends We{constructor({bucket:t,...r}){super({...r,bucket:t,message:`Bucket does not exists [bucket:${t}]`})}}class or extends We{constructor({bucket:t,key:r,...i}){super({...i,bucket:t,message:`Key does not exists [bucket:${t}/${r}]`}),this.key=r}}class di extends or{}class pi extends We{constructor({bucket:t,...r}){super({...r,bucket:t,message:`Missing metadata for bucket [bucket:${t}]`})}}class Tt extends We{constructor({bucket:t,resourceName:r,attributes:i,validation:n}){super({bucket:t,message:`This item is not valid. Resource=${r} [bucket:${t}].
|
|
7
|
-
${JSON.stringify(n,null,2)}`}),this.resourceName=r,this.attributes=i,this.validation=n}}class _i extends We{}const wi={NotFound:di,NoSuchKey:or,UnknownError:_i,NoSuchBucket:ui,MissingMetadata:pi,InvalidResourceItem:Tt},gi="us-east-1",vi="https://s3.us-east-1.amazonaws.com";class mi{constructor(t){let r;try{r=new URL(t)}catch{throw new Error("Invalid connection string: "+t)}this.region=gi,r.protocol==="s3:"?this.defineS3(r):this.defineMinio(r);for(const[i,n]of r.searchParams.entries())this[i]=n}defineS3(t){if(this.bucket=t.hostname,this.accessKeyId=t.username,this.secretAccessKey=t.password,this.endpoint=vi,["/","",null].includes(t.pathname))this.keyPrefix="";else{let[,...r]=t.pathname.split("/");this.keyPrefix=[...r||[]].join("/")}}defineMinio(t){if(this.forcePathStyle=!0,this.endpoint=t.origin,this.accessKeyId=t.username,this.secretAccessKey=t.password,["/","",null].includes(t.pathname))this.bucket="s3db",this.keyPrefix="";else{let[,r,...i]=t.pathname.split("/");this.bucket=r,this.keyPrefix=[...i||[]].join("/")}}}class bi extends b{constructor({verbose:t=!1,id:r=null,AwsS3Client:i,connectionString:n,parallelism:a=10}){super(),this.verbose=t,this.id=r??ni.nanoid(7),this.parallelism=a,this.config=new mi(n),this.client=i||this.createClient()}createClient(){let t={region:this.config.region,endpoint:this.config.endpoint};return this.config.forcePathStyle&&(t.forcePathStyle=!0),this.config.accessKeyId&&(t.credentials={accessKeyId:this.config.accessKeyId,secretAccessKey:this.config.secretAccessKey}),new de.S3Client(t)}async sendCommand(t){this.emit("command.request",t.constructor.name,t.input);const r=console.warn;try{console.warn=n=>{n.includes("Stream of unknown length")||r(n)}}catch(n){console.error(n)}const i=await this.client.send(t);this.emit("command.response",t.constructor.name,i,t.input);try{console.warn=r}catch(n){console.error(n)}return i}errorProxy(t,r){this.verbose&&(r.bucket=this.config.bucket,r.config=this.config,r.verbose=this.verbose),t.data=r;const i=wi[t.name];return i?new i(r):t}async putObject({key:t,metadata:r,contentType:i,body:n,contentEncoding:a}){const o={Bucket:this.config.bucket,Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,t):t,Metadata:{...r},Body:n||"",ContentType:i,ContentEncoding:a};try{const s=await this.sendCommand(new de.PutObjectCommand(o));return this.emit("putObject",s,o),s}catch(s){throw this.errorProxy(s,{key:t,command:o})}}async getObject(t){const r={Bucket:this.config.bucket,Key:ne.join(this.config.keyPrefix,t)};try{const i=await this.sendCommand(new de.GetObjectCommand(r));return this.emit("getObject",i,r),i}catch(i){throw this.errorProxy(i,{key:t,command:r})}}async headObject(t){const r={Bucket:this.config.bucket,Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,t):t};try{const i=await this.client.send(new de.HeadObjectCommand(r));return this.emit("headObject",i,r),i}catch(i){throw this.errorProxy(i,{key:t,command:r})}}async copyObject({from:t,to:r}){const i={Bucket:this.config.bucket,Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,r):r,CopySource:ne.join(this.config.bucket,this.config.keyPrefix?ne.join(this.config.keyPrefix,t):t)};try{const n=await this.client.send(new de.CopyObjectCommand(i));return this.emit("copyObject",n,i),n}catch(n){throw this.errorProxy(n,{from:t,to:r,command:i})}}async exists(t){try{return await this.headObject(t),!0}catch(r){if(r.name==="NoSuchKey")return!1;if(r.name==="NotFound")return!1;throw r}}async deleteObject(t){const r={Bucket:this.config.bucket,Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,t):t};try{const i=await this.sendCommand(new de.DeleteObjectCommand(r));return this.emit("deleteObject",i,r),i}catch(i){throw this.errorProxy(i,{key:t,command:r})}}async deleteObjects(t){const r=O.chunk(t,1e3),{results:i,errors:n}=await ue.PromisePool.for(r).withConcurrency(this.parallelism).process(async o=>{const s={Bucket:this.config.bucket,Delete:{Objects:o.map(h=>({Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,h):h}))}};try{return await this.sendCommand(new de.DeleteObjectsCommand(s))}catch(h){throw this.errorProxy(h,{key,command:s})}}),a={deleted:i,notFound:n};return this.emit("deleteObjects",a,t),a}async deleteAll({prefix:t}={}){const r=await this.getAllKeys({prefix:t}),i=await this.deleteObjects(r);return this.emit("deleteAll",{prefix:t,report:i}),i}async moveObject({from:t,to:r}){try{return await this.copyObject({from:t,to:r}),await this.deleteObject(t),!0}catch(i){throw this.errorProxy(i,{from:t,to:r,command:options})}}async listObjects({prefix:t,maxKeys:r=1e3,continuationToken:i}={}){const n={Bucket:this.config.bucket,MaxKeys:r,ContinuationToken:i,Prefix:this.config.keyPrefix?ne.join(this.config.keyPrefix,t||""):t||""};try{const a=await this.sendCommand(new de.ListObjectsV2Command(n));return this.emit("listObjects",a,n),a}catch(a){throw this.errorProxy(a,{command:n})}}async count({prefix:t}={}){let r=0,i=!0,n;for(;i;){const a={prefix:t,continuationToken:n},o=await this.listObjects(a);r+=o.KeyCount||0,i=o.IsTruncated||!1,n=o.NextContinuationToken}return this.emit("count",r,{prefix:t}),r}async getAllKeys({prefix:t}={}){let r=[],i=!0,n;for(;i;){const a={prefix:t,continuationToken:n},o=await this.listObjects(a);o.Contents&&(r=r.concat(o.Contents.map(s=>s.Key))),i=o.IsTruncated||!1,n=o.NextContinuationToken}return this.config.keyPrefix&&(r=r.map(a=>a.replace(this.config.keyPrefix,"")).map(a=>a.startsWith("/")?a.replace("/",""):a)),this.emit("getAllKeys",r,{prefix:t}),r}async getContinuationTokenAfterOffset(t={}){const{prefix:r,offset:i=1e3}=t;if(i===0)return null;let n=!0,a,o=0;for(;n;){let s=i<1e3?i:i-o>1e3?1e3:i-o;const h={prefix:r,maxKeys:s,continuationToken:a},f=await this.listObjects(h);if(f.Contents&&(o+=f.Contents.length),n=f.IsTruncated||!1,a=f.NextContinuationToken,o>=i)break}return this.emit("getContinuationTokenAfterOffset",a,t),a}async getKeysPage(t={}){const{prefix:r,offset:i=0,amount:n=100}=t;let a=[],o=!0,s;for(i>0&&(s=await this.getContinuationTokenAfterOffset({prefix:r,offset:i}));o;){const h={prefix:r,continuationToken:s},f=await this.listObjects(h);if(f.Contents&&(a=a.concat(f.Contents.map(l=>l.Key))),o=f.IsTruncated||!1,s=f.NextContinuationToken,a.length>n){a=a.splice(0,n);break}}return this.config.keyPrefix&&(a=a.map(h=>h.replace(this.config.keyPrefix,"")).map(h=>h.startsWith("/")?h.replace("/",""):h)),this.emit("getKeysPage",a,t),a}async moveAllObjects({prefixFrom:t,prefixTo:r}){const i=await this.getAllKeys({prefix:t}),{results:n,errors:a}=await ue.PromisePool.for(i).withConcurrency(this.parallelism).process(async o=>{const s=o.replace(t,r);try{return await this.moveObject({from:o,to:s}),s}catch(h){throw this.errorProxy(h,{from:o,to:s})}});if(this.emit("moveAllObjects",{results:n,errors:a},{prefixFrom:t,prefixTo:r}),a.length>0)throw console.log({errors:a}),new Error("Some objects could not be moved");return n}}async function Lt(){return O.isObject(process)?(await Promise.resolve().then(function(){return vh})).webcrypto:window.crypto}async function yi(e){const t=await Lt(),i=new TextEncoder().encode(e),n=await t.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}async function sr(e,t){const r=await Lt(),i=r.getRandomValues(new Uint8Array(16)),n=await Ei(t,i),a=r.getRandomValues(new Uint8Array(12)),s=new TextEncoder().encode(e),h=await r.subtle.encrypt({name:"AES-GCM",iv:a},n,s),f=new Uint8Array(i.length+a.length+h.byteLength);return f.set(i),f.set(a,i.length),f.set(new Uint8Array(h),i.length+a.length),ao(f)}async function xi(e,t){const r=await Lt(),i=oo(e),n=i.slice(0,16),a=i.slice(16,28),o=i.slice(28),s=await Ei(t,n),h=await r.subtle.decrypt({name:"AES-GCM",iv:a},s,o);return new TextDecoder().decode(h)}async function Ei(e,t){const r=await Lt(),n=new TextEncoder().encode(e),a=await r.subtle.importKey("raw",n,{name:"PBKDF2"},!1,["deriveKey"]);return await r.subtle.deriveKey({name:"PBKDF2",salt:t,iterations:1e5,hash:"SHA-256"},a,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}function ao(e){if(O.isObject(process))return Buffer.from(e).toString("base64");{const t=String.fromCharCode.apply(null,new Uint8Array(e));return window.btoa(t)}}function oo(e){if(O.isObject(process))return new Uint8Array(Buffer.from(e,"base64"));{const t=window.atob(e),r=t.length,i=new Uint8Array(r);for(let n=0;n<r;n++)i[n]=t.charCodeAt(n);return i}}async function fr(e,t,r){if(!this.passphrase)return t.push({actual:e,type:"encryptionKeyMissing"}),e;try{return await sr(String(e),this.passphrase)}catch(i){t.push({actual:e,type:"encryptionProblem",error:i})}return e}class ki extends Za{constructor({options:t,passphrase:r,autoEncrypt:i=!0}={}){super(O.merge({},{useNewCustomCheckerFunction:!0,messages:{encryptionKeyMissing:"Missing configuration for secrets encryption.",encryptionProblem:"Problem encrypting secret. Actual: {actual}. Error: {error}"},defaults:{string:{trim:!0},object:{strict:"remove"}}},t)),this.passphrase=r,this.autoEncrypt=i,this.alias("secret",{type:"string",custom:this.autoEncrypt?fr:void 0,messages:{string:"The '{field}' field must be a string.",stringMin:"This secret '{field}' field length must be at least {expected} long."}}),this.alias("secretAny",{type:"any",custom:this.autoEncrypt?fr:void 0}),this.alias("secretNumber",{type:"number",custom:this.autoEncrypt?fr:void 0})}}const Si=new Proxy(ki,{instance:null,construct(e,t){return this.instance||(this.instance=new e(...t)),this.instance}}),so={trim:e=>e.trim(),encrypt:(e,{passphrase:t})=>sr(e,t),decrypt:(e,{passphrase:t})=>xi(e,t),toString:e=>String(e),fromArray:(e,{separator:t})=>(e||[]).join(t),toArray:(e,{separator:t})=>(e||"").split(t),toNumber:e=>O.isString(e)?e.includes(".")?parseFloat(e):parseInt(e):e,toJSON:e=>JSON.stringify(e),fromJSON:e=>JSON.parse(e)};class ti{constructor(t){const{map:r,name:i,attributes:n,passphrase:a,version:o=1,options:s={}}=t;if(this.name=i,this.version=o,this.attributes=n,this.passphrase=a??"secret",this.options=O.merge({},this.defaultOptions(),s),this.validator=new Si({autoEncrypt:!1}).compile(O.merge({$$async:!0},O.cloneDeep(this.attributes))),this.options.generateAutoHooks&&this.generateAutoHooks(),!O.isEmpty(r))this.map=r,this.reversedMap=O.invert(r);else{const h=At.flatten(this.attributes,{safe:!0});this.reversedMap={...Object.keys(h).filter(f=>!f.includes("$$type"))},this.map=O.invert(this.reversedMap)}}defaultOptions(){return{autoEncrypt:!0,autoDecrypt:!0,arraySeparator:"|",generateAutoHooks:!0,hooks:{beforeMap:{},afterMap:{},beforeUnmap:{},afterUnmap:{}}}}addHook(t,r,i){this.options.hooks[t][r]||(this.options.hooks[t][r]=[]),this.options.hooks[t][r]=O.uniq([...this.options.hooks[t][r],i])}generateAutoHooks(){const t=At.flatten(O.cloneDeep(this.attributes),{safe:!0});for(const[r,i]of Object.entries(t))i.includes("array")?(this.addHook("beforeMap",r,"fromArray"),this.addHook("afterUnmap",r,"toArray")):(i.includes("secret")&&(this.options.autoEncrypt&&this.addHook("beforeMap",r,"encrypt"),this.options.autoDecrypt&&this.addHook("afterUnmap",r,"decrypt")),i.includes("number")&&(this.addHook("beforeMap",r,"toString"),this.addHook("afterUnmap",r,"toNumber")),i.includes("boolean")&&(this.addHook("beforeMap",r,"toJson"),this.addHook("afterUnmap",r,"fromJson")))}static import(t){let{map:r,name:i,options:n,version:a,attributes:o}=O.isString(t)?JSON.parse(t):t;return new ti({map:r,name:i,options:n,version:a,attributes:o})}export(){const t={version:this.version,name:this.name,options:this.options,attributes:O.cloneDeep(this.attributes),map:this.map};for(const[r,i]of Object.entries(this.attributes))t.attributes[r]=JSON.stringify(i);return t}async applyHooksActions(t,r){for(const[i,n]of Object.entries(this.options.hooks[r]))for(const a of n){const o=O.get(t,i);o&&O.set(t,i,await so[a](o,{passphrase:this.passphrase,separator:this.options.arraySeparator}))}}async validate(t,{mutateOriginal:r=!1}={}){let i=r?t:O.cloneDeep(t);return await this.validator(i)}async mapper(t){const r=At.flatten(O.cloneDeep(t),{safe:!0});await this.applyHooksActions(r,"beforeMap");const i={_v:this.version+""};for(const[n,a]of Object.entries(r))i[this.map[n]]=a;return await this.applyHooksActions(i,"afterMap"),i}async unmapper(t){const r=O.cloneDeep(t);delete r._v,await this.applyHooksActions(r,"beforeUnmap");const i={};for(const[n,a]of Object.entries(r))i[this.reversedMap[n]]=a;return await this.applyHooksActions(i,"afterUnmap"),At.unflatten(i)}}class Ri extends b{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new rr.ReadableStream({highWaterMark:this.client.parallelism*3,start:this._start.bind(this),pull:this._pull.bind(this),cancel:this._cancel.bind(this)})}build(){return this.stream.getReader()}async _start(t){this.controller=t,this.continuationToken=null,this.closeNextIteration=!1}async _pull(t){if(this.closeNextIteration){t.close();return}const r=await this.client.listObjects({prefix:`resource=${this.resource.name}`,continuationToken:this.continuationToken}),i=r?.Contents.map(n=>n.Key).map(n=>n.replace(this.client.config.keyPrefix,"")).map(n=>n.startsWith("/")?n.replace("/",""):n).map(n=>n.replace(`resource=${this.resource.name}/id=`,""));this.continuationToken=r.NextContinuationToken,this.enqueue(i),r.IsTruncated||(this.closeNextIteration=!0)}enqueue(t){t.forEach(r=>{this.controller.enqueue(r),this.emit("id",r)})}_cancel(t){console.warn("Stream cancelled",t)}}class Ai extends Ri{enqueue(t){this.controller.enqueue(t),this.emit("page",t)}}class Ti extends b{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.input=new Ai({resource:this.resource}),this.output=new rr.TransformStream({transform:this._transform.bind(this)},{highWaterMark:this.client.parallelism*2},{highWaterMark:1}),this.stream=this.input.stream.pipeThrough(this.output)}build(){return this.stream.getReader()}async _transform(t,r){await ue.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async i=>{const n=await this.resource.get(i);return r.enqueue(n),n})}}class Li extends b{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new rr.WritableStream({start:this._start.bind(this),write:this._write.bind(this),close:this._close.bind(this),abort:this._abort.bind(this)})}build(){return this.stream.getWriter()}async _start(t){this.controller=t}async _write(t,r){const i=this.resource;await ue.PromisePool.for([].concat(t)).withConcurrency(this.client.parallelism).process(async n=>{await i.insert(n)})}async _close(t){}async _abort(t){console.error("Stream aborted:",t)}}function lr(e){return new Promise((t,r)=>{const i=[];e.on("data",n=>i.push(n)),e.on("error",r),e.on("end",()=>t(Buffer.concat(i).toString("utf-8")))})}class Ci extends b{constructor({name:t,client:r,options:i={},attributes:n={},parallelism:a=10,passphrase:o="secret",observers:s=[]}){super(),this.name=t,this.client=r,this.options=i,this.observers=s,this.parallelism=a,this.passphrase=o??"secret",this.schema=new ti({name:t,attributes:n,passphrase:o})}export(){return this.schema.export()}async validate(t){const r={original:O.cloneDeep(t),isValid:!1,errors:[]},i=await this.schema.validate(t,{mutateOriginal:!0});return i===!0?r.isValid=!0:r.errors=i,r.data=t,r}async insert({id:t,...r}){const{errors:i,isValid:n,data:a}=await this.validate(r);if(!n)throw new Tt({bucket:this.client.config.bucket,resourceName:this.name,attributes:r,validation:i});!t&&t!==0&&(t=ni.nanoid());const o=await this.schema.mapper(a);await this.client.putObject({metadata:o,key:Y(`resource=${this.name}`,`id=${t}`)});const s=O.merge({id:t},a);return this.emit("insert",s),s}async get(t){const r=await this.client.headObject(Y(`resource=${this.name}`,`id=${t}`));let i=await this.schema.unmapper(r.Metadata);return i.id=t,i._length=r.ContentLength,i._createdAt=r.LastModified,r.Expiration&&(i._expiresAt=r.Expiration),this.emit("get",i),i}async update(t,r){const i=await this.get(t),n=O.merge(i,r);delete n.id;const{isValid:a,errors:o,data:s}=await this.validate(n);if(!a)throw new Tt({bucket:this.client.bucket,resourceName:this.name,attributes:r,validation:o});return await this.client.putObject({key:Y(`resource=${this.name}`,`id=${t}`),body:"",metadata:await this.schema.mapper(s)}),s.id=t,this.emit("update",r,s),s}async delete(t){const r=Y(`resource=${this.name}`,`id=${t}`),i=await this.client.deleteObject(r);return this.emit("delete",t),i}async count(){const t=await this.client.count({prefix:`resource=${this.name}`});return this.emit("count",t),t}async insertMany(t){const{results:r}=await ue.PromisePool.for(t).withConcurrency(this.parallelism).handleError(async(i,n)=>{this.emit("error",i,n),this.observers.map(a=>a.emit("error",this.name,i,n))}).process(async i=>await this.insert(i));return this.emit("insertMany",t.length),r}async deleteMany(t){const r=O.chunk(t.map(n=>Y(`resource=${this.name}`,`id=${n}`)),1e3),{results:i}=await ue.PromisePool.for(r).withConcurrency(this.parallelism).handleError(async(n,a)=>{this.emit("error",n,a),this.observers.map(o=>o.emit("error",this.name,n,a))}).process(async n=>{const a=await this.client.deleteObjects(n);return n.forEach(o=>{const s=o.split("=").pop();this.emit("deleted",s),this.observers.map(h=>h.emit("deleted",this.name,s))}),a});return this.emit("deleteMany",t.length),i}async deleteAll(){const t=await this.listIds();this.emit("deleteAll",t.length),await this.deleteMany(t)}async listIds(){const r=(await this.client.getAllKeys({prefix:`resource=${this.name}`})).map(i=>i.replace(`resource=${this.name}/id=`,""));return this.emit("listIds",r.length),r}async getMany(t){const{results:r}=await ue.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async i=>{this.emit("id",i);const n=await this.get(i);return this.emit("data",n),n});return this.emit("getMany",t.length),r}async getAll(){let t=await this.listIds();if(t.length===0)return[];const{results:r}=await ue.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async i=>await this.get(i));return this.emit("getAll",r.length),r}async page({offset:t=0,size:r=100}){const n=(await this.client.getKeysPage({offset:t,amount:r,prefix:`resource=${this.name}`})).map(o=>o.replace(`resource=${this.name}/id=`,""));return await this.getMany(n)}readable(){return new Ti({resource:this}).build()}writable(){return new Li({resource:this}).build()}}class Oi extends b{constructor(t){super(),this.version="1",this.resources={},this.options=t,this.verbose=t.verbose||!1,this.parallelism=parseInt(t.parallelism+"")||10,this.plugins=t.plugins||[],this.cache=t.cache,this.passphrase=t.passphrase||"secret",this.client=t.client||new bi({verbose:this.verbose,parallelism:this.parallelism,connectionString:t.connectionString}),this.bucket=this.client.bucket,this.keyPrefix=this.client.keyPrefix}async connect(){await this.startPlugins();let t=null;if(await this.client.exists("s3db.json")){const r=await this.client.getObject("s3db.json");t=JSON.parse(await lr(r?.Body)),t=this.unserializeMetadata(t)}else t=this.blankMetadataStructure(),await this.uploadMetadataFile();for(const r of Object.entries(t.resources)){const[i,n]=r;this.resources[i]=new Ci({name:i,client:this.client,options:n.options,attributes:n.schema,parallelism:this.parallelism,passphrase:this.passphrase,observers:[this]})}this.emit("connected",new Date)}async startPlugins(){const t=this;if(!O.isEmpty(this.plugins)){const r=this.plugins.map(a=>O.isFunction(a)?new a(this):a),i=r.map(async a=>{a.beforeSetup&&await a.beforeSetup(),await a.setup(t),a.afterSetup&&await a.afterSetup()});await Promise.all(i);const n=r.map(async a=>{a.beforeStart&&await a.beforeStart(),await a.start(),a.afterStart&&await a.afterStart()});await Promise.all(n)}}unserializeMetadata(t){const r={...t};if(O.isEmpty(r.resources))return r;for(const[i,n]of Object.entries(r.resources))for(const[a,o]of Object.entries(n.attributes))r.resources[i].attributes[a]=JSON.parse(o);return r}async uploadMetadataFile(){const t={version:this.version,resources:Object.entries(this.resources).reduce((r,i)=>{const[n,a]=i;return r[n]=a.export(),r},{})};await this.client.putObject({key:"s3db.json",contentType:"application/json",body:JSON.stringify(t,null,2)})}blankMetadataStructure(){return{version:"1",resources:{}}}async createResource({name:t,attributes:r,options:i={}}){const n=new Ci({name:t,attributes:r,observers:[this],client:this.client,options:{autoDecrypt:!0,cache:this.cache,...i}});return this.resources[t]=n,await this.uploadMetadataFile(),this.emit("s3db.resourceCreated",t),n}resource(t){return this.resources[t]?this.resources[t]:Promise.reject(`resource ${t} does not exist`)}}class fo extends Oi{}class hr extends b{async _set(t,r){}async _get(t){}async _del(t){}async _clear(t){}async set(t,r){return await this._set(t,r),this.emit("set",r),r}async get(t){const r=await this._get(t);return this.emit("get",r),r}async del(t){const r=await this._del(t);return this.emit("delete",r),r}async clear(){const t=await this._clear();return this.emit("clear",t),t}}class lo extends hr{constructor(){super(),this.cache={}}async _set(t,r){return this.cache[t]=r,r}async _get(t){return this.cache[t]}async _del(t){return delete this.cache[t],!0}async _clear(){return this.cache={},!0}}var Ye=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},ee=[],q=[],ho=typeof Uint8Array<"u"?Uint8Array:Array,cr=!1;function Ii(){cr=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)ee[t]=e[t],q[e.charCodeAt(t)]=t;q[45]=62,q[95]=63}function co(e){cr||Ii();var t,r,i,n,a,o,s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=e[s-2]==="="?2:e[s-1]==="="?1:0,o=new ho(s*3/4-a),i=a>0?s-4:s;var h=0;for(t=0,r=0;t<i;t+=4,r+=3)n=q[e.charCodeAt(t)]<<18|q[e.charCodeAt(t+1)]<<12|q[e.charCodeAt(t+2)]<<6|q[e.charCodeAt(t+3)],o[h++]=n>>16&255,o[h++]=n>>8&255,o[h++]=n&255;return a===2?(n=q[e.charCodeAt(t)]<<2|q[e.charCodeAt(t+1)]>>4,o[h++]=n&255):a===1&&(n=q[e.charCodeAt(t)]<<10|q[e.charCodeAt(t+1)]<<4|q[e.charCodeAt(t+2)]>>2,o[h++]=n>>8&255,o[h++]=n&255),o}function uo(e){return ee[e>>18&63]+ee[e>>12&63]+ee[e>>6&63]+ee[e&63]}function po(e,t,r){for(var i,n=[],a=t;a<r;a+=3)i=(e[a]<<16)+(e[a+1]<<8)+e[a+2],n.push(uo(i));return n.join("")}function Mi(e){cr||Ii();for(var t,r=e.length,i=r%3,n="",a=[],o=16383,s=0,h=r-i;s<h;s+=o)a.push(po(e,s,s+o>h?h:s+o));return i===1?(t=e[r-1],n+=ee[t>>2],n+=ee[t<<4&63],n+="=="):i===2&&(t=(e[r-2]<<8)+e[r-1],n+=ee[t>>10],n+=ee[t>>4&63],n+=ee[t<<2&63],n+="="),a.push(n),a.join("")}function Ct(e,t,r,i,n){var a,o,s=n*8-i-1,h=(1<<s)-1,f=h>>1,l=-7,d=r?n-1:0,p=r?-1:1,u=e[t+d];for(d+=p,a=u&(1<<-l)-1,u>>=-l,l+=s;l>0;a=a*256+e[t+d],d+=p,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=i;l>0;o=o*256+e[t+d],d+=p,l-=8);if(a===0)a=1-f;else{if(a===h)return o?NaN:(u?-1:1)*(1/0);o=o+Math.pow(2,i),a=a-f}return(u?-1:1)*o*Math.pow(2,a-i)}function Di(e,t,r,i,n,a){var o,s,h,f=a*8-n-1,l=(1<<f)-1,d=l>>1,p=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,u=i?0:a-1,g=i?1:-1,S=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),o+d>=1?t+=p/h:t+=p*Math.pow(2,1-d),t*h>=2&&(o++,h/=2),o+d>=l?(s=0,o=l):o+d>=1?(s=(t*h-1)*Math.pow(2,n),o=o+d):(s=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[r+u]=s&255,u+=g,s/=256,n-=8);for(o=o<<n|s,f+=n;f>0;e[r+u]=o&255,u+=g,o/=256,f-=8);e[r+u-g]|=S*128}var _o={}.toString,Fi=Array.isArray||function(e){return _o.call(e)=="[object Array]"};/*!
|
|
7
|
+
${JSON.stringify(n,null,2)}`}),this.resourceName=r,this.attributes=i,this.validation=n}}class _i extends We{}const wi={NotFound:di,NoSuchKey:or,UnknownError:_i,NoSuchBucket:ui,MissingMetadata:pi,InvalidResourceItem:Tt},gi="us-east-1",vi="https://s3.us-east-1.amazonaws.com";class mi{constructor(t){let r;try{r=new URL(t)}catch{throw new Error("Invalid connection string: "+t)}this.region=gi,r.protocol==="s3:"?this.defineS3(r):this.defineMinio(r);for(const[i,n]of r.searchParams.entries())this[i]=n}defineS3(t){if(this.bucket=t.hostname,this.accessKeyId=t.username,this.secretAccessKey=t.password,this.endpoint=vi,["/","",null].includes(t.pathname))this.keyPrefix="";else{let[,...r]=t.pathname.split("/");this.keyPrefix=[...r||[]].join("/")}}defineMinio(t){if(this.forcePathStyle=!0,this.endpoint=t.origin,this.accessKeyId=t.username,this.secretAccessKey=t.password,["/","",null].includes(t.pathname))this.bucket="s3db",this.keyPrefix="";else{let[,r,...i]=t.pathname.split("/");this.bucket=r,this.keyPrefix=[...i||[]].join("/")}}}class bi extends b{constructor({verbose:t=!1,id:r=null,AwsS3Client:i,connectionString:n,parallelism:a=10}){super(),this.verbose=t,this.id=r??ni.nanoid(7),this.parallelism=a,this.config=new mi(n),this.client=i||this.createClient()}createClient(){let t={region:this.config.region,endpoint:this.config.endpoint};return this.config.forcePathStyle&&(t.forcePathStyle=!0),this.config.accessKeyId&&(t.credentials={accessKeyId:this.config.accessKeyId,secretAccessKey:this.config.secretAccessKey}),new de.S3Client(t)}async sendCommand(t){this.emit("command.request",t.constructor.name,t.input);const r=console.warn;try{console.warn=n=>{n.includes("Stream of unknown length")||r(n)}}catch(n){console.error(n)}const i=await this.client.send(t);this.emit("command.response",t.constructor.name,i,t.input);try{console.warn=r}catch(n){console.error(n)}return i}errorProxy(t,r){this.verbose&&(r.bucket=this.config.bucket,r.config=this.config,r.verbose=this.verbose),t.data=r;const i=wi[t.name];return i?new i(r):t}async putObject({key:t,metadata:r,contentType:i,body:n,contentEncoding:a}){const o={Bucket:this.config.bucket,Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,t):t,Metadata:{...r},Body:n||"",ContentType:i,ContentEncoding:a};try{const s=await this.sendCommand(new de.PutObjectCommand(o));return this.emit("putObject",s,o),s}catch(s){throw this.errorProxy(s,{key:t,command:o})}}async getObject(t){const r={Bucket:this.config.bucket,Key:ne.join(this.config.keyPrefix,t)};try{const i=await this.sendCommand(new de.GetObjectCommand(r));return this.emit("getObject",i,r),i}catch(i){throw this.errorProxy(i,{key:t,command:r})}}async headObject(t){const r={Bucket:this.config.bucket,Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,t):t};try{const i=await this.client.send(new de.HeadObjectCommand(r));return this.emit("headObject",i,r),i}catch(i){throw this.errorProxy(i,{key:t,command:r})}}async copyObject({from:t,to:r}){const i={Bucket:this.config.bucket,Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,r):r,CopySource:ne.join(this.config.bucket,this.config.keyPrefix?ne.join(this.config.keyPrefix,t):t)};try{const n=await this.client.send(new de.CopyObjectCommand(i));return this.emit("copyObject",n,i),n}catch(n){throw this.errorProxy(n,{from:t,to:r,command:i})}}async exists(t){try{return await this.headObject(t),!0}catch(r){if(r.name==="NoSuchKey")return!1;if(r.name==="NotFound")return!1;throw r}}async deleteObject(t){const r={Bucket:this.config.bucket,Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,t):t};try{const i=await this.sendCommand(new de.DeleteObjectCommand(r));return this.emit("deleteObject",i,r),i}catch(i){throw this.errorProxy(i,{key:t,command:r})}}async deleteObjects(t){const r=O.chunk(t,1e3),{results:i,errors:n}=await ue.PromisePool.for(r).withConcurrency(this.parallelism).process(async o=>{const s={Bucket:this.config.bucket,Delete:{Objects:o.map(h=>({Key:this.config.keyPrefix?ne.join(this.config.keyPrefix,h):h}))}};try{return await this.sendCommand(new de.DeleteObjectsCommand(s))}catch(h){throw this.errorProxy(h,{key,command:s})}}),a={deleted:i,notFound:n};return this.emit("deleteObjects",a,t),a}async deleteAll({prefix:t}={}){const r=await this.getAllKeys({prefix:t}),i=await this.deleteObjects(r);return this.emit("deleteAll",{prefix:t,report:i}),i}async moveObject({from:t,to:r}){try{return await this.copyObject({from:t,to:r}),await this.deleteObject(t),!0}catch(i){throw this.errorProxy(i,{from:t,to:r,command:options})}}async listObjects({prefix:t,maxKeys:r=1e3,continuationToken:i}={}){const n={Bucket:this.config.bucket,MaxKeys:r,ContinuationToken:i,Prefix:this.config.keyPrefix?ne.join(this.config.keyPrefix,t||""):t||""};try{const a=await this.sendCommand(new de.ListObjectsV2Command(n));return this.emit("listObjects",a,n),a}catch(a){throw this.errorProxy(a,{command:n})}}async count({prefix:t}={}){let r=0,i=!0,n;for(;i;){const a={prefix:t,continuationToken:n},o=await this.listObjects(a);r+=o.KeyCount||0,i=o.IsTruncated||!1,n=o.NextContinuationToken}return this.emit("count",r,{prefix:t}),r}async getAllKeys({prefix:t}={}){let r=[],i=!0,n;for(;i;){const a={prefix:t,continuationToken:n},o=await this.listObjects(a);o.Contents&&(r=r.concat(o.Contents.map(s=>s.Key))),i=o.IsTruncated||!1,n=o.NextContinuationToken}return this.config.keyPrefix&&(r=r.map(a=>a.replace(this.config.keyPrefix,"")).map(a=>a.startsWith("/")?a.replace("/",""):a)),this.emit("getAllKeys",r,{prefix:t}),r}async getContinuationTokenAfterOffset(t={}){const{prefix:r,offset:i=1e3}=t;if(i===0)return null;let n=!0,a,o=0;for(;n;){let s=i<1e3?i:i-o>1e3?1e3:i-o;const h={prefix:r,maxKeys:s,continuationToken:a},f=await this.listObjects(h);if(f.Contents&&(o+=f.Contents.length),n=f.IsTruncated||!1,a=f.NextContinuationToken,o>=i)break}return this.emit("getContinuationTokenAfterOffset",a,t),a}async getKeysPage(t={}){const{prefix:r,offset:i=0,amount:n=100}=t;let a=[],o=!0,s;for(i>0&&(s=await this.getContinuationTokenAfterOffset({prefix:r,offset:i}));o;){const h={prefix:r,continuationToken:s},f=await this.listObjects(h);if(f.Contents&&(a=a.concat(f.Contents.map(l=>l.Key))),o=f.IsTruncated||!1,s=f.NextContinuationToken,a.length>n){a=a.splice(0,n);break}}return this.config.keyPrefix&&(a=a.map(h=>h.replace(this.config.keyPrefix,"")).map(h=>h.startsWith("/")?h.replace("/",""):h)),this.emit("getKeysPage",a,t),a}async moveAllObjects({prefixFrom:t,prefixTo:r}){const i=await this.getAllKeys({prefix:t}),{results:n,errors:a}=await ue.PromisePool.for(i).withConcurrency(this.parallelism).process(async o=>{const s=o.replace(t,r);try{return await this.moveObject({from:o,to:s}),s}catch(h){throw this.errorProxy(h,{from:o,to:s})}});if(this.emit("moveAllObjects",{results:n,errors:a},{prefixFrom:t,prefixTo:r}),a.length>0)throw console.log({errors:a}),new Error("Some objects could not be moved");return n}}async function Lt(){return O.isObject(process)?(await Promise.resolve().then(function(){return vh})).webcrypto:window.crypto}async function yi(e){const t=await Lt(),i=new TextEncoder().encode(e),n=await t.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}async function sr(e,t){const r=await Lt(),i=r.getRandomValues(new Uint8Array(16)),n=await Ei(t,i),a=r.getRandomValues(new Uint8Array(12)),s=new TextEncoder().encode(e),h=await r.subtle.encrypt({name:"AES-GCM",iv:a},n,s),f=new Uint8Array(i.length+a.length+h.byteLength);return f.set(i),f.set(a,i.length),f.set(new Uint8Array(h),i.length+a.length),ao(f)}async function xi(e,t){const r=await Lt(),i=oo(e),n=i.slice(0,16),a=i.slice(16,28),o=i.slice(28),s=await Ei(t,n),h=await r.subtle.decrypt({name:"AES-GCM",iv:a},s,o);return new TextDecoder().decode(h)}async function Ei(e,t){const r=await Lt(),n=new TextEncoder().encode(e),a=await r.subtle.importKey("raw",n,{name:"PBKDF2"},!1,["deriveKey"]);return await r.subtle.deriveKey({name:"PBKDF2",salt:t,iterations:1e5,hash:"SHA-256"},a,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}function ao(e){if(O.isObject(process))return Buffer.from(e).toString("base64");{const t=String.fromCharCode.apply(null,new Uint8Array(e));return window.btoa(t)}}function oo(e){if(O.isObject(process))return new Uint8Array(Buffer.from(e,"base64"));{const t=window.atob(e),r=t.length,i=new Uint8Array(r);for(let n=0;n<r;n++)i[n]=t.charCodeAt(n);return i}}async function fr(e,t,r){if(!this.passphrase)return t.push({actual:e,type:"encryptionKeyMissing"}),e;try{return await sr(String(e),this.passphrase)}catch(i){t.push({actual:e,type:"encryptionProblem",error:i})}return e}class ki extends Za{constructor({options:t,passphrase:r,autoEncrypt:i=!0}={}){super(O.merge({},{useNewCustomCheckerFunction:!0,messages:{encryptionKeyMissing:"Missing configuration for secrets encryption.",encryptionProblem:"Problem encrypting secret. Actual: {actual}. Error: {error}"},defaults:{string:{trim:!0},object:{strict:"remove"}}},t)),this.passphrase=r,this.autoEncrypt=i,this.alias("secret",{type:"string",custom:this.autoEncrypt?fr:void 0,messages:{string:"The '{field}' field must be a string.",stringMin:"This secret '{field}' field length must be at least {expected} long."}}),this.alias("secretAny",{type:"any",custom:this.autoEncrypt?fr:void 0}),this.alias("secretNumber",{type:"number",custom:this.autoEncrypt?fr:void 0})}}const Si=new Proxy(ki,{instance:null,construct(e,t){return this.instance||(this.instance=new e(...t)),this.instance}}),so={trim:e=>e.trim(),encrypt:(e,{passphrase:t})=>sr(e,t),decrypt:(e,{passphrase:t})=>xi(e,t),toString:e=>String(e),fromArray:(e,{separator:t})=>(e||[]).join(t),toArray:(e,{separator:t})=>(e||"").split(t),toNumber:e=>O.isString(e)?e.includes(".")?parseFloat(e):parseInt(e):e,toJSON:e=>JSON.stringify(e),fromJSON:e=>JSON.parse(e)};class ti{constructor(t){const{map:r,name:i,attributes:n,passphrase:a,version:o=1,options:s={}}=t;if(this.name=i,this.version=o,this.attributes=n,this.passphrase=a??"secret",this.options=O.merge({},this.defaultOptions(),s),this.validator=new Si({autoEncrypt:!1}).compile(O.merge({$$async:!0},O.cloneDeep(this.attributes))),this.options.generateAutoHooks&&this.generateAutoHooks(),!O.isEmpty(r))this.map=r,this.reversedMap=O.invert(r);else{const h=At.flatten(this.attributes,{safe:!0});this.reversedMap={...Object.keys(h).filter(f=>!f.includes("$$"))},this.map=O.invert(this.reversedMap)}}defaultOptions(){return{autoEncrypt:!0,autoDecrypt:!0,arraySeparator:"|",generateAutoHooks:!0,hooks:{beforeMap:{},afterMap:{},beforeUnmap:{},afterUnmap:{}}}}addHook(t,r,i){this.options.hooks[t][r]||(this.options.hooks[t][r]=[]),this.options.hooks[t][r]=O.uniq([...this.options.hooks[t][r],i])}generateAutoHooks(){const t=At.flatten(O.cloneDeep(this.attributes),{safe:!0});for(const[r,i]of Object.entries(t))i.includes("array")?(this.addHook("beforeMap",r,"fromArray"),this.addHook("afterUnmap",r,"toArray")):(i.includes("secret")&&(this.options.autoEncrypt&&this.addHook("beforeMap",r,"encrypt"),this.options.autoDecrypt&&this.addHook("afterUnmap",r,"decrypt")),i.includes("number")&&(this.addHook("beforeMap",r,"toString"),this.addHook("afterUnmap",r,"toNumber")),i.includes("boolean")&&(this.addHook("beforeMap",r,"toJson"),this.addHook("afterUnmap",r,"fromJson")))}static import(t){let{map:r,name:i,options:n,version:a,attributes:o}=O.isString(t)?JSON.parse(t):t;return new ti({map:r,name:i,options:n,version:a,attributes:o})}export(){const t={version:this.version,name:this.name,options:this.options,attributes:O.cloneDeep(this.attributes),map:this.map};for(const[r,i]of Object.entries(this.attributes))t.attributes[r]=JSON.stringify(i);return t}async applyHooksActions(t,r){for(const[i,n]of Object.entries(this.options.hooks[r]))for(const a of n){const o=O.get(t,i);o&&O.set(t,i,await so[a](o,{passphrase:this.passphrase,separator:this.options.arraySeparator}))}}async validate(t,{mutateOriginal:r=!1}={}){let i=r?t:O.cloneDeep(t);return await this.validator(i)}async mapper(t){const r=At.flatten(O.cloneDeep(t),{safe:!0});await this.applyHooksActions(r,"beforeMap");const i={_v:this.version+""};for(const[n,a]of Object.entries(r))i[this.map[n]]=a;return await this.applyHooksActions(i,"afterMap"),i}async unmapper(t){const r=O.cloneDeep(t);delete r._v,await this.applyHooksActions(r,"beforeUnmap");const i={};for(const[n,a]of Object.entries(r))i[this.reversedMap[n]]=a;return await this.applyHooksActions(i,"afterUnmap"),At.unflatten(i)}}class Ri extends b{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new rr.ReadableStream({highWaterMark:this.client.parallelism*3,start:this._start.bind(this),pull:this._pull.bind(this),cancel:this._cancel.bind(this)})}build(){return this.stream.getReader()}async _start(t){this.controller=t,this.continuationToken=null,this.closeNextIteration=!1}async _pull(t){if(this.closeNextIteration){t.close();return}const r=await this.client.listObjects({prefix:`resource=${this.resource.name}`,continuationToken:this.continuationToken}),i=r?.Contents.map(n=>n.Key).map(n=>n.replace(this.client.config.keyPrefix,"")).map(n=>n.startsWith("/")?n.replace("/",""):n).map(n=>n.replace(`resource=${this.resource.name}/id=`,""));this.continuationToken=r.NextContinuationToken,this.enqueue(i),r.IsTruncated||(this.closeNextIteration=!0)}enqueue(t){t.forEach(r=>{this.controller.enqueue(r),this.emit("id",r)})}_cancel(t){console.warn("Stream cancelled",t)}}class Ai extends Ri{enqueue(t){this.controller.enqueue(t),this.emit("page",t)}}class Ti extends b{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.input=new Ai({resource:this.resource}),this.output=new rr.TransformStream({transform:this._transform.bind(this)},{highWaterMark:this.client.parallelism*2},{highWaterMark:1}),this.stream=this.input.stream.pipeThrough(this.output)}build(){return this.stream.getReader()}async _transform(t,r){await ue.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async i=>{const n=await this.resource.get(i);return r.enqueue(n),n})}}class Li extends b{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new rr.WritableStream({start:this._start.bind(this),write:this._write.bind(this),close:this._close.bind(this),abort:this._abort.bind(this)})}build(){return this.stream.getWriter()}async _start(t){this.controller=t}async _write(t,r){const i=this.resource;await ue.PromisePool.for([].concat(t)).withConcurrency(this.client.parallelism).process(async n=>{await i.insert(n)})}async _close(t){}async _abort(t){console.error("Stream aborted:",t)}}function lr(e){return new Promise((t,r)=>{const i=[];e.on("data",n=>i.push(n)),e.on("error",r),e.on("end",()=>t(Buffer.concat(i).toString("utf-8")))})}class Ci extends b{constructor({name:t,client:r,options:i={},attributes:n={},parallelism:a=10,passphrase:o="secret",observers:s=[]}){super(),this.name=t,this.client=r,this.options=i,this.observers=s,this.parallelism=a,this.passphrase=o??"secret",this.schema=new ti({name:t,attributes:n,passphrase:o})}export(){return this.schema.export()}async validate(t){const r={original:O.cloneDeep(t),isValid:!1,errors:[]},i=await this.schema.validate(t,{mutateOriginal:!0});return i===!0?r.isValid=!0:r.errors=i,r.data=t,r}async insert({id:t,...r}){const{errors:i,isValid:n,data:a}=await this.validate(r);if(!n)throw new Tt({bucket:this.client.config.bucket,resourceName:this.name,attributes:r,validation:i});!t&&t!==0&&(t=ni.nanoid());const o=await this.schema.mapper(a);await this.client.putObject({metadata:o,key:W(`resource=${this.name}`,`id=${t}`)});const s=O.merge({id:t},a);return this.emit("insert",s),s}async get(t){const r=await this.client.headObject(W(`resource=${this.name}`,`id=${t}`));let i=await this.schema.unmapper(r.Metadata);return i.id=t,i._length=r.ContentLength,i._createdAt=r.LastModified,r.Expiration&&(i._expiresAt=r.Expiration),this.emit("get",i),i}async exists(t){try{return await this.client.headObject(W(`resource=${this.name}`,`id=${t}`)),!0}catch{return!1}}async update(t,r){const i=await this.get(t),n=O.merge(i,r);delete n.id;const{isValid:a,errors:o,data:s}=await this.validate(n);if(!a)throw new Tt({bucket:this.client.bucket,resourceName:this.name,attributes:r,validation:o});return await this.client.putObject({key:W(`resource=${this.name}`,`id=${t}`),body:"",metadata:await this.schema.mapper(s)}),s.id=t,this.emit("update",r,s),s}async delete(t){const r=W(`resource=${this.name}`,`id=${t}`),i=await this.client.deleteObject(r);return this.emit("delete",t),i}async count(){const t=await this.client.count({prefix:`resource=${this.name}`});return this.emit("count",t),t}async insertMany(t){const{results:r}=await ue.PromisePool.for(t).withConcurrency(this.parallelism).handleError(async(i,n)=>{this.emit("error",i,n),this.observers.map(a=>a.emit("error",this.name,i,n))}).process(async i=>await this.insert(i));return this.emit("insertMany",t.length),r}async deleteMany(t){const r=O.chunk(t.map(n=>W(`resource=${this.name}`,`id=${n}`)),1e3),{results:i}=await ue.PromisePool.for(r).withConcurrency(this.parallelism).handleError(async(n,a)=>{this.emit("error",n,a),this.observers.map(o=>o.emit("error",this.name,n,a))}).process(async n=>{const a=await this.client.deleteObjects(n);return n.forEach(o=>{const s=o.split("=").pop();this.emit("deleted",s),this.observers.map(h=>h.emit("deleted",this.name,s))}),a});return this.emit("deleteMany",t.length),i}async deleteAll(){const t=await this.listIds();this.emit("deleteAll",t.length),await this.deleteMany(t)}async listIds(){const r=(await this.client.getAllKeys({prefix:`resource=${this.name}`})).map(i=>i.replace(`resource=${this.name}/id=`,""));return this.emit("listIds",r.length),r}async getMany(t){const{results:r}=await ue.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async i=>{this.emit("id",i);const n=await this.get(i);return this.emit("data",n),n});return this.emit("getMany",t.length),r}async getAll(){let t=await this.listIds();if(t.length===0)return[];const{results:r}=await ue.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async i=>await this.get(i));return this.emit("getAll",r.length),r}async page({offset:t=0,size:r=100}){const n=(await this.client.getKeysPage({offset:t,amount:r,prefix:`resource=${this.name}`})).map(o=>o.replace(`resource=${this.name}/id=`,""));return await this.getMany(n)}readable(){return new Ti({resource:this}).build()}writable(){return new Li({resource:this}).build()}}class Oi extends b{constructor(t){super(),this.version="1",this.resources={},this.options=t,this.verbose=t.verbose||!1,this.parallelism=parseInt(t.parallelism+"")||10,this.plugins=t.plugins||[],this.cache=t.cache,this.passphrase=t.passphrase||"secret",this.client=t.client||new bi({verbose:this.verbose,parallelism:this.parallelism,connectionString:t.connectionString}),this.bucket=this.client.bucket,this.keyPrefix=this.client.keyPrefix}async connect(){await this.startPlugins();let t=null;if(await this.client.exists("s3db.json")){const r=await this.client.getObject("s3db.json");t=JSON.parse(await lr(r?.Body)),t=this.unserializeMetadata(t)}else t=this.blankMetadataStructure(),await this.uploadMetadataFile();for(const r of Object.entries(t.resources)){const[i,n]=r;this.resources[i]=new Ci({name:i,client:this.client,options:n.options,attributes:n.schema,parallelism:this.parallelism,passphrase:this.passphrase,observers:[this]})}this.emit("connected",new Date)}async startPlugins(){const t=this;if(!O.isEmpty(this.plugins)){const r=this.plugins.map(a=>O.isFunction(a)?new a(this):a),i=r.map(async a=>{a.beforeSetup&&await a.beforeSetup(),await a.setup(t),a.afterSetup&&await a.afterSetup()});await Promise.all(i);const n=r.map(async a=>{a.beforeStart&&await a.beforeStart(),await a.start(),a.afterStart&&await a.afterStart()});await Promise.all(n)}}unserializeMetadata(t){const r={...t};if(O.isEmpty(r.resources))return r;for(const[i,n]of Object.entries(r.resources))for(const[a,o]of Object.entries(n.attributes))r.resources[i].attributes[a]=JSON.parse(o);return r}async uploadMetadataFile(){const t={version:this.version,resources:Object.entries(this.resources).reduce((r,i)=>{const[n,a]=i;return r[n]=a.export(),r},{})};await this.client.putObject({key:"s3db.json",contentType:"application/json",body:JSON.stringify(t,null,2)})}blankMetadataStructure(){return{version:"1",resources:{}}}async createResource({name:t,attributes:r,options:i={}}){const n=new Ci({name:t,attributes:r,observers:[this],client:this.client,options:{autoDecrypt:!0,cache:this.cache,...i}});return this.resources[t]=n,await this.uploadMetadataFile(),this.emit("s3db.resourceCreated",t),n}resource(t){return this.resources[t]?this.resources[t]:Promise.reject(`resource ${t} does not exist`)}}class fo extends Oi{}class hr extends b{async _set(t,r){}async _get(t){}async _del(t){}async _clear(t){}async set(t,r){return await this._set(t,r),this.emit("set",r),r}async get(t){const r=await this._get(t);return this.emit("get",r),r}async del(t){const r=await this._del(t);return this.emit("delete",r),r}async clear(){const t=await this._clear();return this.emit("clear",t),t}}class lo extends hr{constructor(){super(),this.cache={}}async _set(t,r){return this.cache[t]=r,r}async _get(t){return this.cache[t]}async _del(t){return delete this.cache[t],!0}async _clear(){return this.cache={},!0}}var Ye=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},ee=[],q=[],ho=typeof Uint8Array<"u"?Uint8Array:Array,cr=!1;function Ii(){cr=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)ee[t]=e[t],q[e.charCodeAt(t)]=t;q[45]=62,q[95]=63}function co(e){cr||Ii();var t,r,i,n,a,o,s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=e[s-2]==="="?2:e[s-1]==="="?1:0,o=new ho(s*3/4-a),i=a>0?s-4:s;var h=0;for(t=0,r=0;t<i;t+=4,r+=3)n=q[e.charCodeAt(t)]<<18|q[e.charCodeAt(t+1)]<<12|q[e.charCodeAt(t+2)]<<6|q[e.charCodeAt(t+3)],o[h++]=n>>16&255,o[h++]=n>>8&255,o[h++]=n&255;return a===2?(n=q[e.charCodeAt(t)]<<2|q[e.charCodeAt(t+1)]>>4,o[h++]=n&255):a===1&&(n=q[e.charCodeAt(t)]<<10|q[e.charCodeAt(t+1)]<<4|q[e.charCodeAt(t+2)]>>2,o[h++]=n>>8&255,o[h++]=n&255),o}function uo(e){return ee[e>>18&63]+ee[e>>12&63]+ee[e>>6&63]+ee[e&63]}function po(e,t,r){for(var i,n=[],a=t;a<r;a+=3)i=(e[a]<<16)+(e[a+1]<<8)+e[a+2],n.push(uo(i));return n.join("")}function Mi(e){cr||Ii();for(var t,r=e.length,i=r%3,n="",a=[],o=16383,s=0,h=r-i;s<h;s+=o)a.push(po(e,s,s+o>h?h:s+o));return i===1?(t=e[r-1],n+=ee[t>>2],n+=ee[t<<4&63],n+="=="):i===2&&(t=(e[r-2]<<8)+e[r-1],n+=ee[t>>10],n+=ee[t>>4&63],n+=ee[t<<2&63],n+="="),a.push(n),a.join("")}function Ct(e,t,r,i,n){var a,o,s=n*8-i-1,h=(1<<s)-1,f=h>>1,l=-7,d=r?n-1:0,p=r?-1:1,u=e[t+d];for(d+=p,a=u&(1<<-l)-1,u>>=-l,l+=s;l>0;a=a*256+e[t+d],d+=p,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=i;l>0;o=o*256+e[t+d],d+=p,l-=8);if(a===0)a=1-f;else{if(a===h)return o?NaN:(u?-1:1)*(1/0);o=o+Math.pow(2,i),a=a-f}return(u?-1:1)*o*Math.pow(2,a-i)}function Di(e,t,r,i,n,a){var o,s,h,f=a*8-n-1,l=(1<<f)-1,d=l>>1,p=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,u=i?0:a-1,g=i?1:-1,S=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),o+d>=1?t+=p/h:t+=p*Math.pow(2,1-d),t*h>=2&&(o++,h/=2),o+d>=l?(s=0,o=l):o+d>=1?(s=(t*h-1)*Math.pow(2,n),o=o+d):(s=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[r+u]=s&255,u+=g,s/=256,n-=8);for(o=o<<n|s,f+=n;f>0;e[r+u]=o&255,u+=g,o/=256,f-=8);e[r+u-g]|=S*128}var _o={}.toString,Fi=Array.isArray||function(e){return _o.call(e)=="[object Array]"};/*!
|
|
8
8
|
* The buffer module from node.js, for the browser.
|
|
9
9
|
*
|
|
10
10
|
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
11
11
|
* @license MIT
|
|
12
|
-
*/var wo=50;c.TYPED_ARRAY_SUPPORT=Ye.TYPED_ARRAY_SUPPORT!==void 0?Ye.TYPED_ARRAY_SUPPORT:!0,Ot();function Ot(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ae(e,t){if(Ot()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=c.prototype):(e===null&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!c.TYPED_ARRAY_SUPPORT&&!(this instanceof c))return new c(e,t,r);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return ur(this,e)}return Ni(this,e,t,r)}c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e};function Ni(e,t,r,i){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?mo(e,t,r,i):typeof t=="string"?vo(e,t,r):bo(e,t)}c.from=function(e,t,r){return Ni(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&c[Symbol.species]);function Pi(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function go(e,t,r,i){return Pi(t),t<=0?ae(e,t):r!==void 0?typeof i=="string"?ae(e,t).fill(r,i):ae(e,t).fill(r):ae(e,t)}c.alloc=function(e,t,r){return go(null,e,t,r)};function ur(e,t){if(Pi(t),e=ae(e,t<0?0:pr(t)|0),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}c.allocUnsafe=function(e){return ur(null,e)},c.allocUnsafeSlow=function(e){return ur(null,e)};function vo(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=zi(t,r)|0;e=ae(e,i);var n=e.write(t,r);return n!==i&&(e=e.slice(0,n)),e}function dr(e,t){var r=t.length<0?0:pr(t.length)|0;e=ae(e,r);for(var i=0;i<r;i+=1)e[i]=t[i]&255;return e}function mo(e,t,r,i){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");return r===void 0&&i===void 0?t=new Uint8Array(t):i===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,i),c.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=c.prototype):e=dr(e,t),e}function bo(e,t){if(te(t)){var r=pr(t.length)|0;return e=ae(e,r),e.length===0||t.copy(e,0,0,r),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Uo(t.length)?ae(e,0):dr(e,t);if(t.type==="Buffer"&&Fi(t.data))return dr(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function pr(e){if(e>=Ot())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ot().toString(16)+" bytes");return e|0}c.isBuffer=Bo;function te(e){return!!(e!=null&&e._isBuffer)}c.compare=function(t,r){if(!te(t)||!te(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var i=t.length,n=r.length,a=0,o=Math.min(i,n);a<o;++a)if(t[a]!==r[a]){i=t[a],n=r[a];break}return i<n?-1:n<i?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,r){if(!Fi(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return c.alloc(0);var i;if(r===void 0)for(r=0,i=0;i<t.length;++i)r+=t[i].length;var n=c.allocUnsafe(r),a=0;for(i=0;i<t.length;++i){var o=t[i];if(!te(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,a),a+=o.length}return n};function zi(e,t){if(te(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var r=e.length;if(r===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Dt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Yi(e).length;default:if(i)return Dt(e).length;t=(""+t).toLowerCase(),i=!0}}c.byteLength=zi;function yo(e,t,r){var i=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Oo(this,t,r);case"utf8":case"utf-8":return ji(this,t,r);case"ascii":return Lo(this,t,r);case"latin1":case"binary":return Co(this,t,r);case"base64":return Ao(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Io(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}c.prototype._isBuffer=!0;function Te(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}c.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)Te(this,r,r+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)Te(this,r,r+3),Te(this,r+1,r+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)Te(this,r,r+7),Te(this,r+1,r+6),Te(this,r+2,r+5),Te(this,r+3,r+4);return this},c.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?ji(this,0,t):yo.apply(this,arguments)},c.prototype.equals=function(t){if(!te(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:c.compare(this,t)===0},c.prototype.inspect=function(){var t="",r=wo;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,r,i,n,a){if(!te(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),i===void 0&&(i=t?t.length:0),n===void 0&&(n=0),a===void 0&&(a=this.length),r<0||i>t.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&r>=i)return 0;if(n>=a)return-1;if(r>=i)return 1;if(r>>>=0,i>>>=0,n>>>=0,a>>>=0,this===t)return 0;for(var o=a-n,s=i-r,h=Math.min(o,s),f=this.slice(n,a),l=t.slice(r,i),d=0;d<h;++d)if(f[d]!==l[d]){o=f[d],s=l[d];break}return o<s?-1:s<o?1:0};function Ui(e,t,r,i,n){if(e.length===0)return-1;if(typeof r=="string"?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0)if(n)r=0;else return-1;if(typeof t=="string"&&(t=c.from(t,i)),te(t))return t.length===0?-1:Bi(e,t,r,i,n);if(typeof t=="number")return t=t&255,c.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Bi(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function Bi(e,t,r,i,n){var a=1,o=e.length,s=t.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,r/=2}function h(u,g){return a===1?u[g]:u.readUInt16BE(g*a)}var f;if(n){var l=-1;for(f=r;f<o;f++)if(h(e,f)===h(t,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===s)return l*a}else l!==-1&&(f-=f-l),l=-1}else for(r+s>o&&(r=o-s),f=r;f>=0;f--){for(var d=!0,p=0;p<s;p++)if(h(e,f+p)!==h(t,p)){d=!1;break}if(d)return f}return-1}c.prototype.includes=function(t,r,i){return this.indexOf(t,r,i)!==-1},c.prototype.indexOf=function(t,r,i){return Ui(this,t,r,i,!0)},c.prototype.lastIndexOf=function(t,r,i){return Ui(this,t,r,i,!1)};function xo(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");i>a/2&&(i=a/2);for(var o=0;o<i;++o){var s=parseInt(t.substr(o*2,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function Eo(e,t,r,i){return Ft(Dt(t,e.length-r),e,r,i)}function Zi(e,t,r,i){return Ft(Po(t),e,r,i)}function ko(e,t,r,i){return Zi(e,t,r,i)}function So(e,t,r,i){return Ft(Yi(t),e,r,i)}function Ro(e,t,r,i){return Ft(zo(t,e.length-r),e,r,i)}c.prototype.write=function(t,r,i,n){if(r===void 0)n="utf8",i=this.length,r=0;else if(i===void 0&&typeof r=="string")n=r,i=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(i)?(i=i|0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-r;if((i===void 0||i>a)&&(i=a),t.length>0&&(i<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return xo(this,t,r,i);case"utf8":case"utf-8":return Eo(this,t,r,i);case"ascii":return Zi(this,t,r,i);case"latin1":case"binary":return ko(this,t,r,i);case"base64":return So(this,t,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ro(this,t,r,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ao(e,t,r){return t===0&&r===e.length?Mi(e):Mi(e.slice(t,r))}function ji(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var a=e[n],o=null,s=a>239?4:a>223?3:a>191?2:1;if(n+s<=r){var h,f,l,d;switch(s){case 1:a<128&&(o=a);break;case 2:h=e[n+1],(h&192)===128&&(d=(a&31)<<6|h&63,d>127&&(o=d));break;case 3:h=e[n+1],f=e[n+2],(h&192)===128&&(f&192)===128&&(d=(a&15)<<12|(h&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:h=e[n+1],f=e[n+2],l=e[n+3],(h&192)===128&&(f&192)===128&&(l&192)===128&&(d=(a&15)<<18|(h&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|o&1023),i.push(o),n+=s}return To(i)}var Hi=4096;function To(e){var t=e.length;if(t<=Hi)return String.fromCharCode.apply(String,e);for(var r="",i=0;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=Hi));return r}function Lo(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]&127);return i}function Co(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function Oo(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",a=t;a<r;++a)n+=No(e[a]);return n}function Io(e,t,r){for(var i=e.slice(t,r),n="",a=0;a<i.length;a+=2)n+=String.fromCharCode(i[a]+i[a+1]*256);return n}c.prototype.slice=function(t,r){var i=this.length;t=~~t,r=r===void 0?i:~~r,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),r<t&&(r=t);var n;if(c.TYPED_ARRAY_SUPPORT)n=this.subarray(t,r),n.__proto__=c.prototype;else{var a=r-t;n=new c(a,void 0);for(var o=0;o<a;++o)n[o]=this[o+t]}return n};function U(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUIntLE=function(t,r,i){t=t|0,r=r|0,i||U(t,r,this.length);for(var n=this[t],a=1,o=0;++o<r&&(a*=256);)n+=this[t+o]*a;return n},c.prototype.readUIntBE=function(t,r,i){t=t|0,r=r|0,i||U(t,r,this.length);for(var n=this[t+--r],a=1;r>0&&(a*=256);)n+=this[t+--r]*a;return n},c.prototype.readUInt8=function(t,r){return r||U(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return r||U(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return r||U(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return r||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},c.prototype.readUInt32BE=function(t,r){return r||U(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,i){t=t|0,r=r|0,i||U(t,r,this.length);for(var n=this[t],a=1,o=0;++o<r&&(a*=256);)n+=this[t+o]*a;return a*=128,n>=a&&(n-=Math.pow(2,8*r)),n},c.prototype.readIntBE=function(t,r,i){t=t|0,r=r|0,i||U(t,r,this.length);for(var n=r,a=1,o=this[t+--n];n>0&&(a*=256);)o+=this[t+--n]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o},c.prototype.readInt8=function(t,r){return r||U(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},c.prototype.readInt16LE=function(t,r){r||U(t,2,this.length);var i=this[t]|this[t+1]<<8;return i&32768?i|4294901760:i},c.prototype.readInt16BE=function(t,r){r||U(t,2,this.length);var i=this[t+1]|this[t]<<8;return i&32768?i|4294901760:i},c.prototype.readInt32LE=function(t,r){return r||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return r||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return r||U(t,4,this.length),Ct(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return r||U(t,4,this.length),Ct(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return r||U(t,8,this.length),Ct(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return r||U(t,8,this.length),Ct(this,t,!1,52,8)};function $(e,t,r,i,n,a){if(!te(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<a)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}c.prototype.writeUIntLE=function(t,r,i,n){if(t=+t,r=r|0,i=i|0,!n){var a=Math.pow(2,8*i)-1;$(this,t,r,i,a,0)}var o=1,s=0;for(this[r]=t&255;++s<i&&(o*=256);)this[r+s]=t/o&255;return r+i},c.prototype.writeUIntBE=function(t,r,i,n){if(t=+t,r=r|0,i=i|0,!n){var a=Math.pow(2,8*i)-1;$(this,t,r,i,a,0)}var o=i-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+i},c.prototype.writeUInt8=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};function It(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,a=Math.min(e.length-r,2);n<a;++n)e[r+n]=(t&255<<8*(i?n:1-n))>>>(i?n:1-n)*8}c.prototype.writeUInt16LE=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):It(this,t,r,!0),r+2},c.prototype.writeUInt16BE=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):It(this,t,r,!1),r+2};function Mt(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,a=Math.min(e.length-r,4);n<a;++n)e[r+n]=t>>>(i?n:3-n)*8&255}c.prototype.writeUInt32LE=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):Mt(this,t,r,!0),r+4},c.prototype.writeUInt32BE=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):Mt(this,t,r,!1),r+4},c.prototype.writeIntLE=function(t,r,i,n){if(t=+t,r=r|0,!n){var a=Math.pow(2,8*i-1);$(this,t,r,i,a-1,-a)}var o=0,s=1,h=0;for(this[r]=t&255;++o<i&&(s*=256);)t<0&&h===0&&this[r+o-1]!==0&&(h=1),this[r+o]=(t/s>>0)-h&255;return r+i},c.prototype.writeIntBE=function(t,r,i,n){if(t=+t,r=r|0,!n){var a=Math.pow(2,8*i-1);$(this,t,r,i,a-1,-a)}var o=i-1,s=1,h=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&h===0&&this[r+o+1]!==0&&(h=1),this[r+o]=(t/s>>0)-h&255;return r+i},c.prototype.writeInt8=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1},c.prototype.writeInt16LE=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):It(this,t,r,!0),r+2},c.prototype.writeInt16BE=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):It(this,t,r,!1),r+2},c.prototype.writeInt32LE=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):Mt(this,t,r,!0),r+4},c.prototype.writeInt32BE=function(t,r,i){return t=+t,r=r|0,i||$(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):Mt(this,t,r,!1),r+4};function $i(e,t,r,i,n,a){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ki(e,t,r,i,n){return n||$i(e,t,r,4),Di(e,t,r,i,23,4),r+4}c.prototype.writeFloatLE=function(t,r,i){return Ki(this,t,r,!0,i)},c.prototype.writeFloatBE=function(t,r,i){return Ki(this,t,r,!1,i)};function Wi(e,t,r,i,n){return n||$i(e,t,r,8),Di(e,t,r,i,52,8),r+8}c.prototype.writeDoubleLE=function(t,r,i){return Wi(this,t,r,!0,i)},c.prototype.writeDoubleBE=function(t,r,i){return Wi(this,t,r,!1,i)},c.prototype.copy=function(t,r,i,n){if(i||(i=0),!n&&n!==0&&(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<i&&(n=i),n===i||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r<n-i&&(n=t.length-r+i);var a=n-i,o;if(this===t&&i<r&&r<n)for(o=a-1;o>=0;--o)t[o+r]=this[o+i];else if(a<1e3||!c.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)t[o+r]=this[o+i];else Uint8Array.prototype.set.call(t,this.subarray(i,i+a),r);return a},c.prototype.fill=function(t,r,i,n){if(typeof t=="string"){if(typeof r=="string"?(n=r,r=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),t.length===1){var a=t.charCodeAt(0);a<256&&(t=a)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof t=="number"&&(t=t&255);if(r<0||this.length<r||this.length<i)throw new RangeError("Out of range index");if(i<=r)return this;r=r>>>0,i=i===void 0?this.length:i>>>0,t||(t=0);var o;if(typeof t=="number")for(o=r;o<i;++o)this[o]=t;else{var s=te(t)?t:Dt(new c(t,n).toString()),h=s.length;for(o=0;o<i-r;++o)this[o+r]=s[o%h]}return this};var Mo=/[^+\/0-9A-Za-z-_]/g;function Do(e){if(e=Fo(e).replace(Mo,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Fo(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function No(e){return e<16?"0"+e.toString(16):e.toString(16)}function Dt(e,t){t=t||1/0;for(var r,i=e.length,n=null,a=[],o=0;o<i;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===i){(t-=3)>-1&&a.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),n=r;continue}r=(n-55296<<10|r-56320)+65536}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function Po(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function zo(e,t){for(var r,i,n,a=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),i=r>>8,n=r%256,a.push(n),a.push(i);return a}function Yi(e){return co(Do(e))}function Ft(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function Uo(e){return e!==e}function Bo(e){return e!=null&&(!!e._isBuffer||qi(e)||Zo(e))}function qi(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function Zo(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&qi(e.slice(0,0))}function Gi(){throw new Error("setTimeout has not been defined")}function Vi(){throw new Error("clearTimeout has not been defined")}var _e=Gi,we=Vi;typeof Ye.setTimeout=="function"&&(_e=setTimeout),typeof Ye.clearTimeout=="function"&&(we=clearTimeout);function Xi(e){if(_e===setTimeout)return setTimeout(e,0);if((_e===Gi||!_e)&&setTimeout)return _e=setTimeout,setTimeout(e,0);try{return _e(e,0)}catch{try{return _e.call(null,e,0)}catch{return _e.call(this,e,0)}}}function jo(e){if(we===clearTimeout)return clearTimeout(e);if((we===Vi||!we)&&clearTimeout)return we=clearTimeout,clearTimeout(e);try{return we(e)}catch{try{return we.call(null,e)}catch{return we.call(this,e)}}}var oe=[],qe=!1,Le,Nt=-1;function Ho(){!qe||!Le||(qe=!1,Le.length?oe=Le.concat(oe):Nt=-1,oe.length&&Ji())}function Ji(){if(!qe){var e=Xi(Ho);qe=!0;for(var t=oe.length;t;){for(Le=oe,oe=[];++Nt<t;)Le&&Le[Nt].run();Nt=-1,t=oe.length}Le=null,qe=!1,jo(e)}}function W(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];oe.push(new Qi(e,t)),oe.length===1&&!qe&&Xi(Ji)}function Qi(e,t){this.fun=e,this.array=t}Qi.prototype.run=function(){this.fun.apply(null,this.array)};var $o="browser",Ko="browser",Wo=!0,Yo={},qo=[],Go="",Vo={},Xo={},Jo={};function Ce(){}var Qo=Ce,es=Ce,ts=Ce,rs=Ce,is=Ce,ns=Ce,as=Ce;function os(e){throw new Error("process.binding is not supported")}function ss(){return"/"}function fs(e){throw new Error("process.chdir is not supported")}function ls(){return 0}var Ge=Ye.performance||{},hs=Ge.now||Ge.mozNow||Ge.msNow||Ge.oNow||Ge.webkitNow||function(){return new Date().getTime()};function cs(e){var t=hs.call(Ge)*.001,r=Math.floor(t),i=Math.floor(t%1*1e9);return e&&(r=r-e[0],i=i-e[1],i<0&&(r--,i+=1e9)),[r,i]}var us=new Date;function ds(){var e=new Date,t=e-us;return t/1e3}var se={nextTick:W,title:$o,browser:Wo,env:Yo,argv:qo,version:Go,versions:Vo,on:Qo,addListener:es,once:ts,off:rs,removeListener:is,removeAllListeners:ns,emit:as,binding:os,cwd:ss,chdir:fs,umask:ls,hrtime:cs,platform:Ko,release:Xo,config:Jo,uptime:ds},j;typeof Object.create=="function"?j=function(t,r){t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:j=function(t,r){t.super_=r;var i=function(){};i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t};var ps=/%[sdj%]/g;function _s(e){if(!mr(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(ge(arguments[r]));return t.join(" ")}for(var r=1,i=arguments,n=i.length,a=String(e).replace(ps,function(s){if(s==="%%")return"%";if(r>=n)return s;switch(s){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch{return"[Circular]"}default:return s}}),o=i[r];r<n;o=i[++r])vr(o)||!at(o)?a+=" "+o:a+=" "+ge(o);return a}function en(e,t){if(ve(Ye.process))return function(){return en(e,t).apply(this,arguments)};if(se.noDeprecation===!0)return e;var r=!1;function i(){if(!r){if(se.throwDeprecation)throw new Error(t);se.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return i}var Pt={},_r;function ws(e){if(ve(_r)&&(_r=se.env.NODE_DEBUG||""),e=e.toUpperCase(),!Pt[e])if(new RegExp("\\b"+e+"\\b","i").test(_r)){var t=0;Pt[e]=function(){var r=_s.apply(null,arguments);console.error("%s %d: %s",e,t,r)}}else Pt[e]=function(){};return Pt[e]}function ge(e,t){var r={seen:[],stylize:vs};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),tn(t)?r.showHidden=t:t&&Ss(r,t),ve(r.showHidden)&&(r.showHidden=!1),ve(r.depth)&&(r.depth=2),ve(r.colors)&&(r.colors=!1),ve(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=gs),zt(r,e,r.depth)}ge.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},ge.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function gs(e,t){var r=ge.styles[t];return r?"\x1B["+ge.colors[r][0]+"m"+e+"\x1B["+ge.colors[r][1]+"m":e}function vs(e,t){return e}function ms(e){var t={};return e.forEach(function(r,i){t[r]=!0}),t}function zt(e,t,r){if(e.customInspect&&t&&xr(t.inspect)&&t.inspect!==ge&&!(t.constructor&&t.constructor.prototype===t)){var i=t.inspect(r,e);return mr(i)||(i=zt(e,i,r)),i}var n=bs(e,t);if(n)return n;var a=Object.keys(t),o=ms(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),yr(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return wr(t);if(a.length===0){if(xr(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(br(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(rn(t))return e.stylize(Date.prototype.toString.call(t),"date");if(yr(t))return wr(t)}var h="",f=!1,l=["{","}"];if(Es(t)&&(f=!0,l=["[","]"]),xr(t)){var d=t.name?": "+t.name:"";h=" [Function"+d+"]"}if(br(t)&&(h=" "+RegExp.prototype.toString.call(t)),rn(t)&&(h=" "+Date.prototype.toUTCString.call(t)),yr(t)&&(h=" "+wr(t)),a.length===0&&(!f||t.length==0))return l[0]+h+l[1];if(r<0)return br(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var p;return f?p=ys(e,t,r,o,a):p=a.map(function(u){return gr(e,t,r,o,u,f)}),e.seen.pop(),xs(p,h,l)}function bs(e,t){if(ve(t))return e.stylize("undefined","undefined");if(mr(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(ks(t))return e.stylize(""+t,"number");if(tn(t))return e.stylize(""+t,"boolean");if(vr(t))return e.stylize("null","null")}function wr(e){return"["+Error.prototype.toString.call(e)+"]"}function ys(e,t,r,i,n){for(var a=[],o=0,s=t.length;o<s;++o)nn(t,String(o))?a.push(gr(e,t,r,i,String(o),!0)):a.push("");return n.forEach(function(h){h.match(/^\d+$/)||a.push(gr(e,t,r,i,h,!0))}),a}function gr(e,t,r,i,n,a){var o,s,h;if(h=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]},h.get?h.set?s=e.stylize("[Getter/Setter]","special"):s=e.stylize("[Getter]","special"):h.set&&(s=e.stylize("[Setter]","special")),nn(i,n)||(o="["+n+"]"),s||(e.seen.indexOf(h.value)<0?(vr(r)?s=zt(e,h.value,null):s=zt(e,h.value,r-1),s.indexOf(`
|
|
12
|
+
*/var wo=50;c.TYPED_ARRAY_SUPPORT=Ye.TYPED_ARRAY_SUPPORT!==void 0?Ye.TYPED_ARRAY_SUPPORT:!0,Ot();function Ot(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ae(e,t){if(Ot()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=c.prototype):(e===null&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!c.TYPED_ARRAY_SUPPORT&&!(this instanceof c))return new c(e,t,r);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return ur(this,e)}return Ni(this,e,t,r)}c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e};function Ni(e,t,r,i){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?mo(e,t,r,i):typeof t=="string"?vo(e,t,r):bo(e,t)}c.from=function(e,t,r){return Ni(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&c[Symbol.species]);function Pi(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function go(e,t,r,i){return Pi(t),t<=0?ae(e,t):r!==void 0?typeof i=="string"?ae(e,t).fill(r,i):ae(e,t).fill(r):ae(e,t)}c.alloc=function(e,t,r){return go(null,e,t,r)};function ur(e,t){if(Pi(t),e=ae(e,t<0?0:pr(t)|0),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}c.allocUnsafe=function(e){return ur(null,e)},c.allocUnsafeSlow=function(e){return ur(null,e)};function vo(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=zi(t,r)|0;e=ae(e,i);var n=e.write(t,r);return n!==i&&(e=e.slice(0,n)),e}function dr(e,t){var r=t.length<0?0:pr(t.length)|0;e=ae(e,r);for(var i=0;i<r;i+=1)e[i]=t[i]&255;return e}function mo(e,t,r,i){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");return r===void 0&&i===void 0?t=new Uint8Array(t):i===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,i),c.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=c.prototype):e=dr(e,t),e}function bo(e,t){if(te(t)){var r=pr(t.length)|0;return e=ae(e,r),e.length===0||t.copy(e,0,0,r),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Uo(t.length)?ae(e,0):dr(e,t);if(t.type==="Buffer"&&Fi(t.data))return dr(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function pr(e){if(e>=Ot())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ot().toString(16)+" bytes");return e|0}c.isBuffer=Bo;function te(e){return!!(e!=null&&e._isBuffer)}c.compare=function(t,r){if(!te(t)||!te(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var i=t.length,n=r.length,a=0,o=Math.min(i,n);a<o;++a)if(t[a]!==r[a]){i=t[a],n=r[a];break}return i<n?-1:n<i?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,r){if(!Fi(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return c.alloc(0);var i;if(r===void 0)for(r=0,i=0;i<t.length;++i)r+=t[i].length;var n=c.allocUnsafe(r),a=0;for(i=0;i<t.length;++i){var o=t[i];if(!te(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,a),a+=o.length}return n};function zi(e,t){if(te(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var r=e.length;if(r===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Dt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Yi(e).length;default:if(i)return Dt(e).length;t=(""+t).toLowerCase(),i=!0}}c.byteLength=zi;function yo(e,t,r){var i=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Oo(this,t,r);case"utf8":case"utf-8":return ji(this,t,r);case"ascii":return Lo(this,t,r);case"latin1":case"binary":return Co(this,t,r);case"base64":return Ao(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Io(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}c.prototype._isBuffer=!0;function Te(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}c.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)Te(this,r,r+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)Te(this,r,r+3),Te(this,r+1,r+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)Te(this,r,r+7),Te(this,r+1,r+6),Te(this,r+2,r+5),Te(this,r+3,r+4);return this},c.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?ji(this,0,t):yo.apply(this,arguments)},c.prototype.equals=function(t){if(!te(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:c.compare(this,t)===0},c.prototype.inspect=function(){var t="",r=wo;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,r,i,n,a){if(!te(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),i===void 0&&(i=t?t.length:0),n===void 0&&(n=0),a===void 0&&(a=this.length),r<0||i>t.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&r>=i)return 0;if(n>=a)return-1;if(r>=i)return 1;if(r>>>=0,i>>>=0,n>>>=0,a>>>=0,this===t)return 0;for(var o=a-n,s=i-r,h=Math.min(o,s),f=this.slice(n,a),l=t.slice(r,i),d=0;d<h;++d)if(f[d]!==l[d]){o=f[d],s=l[d];break}return o<s?-1:s<o?1:0};function Ui(e,t,r,i,n){if(e.length===0)return-1;if(typeof r=="string"?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0)if(n)r=0;else return-1;if(typeof t=="string"&&(t=c.from(t,i)),te(t))return t.length===0?-1:Bi(e,t,r,i,n);if(typeof t=="number")return t=t&255,c.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Bi(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function Bi(e,t,r,i,n){var a=1,o=e.length,s=t.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,r/=2}function h(u,g){return a===1?u[g]:u.readUInt16BE(g*a)}var f;if(n){var l=-1;for(f=r;f<o;f++)if(h(e,f)===h(t,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===s)return l*a}else l!==-1&&(f-=f-l),l=-1}else for(r+s>o&&(r=o-s),f=r;f>=0;f--){for(var d=!0,p=0;p<s;p++)if(h(e,f+p)!==h(t,p)){d=!1;break}if(d)return f}return-1}c.prototype.includes=function(t,r,i){return this.indexOf(t,r,i)!==-1},c.prototype.indexOf=function(t,r,i){return Ui(this,t,r,i,!0)},c.prototype.lastIndexOf=function(t,r,i){return Ui(this,t,r,i,!1)};function xo(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");i>a/2&&(i=a/2);for(var o=0;o<i;++o){var s=parseInt(t.substr(o*2,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function Eo(e,t,r,i){return Ft(Dt(t,e.length-r),e,r,i)}function Zi(e,t,r,i){return Ft(Po(t),e,r,i)}function ko(e,t,r,i){return Zi(e,t,r,i)}function So(e,t,r,i){return Ft(Yi(t),e,r,i)}function Ro(e,t,r,i){return Ft(zo(t,e.length-r),e,r,i)}c.prototype.write=function(t,r,i,n){if(r===void 0)n="utf8",i=this.length,r=0;else if(i===void 0&&typeof r=="string")n=r,i=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(i)?(i=i|0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-r;if((i===void 0||i>a)&&(i=a),t.length>0&&(i<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return xo(this,t,r,i);case"utf8":case"utf-8":return Eo(this,t,r,i);case"ascii":return Zi(this,t,r,i);case"latin1":case"binary":return ko(this,t,r,i);case"base64":return So(this,t,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ro(this,t,r,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ao(e,t,r){return t===0&&r===e.length?Mi(e):Mi(e.slice(t,r))}function ji(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var a=e[n],o=null,s=a>239?4:a>223?3:a>191?2:1;if(n+s<=r){var h,f,l,d;switch(s){case 1:a<128&&(o=a);break;case 2:h=e[n+1],(h&192)===128&&(d=(a&31)<<6|h&63,d>127&&(o=d));break;case 3:h=e[n+1],f=e[n+2],(h&192)===128&&(f&192)===128&&(d=(a&15)<<12|(h&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:h=e[n+1],f=e[n+2],l=e[n+3],(h&192)===128&&(f&192)===128&&(l&192)===128&&(d=(a&15)<<18|(h&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|o&1023),i.push(o),n+=s}return To(i)}var $i=4096;function To(e){var t=e.length;if(t<=$i)return String.fromCharCode.apply(String,e);for(var r="",i=0;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=$i));return r}function Lo(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]&127);return i}function Co(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function Oo(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",a=t;a<r;++a)n+=No(e[a]);return n}function Io(e,t,r){for(var i=e.slice(t,r),n="",a=0;a<i.length;a+=2)n+=String.fromCharCode(i[a]+i[a+1]*256);return n}c.prototype.slice=function(t,r){var i=this.length;t=~~t,r=r===void 0?i:~~r,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),r<t&&(r=t);var n;if(c.TYPED_ARRAY_SUPPORT)n=this.subarray(t,r),n.__proto__=c.prototype;else{var a=r-t;n=new c(a,void 0);for(var o=0;o<a;++o)n[o]=this[o+t]}return n};function U(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUIntLE=function(t,r,i){t=t|0,r=r|0,i||U(t,r,this.length);for(var n=this[t],a=1,o=0;++o<r&&(a*=256);)n+=this[t+o]*a;return n},c.prototype.readUIntBE=function(t,r,i){t=t|0,r=r|0,i||U(t,r,this.length);for(var n=this[t+--r],a=1;r>0&&(a*=256);)n+=this[t+--r]*a;return n},c.prototype.readUInt8=function(t,r){return r||U(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,r){return r||U(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,r){return r||U(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,r){return r||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},c.prototype.readUInt32BE=function(t,r){return r||U(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,r,i){t=t|0,r=r|0,i||U(t,r,this.length);for(var n=this[t],a=1,o=0;++o<r&&(a*=256);)n+=this[t+o]*a;return a*=128,n>=a&&(n-=Math.pow(2,8*r)),n},c.prototype.readIntBE=function(t,r,i){t=t|0,r=r|0,i||U(t,r,this.length);for(var n=r,a=1,o=this[t+--n];n>0&&(a*=256);)o+=this[t+--n]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o},c.prototype.readInt8=function(t,r){return r||U(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},c.prototype.readInt16LE=function(t,r){r||U(t,2,this.length);var i=this[t]|this[t+1]<<8;return i&32768?i|4294901760:i},c.prototype.readInt16BE=function(t,r){r||U(t,2,this.length);var i=this[t+1]|this[t]<<8;return i&32768?i|4294901760:i},c.prototype.readInt32LE=function(t,r){return r||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,r){return r||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,r){return r||U(t,4,this.length),Ct(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return r||U(t,4,this.length),Ct(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return r||U(t,8,this.length),Ct(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return r||U(t,8,this.length),Ct(this,t,!1,52,8)};function H(e,t,r,i,n,a){if(!te(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<a)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}c.prototype.writeUIntLE=function(t,r,i,n){if(t=+t,r=r|0,i=i|0,!n){var a=Math.pow(2,8*i)-1;H(this,t,r,i,a,0)}var o=1,s=0;for(this[r]=t&255;++s<i&&(o*=256);)this[r+s]=t/o&255;return r+i},c.prototype.writeUIntBE=function(t,r,i,n){if(t=+t,r=r|0,i=i|0,!n){var a=Math.pow(2,8*i)-1;H(this,t,r,i,a,0)}var o=i-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+i},c.prototype.writeUInt8=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};function It(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,a=Math.min(e.length-r,2);n<a;++n)e[r+n]=(t&255<<8*(i?n:1-n))>>>(i?n:1-n)*8}c.prototype.writeUInt16LE=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):It(this,t,r,!0),r+2},c.prototype.writeUInt16BE=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):It(this,t,r,!1),r+2};function Mt(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,a=Math.min(e.length-r,4);n<a;++n)e[r+n]=t>>>(i?n:3-n)*8&255}c.prototype.writeUInt32LE=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):Mt(this,t,r,!0),r+4},c.prototype.writeUInt32BE=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):Mt(this,t,r,!1),r+4},c.prototype.writeIntLE=function(t,r,i,n){if(t=+t,r=r|0,!n){var a=Math.pow(2,8*i-1);H(this,t,r,i,a-1,-a)}var o=0,s=1,h=0;for(this[r]=t&255;++o<i&&(s*=256);)t<0&&h===0&&this[r+o-1]!==0&&(h=1),this[r+o]=(t/s>>0)-h&255;return r+i},c.prototype.writeIntBE=function(t,r,i,n){if(t=+t,r=r|0,!n){var a=Math.pow(2,8*i-1);H(this,t,r,i,a-1,-a)}var o=i-1,s=1,h=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&h===0&&this[r+o+1]!==0&&(h=1),this[r+o]=(t/s>>0)-h&255;return r+i},c.prototype.writeInt8=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1},c.prototype.writeInt16LE=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):It(this,t,r,!0),r+2},c.prototype.writeInt16BE=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):It(this,t,r,!1),r+2},c.prototype.writeInt32LE=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):Mt(this,t,r,!0),r+4},c.prototype.writeInt32BE=function(t,r,i){return t=+t,r=r|0,i||H(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):Mt(this,t,r,!1),r+4};function Hi(e,t,r,i,n,a){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ki(e,t,r,i,n){return n||Hi(e,t,r,4),Di(e,t,r,i,23,4),r+4}c.prototype.writeFloatLE=function(t,r,i){return Ki(this,t,r,!0,i)},c.prototype.writeFloatBE=function(t,r,i){return Ki(this,t,r,!1,i)};function Wi(e,t,r,i,n){return n||Hi(e,t,r,8),Di(e,t,r,i,52,8),r+8}c.prototype.writeDoubleLE=function(t,r,i){return Wi(this,t,r,!0,i)},c.prototype.writeDoubleBE=function(t,r,i){return Wi(this,t,r,!1,i)},c.prototype.copy=function(t,r,i,n){if(i||(i=0),!n&&n!==0&&(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<i&&(n=i),n===i||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r<n-i&&(n=t.length-r+i);var a=n-i,o;if(this===t&&i<r&&r<n)for(o=a-1;o>=0;--o)t[o+r]=this[o+i];else if(a<1e3||!c.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)t[o+r]=this[o+i];else Uint8Array.prototype.set.call(t,this.subarray(i,i+a),r);return a},c.prototype.fill=function(t,r,i,n){if(typeof t=="string"){if(typeof r=="string"?(n=r,r=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),t.length===1){var a=t.charCodeAt(0);a<256&&(t=a)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof t=="number"&&(t=t&255);if(r<0||this.length<r||this.length<i)throw new RangeError("Out of range index");if(i<=r)return this;r=r>>>0,i=i===void 0?this.length:i>>>0,t||(t=0);var o;if(typeof t=="number")for(o=r;o<i;++o)this[o]=t;else{var s=te(t)?t:Dt(new c(t,n).toString()),h=s.length;for(o=0;o<i-r;++o)this[o+r]=s[o%h]}return this};var Mo=/[^+\/0-9A-Za-z-_]/g;function Do(e){if(e=Fo(e).replace(Mo,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Fo(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function No(e){return e<16?"0"+e.toString(16):e.toString(16)}function Dt(e,t){t=t||1/0;for(var r,i=e.length,n=null,a=[],o=0;o<i;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===i){(t-=3)>-1&&a.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),n=r;continue}r=(n-55296<<10|r-56320)+65536}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function Po(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function zo(e,t){for(var r,i,n,a=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),i=r>>8,n=r%256,a.push(n),a.push(i);return a}function Yi(e){return co(Do(e))}function Ft(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function Uo(e){return e!==e}function Bo(e){return e!=null&&(!!e._isBuffer||qi(e)||Zo(e))}function qi(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function Zo(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&qi(e.slice(0,0))}function Gi(){throw new Error("setTimeout has not been defined")}function Vi(){throw new Error("clearTimeout has not been defined")}var _e=Gi,we=Vi;typeof Ye.setTimeout=="function"&&(_e=setTimeout),typeof Ye.clearTimeout=="function"&&(we=clearTimeout);function Xi(e){if(_e===setTimeout)return setTimeout(e,0);if((_e===Gi||!_e)&&setTimeout)return _e=setTimeout,setTimeout(e,0);try{return _e(e,0)}catch{try{return _e.call(null,e,0)}catch{return _e.call(this,e,0)}}}function jo(e){if(we===clearTimeout)return clearTimeout(e);if((we===Vi||!we)&&clearTimeout)return we=clearTimeout,clearTimeout(e);try{return we(e)}catch{try{return we.call(null,e)}catch{return we.call(this,e)}}}var oe=[],qe=!1,Le,Nt=-1;function $o(){!qe||!Le||(qe=!1,Le.length?oe=Le.concat(oe):Nt=-1,oe.length&&Ji())}function Ji(){if(!qe){var e=Xi($o);qe=!0;for(var t=oe.length;t;){for(Le=oe,oe=[];++Nt<t;)Le&&Le[Nt].run();Nt=-1,t=oe.length}Le=null,qe=!1,jo(e)}}function Y(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];oe.push(new Qi(e,t)),oe.length===1&&!qe&&Xi(Ji)}function Qi(e,t){this.fun=e,this.array=t}Qi.prototype.run=function(){this.fun.apply(null,this.array)};var Ho="browser",Ko="browser",Wo=!0,Yo={},qo=[],Go="",Vo={},Xo={},Jo={};function Ce(){}var Qo=Ce,es=Ce,ts=Ce,rs=Ce,is=Ce,ns=Ce,as=Ce;function os(e){throw new Error("process.binding is not supported")}function ss(){return"/"}function fs(e){throw new Error("process.chdir is not supported")}function ls(){return 0}var Ge=Ye.performance||{},hs=Ge.now||Ge.mozNow||Ge.msNow||Ge.oNow||Ge.webkitNow||function(){return new Date().getTime()};function cs(e){var t=hs.call(Ge)*.001,r=Math.floor(t),i=Math.floor(t%1*1e9);return e&&(r=r-e[0],i=i-e[1],i<0&&(r--,i+=1e9)),[r,i]}var us=new Date;function ds(){var e=new Date,t=e-us;return t/1e3}var se={nextTick:Y,title:Ho,browser:Wo,env:Yo,argv:qo,version:Go,versions:Vo,on:Qo,addListener:es,once:ts,off:rs,removeListener:is,removeAllListeners:ns,emit:as,binding:os,cwd:ss,chdir:fs,umask:ls,hrtime:cs,platform:Ko,release:Xo,config:Jo,uptime:ds},j;typeof Object.create=="function"?j=function(t,r){t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:j=function(t,r){t.super_=r;var i=function(){};i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t};var ps=/%[sdj%]/g;function _s(e){if(!mr(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(ge(arguments[r]));return t.join(" ")}for(var r=1,i=arguments,n=i.length,a=String(e).replace(ps,function(s){if(s==="%%")return"%";if(r>=n)return s;switch(s){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch{return"[Circular]"}default:return s}}),o=i[r];r<n;o=i[++r])vr(o)||!at(o)?a+=" "+o:a+=" "+ge(o);return a}function en(e,t){if(ve(Ye.process))return function(){return en(e,t).apply(this,arguments)};if(se.noDeprecation===!0)return e;var r=!1;function i(){if(!r){if(se.throwDeprecation)throw new Error(t);se.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return i}var Pt={},_r;function ws(e){if(ve(_r)&&(_r=se.env.NODE_DEBUG||""),e=e.toUpperCase(),!Pt[e])if(new RegExp("\\b"+e+"\\b","i").test(_r)){var t=0;Pt[e]=function(){var r=_s.apply(null,arguments);console.error("%s %d: %s",e,t,r)}}else Pt[e]=function(){};return Pt[e]}function ge(e,t){var r={seen:[],stylize:vs};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),tn(t)?r.showHidden=t:t&&Ss(r,t),ve(r.showHidden)&&(r.showHidden=!1),ve(r.depth)&&(r.depth=2),ve(r.colors)&&(r.colors=!1),ve(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=gs),zt(r,e,r.depth)}ge.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},ge.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function gs(e,t){var r=ge.styles[t];return r?"\x1B["+ge.colors[r][0]+"m"+e+"\x1B["+ge.colors[r][1]+"m":e}function vs(e,t){return e}function ms(e){var t={};return e.forEach(function(r,i){t[r]=!0}),t}function zt(e,t,r){if(e.customInspect&&t&&xr(t.inspect)&&t.inspect!==ge&&!(t.constructor&&t.constructor.prototype===t)){var i=t.inspect(r,e);return mr(i)||(i=zt(e,i,r)),i}var n=bs(e,t);if(n)return n;var a=Object.keys(t),o=ms(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),yr(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return wr(t);if(a.length===0){if(xr(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(br(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(rn(t))return e.stylize(Date.prototype.toString.call(t),"date");if(yr(t))return wr(t)}var h="",f=!1,l=["{","}"];if(Es(t)&&(f=!0,l=["[","]"]),xr(t)){var d=t.name?": "+t.name:"";h=" [Function"+d+"]"}if(br(t)&&(h=" "+RegExp.prototype.toString.call(t)),rn(t)&&(h=" "+Date.prototype.toUTCString.call(t)),yr(t)&&(h=" "+wr(t)),a.length===0&&(!f||t.length==0))return l[0]+h+l[1];if(r<0)return br(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var p;return f?p=ys(e,t,r,o,a):p=a.map(function(u){return gr(e,t,r,o,u,f)}),e.seen.pop(),xs(p,h,l)}function bs(e,t){if(ve(t))return e.stylize("undefined","undefined");if(mr(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(ks(t))return e.stylize(""+t,"number");if(tn(t))return e.stylize(""+t,"boolean");if(vr(t))return e.stylize("null","null")}function wr(e){return"["+Error.prototype.toString.call(e)+"]"}function ys(e,t,r,i,n){for(var a=[],o=0,s=t.length;o<s;++o)nn(t,String(o))?a.push(gr(e,t,r,i,String(o),!0)):a.push("");return n.forEach(function(h){h.match(/^\d+$/)||a.push(gr(e,t,r,i,h,!0))}),a}function gr(e,t,r,i,n,a){var o,s,h;if(h=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]},h.get?h.set?s=e.stylize("[Getter/Setter]","special"):s=e.stylize("[Getter]","special"):h.set&&(s=e.stylize("[Setter]","special")),nn(i,n)||(o="["+n+"]"),s||(e.seen.indexOf(h.value)<0?(vr(r)?s=zt(e,h.value,null):s=zt(e,h.value,r-1),s.indexOf(`
|
|
13
13
|
`)>-1&&(a?s=s.split(`
|
|
14
14
|
`).map(function(f){return" "+f}).join(`
|
|
15
15
|
`).substr(2):s=`
|
|
@@ -18,4 +18,4 @@ ${JSON.stringify(n,null,2)}`}),this.resourceName=r,this.attributes=i,this.valida
|
|
|
18
18
|
`))):s=e.stylize("[Circular]","special")),ve(o)){if(a&&n.match(/^\d+$/))return s;o=JSON.stringify(""+n),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+s}function xs(e,t,r){var i=e.reduce(function(n,a){return a.indexOf(`
|
|
19
19
|
`)>=0,n+a.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(t===""?"":t+`
|
|
20
20
|
`)+" "+e.join(`,
|
|
21
|
-
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function Es(e){return Array.isArray(e)}function tn(e){return typeof e=="boolean"}function vr(e){return e===null}function ks(e){return typeof e=="number"}function mr(e){return typeof e=="string"}function ve(e){return e===void 0}function br(e){return at(e)&&Er(e)==="[object RegExp]"}function at(e){return typeof e=="object"&&e!==null}function rn(e){return at(e)&&Er(e)==="[object Date]"}function yr(e){return at(e)&&(Er(e)==="[object Error]"||e instanceof Error)}function xr(e){return typeof e=="function"}function Er(e){return Object.prototype.toString.call(e)}function Ss(e,t){if(!t||!at(t))return e;for(var r=Object.keys(t),i=r.length;i--;)e[r[i]]=t[r[i]];return e}function nn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Oe(){this.head=null,this.tail=null,this.length=0}Oe.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},Oe.prototype.unshift=function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length},Oe.prototype.shift=function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},Oe.prototype.clear=function(){this.head=this.tail=null,this.length=0},Oe.prototype.join=function(e){if(this.length===0)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},Oe.prototype.concat=function(e){if(this.length===0)return c.alloc(0);if(this.length===1)return this.head.data;for(var t=c.allocUnsafe(e>>>0),r=this.head,i=0;r;)r.data.copy(t,i),i+=r.data.length,r=r.next;return t};var Rs=c.isEncoding||function(e){switch(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 As(e){if(e&&!Rs(e))throw new Error("Unknown encoding: "+e)}function ot(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),As(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Ls;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Cs;break;default:this.write=Ts;return}this.charBuffer=new c(6),this.charReceived=0,this.charLength=0}ot.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";e=e.slice(r,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=t.charCodeAt(t.length-1);if(n>=55296&&n<=56319){this.charLength+=this.surrogateSize,t="";continue}if(this.charReceived=this.charLength=0,e.length===0)return t;break}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,n=t.charCodeAt(i);if(n>=55296&&n<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),e.copy(this.charBuffer,0,0,a),t.substring(0,i)}return t},ot.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},ot.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,i=this.charBuffer,n=this.encoding;t+=i.slice(0,r).toString(n)}return t};function Ts(e){return e.toString(this.encoding)}function Ls(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Cs(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}F.ReadableState=an;var C=ws("stream");j(F,b);function Os(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function Is(e,t){return e.listeners(t).length}function an(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof G&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,i=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:i,this.highWaterMark=~~this.highWaterMark,this.buffer=new Oe,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.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new ot(e.encoding),this.encoding=e.encoding)}function F(e){if(!(this instanceof F))return new F(e);this._readableState=new an(e,this),this.readable=!0,e&&typeof e.read=="function"&&(this._read=e.read),b.call(this)}F.prototype.push=function(e,t){var r=this._readableState;return!r.objectMode&&typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=c.from(e,t),t="")),on(this,r,e,t,!1)},F.prototype.unshift=function(e){var t=this._readableState;return on(this,t,e,"",!0)},F.prototype.isPaused=function(){return this._readableState.flowing===!1};function on(e,t,r,i,n){var a=Fs(t,r);if(a)e.emit("error",a);else if(r===null)t.reading=!1,Ns(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!n){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&n){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var h;t.decoder&&!n&&!i&&(r=t.decoder.write(r),h=!t.objectMode&&r.length===0),n||(t.reading=!1),h||(t.flowing&&t.length===0&&!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&&Ut(e))),Ps(e,t)}else n||(t.reading=!1);return Ms(t)}function Ms(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}F.prototype.setEncoding=function(e){return this._readableState.decoder=new ot(e),this._readableState.encoding=e,this};var sn=8388608;function Ds(e){return e>=sn?e=sn:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function fn(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=Ds(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}F.prototype.read=function(e){C("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return C("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Sr(this):Ut(this),null;if(e=fn(e,t),e===0&&t.ended)return t.length===0&&Sr(this),null;var i=t.needReadable;C("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,C("length less than watermark",i)),t.ended||t.reading?(i=!1,C("reading or ended",i)):i&&(C("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=fn(r,t)));var n;return e>0?n=hn(e,t):n=null,n===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Sr(this)),n!==null&&this.emit("data",n),n};function Fs(e,t){var r=null;return!c.isBuffer(t)&&typeof t!="string"&&t!==null&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function Ns(e,t){if(!t.ended){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,Ut(e)}}function Ut(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(C("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?W(ln,e):ln(e))}function ln(e){C("emit readable"),e.emit("readable"),kr(e)}function Ps(e,t){t.readingMore||(t.readingMore=!0,W(zs,e,t))}function zs(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(C("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}F.prototype._read=function(e){this.emit("error",new Error("not implemented"))},F.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,C("pipe count=%d opts=%j",i.pipesCount,t);var n=!t||t.end!==!1,a=n?s:l;i.endEmitted?W(a):r.once("end",a),e.on("unpipe",o);function o(v){C("onunpipe"),v===r&&l()}function s(){C("onend"),e.end()}var h=Us(r);e.on("drain",h);var f=!1;function l(){C("cleanup"),e.removeListener("close",g),e.removeListener("finish",S),e.removeListener("drain",h),e.removeListener("error",u),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",l),r.removeListener("data",p),f=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&h()}var d=!1;r.on("data",p);function p(v){C("ondata"),d=!1;var k=e.write(v);k===!1&&!d&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&cn(i.pipes,e)!==-1)&&!f&&(C("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function u(v){C("onerror",v),y(),e.removeListener("error",u),Is(e,"error")===0&&e.emit("error",v)}Os(e,"error",u);function g(){e.removeListener("finish",S),y()}e.once("close",g);function S(){C("onfinish"),e.removeListener("close",g),y()}e.once("finish",S);function y(){C("unpipe"),r.unpipe(e)}return e.emit("pipe",r),i.flowing||(C("pipe resume"),r.resume()),e};function Us(e){return function(){var t=e._readableState;C("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&e.listeners("data").length&&(t.flowing=!0,kr(e))}}F.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var n=0;n<i;n++)r[n].emit("unpipe",this);return this}var a=cn(t.pipes,e);return a===-1?this:(t.pipes.splice(a,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},F.prototype.on=function(e,t){var r=b.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var i=this._readableState;!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&Ut(this):W(Bs,this))}return r},F.prototype.addListener=F.prototype.on;function Bs(e){C("readable nexttick read 0"),e.read(0)}F.prototype.resume=function(){var e=this._readableState;return e.flowing||(C("resume"),e.flowing=!0,Zs(this,e)),this};function Zs(e,t){t.resumeScheduled||(t.resumeScheduled=!0,W(js,e,t))}function js(e,t){t.reading||(C("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),kr(e),t.flowing&&!t.reading&&e.read(0)}F.prototype.pause=function(){return C("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(C("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function kr(e){var t=e._readableState;for(C("flow",t.flowing);t.flowing&&e.read()!==null;);}F.prototype.wrap=function(e){var t=this._readableState,r=!1,i=this;e.on("end",function(){if(C("wrapped end"),t.decoder&&!t.ended){var o=t.decoder.end();o&&o.length&&i.push(o)}i.push(null)}),e.on("data",function(o){if(C("wrapped data"),t.decoder&&(o=t.decoder.write(o)),!(t.objectMode&&o==null)&&!(!t.objectMode&&(!o||!o.length))){var s=i.push(o);s||(r=!0,e.pause())}});for(var n in e)this[n]===void 0&&typeof e[n]=="function"&&(this[n]=function(o){return function(){return e[o].apply(e,arguments)}}(n));var a=["error","close","destroy","pause","resume"];return Ys(a,function(o){e.on(o,i.emit.bind(i,o))}),i._read=function(o){C("wrapped _read",o),r&&(r=!1,e.resume())},i},F._fromList=hn;function hn(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=Hs(e,t.buffer,t.decoder),r}function Hs(e,t,r){var i;return e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?i=t.shift():i=r?$s(e,t):Ks(e,t),i}function $s(e,t){var r=t.head,i=1,n=r.data;for(e-=n.length;r=r.next;){var a=r.data,o=e>a.length?a.length:e;if(o===a.length?n+=a:n+=a.slice(0,e),e-=o,e===0){o===a.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(o));break}++i}return t.length-=i,n}function Ks(e,t){var r=c.allocUnsafe(e),i=t.head,n=1;for(i.data.copy(r),e-=i.data.length;i=i.next;){var a=i.data,o=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,o),e-=o,e===0){o===a.length?(++n,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=a.slice(o));break}++n}return t.length-=n,r}function Sr(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,W(Ws,t,e))}function Ws(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ys(e,t){for(var r=0,i=e.length;r<i;r++)t(e[r],r)}function cn(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}H.WritableState=Rr,j(H,b);function qs(){}function Gs(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function Rr(e,t){Object.defineProperty(this,"buffer",{get:en(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof G&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,i=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:i,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){rf(t,a)},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 gn(this)}Rr.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};function H(e){if(!(this instanceof H)&&!(this instanceof G))return new H(e);this._writableState=new Rr(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev)),b.call(this)}H.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function Vs(e,t){var r=new Error("write after end");e.emit("error",r),W(t,r)}function Xs(e,t,r,i){var n=!0,a=!1;return r===null?a=new TypeError("May not write null values to stream"):!c.isBuffer(r)&&typeof r!="string"&&r!==void 0&&!t.objectMode&&(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),W(i,a),n=!1),n}H.prototype.write=function(e,t,r){var i=this._writableState,n=!1;return typeof t=="function"&&(r=t,t=null),c.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),typeof r!="function"&&(r=qs),i.ended?Vs(this,r):Xs(this,i,e,r)&&(i.pendingcb++,n=Qs(this,i,e,t,r)),n},H.prototype.cork=function(){var e=this._writableState;e.corked++},H.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&dn(this,e))},H.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function Js(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=c.from(t,r)),t}function Qs(e,t,r,i,n){r=Js(t,r,i),c.isBuffer(r)&&(i="buffer");var a=t.objectMode?1:r.length;t.length+=a;var o=t.length<t.highWaterMark;if(o||(t.needDrain=!0),t.writing||t.corked){var s=t.lastBufferedRequest;t.lastBufferedRequest=new Gs(r,i,n),s?s.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Ar(e,t,!1,a,r,i,n);return o}function Ar(e,t,r,i,n,a,o){t.writelen=i,t.writecb=o,t.writing=!0,t.sync=!0,r?e._writev(n,t.onwrite):e._write(n,a,t.onwrite),t.sync=!1}function ef(e,t,r,i,n){--t.pendingcb,r?W(n,i):n(i),e._writableState.errorEmitted=!0,e.emit("error",i)}function tf(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function rf(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(tf(r),t)ef(e,r,i,t,n);else{var a=pn(r);!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&dn(e,r),i?W(un,e,r,a,n):un(e,r,a,n)}}function un(e,t,r,i){r||nf(e,t),t.pendingcb--,i(),wn(e,t)}function nf(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function dn(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),a=t.corkedRequestsFree;a.entry=r;for(var o=0;r;)n[o]=r,r=r.next,o+=1;Ar(e,t,!0,t.length,n,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new gn(t)}else{for(;r;){var s=r.chunk,h=r.encoding,f=r.callback,l=t.objectMode?1:s.length;if(Ar(e,t,!1,l,s,h,f),r=r.next,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=r,t.bufferProcessing=!1}H.prototype._write=function(e,t,r){r(new Error("not implemented"))},H.prototype._writev=null,H.prototype.end=function(e,t,r){var i=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),!i.ending&&!i.finished&&af(this,i,r)};function pn(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function _n(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function wn(e,t){var r=pn(t);return r&&(t.pendingcb===0?(_n(e,t),t.finished=!0,e.emit("finish")):_n(e,t)),r}function af(e,t,r){t.ending=!0,wn(e,t),r&&(t.finished?W(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function gn(e){var t=this;this.next=null,this.entry=null,this.finish=function(r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}j(G,F);for(var vn=Object.keys(H.prototype),Tr=0;Tr<vn.length;Tr++){var Lr=vn[Tr];G.prototype[Lr]||(G.prototype[Lr]=H.prototype[Lr])}function G(e){if(!(this instanceof G))return new G(e);F.call(this,e),H.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",of)}function of(){this.allowHalfOpen||this._writableState.ended||W(sf,this)}function sf(e){e.end()}j(V,G);function ff(e){this.afterTransform=function(t,r){return lf(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function lf(e,t,r){var i=e._transformState;i.transforming=!1;var n=i.writecb;if(!n)return e.emit("error",new Error("no writecb in Transform class"));i.writechunk=null,i.writecb=null,r!=null&&e.push(r),n(t);var a=e._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&e._read(a.highWaterMark)}function V(e){if(!(this instanceof V))return new V(e);G.call(this,e),this._transformState=new ff(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.once("prefinish",function(){typeof this._flush=="function"?this._flush(function(r){mn(t,r)}):mn(t)})}V.prototype.push=function(e,t){return this._transformState.needTransform=!1,G.prototype.push.call(this,e,t)},V.prototype._transform=function(e,t,r){throw new Error("Not implemented")},V.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},V.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};function mn(e,t){if(t)return e.emit("error",t);var r=e._writableState,i=e._transformState;if(r.length)throw new Error("Calling transform done when ws.length != 0");if(i.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}j(st,V);function st(e){if(!(this instanceof st))return new st(e);V.call(this,e)}st.prototype._transform=function(e,t,r){r(null,e)},j(fe,b),fe.Readable=F,fe.Writable=H,fe.Duplex=G,fe.Transform=V,fe.PassThrough=st,fe.Stream=fe;function fe(){b.call(this)}fe.prototype.pipe=function(e,t){var r=this;function i(l){e.writable&&e.write(l)===!1&&r.pause&&r.pause()}r.on("data",i);function n(){r.readable&&r.resume&&r.resume()}e.on("drain",n),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",o),r.on("close",s));var a=!1;function o(){a||(a=!0,e.end())}function s(){a||(a=!0,typeof e.destroy=="function"&&e.destroy())}function h(l){if(f(),b.listenerCount(this,"error")===0)throw l}r.on("error",h),e.on("error",h);function f(){r.removeListener("data",i),e.removeListener("drain",n),r.removeListener("end",o),r.removeListener("close",s),r.removeListener("error",h),e.removeListener("error",h),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e};var bn={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function hf(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function le(e,t,r,i,n){if(t.subarray&&e.subarray){e.set(t.subarray(r,r+i),n);return}for(var a=0;a<i;a++)e[n+a]=t[r+a]}var Bt=Uint8Array,X=Uint16Array,Zt=Int32Array,cf=4,yn=0,xn=1,uf=2;function Ve(e){for(var t=e.length;--t>=0;)e[t]=0}var df=0,En=1,pf=2,_f=3,wf=258,Cr=29,ft=256,lt=ft+1+Cr,Xe=30,Or=19,kn=2*lt+1,Ie=15,Ir=16,gf=7,Mr=256,Sn=16,Rn=17,An=18,Dr=[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],jt=[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],vf=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Tn=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],mf=512,he=new Array((lt+2)*2);Ve(he);var ht=new Array(Xe*2);Ve(ht);var ct=new Array(mf);Ve(ct);var ut=new Array(wf-_f+1);Ve(ut);var Fr=new Array(Cr);Ve(Fr);var Ht=new Array(Xe);Ve(Ht);function Nr(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}var Ln,Cn,On;function Pr(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function In(e){return e<256?ct[e]:ct[256+(e>>>7)]}function dt(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function K(e,t,r){e.bi_valid>Ir-r?(e.bi_buf|=t<<e.bi_valid&65535,dt(e,e.bi_buf),e.bi_buf=t>>Ir-e.bi_valid,e.bi_valid+=r-Ir):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function re(e,t,r){K(e,r[t*2],r[t*2+1])}function Mn(e,t){var r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1}function bf(e){e.bi_valid===16?(dt(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function yf(e,t){var r=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,h=t.stat_desc.max_length,f,l,d,p,u,g,S=0;for(p=0;p<=Ie;p++)e.bl_count[p]=0;for(r[e.heap[e.heap_max]*2+1]=0,f=e.heap_max+1;f<kn;f++)l=e.heap[f],p=r[r[l*2+1]*2+1]+1,p>h&&(p=h,S++),r[l*2+1]=p,!(l>i)&&(e.bl_count[p]++,u=0,l>=s&&(u=o[l-s]),g=r[l*2],e.opt_len+=g*(p+u),a&&(e.static_len+=g*(n[l*2+1]+u)));if(S!==0){do{for(p=h-1;e.bl_count[p]===0;)p--;e.bl_count[p]--,e.bl_count[p+1]+=2,e.bl_count[h]--,S-=2}while(S>0);for(p=h;p!==0;p--)for(l=e.bl_count[p];l!==0;)d=e.heap[--f],!(d>i)&&(r[d*2+1]!==p&&(e.opt_len+=(p-r[d*2+1])*r[d*2],r[d*2+1]=p),l--)}}function Dn(e,t,r){var i=new Array(Ie+1),n=0,a,o;for(a=1;a<=Ie;a++)i[a]=n=n+r[a-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=Mn(i[s]++,s))}}function xf(){var e,t,r,i,n,a=new Array(Ie+1);for(r=0,i=0;i<Cr-1;i++)for(Fr[i]=r,e=0;e<1<<Dr[i];e++)ut[r++]=i;for(ut[r-1]=i,n=0,i=0;i<16;i++)for(Ht[i]=n,e=0;e<1<<jt[i];e++)ct[n++]=i;for(n>>=7;i<Xe;i++)for(Ht[i]=n<<7,e=0;e<1<<jt[i]-7;e++)ct[256+n++]=i;for(t=0;t<=Ie;t++)a[t]=0;for(e=0;e<=143;)he[e*2+1]=8,e++,a[8]++;for(;e<=255;)he[e*2+1]=9,e++,a[9]++;for(;e<=279;)he[e*2+1]=7,e++,a[7]++;for(;e<=287;)he[e*2+1]=8,e++,a[8]++;for(Dn(he,lt+1,a),e=0;e<Xe;e++)ht[e*2+1]=5,ht[e*2]=Mn(e,5);Ln=new Nr(he,Dr,ft+1,lt,Ie),Cn=new Nr(ht,jt,0,Xe,Ie),On=new Nr(new Array(0),vf,0,Or,gf)}function Fn(e){var t;for(t=0;t<lt;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Xe;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Or;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Mr*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Nn(e){e.bi_valid>8?dt(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 Ef(e,t,r,i){Nn(e),dt(e,r),dt(e,~r),le(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function Pn(e,t,r,i){var n=t*2,a=r*2;return e[n]<e[a]||e[n]===e[a]&&i[t]<=i[r]}function zr(e,t,r){for(var i=e.heap[r],n=r<<1;n<=e.heap_len&&(n<e.heap_len&&Pn(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Pn(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i}function zn(e,t,r){var i,n,a=0,o,s;if(e.last_lit!==0)do i=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],n=e.pending_buf[e.l_buf+a],a++,i===0?re(e,n,t):(o=ut[n],re(e,o+ft+1,t),s=Dr[o],s!==0&&(n-=Fr[o],K(e,n,s)),i--,o=In(i),re(e,o,r),s=jt[o],s!==0&&(i-=Ht[o],K(e,i,s)));while(a<e.last_lit);re(e,Mr,t)}function Ur(e,t){var r=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,h=-1,f;for(e.heap_len=0,e.heap_max=kn,o=0;o<a;o++)r[o*2]!==0?(e.heap[++e.heap_len]=h=o,e.depth[o]=0):r[o*2+1]=0;for(;e.heap_len<2;)f=e.heap[++e.heap_len]=h<2?++h:0,r[f*2]=1,e.depth[f]=0,e.opt_len--,n&&(e.static_len-=i[f*2+1]);for(t.max_code=h,o=e.heap_len>>1;o>=1;o--)zr(e,r,o);f=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],zr(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,r[f*2]=r[o*2]+r[s*2],e.depth[f]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,r[o*2+1]=r[s*2+1]=f,e.heap[1]=f++,zr(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],yf(e,t),Dn(r,h,e.bl_count)}function Un(e,t,r){var i,n=-1,a,o=t[0*2+1],s=0,h=7,f=4;for(o===0&&(h=138,f=3),t[(r+1)*2+1]=65535,i=0;i<=r;i++)a=o,o=t[(i+1)*2+1],!(++s<h&&a===o)&&(s<f?e.bl_tree[a*2]+=s:a!==0?(a!==n&&e.bl_tree[a*2]++,e.bl_tree[Sn*2]++):s<=10?e.bl_tree[Rn*2]++:e.bl_tree[An*2]++,s=0,n=a,o===0?(h=138,f=3):a===o?(h=6,f=3):(h=7,f=4))}function Bn(e,t,r){var i,n=-1,a,o=t[0*2+1],s=0,h=7,f=4;for(o===0&&(h=138,f=3),i=0;i<=r;i++)if(a=o,o=t[(i+1)*2+1],!(++s<h&&a===o)){if(s<f)do re(e,a,e.bl_tree);while(--s!==0);else a!==0?(a!==n&&(re(e,a,e.bl_tree),s--),re(e,Sn,e.bl_tree),K(e,s-3,2)):s<=10?(re(e,Rn,e.bl_tree),K(e,s-3,3)):(re(e,An,e.bl_tree),K(e,s-11,7));s=0,n=a,o===0?(h=138,f=3):a===o?(h=6,f=3):(h=7,f=4)}}function kf(e){var t;for(Un(e,e.dyn_ltree,e.l_desc.max_code),Un(e,e.dyn_dtree,e.d_desc.max_code),Ur(e,e.bl_desc),t=Or-1;t>=3&&e.bl_tree[Tn[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Sf(e,t,r,i){var n;for(K(e,t-257,5),K(e,r-1,5),K(e,i-4,4),n=0;n<i;n++)K(e,e.bl_tree[Tn[n]*2+1],3);Bn(e,e.dyn_ltree,t-1),Bn(e,e.dyn_dtree,r-1)}function Rf(e){var t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return yn;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return xn;for(r=32;r<ft;r++)if(e.dyn_ltree[r*2]!==0)return xn;return yn}var Zn=!1;function Af(e){Zn||(xf(),Zn=!0),e.l_desc=new Pr(e.dyn_ltree,Ln),e.d_desc=new Pr(e.dyn_dtree,Cn),e.bl_desc=new Pr(e.bl_tree,On),e.bi_buf=0,e.bi_valid=0,Fn(e)}function jn(e,t,r,i){K(e,(df<<1)+(i?1:0),3),Ef(e,t,r)}function Tf(e){K(e,En<<1,3),re(e,Mr,he),bf(e)}function Lf(e,t,r,i){var n,a,o=0;e.level>0?(e.strm.data_type===uf&&(e.strm.data_type=Rf(e)),Ur(e,e.l_desc),Ur(e,e.d_desc),o=kf(e),n=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=n&&(n=a)):n=a=r+5,r+4<=n&&t!==-1?jn(e,t,r,i):e.strategy===cf||a===n?(K(e,(En<<1)+(i?1:0),3),zn(e,he,ht)):(K(e,(pf<<1)+(i?1:0),3),Sf(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),zn(e,e.dyn_ltree,e.dyn_dtree)),Fn(e),i&&Nn(e)}function me(e,t,r){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=r&255,e.last_lit++,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(ut[r]+ft+1)*2]++,e.dyn_dtree[In(t)*2]++),e.last_lit===e.lit_bufsize-1}function Br(e,t,r,i){for(var n=e&65535|0,a=e>>>16&65535|0,o=0;r!==0;){o=r>2e3?2e3:r,r-=o;do n=n+t[i++]|0,a=a+n|0;while(--o);n%=65521,a%=65521}return n|a<<16|0}function Cf(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t}var Of=Cf();function B(e,t,r,i){var n=Of,a=i+r;e^=-1;for(var o=i;o<a;o++)e=e>>>8^n[(e^t[o])&255];return e^-1}var Me=0,If=1,Mf=3,be=4,Hn=5,ye=0,$n=1,xe=-2,Df=-3,Zr=-5,Ff=-1,Nf=1,$t=2,Pf=3,zf=4,Uf=2,jr=8,Bf=9,Zf=29,jf=256,Hr=jf+1+Zf,Hf=30,$f=19,Kf=2*Hr+1,Wf=15,T=3,Ee=258,J=Ee+T+1,Yf=32,$r=42,Kr=69,Kt=73,Wt=91,Yt=103,De=113,pt=666,P=1,_t=2,Fe=3,Je=4,qf=3;function ke(e,t){return e.msg=bn[t],t}function Kn(e){return(e<<1)-(e>4?9:0)}function Ne(e){for(var t=e.length;--t>=0;)e[t]=0}function Se(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(le(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,t.pending===0&&(t.pending_out=0))}function Z(e,t){Lf(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Se(e.strm)}function R(e,t){e.pending_buf[e.pending++]=t}function wt(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function Gf(e,t,r,i){var n=e.avail_in;return n>i&&(n=i),n===0?0:(e.avail_in-=n,le(t,e.input,e.next_in,n,r),e.state.wrap===1?e.adler=Br(e.adler,t,n,r):e.state.wrap===2&&(e.adler=B(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)}function Wn(e,t){var r=e.max_chain_length,i=e.strstart,n,a,o=e.prev_length,s=e.nice_match,h=e.strstart>e.w_size-J?e.strstart-(e.w_size-J):0,f=e.window,l=e.w_mask,d=e.prev,p=e.strstart+Ee,u=f[i+o-1],g=f[i+o];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do if(n=t,!(f[n+o]!==g||f[n+o-1]!==u||f[n]!==f[i]||f[++n]!==f[i+1])){i+=2,n++;do;while(f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&i<p);if(a=Ee-(p-i),i=p-Ee,a>o){if(e.match_start=t,o=a,a>=s)break;u=f[i+o-1],g=f[i+o]}}while((t=d[t&l])>h&&--r!==0);return o<=e.lookahead?o:e.lookahead}function gt(e){var t=e.w_size,r,i,n,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-J)){le(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,i=e.hash_size,r=i;do n=e.head[--r],e.head[r]=n>=t?n-t:0;while(--i);i=t,r=i;do n=e.prev[--r],e.prev[r]=n>=t?n-t:0;while(--i);a+=t}if(e.strm.avail_in===0)break;if(i=Gf(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=i,e.lookahead+e.insert>=T)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+T-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<T)););}while(e.lookahead<J&&e.strm.avail_in!==0)}function Vf(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(gt(e),e.lookahead===0&&t===Me)return P;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+r;if((e.strstart===0||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,Z(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-J&&(Z(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):(e.strstart>e.block_start&&(Z(e,!1),e.strm.avail_out===0),P)}function Wr(e,t){for(var r,i;;){if(e.lookahead<J){if(gt(e),e.lookahead<J&&t===Me)return P;if(e.lookahead===0)break}if(r=0,e.lookahead>=T&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-J&&(e.match_length=Wn(e,r)),e.match_length>=T)if(i=me(e,e.strstart-e.match_start,e.match_length-T),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=T){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-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(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Z(e,!1),e.strm.avail_out===0))return P}return e.insert=e.strstart<T-1?e.strstart:T-1,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):e.last_lit&&(Z(e,!1),e.strm.avail_out===0)?P:_t}function Qe(e,t){for(var r,i,n;;){if(e.lookahead<J){if(gt(e),e.lookahead<J&&t===Me)return P;if(e.lookahead===0)break}if(r=0,e.lookahead>=T&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-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=T-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-J&&(e.match_length=Wn(e,r),e.match_length<=5&&(e.strategy===Nf||e.match_length===T&&e.strstart-e.match_start>4096)&&(e.match_length=T-1)),e.prev_length>=T&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-T,i=me(e,e.strstart-1-e.prev_match,e.prev_length-T),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-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(--e.prev_length!==0);if(e.match_available=0,e.match_length=T-1,e.strstart++,i&&(Z(e,!1),e.strm.avail_out===0))return P}else if(e.match_available){if(i=me(e,0,e.window[e.strstart-1]),i&&Z(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return P}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=me(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<T-1?e.strstart:T-1,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):e.last_lit&&(Z(e,!1),e.strm.avail_out===0)?P:_t}function Xf(e,t){for(var r,i,n,a,o=e.window;;){if(e.lookahead<=Ee){if(gt(e),e.lookahead<=Ee&&t===Me)return P;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=T&&e.strstart>0&&(n=e.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){a=e.strstart+Ee;do;while(i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&n<a);e.match_length=Ee-(a-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=T?(r=me(e,1,e.match_length-T),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Z(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):e.last_lit&&(Z(e,!1),e.strm.avail_out===0)?P:_t}function Jf(e,t){for(var r;;){if(e.lookahead===0&&(gt(e),e.lookahead===0)){if(t===Me)return P;break}if(e.match_length=0,r=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Z(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):e.last_lit&&(Z(e,!1),e.strm.avail_out===0)?P:_t}function ie(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}var et;et=[new ie(0,0,0,0,Vf),new ie(4,4,8,4,Wr),new ie(4,5,16,8,Wr),new ie(4,6,32,32,Wr),new ie(4,4,16,16,Qe),new ie(8,16,32,32,Qe),new ie(8,16,128,128,Qe),new ie(8,32,128,256,Qe),new ie(32,128,258,1024,Qe),new ie(32,258,258,4096,Qe)];function Qf(e){e.window_size=2*e.w_size,Ne(e.head),e.max_lazy_match=et[e.level].max_lazy,e.good_match=et[e.level].good_length,e.nice_match=et[e.level].nice_length,e.max_chain_length=et[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=T-1,e.match_available=0,e.ins_h=0}function el(){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=jr,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 X(Kf*2),this.dyn_dtree=new X((2*Hf+1)*2),this.bl_tree=new X((2*$f+1)*2),Ne(this.dyn_ltree),Ne(this.dyn_dtree),Ne(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new X(Wf+1),this.heap=new X(2*Hr+1),Ne(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new X(2*Hr+1),Ne(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 tl(e){var t;return!e||!e.state?ke(e,xe):(e.total_in=e.total_out=0,e.data_type=Uf,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?$r:De,e.adler=t.wrap===2?0:1,t.last_flush=Me,Af(t),ye)}function Yn(e){var t=tl(e);return t===ye&&Qf(e.state),t}function rl(e,t,r,i,n,a){if(!e)return xe;var o=1;if(t===Ff&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>Bf||r!==jr||i<8||i>15||t<0||t>9||a<0||a>zf)return ke(e,xe);i===8&&(i=9);var s=new el;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=n+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+T-1)/T),s.window=new Bt(s.w_size*2),s.head=new X(s.hash_size),s.prev=new X(s.w_size),s.lit_bufsize=1<<n+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Bt(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=a,s.method=r,Yn(e)}function il(e,t){var r,i,n,a;if(!e||!e.state||t>Hn||t<0)return e?ke(e,xe):xe;if(i=e.state,!e.output||!e.input&&e.avail_in!==0||i.status===pt&&t!==be)return ke(e,e.avail_out===0?Zr:xe);if(i.strm=e,r=i.last_flush,i.last_flush=t,i.status===$r)if(i.wrap===2)e.adler=0,R(i,31),R(i,139),R(i,8),i.gzhead?(R(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),R(i,i.gzhead.time&255),R(i,i.gzhead.time>>8&255),R(i,i.gzhead.time>>16&255),R(i,i.gzhead.time>>24&255),R(i,i.level===9?2:i.strategy>=$t||i.level<2?4:0),R(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(R(i,i.gzhead.extra.length&255),R(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=B(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Kr):(R(i,0),R(i,0),R(i,0),R(i,0),R(i,0),R(i,i.level===9?2:i.strategy>=$t||i.level<2?4:0),R(i,qf),i.status=De);else{var o=jr+(i.w_bits-8<<4)<<8,s=-1;i.strategy>=$t||i.level<2?s=0:i.level<6?s=1:i.level===6?s=2:s=3,o|=s<<6,i.strstart!==0&&(o|=Yf),o+=31-o%31,i.status=De,wt(i,o),i.strstart!==0&&(wt(i,e.adler>>>16),wt(i,e.adler&65535)),e.adler=1}if(i.status===Kr)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),Se(e),n=i.pending,i.pending===i.pending_buf_size));)R(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Kt)}else i.status=Kt;if(i.status===Kt)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),Se(e),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}i.gzindex<i.gzhead.name.length?a=i.gzhead.name.charCodeAt(i.gzindex++)&255:a=0,R(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),a===0&&(i.gzindex=0,i.status=Wt)}else i.status=Wt;if(i.status===Wt)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),Se(e),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}i.gzindex<i.gzhead.comment.length?a=i.gzhead.comment.charCodeAt(i.gzindex++)&255:a=0,R(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),a===0&&(i.status=Yt)}else i.status=Yt;if(i.status===Yt&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Se(e),i.pending+2<=i.pending_buf_size&&(R(i,e.adler&255),R(i,e.adler>>8&255),e.adler=0,i.status=De)):i.status=De),i.pending!==0){if(Se(e),e.avail_out===0)return i.last_flush=-1,ye}else if(e.avail_in===0&&Kn(t)<=Kn(r)&&t!==be)return ke(e,Zr);if(i.status===pt&&e.avail_in!==0)return ke(e,Zr);if(e.avail_in!==0||i.lookahead!==0||t!==Me&&i.status!==pt){var h=i.strategy===$t?Jf(i,t):i.strategy===Pf?Xf(i,t):et[i.level].func(i,t);if((h===Fe||h===Je)&&(i.status=pt),h===P||h===Fe)return e.avail_out===0&&(i.last_flush=-1),ye;if(h===_t&&(t===If?Tf(i):t!==Hn&&(jn(i,0,0,!1),t===Mf&&(Ne(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Se(e),e.avail_out===0))return i.last_flush=-1,ye}return t!==be?ye:i.wrap<=0?$n:(i.wrap===2?(R(i,e.adler&255),R(i,e.adler>>8&255),R(i,e.adler>>16&255),R(i,e.adler>>24&255),R(i,e.total_in&255),R(i,e.total_in>>8&255),R(i,e.total_in>>16&255),R(i,e.total_in>>24&255)):(wt(i,e.adler>>>16),wt(i,e.adler&65535)),Se(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?ye:$n)}function nl(e){var t;return!e||!e.state?xe:(t=e.state.status,t!==$r&&t!==Kr&&t!==Kt&&t!==Wt&&t!==Yt&&t!==De&&t!==pt?ke(e,xe):(e.state=null,t===De?ke(e,Df):ye))}var qt=30,al=12;function ol(e,t){var r,i,n,a,o,s,h,f,l,d,p,u,g,S,y,v,k,E,_,A,z,m,I,L,x;r=e.state,i=e.next_in,L=e.input,n=i+(e.avail_in-5),a=e.next_out,x=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),h=r.dmax,f=r.wsize,l=r.whave,d=r.wnext,p=r.window,u=r.hold,g=r.bits,S=r.lencode,y=r.distcode,v=(1<<r.lenbits)-1,k=(1<<r.distbits)-1;e:do{g<15&&(u+=L[i++]<<g,g+=8,u+=L[i++]<<g,g+=8),E=S[u&v];t:for(;;){if(_=E>>>24,u>>>=_,g-=_,_=E>>>16&255,_===0)x[a++]=E&65535;else if(_&16){A=E&65535,_&=15,_&&(g<_&&(u+=L[i++]<<g,g+=8),A+=u&(1<<_)-1,u>>>=_,g-=_),g<15&&(u+=L[i++]<<g,g+=8,u+=L[i++]<<g,g+=8),E=y[u&k];r:for(;;){if(_=E>>>24,u>>>=_,g-=_,_=E>>>16&255,_&16){if(z=E&65535,_&=15,g<_&&(u+=L[i++]<<g,g+=8,g<_&&(u+=L[i++]<<g,g+=8)),z+=u&(1<<_)-1,z>h){e.msg="invalid distance too far back",r.mode=qt;break e}if(u>>>=_,g-=_,_=a-o,z>_){if(_=z-_,_>l&&r.sane){e.msg="invalid distance too far back",r.mode=qt;break e}if(m=0,I=p,d===0){if(m+=f-_,_<A){A-=_;do x[a++]=p[m++];while(--_);m=a-z,I=x}}else if(d<_){if(m+=f+d-_,_-=d,_<A){A-=_;do x[a++]=p[m++];while(--_);if(m=0,d<A){_=d,A-=_;do x[a++]=p[m++];while(--_);m=a-z,I=x}}}else if(m+=d-_,_<A){A-=_;do x[a++]=p[m++];while(--_);m=a-z,I=x}for(;A>2;)x[a++]=I[m++],x[a++]=I[m++],x[a++]=I[m++],A-=3;A&&(x[a++]=I[m++],A>1&&(x[a++]=I[m++]))}else{m=a-z;do x[a++]=x[m++],x[a++]=x[m++],x[a++]=x[m++],A-=3;while(A>2);A&&(x[a++]=x[m++],A>1&&(x[a++]=x[m++]))}}else if(_&64){e.msg="invalid distance code",r.mode=qt;break e}else{E=y[(E&65535)+(u&(1<<_)-1)];continue r}break}}else if(_&64)if(_&32){r.mode=al;break e}else{e.msg="invalid literal/length code",r.mode=qt;break e}else{E=S[(E&65535)+(u&(1<<_)-1)];continue t}break}}while(i<n&&a<s);A=g>>3,i-=A,g-=A<<3,u&=(1<<g)-1,e.next_in=i,e.next_out=a,e.avail_in=i<n?5+(n-i):5-(i-n),e.avail_out=a<s?257+(s-a):257-(a-s),r.hold=u,r.bits=g}var tt=15,qn=852,Gn=592,Vn=0,Yr=1,Xn=2,sl=[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],fl=[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],ll=[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],hl=[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];function vt(e,t,r,i,n,a,o,s){var h=s.bits,f=0,l=0,d=0,p=0,u=0,g=0,S=0,y=0,v=0,k=0,E,_,A,z,m,I=null,L=0,x,N=new X(tt+1),Ae=new X(tt+1),kt=null,ri=0,ii,St,Rt;for(f=0;f<=tt;f++)N[f]=0;for(l=0;l<i;l++)N[t[r+l]]++;for(u=h,p=tt;p>=1&&N[p]===0;p--);if(u>p&&(u=p),p===0)return n[a++]=1<<24|64<<16|0,n[a++]=1<<24|64<<16|0,s.bits=1,0;for(d=1;d<p&&N[d]===0;d++);for(u<d&&(u=d),y=1,f=1;f<=tt;f++)if(y<<=1,y-=N[f],y<0)return-1;if(y>0&&(e===Vn||p!==1))return-1;for(Ae[1]=0,f=1;f<tt;f++)Ae[f+1]=Ae[f]+N[f];for(l=0;l<i;l++)t[r+l]!==0&&(o[Ae[t[r+l]]++]=l);if(e===Vn?(I=kt=o,x=19):e===Yr?(I=sl,L-=257,kt=fl,ri-=257,x=256):(I=ll,kt=hl,x=-1),k=0,l=0,f=d,m=a,g=u,S=0,A=-1,v=1<<u,z=v-1,e===Yr&&v>qn||e===Xn&&v>Gn)return 1;for(;;){ii=f-S,o[l]<x?(St=0,Rt=o[l]):o[l]>x?(St=kt[ri+o[l]],Rt=I[L+o[l]]):(St=96,Rt=0),E=1<<f-S,_=1<<g,d=_;do _-=E,n[m+(k>>S)+_]=ii<<24|St<<16|Rt|0;while(_!==0);for(E=1<<f-1;k&E;)E>>=1;if(E!==0?(k&=E-1,k+=E):k=0,l++,--N[f]===0){if(f===p)break;f=t[r+o[l]]}if(f>u&&(k&z)!==A){for(S===0&&(S=u),m+=d,g=f-S,y=1<<g;g+S<p&&(y-=N[g+S],!(y<=0));)g++,y<<=1;if(v+=1<<g,e===Yr&&v>qn||e===Xn&&v>Gn)return 1;A=k&z,n[A]=u<<24|g<<16|m-a|0}}return k!==0&&(n[m+k]=f-S<<24|64<<16|0),s.bits=u,0}var cl=0,Jn=1,Qn=2,ea=4,ul=5,Gt=6,mt=0,dl=1,pl=2,Re=-2,_l=-3,wl=-4,gl=-5,ta=8,ra=1,ia=2,na=3,aa=4,oa=5,sa=6,fa=7,la=8,ha=9,ca=10,ua=11,ce=12,qr=13,da=14,Gr=15,pa=16,_a=17,wa=18,ga=19,Vt=20,Xt=21,va=22,ma=23,ba=24,ya=25,xa=26,Vr=27,Ea=28,ka=29,M=30,vl=31,ml=32,bl=852,yl=592;function Sa(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function xl(){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 X(320),this.work=new X(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function El(e){var t;return!e||!e.state?Re:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=ra,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Zt(bl),t.distcode=t.distdyn=new Zt(yl),t.sane=1,t.back=-1,mt)}function Ra(e){var t;return!e||!e.state?Re:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,El(e))}function kl(e,t){var r,i;return!e||!e.state||(i=e.state,t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Re:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,Ra(e))}function Sl(e,t){var r,i;return e?(i=new xl,e.state=i,i.window=null,r=kl(e,t),r!==mt&&(e.state=null),r):Re}var Aa=!0,Xr,Jr;function Rl(e){if(Aa){var t;for(Xr=new Zt(512),Jr=new Zt(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(vt(Jn,e.lens,0,288,Xr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;vt(Qn,e.lens,0,32,Jr,0,e.work,{bits:5}),Aa=!1}e.lencode=Xr,e.lenbits=9,e.distcode=Jr,e.distbits=5}function Al(e,t,r,i){var n,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Bt(a.wsize)),i>=a.wsize?(le(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>i&&(n=i),le(a.window,t,r-i,n,a.wnext),i-=n,i?(le(a.window,t,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0}function Tl(e,t){var r,i,n,a,o,s,h,f,l,d,p,u,g,S,y=0,v,k,E,_,A,z,m,I,L=new Bt(4),x,N,Ae=[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&&e.avail_in!==0)return Re;r=e.state,r.mode===ce&&(r.mode=qr),o=e.next_out,n=e.output,h=e.avail_out,a=e.next_in,i=e.input,s=e.avail_in,f=r.hold,l=r.bits,d=s,p=h,I=mt;e:for(;;)switch(r.mode){case ra:if(r.wrap===0){r.mode=qr;break}for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(r.wrap&2&&f===35615){r.check=0,L[0]=f&255,L[1]=f>>>8&255,r.check=B(r.check,L,2,0),f=0,l=0,r.mode=ia;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((f&255)<<8)+(f>>8))%31){e.msg="incorrect header check",r.mode=M;break}if((f&15)!==ta){e.msg="unknown compression method",r.mode=M;break}if(f>>>=4,l-=4,m=(f&15)+8,r.wbits===0)r.wbits=m;else if(m>r.wbits){e.msg="invalid window size",r.mode=M;break}r.dmax=1<<m,e.adler=r.check=1,r.mode=f&512?ca:ce,f=0,l=0;break;case ia:for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(r.flags=f,(r.flags&255)!==ta){e.msg="unknown compression method",r.mode=M;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=M;break}r.head&&(r.head.text=f>>8&1),r.flags&512&&(L[0]=f&255,L[1]=f>>>8&255,r.check=B(r.check,L,2,0)),f=0,l=0,r.mode=na;case na:for(;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.head&&(r.head.time=f),r.flags&512&&(L[0]=f&255,L[1]=f>>>8&255,L[2]=f>>>16&255,L[3]=f>>>24&255,r.check=B(r.check,L,4,0)),f=0,l=0,r.mode=aa;case aa:for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.head&&(r.head.xflags=f&255,r.head.os=f>>8),r.flags&512&&(L[0]=f&255,L[1]=f>>>8&255,r.check=B(r.check,L,2,0)),f=0,l=0,r.mode=oa;case oa:if(r.flags&1024){for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.length=f,r.head&&(r.head.extra_len=f),r.flags&512&&(L[0]=f&255,L[1]=f>>>8&255,r.check=B(r.check,L,2,0)),f=0,l=0}else r.head&&(r.head.extra=null);r.mode=sa;case sa:if(r.flags&1024&&(u=r.length,u>s&&(u=s),u&&(r.head&&(m=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),le(r.head.extra,i,a,u,m)),r.flags&512&&(r.check=B(r.check,i,u,a)),s-=u,a+=u,r.length-=u),r.length))break e;r.length=0,r.mode=fa;case fa:if(r.flags&2048){if(s===0)break e;u=0;do m=i[a+u++],r.head&&m&&r.length<65536&&(r.head.name+=String.fromCharCode(m));while(m&&u<s);if(r.flags&512&&(r.check=B(r.check,i,u,a)),s-=u,a+=u,m)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=la;case la:if(r.flags&4096){if(s===0)break e;u=0;do m=i[a+u++],r.head&&m&&r.length<65536&&(r.head.comment+=String.fromCharCode(m));while(m&&u<s);if(r.flags&512&&(r.check=B(r.check,i,u,a)),s-=u,a+=u,m)break e}else r.head&&(r.head.comment=null);r.mode=ha;case ha:if(r.flags&512){for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(f!==(r.check&65535)){e.msg="header crc mismatch",r.mode=M;break}f=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=ce;break;case ca:for(;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}e.adler=r.check=Sa(f),f=0,l=0,r.mode=ua;case ua:if(r.havedict===0)return e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,pl;e.adler=r.check=1,r.mode=ce;case ce:if(t===ul||t===Gt)break e;case qr:if(r.last){f>>>=l&7,l-=l&7,r.mode=Vr;break}for(;l<3;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}switch(r.last=f&1,f>>>=1,l-=1,f&3){case 0:r.mode=da;break;case 1:if(Rl(r),r.mode=Vt,t===Gt){f>>>=2,l-=2;break e}break;case 2:r.mode=_a;break;case 3:e.msg="invalid block type",r.mode=M}f>>>=2,l-=2;break;case da:for(f>>>=l&7,l-=l&7;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if((f&65535)!==(f>>>16^65535)){e.msg="invalid stored block lengths",r.mode=M;break}if(r.length=f&65535,f=0,l=0,r.mode=Gr,t===Gt)break e;case Gr:r.mode=pa;case pa:if(u=r.length,u){if(u>s&&(u=s),u>h&&(u=h),u===0)break e;le(n,i,a,u,o),s-=u,a+=u,h-=u,o+=u,r.length-=u;break}r.mode=ce;break;case _a:for(;l<14;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(r.nlen=(f&31)+257,f>>>=5,l-=5,r.ndist=(f&31)+1,f>>>=5,l-=5,r.ncode=(f&15)+4,f>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=M;break}r.have=0,r.mode=wa;case wa:for(;r.have<r.ncode;){for(;l<3;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.lens[Ae[r.have++]]=f&7,f>>>=3,l-=3}for(;r.have<19;)r.lens[Ae[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},I=vt(cl,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,I){e.msg="invalid code lengths set",r.mode=M;break}r.have=0,r.mode=ga;case ga:for(;r.have<r.nlen+r.ndist;){for(;y=r.lencode[f&(1<<r.lenbits)-1],v=y>>>24,k=y>>>16&255,E=y&65535,!(v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(E<16)f>>>=v,l-=v,r.lens[r.have++]=E;else{if(E===16){for(N=v+2;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(f>>>=v,l-=v,r.have===0){e.msg="invalid bit length repeat",r.mode=M;break}m=r.lens[r.have-1],u=3+(f&3),f>>>=2,l-=2}else if(E===17){for(N=v+3;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}f>>>=v,l-=v,m=0,u=3+(f&7),f>>>=3,l-=3}else{for(N=v+7;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}f>>>=v,l-=v,m=0,u=11+(f&127),f>>>=7,l-=7}if(r.have+u>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=M;break}for(;u--;)r.lens[r.have++]=m}}if(r.mode===M)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=M;break}if(r.lenbits=9,x={bits:r.lenbits},I=vt(Jn,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,I){e.msg="invalid literal/lengths set",r.mode=M;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},I=vt(Qn,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,I){e.msg="invalid distances set",r.mode=M;break}if(r.mode=Vt,t===Gt)break e;case Vt:r.mode=Xt;case Xt:if(s>=6&&h>=258){e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,ol(e,p),o=e.next_out,n=e.output,h=e.avail_out,a=e.next_in,i=e.input,s=e.avail_in,f=r.hold,l=r.bits,r.mode===ce&&(r.back=-1);break}for(r.back=0;y=r.lencode[f&(1<<r.lenbits)-1],v=y>>>24,k=y>>>16&255,E=y&65535,!(v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(k&&!(k&240)){for(_=v,A=k,z=E;y=r.lencode[z+((f&(1<<_+A)-1)>>_)],v=y>>>24,k=y>>>16&255,E=y&65535,!(_+v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}f>>>=_,l-=_,r.back+=_}if(f>>>=v,l-=v,r.back+=v,r.length=E,k===0){r.mode=xa;break}if(k&32){r.back=-1,r.mode=ce;break}if(k&64){e.msg="invalid literal/length code",r.mode=M;break}r.extra=k&15,r.mode=va;case va:if(r.extra){for(N=r.extra;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=ma;case ma:for(;y=r.distcode[f&(1<<r.distbits)-1],v=y>>>24,k=y>>>16&255,E=y&65535,!(v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(!(k&240)){for(_=v,A=k,z=E;y=r.distcode[z+((f&(1<<_+A)-1)>>_)],v=y>>>24,k=y>>>16&255,E=y&65535,!(_+v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}f>>>=_,l-=_,r.back+=_}if(f>>>=v,l-=v,r.back+=v,k&64){e.msg="invalid distance code",r.mode=M;break}r.offset=E,r.extra=k&15,r.mode=ba;case ba:if(r.extra){for(N=r.extra;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=M;break}r.mode=ya;case ya:if(h===0)break e;if(u=p-h,r.offset>u){if(u=r.offset-u,u>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=M;break}u>r.wnext?(u-=r.wnext,g=r.wsize-u):g=r.wnext-u,u>r.length&&(u=r.length),S=r.window}else S=n,g=o-r.offset,u=r.length;u>h&&(u=h),h-=u,r.length-=u;do n[o++]=S[g++];while(--u);r.length===0&&(r.mode=Xt);break;case xa:if(h===0)break e;n[o++]=r.length,h--,r.mode=Xt;break;case Vr:if(r.wrap){for(;l<32;){if(s===0)break e;s--,f|=i[a++]<<l,l+=8}if(p-=h,e.total_out+=p,r.total+=p,p&&(e.adler=r.check=r.flags?B(r.check,n,p,o-p):Br(r.check,n,p,o-p)),p=h,(r.flags?f:Sa(f))!==r.check){e.msg="incorrect data check",r.mode=M;break}f=0,l=0}r.mode=Ea;case Ea:if(r.wrap&&r.flags){for(;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(f!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=M;break}f=0,l=0}r.mode=ka;case ka:I=dl;break e;case M:I=_l;break e;case vl:return wl;case ml:default:return Re}return e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,(r.wsize||p!==e.avail_out&&r.mode<M&&(r.mode<Vr||t!==ea))&&Al(e,e.output,e.next_out,p-e.avail_out),d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,r.total+=p,r.wrap&&p&&(e.adler=r.check=r.flags?B(r.check,n,p,e.next_out-p):Br(r.check,n,p,e.next_out-p)),e.data_type=r.bits+(r.last?64:0)+(r.mode===ce?128:0)+(r.mode===Vt||r.mode===Gr?256:0),(d===0&&p===0||t===ea)&&I===mt&&(I=gl),I}function Ll(e){if(!e||!e.state)return Re;var t=e.state;return t.window&&(t.window=null),e.state=null,mt}var Qr=0,rt=1,Jt=2,bt=3,Qt=4,it=5,yt=6,xt=7,Ta=0,La=1,Ca=2,Oa=3,ei=4,Ia=5,Cl=6,er=0,Ma=1,Da=2,Ol=-1,Il=-2,Ml=-3,Fa=-5,Dl=0,Fl=1,Nl=9,Pl=-1,zl=1,Ul=2,Bl=3,Zl=4,jl=0,Hl=0,$l=1,Kl=2,Na=8;function Q(e){if(e<rt||e>xt)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}Q.prototype.init=function(e,t,r,i,n){this.windowBits=e,this.level=t,this.memLevel=r,this.strategy=i,(this.mode===bt||this.mode===Qt)&&(this.windowBits+=16),this.mode===xt&&(this.windowBits+=32),(this.mode===it||this.mode===yt)&&(this.windowBits=-this.windowBits),this.strm=new hf;var a;switch(this.mode){case rt:case bt:case it:a=rl(this.strm,this.level,Na,this.windowBits,this.memLevel,this.strategy);break;case Jt:case Qt:case yt:case xt:a=Sl(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(a!==er){this._error(a);return}this.write_in_progress=!1,this.init_done=!0},Q.prototype.params=function(){throw new Error("deflateParams Not supported")},Q.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(this.mode===Qr)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},Q.prototype.write=function(e,t,r,i,n,a,o){this._writeCheck(),this.write_in_progress=!0;var s=this;return se.nextTick(function(){s.write_in_progress=!1;var h=s._write(e,t,r,i,n,a,o);s.callback(h[0],h[1]),s.pending_close&&s.close()}),this};function Wl(e,t){for(var r=0;r<e.length;r++)this[t+r]=e[r]}Q.prototype.writeSync=function(e,t,r,i,n,a,o){return this._writeCheck(),this._write(e,t,r,i,n,a,o)},Q.prototype._write=function(e,t,r,i,n,a,o){if(this.write_in_progress=!0,e!==Ta&&e!==La&&e!==Ca&&e!==Oa&&e!==ei&&e!==Ia)throw new Error("Invalid flush value");t==null&&(t=new c(0),i=0,r=0),n._set?n.set=n._set:n.set=Wl;var s=this.strm;s.avail_in=i,s.input=t,s.next_in=r,s.avail_out=o,s.output=n,s.next_out=a;var h;switch(this.mode){case rt:case bt:case it:h=il(s,e);break;case xt:case Jt:case Qt:case yt:h=Tl(s,e);break;default:throw new Error("Unknown mode "+this.mode)}return this._checkError(h,s,e)||this._error(h),this.write_in_progress=!1,[s.avail_in,s.avail_out]},Q.prototype._checkError=function(e,t,r){switch(e){case er:case Fa:if(t.avail_out!==0&&r===ei)return!1;break;case Ma:break;case Da:return!1;default:return!1}return!0},Q.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}this.pending_close=!1,this.mode===rt||this.mode===bt||this.mode===it?nl(this.strm):Ll(this.strm),this.mode=Qr};var tr;Q.prototype.reset=function(){switch(this.mode){case rt:case it:tr=Yn(this.strm);break;case Jt:case yt:tr=Ra(this.strm);break}tr!==er&&this._error(tr)},Q.prototype._error=function(e){this.onerror(bn[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var Pa=Object.freeze({__proto__:null,DEFLATE:rt,DEFLATERAW:it,GUNZIP:Qt,GZIP:bt,INFLATE:Jt,INFLATERAW:yt,NONE:Qr,UNZIP:xt,Z_BEST_COMPRESSION:Nl,Z_BEST_SPEED:Fl,Z_BINARY:Hl,Z_BLOCK:Ia,Z_BUF_ERROR:Fa,Z_DATA_ERROR:Ml,Z_DEFAULT_COMPRESSION:Pl,Z_DEFAULT_STRATEGY:jl,Z_DEFLATED:Na,Z_ERRNO:Ol,Z_FILTERED:zl,Z_FINISH:ei,Z_FIXED:Zl,Z_FULL_FLUSH:Oa,Z_HUFFMAN_ONLY:Ul,Z_NEED_DICT:Da,Z_NO_COMPRESSION:Dl,Z_NO_FLUSH:Ta,Z_OK:er,Z_PARTIAL_FLUSH:La,Z_RLE:Bl,Z_STREAM_END:Ma,Z_STREAM_ERROR:Il,Z_SYNC_FLUSH:Ca,Z_TEXT:$l,Z_TREES:Cl,Z_UNKNOWN:Kl,Zlib:Q});function Yl(e,t){if(!e)throw new Error(t)}var w={};Object.keys(Pa).forEach(function(e){w[e]=Pa[e]}),w.Z_MIN_WINDOWBITS=8,w.Z_MAX_WINDOWBITS=15,w.Z_DEFAULT_WINDOWBITS=15,w.Z_MIN_CHUNK=64,w.Z_MAX_CHUNK=1/0,w.Z_DEFAULT_CHUNK=16*1024,w.Z_MIN_MEMLEVEL=1,w.Z_MAX_MEMLEVEL=9,w.Z_DEFAULT_MEMLEVEL=8,w.Z_MIN_LEVEL=-1,w.Z_MAX_LEVEL=9,w.Z_DEFAULT_LEVEL=w.Z_DEFAULT_COMPRESSION;var Et={Z_OK:w.Z_OK,Z_STREAM_END:w.Z_STREAM_END,Z_NEED_DICT:w.Z_NEED_DICT,Z_ERRNO:w.Z_ERRNO,Z_STREAM_ERROR:w.Z_STREAM_ERROR,Z_DATA_ERROR:w.Z_DATA_ERROR,Z_MEM_ERROR:w.Z_MEM_ERROR,Z_BUF_ERROR:w.Z_BUF_ERROR,Z_VERSION_ERROR:w.Z_VERSION_ERROR};Object.keys(Et).forEach(function(e){Et[Et[e]]=e});function ql(e){return new Ue(e)}function Gl(e){return new Be(e)}function Vl(e){return new He(e)}function Xl(e){return new $e(e)}function Jl(e){return new Ze(e)}function Ql(e){return new je(e)}function eh(e){return new Ke(e)}function th(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ue(t),e,r)}function rh(e,t){return ze(new Ue(t),e)}function ih(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ze(t),e,r)}function nh(e,t){return ze(new Ze(t),e)}function ah(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new He(t),e,r)}function oh(e,t){return ze(new He(t),e)}function sh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ke(t),e,r)}function fh(e,t){return ze(new Ke(t),e)}function lh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Be(t),e,r)}function hh(e,t){return ze(new Be(t),e)}function ch(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new je(t),e,r)}function uh(e,t){return ze(new je(t),e)}function dh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new $e(t),e,r)}function ph(e,t){return ze(new $e(t),e)}function Pe(e,t,r){var i=[],n=0;e.on("error",o),e.on("end",s),e.end(t),a();function a(){for(var h;(h=e.read())!==null;)i.push(h),n+=h.length;e.once("readable",a)}function o(h){e.removeListener("end",s),e.removeListener("readable",a),r(h)}function s(){var h=c.concat(i,n);i=[],r(null,h),e.close()}}function ze(e,t){if(typeof t=="string"&&(t=new c(t)),!c.isBuffer(t))throw new TypeError("Not a string or buffer");var r=w.Z_FINISH;return e._processChunk(t,r)}function Ue(e){if(!(this instanceof Ue))return new Ue(e);D.call(this,e,w.DEFLATE)}function Be(e){if(!(this instanceof Be))return new Be(e);D.call(this,e,w.INFLATE)}function Ze(e){if(!(this instanceof Ze))return new Ze(e);D.call(this,e,w.GZIP)}function je(e){if(!(this instanceof je))return new je(e);D.call(this,e,w.GUNZIP)}function He(e){if(!(this instanceof He))return new He(e);D.call(this,e,w.DEFLATERAW)}function $e(e){if(!(this instanceof $e))return new $e(e);D.call(this,e,w.INFLATERAW)}function Ke(e){if(!(this instanceof Ke))return new Ke(e);D.call(this,e,w.UNZIP)}function D(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||w.Z_DEFAULT_CHUNK,V.call(this,e),e.flush&&e.flush!==w.Z_NO_FLUSH&&e.flush!==w.Z_PARTIAL_FLUSH&&e.flush!==w.Z_SYNC_FLUSH&&e.flush!==w.Z_FULL_FLUSH&&e.flush!==w.Z_FINISH&&e.flush!==w.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||w.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<w.Z_MIN_CHUNK||e.chunkSize>w.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<w.Z_MIN_WINDOWBITS||e.windowBits>w.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<w.Z_MIN_LEVEL||e.level>w.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<w.Z_MIN_MEMLEVEL||e.memLevel>w.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=w.Z_FILTERED&&e.strategy!=w.Z_HUFFMAN_ONLY&&e.strategy!=w.Z_RLE&&e.strategy!=w.Z_FIXED&&e.strategy!=w.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!c.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new w.Zlib(t);var r=this;this._hadError=!1,this._binding.onerror=function(a,o){r._binding=null,r._hadError=!0;var s=new Error(a);s.errno=o,s.code=Et[o],r.emit("error",s)};var i=w.Z_DEFAULT_COMPRESSION;typeof e.level=="number"&&(i=e.level);var n=w.Z_DEFAULT_STRATEGY;typeof e.strategy=="number"&&(n=e.strategy),this._binding.init(e.windowBits||w.Z_DEFAULT_WINDOWBITS,i,e.memLevel||w.Z_DEFAULT_MEMLEVEL,n,e.dictionary),this._buffer=new c(this._chunkSize),this._offset=0,this._closed=!1,this._level=i,this._strategy=n,this.once("end",this.close)}j(D,V),D.prototype.params=function(e,t,r){if(e<w.Z_MIN_LEVEL||e>w.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=w.Z_FILTERED&&t!=w.Z_HUFFMAN_ONLY&&t!=w.Z_RLE&&t!=w.Z_FIXED&&t!=w.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var i=this;this.flush(w.Z_SYNC_FLUSH,function(){i._binding.params(e,t),i._hadError||(i._level=e,i._strategy=t,r&&r())})}else se.nextTick(r)},D.prototype.reset=function(){return this._binding.reset()},D.prototype._flush=function(e){this._transform(new c(0),"",e)},D.prototype.flush=function(e,t){var r=this._writableState;if((typeof e=="function"||e===void 0&&!t)&&(t=e,e=w.Z_FULL_FLUSH),r.ended)t&&se.nextTick(t);else if(r.ending)t&&this.once("end",t);else if(r.needDrain){var i=this;this.once("drain",function(){i.flush(t)})}else this._flushFlag=e,this.write(new c(0),"",t)},D.prototype.close=function(e){if(e&&se.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;se.nextTick(function(){t.emit("close")})}},D.prototype._transform=function(e,t,r){var i,n=this._writableState,a=n.ending||n.ended,o=a&&(!e||n.length===e.length);if(!e===null&&!c.isBuffer(e))return r(new Error("invalid input"));o?i=w.Z_FINISH:(i=this._flushFlag,e.length>=n.length&&(this._flushFlag=this._opts.flush||w.Z_NO_FLUSH)),this._processChunk(e,i,r)},D.prototype._processChunk=function(e,t,r){var i=e&&e.length,n=this._chunkSize-this._offset,a=0,o=this,s=typeof r=="function";if(!s){var h=[],f=0,l;this.on("error",function(S){l=S});do var d=this._binding.writeSync(t,e,a,i,this._buffer,this._offset,n);while(!this._hadError&&g(d[0],d[1]));if(this._hadError)throw l;var p=c.concat(h,f);return this.close(),p}var u=this._binding.write(t,e,a,i,this._buffer,this._offset,n);u.buffer=e,u.callback=g;function g(S,y){if(!o._hadError){var v=n-y;if(Yl(v>=0,"have should not go down"),v>0){var k=o._buffer.slice(o._offset,o._offset+v);o._offset+=v,s?o.push(k):(h.push(k),f+=k.length)}if((y===0||o._offset>=o._chunkSize)&&(n=o._chunkSize,o._offset=0,o._buffer=new c(o._chunkSize)),y===0){if(a+=i-S,i=S,!s)return!0;var E=o._binding.write(t,e,a,i,o._buffer,o._offset,o._chunkSize);E.callback=g,E.buffer=e;return}if(!s)return!1;r()}}},j(Ue,D),j(Be,D),j(Ze,D),j(je,D),j(He,D),j($e,D),j(Ke,D);var za={codes:Et,createDeflate:ql,createInflate:Gl,createDeflateRaw:Vl,createInflateRaw:Xl,createGzip:Jl,createGunzip:Ql,createUnzip:eh,deflate:th,deflateSync:rh,gzip:ih,gzipSync:nh,deflateRaw:ah,deflateRawSync:oh,unzip:sh,unzipSync:fh,inflate:lh,inflateSync:hh,gunzip:ch,gunzipSync:uh,inflateRaw:dh,inflateRawSync:ph,Deflate:Ue,Inflate:Be,Gzip:Ze,Gunzip:je,DeflateRaw:He,InflateRaw:$e,Unzip:Ke,Zlib:D};class Ua extends hr{constructor({client:t,keyPrefix:r="cache"}){super(),this.client=t,this.keyPrefix=r}async _set(t,r){let i=JSON.stringify(r);const n=i.length;return i=za.gzipSync(i).toString("base64"),this.client.putObject({key:Y(this.keyPrefix,t),body:i,contentEncoding:"gzip",contentType:"application/gzip",metadata:{compressor:"zlib",compressed:"true","client-id":this.client.id,"length-serialized":String(n),"length-compressed":String(i.length),"compression-gain":(i.length/n).toFixed(2)}})}async _get(t){const{Body:r}=await this.client.getObject(Y(this.keyPrefix,t));let i=await lr(r);return i=Buffer.from(i,"base64"),i=za.unzipSync(i).toString(),JSON.parse(i)}async _del(t){return await this.client.deleteObject(Y(this.keyPrefix,t)),!0}async _clear(t=""){const r=await this.client.getAllKeys({prefix:Y(this.keyPrefix,t)});await this.client.deleteObjects(r)}}class Ba extends b{async setup(t){}async start(){}async stop(){}beforeSetup(){this.emit("plugin.beforeSetup",new Date)}afterSetup(){this.emit("plugin.afterSetup",new Date)}beforeStart(){this.emit("plugin.beforeStart",new Date)}afterStart(){this.emit("plugin.afterStart",new Date)}beforeStop(){this.emit("plugin.beforeStop",new Date)}afterStop(){this.emit("plugin.afterStop",new Date)}}const _h={setup(e){},start(){},stop(){}},wh={async setup(e){this.client=e.client,this.map={PutObjectCommand:"put",GetObjectCommand:"get",HeadObjectCommand:"get",DeleteObjectCommand:"delete",DeleteObjectsCommand:"delete",ListObjectsV2Command:"list"},this.costs={total:0,prices:{put:.005/1e3,copy:.005/1e3,list:.005/1e3,post:.005/1e3,get:4e-4/1e3,select:4e-4/1e3,delete:4e-4/1e3},requests:{total:0,put:0,post:0,copy:0,list:0,get:0,select:0,delete:0},events:{total:0,PutObjectCommand:0,GetObjectCommand:0,HeadObjectCommand:0,DeleteObjectCommand:0,DeleteObjectsCommand:0,ListObjectsV2Command:0}},this.client.costs=JSON.parse(JSON.stringify(this.costs))},async start(){this.client.on("command.response",e=>this.addRequest(e,this.map[e]))},addRequest(e,t){this.costs.events[e]++,this.costs.events.total++,this.costs.requests.total++,this.costs.requests[t]++,this.costs.total+=this.costs.prices[t],this.client.costs.events[e]++,this.client.costs.events.total++,this.client.costs.requests.total++,this.client.costs.requests[t]++,this.client.costs.total+=this.client.costs.prices[t]}};class gh extends Ba{constructor(t={}){super(),this.driver=t.driver}async setup(t){this.database=t,this.driver||(this.driver=new Ua({keyPrefix:"cache",client:t.client})),this.installDatabaseProxy();for(const r of Object.values(t.resources))this.installResourcesProxies(r)}async start(){}async stop(){}installDatabaseProxy(){const t=this.installResourcesProxies.bind(this);this.database._createResource=this.database.createResource,this.database.createResource=async function(...r){const i=await this._createResource(...r);return t(i),i}}installResourcesProxies(t){t.cache=this.driver;let r=`resource=${t.name}`;this.driver.keyPrefix&&(this.driver.keyPrefix=Y(this.driver.keyPrefix,r)),t.cacheKeyFor=async function({params:i={},action:n="list"}){let a=Object.keys(i).sort().map(o=>`${o}:${i[o]}`).join("|")||"empty";return a=await yi(a),a=Y(r,`action=${n}`,`${a}.json.gz`),a},t._count=t.count,t._listIds=t.listIds,t._getMany=t.getMany,t._getAll=t.getAll,t._page=t.page,t.count=async function(){const i=await this.cacheKeyFor({action:"count"});try{const a=await this.cache.get(i);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const n=await t._count();return await this.cache.set(i,n),n},t.listIds=async function(){const i=await this.cacheKeyFor({action:"listIds"});try{const a=await this.cache.get(i);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const n=await t._listIds();return await this.cache.set(i,n),n},t.getMany=async function(i){const n=await this.cacheKeyFor({action:"getMany",params:{ids:i}});try{const o=await this.cache.get(n);if(o)return o}catch(o){if(o.name!=="NoSuchKey")throw o}const a=await t._getMany(i);return await this.cache.set(n,a),a},t.getAll=async function(){const i=await this.cacheKeyFor({action:"getAll"});try{const a=await this.cache.get(i);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const n=await t._getAll();return await this.cache.set(i,n),n},t.page=async function({offset:i,size:n}){const a=await this.cacheKeyFor({action:"page",params:{offset:i,size:n}});try{const s=await this.cache.get(a);if(s)return s}catch(s){if(s.name!=="NoSuchKey")throw s}const o=await t._page({offset:i,size:n});return await this.cache.set(a,o),o},t._insert=t.insert,t._update=t.update,t._delete=t.delete,t._deleteMany=t.deleteMany,t.insert=async function(...i){const n=await t._insert(...i);return await this.cache.clear(r),n},t.update=async function(...i){const n=await t._update(...i);return await this.cache.clear(r),n},t.delete=async function(...i){const n=await t._delete(...i);return await this.cache.clear(r),n},t.deleteMany=async function(...i){const n=await t._deleteMany(...i);return await this.cache.clear(r),n}}}var vh=Object.freeze({__proto__:null});exports.BaseError=We,exports.Cache=hr,exports.CachePlugin=gh,exports.Client=bi,exports.ConnectionString=mi,exports.CostsPlugin=wh,exports.Database=Oi,exports.ErrorMap=wi,exports.InvalidResourceItem=Tt,exports.MemoryCache=lo,exports.MissingMetadata=pi,exports.NoSuchBucket=ui,exports.NoSuchKey=or,exports.NotFound=di,exports.Plugin=Ba,exports.PluginObject=_h,exports.ResourceIdsPageReader=Ai,exports.ResourceIdsReader=Ri,exports.ResourceReader=Ti,exports.ResourceWriter=Li,exports.S3Cache=Ua,exports.S3_DEFAULT_ENDPOINT=vi,exports.S3_DEFAULT_REGION=gi,exports.S3db=fo,exports.UnknownError=_i,exports.Validator=ki,exports.ValidatorManager=Si,exports.decrypt=xi,exports.encrypt=sr,exports.sha256=yi,exports.streamToString=lr;
|
|
21
|
+
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function Es(e){return Array.isArray(e)}function tn(e){return typeof e=="boolean"}function vr(e){return e===null}function ks(e){return typeof e=="number"}function mr(e){return typeof e=="string"}function ve(e){return e===void 0}function br(e){return at(e)&&Er(e)==="[object RegExp]"}function at(e){return typeof e=="object"&&e!==null}function rn(e){return at(e)&&Er(e)==="[object Date]"}function yr(e){return at(e)&&(Er(e)==="[object Error]"||e instanceof Error)}function xr(e){return typeof e=="function"}function Er(e){return Object.prototype.toString.call(e)}function Ss(e,t){if(!t||!at(t))return e;for(var r=Object.keys(t),i=r.length;i--;)e[r[i]]=t[r[i]];return e}function nn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Oe(){this.head=null,this.tail=null,this.length=0}Oe.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},Oe.prototype.unshift=function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length},Oe.prototype.shift=function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},Oe.prototype.clear=function(){this.head=this.tail=null,this.length=0},Oe.prototype.join=function(e){if(this.length===0)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},Oe.prototype.concat=function(e){if(this.length===0)return c.alloc(0);if(this.length===1)return this.head.data;for(var t=c.allocUnsafe(e>>>0),r=this.head,i=0;r;)r.data.copy(t,i),i+=r.data.length,r=r.next;return t};var Rs=c.isEncoding||function(e){switch(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 As(e){if(e&&!Rs(e))throw new Error("Unknown encoding: "+e)}function ot(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),As(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Ls;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Cs;break;default:this.write=Ts;return}this.charBuffer=new c(6),this.charReceived=0,this.charLength=0}ot.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";e=e.slice(r,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=t.charCodeAt(t.length-1);if(n>=55296&&n<=56319){this.charLength+=this.surrogateSize,t="";continue}if(this.charReceived=this.charLength=0,e.length===0)return t;break}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,n=t.charCodeAt(i);if(n>=55296&&n<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),e.copy(this.charBuffer,0,0,a),t.substring(0,i)}return t},ot.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},ot.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,i=this.charBuffer,n=this.encoding;t+=i.slice(0,r).toString(n)}return t};function Ts(e){return e.toString(this.encoding)}function Ls(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Cs(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}F.ReadableState=an;var C=ws("stream");j(F,b);function Os(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function Is(e,t){return e.listeners(t).length}function an(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof G&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,i=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:i,this.highWaterMark=~~this.highWaterMark,this.buffer=new Oe,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.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new ot(e.encoding),this.encoding=e.encoding)}function F(e){if(!(this instanceof F))return new F(e);this._readableState=new an(e,this),this.readable=!0,e&&typeof e.read=="function"&&(this._read=e.read),b.call(this)}F.prototype.push=function(e,t){var r=this._readableState;return!r.objectMode&&typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=c.from(e,t),t="")),on(this,r,e,t,!1)},F.prototype.unshift=function(e){var t=this._readableState;return on(this,t,e,"",!0)},F.prototype.isPaused=function(){return this._readableState.flowing===!1};function on(e,t,r,i,n){var a=Fs(t,r);if(a)e.emit("error",a);else if(r===null)t.reading=!1,Ns(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!n){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&n){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var h;t.decoder&&!n&&!i&&(r=t.decoder.write(r),h=!t.objectMode&&r.length===0),n||(t.reading=!1),h||(t.flowing&&t.length===0&&!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&&Ut(e))),Ps(e,t)}else n||(t.reading=!1);return Ms(t)}function Ms(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}F.prototype.setEncoding=function(e){return this._readableState.decoder=new ot(e),this._readableState.encoding=e,this};var sn=8388608;function Ds(e){return e>=sn?e=sn:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function fn(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=Ds(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}F.prototype.read=function(e){C("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return C("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Sr(this):Ut(this),null;if(e=fn(e,t),e===0&&t.ended)return t.length===0&&Sr(this),null;var i=t.needReadable;C("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,C("length less than watermark",i)),t.ended||t.reading?(i=!1,C("reading or ended",i)):i&&(C("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=fn(r,t)));var n;return e>0?n=hn(e,t):n=null,n===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Sr(this)),n!==null&&this.emit("data",n),n};function Fs(e,t){var r=null;return!c.isBuffer(t)&&typeof t!="string"&&t!==null&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function Ns(e,t){if(!t.ended){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,Ut(e)}}function Ut(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(C("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Y(ln,e):ln(e))}function ln(e){C("emit readable"),e.emit("readable"),kr(e)}function Ps(e,t){t.readingMore||(t.readingMore=!0,Y(zs,e,t))}function zs(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(C("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}F.prototype._read=function(e){this.emit("error",new Error("not implemented"))},F.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,C("pipe count=%d opts=%j",i.pipesCount,t);var n=!t||t.end!==!1,a=n?s:l;i.endEmitted?Y(a):r.once("end",a),e.on("unpipe",o);function o(v){C("onunpipe"),v===r&&l()}function s(){C("onend"),e.end()}var h=Us(r);e.on("drain",h);var f=!1;function l(){C("cleanup"),e.removeListener("close",g),e.removeListener("finish",S),e.removeListener("drain",h),e.removeListener("error",u),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",l),r.removeListener("data",p),f=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&h()}var d=!1;r.on("data",p);function p(v){C("ondata"),d=!1;var k=e.write(v);k===!1&&!d&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&cn(i.pipes,e)!==-1)&&!f&&(C("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function u(v){C("onerror",v),y(),e.removeListener("error",u),Is(e,"error")===0&&e.emit("error",v)}Os(e,"error",u);function g(){e.removeListener("finish",S),y()}e.once("close",g);function S(){C("onfinish"),e.removeListener("close",g),y()}e.once("finish",S);function y(){C("unpipe"),r.unpipe(e)}return e.emit("pipe",r),i.flowing||(C("pipe resume"),r.resume()),e};function Us(e){return function(){var t=e._readableState;C("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&e.listeners("data").length&&(t.flowing=!0,kr(e))}}F.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var n=0;n<i;n++)r[n].emit("unpipe",this);return this}var a=cn(t.pipes,e);return a===-1?this:(t.pipes.splice(a,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},F.prototype.on=function(e,t){var r=b.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var i=this._readableState;!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&Ut(this):Y(Bs,this))}return r},F.prototype.addListener=F.prototype.on;function Bs(e){C("readable nexttick read 0"),e.read(0)}F.prototype.resume=function(){var e=this._readableState;return e.flowing||(C("resume"),e.flowing=!0,Zs(this,e)),this};function Zs(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Y(js,e,t))}function js(e,t){t.reading||(C("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),kr(e),t.flowing&&!t.reading&&e.read(0)}F.prototype.pause=function(){return C("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(C("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function kr(e){var t=e._readableState;for(C("flow",t.flowing);t.flowing&&e.read()!==null;);}F.prototype.wrap=function(e){var t=this._readableState,r=!1,i=this;e.on("end",function(){if(C("wrapped end"),t.decoder&&!t.ended){var o=t.decoder.end();o&&o.length&&i.push(o)}i.push(null)}),e.on("data",function(o){if(C("wrapped data"),t.decoder&&(o=t.decoder.write(o)),!(t.objectMode&&o==null)&&!(!t.objectMode&&(!o||!o.length))){var s=i.push(o);s||(r=!0,e.pause())}});for(var n in e)this[n]===void 0&&typeof e[n]=="function"&&(this[n]=function(o){return function(){return e[o].apply(e,arguments)}}(n));var a=["error","close","destroy","pause","resume"];return Ys(a,function(o){e.on(o,i.emit.bind(i,o))}),i._read=function(o){C("wrapped _read",o),r&&(r=!1,e.resume())},i},F._fromList=hn;function hn(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=$s(e,t.buffer,t.decoder),r}function $s(e,t,r){var i;return e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?i=t.shift():i=r?Hs(e,t):Ks(e,t),i}function Hs(e,t){var r=t.head,i=1,n=r.data;for(e-=n.length;r=r.next;){var a=r.data,o=e>a.length?a.length:e;if(o===a.length?n+=a:n+=a.slice(0,e),e-=o,e===0){o===a.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(o));break}++i}return t.length-=i,n}function Ks(e,t){var r=c.allocUnsafe(e),i=t.head,n=1;for(i.data.copy(r),e-=i.data.length;i=i.next;){var a=i.data,o=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,o),e-=o,e===0){o===a.length?(++n,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=a.slice(o));break}++n}return t.length-=n,r}function Sr(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Y(Ws,t,e))}function Ws(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Ys(e,t){for(var r=0,i=e.length;r<i;r++)t(e[r],r)}function cn(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}$.WritableState=Rr,j($,b);function qs(){}function Gs(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function Rr(e,t){Object.defineProperty(this,"buffer",{get:en(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof G&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,i=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:i,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){rf(t,a)},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 gn(this)}Rr.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};function $(e){if(!(this instanceof $)&&!(this instanceof G))return new $(e);this._writableState=new Rr(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev)),b.call(this)}$.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function Vs(e,t){var r=new Error("write after end");e.emit("error",r),Y(t,r)}function Xs(e,t,r,i){var n=!0,a=!1;return r===null?a=new TypeError("May not write null values to stream"):!c.isBuffer(r)&&typeof r!="string"&&r!==void 0&&!t.objectMode&&(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),Y(i,a),n=!1),n}$.prototype.write=function(e,t,r){var i=this._writableState,n=!1;return typeof t=="function"&&(r=t,t=null),c.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),typeof r!="function"&&(r=qs),i.ended?Vs(this,r):Xs(this,i,e,r)&&(i.pendingcb++,n=Qs(this,i,e,t,r)),n},$.prototype.cork=function(){var e=this._writableState;e.corked++},$.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&dn(this,e))},$.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function Js(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=c.from(t,r)),t}function Qs(e,t,r,i,n){r=Js(t,r,i),c.isBuffer(r)&&(i="buffer");var a=t.objectMode?1:r.length;t.length+=a;var o=t.length<t.highWaterMark;if(o||(t.needDrain=!0),t.writing||t.corked){var s=t.lastBufferedRequest;t.lastBufferedRequest=new Gs(r,i,n),s?s.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Ar(e,t,!1,a,r,i,n);return o}function Ar(e,t,r,i,n,a,o){t.writelen=i,t.writecb=o,t.writing=!0,t.sync=!0,r?e._writev(n,t.onwrite):e._write(n,a,t.onwrite),t.sync=!1}function ef(e,t,r,i,n){--t.pendingcb,r?Y(n,i):n(i),e._writableState.errorEmitted=!0,e.emit("error",i)}function tf(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function rf(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(tf(r),t)ef(e,r,i,t,n);else{var a=pn(r);!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&dn(e,r),i?Y(un,e,r,a,n):un(e,r,a,n)}}function un(e,t,r,i){r||nf(e,t),t.pendingcb--,i(),wn(e,t)}function nf(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function dn(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),a=t.corkedRequestsFree;a.entry=r;for(var o=0;r;)n[o]=r,r=r.next,o+=1;Ar(e,t,!0,t.length,n,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new gn(t)}else{for(;r;){var s=r.chunk,h=r.encoding,f=r.callback,l=t.objectMode?1:s.length;if(Ar(e,t,!1,l,s,h,f),r=r.next,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=r,t.bufferProcessing=!1}$.prototype._write=function(e,t,r){r(new Error("not implemented"))},$.prototype._writev=null,$.prototype.end=function(e,t,r){var i=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),!i.ending&&!i.finished&&af(this,i,r)};function pn(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function _n(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function wn(e,t){var r=pn(t);return r&&(t.pendingcb===0?(_n(e,t),t.finished=!0,e.emit("finish")):_n(e,t)),r}function af(e,t,r){t.ending=!0,wn(e,t),r&&(t.finished?Y(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function gn(e){var t=this;this.next=null,this.entry=null,this.finish=function(r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}j(G,F);for(var vn=Object.keys($.prototype),Tr=0;Tr<vn.length;Tr++){var Lr=vn[Tr];G.prototype[Lr]||(G.prototype[Lr]=$.prototype[Lr])}function G(e){if(!(this instanceof G))return new G(e);F.call(this,e),$.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",of)}function of(){this.allowHalfOpen||this._writableState.ended||Y(sf,this)}function sf(e){e.end()}j(V,G);function ff(e){this.afterTransform=function(t,r){return lf(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function lf(e,t,r){var i=e._transformState;i.transforming=!1;var n=i.writecb;if(!n)return e.emit("error",new Error("no writecb in Transform class"));i.writechunk=null,i.writecb=null,r!=null&&e.push(r),n(t);var a=e._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&e._read(a.highWaterMark)}function V(e){if(!(this instanceof V))return new V(e);G.call(this,e),this._transformState=new ff(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.once("prefinish",function(){typeof this._flush=="function"?this._flush(function(r){mn(t,r)}):mn(t)})}V.prototype.push=function(e,t){return this._transformState.needTransform=!1,G.prototype.push.call(this,e,t)},V.prototype._transform=function(e,t,r){throw new Error("Not implemented")},V.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},V.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};function mn(e,t){if(t)return e.emit("error",t);var r=e._writableState,i=e._transformState;if(r.length)throw new Error("Calling transform done when ws.length != 0");if(i.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}j(st,V);function st(e){if(!(this instanceof st))return new st(e);V.call(this,e)}st.prototype._transform=function(e,t,r){r(null,e)},j(fe,b),fe.Readable=F,fe.Writable=$,fe.Duplex=G,fe.Transform=V,fe.PassThrough=st,fe.Stream=fe;function fe(){b.call(this)}fe.prototype.pipe=function(e,t){var r=this;function i(l){e.writable&&e.write(l)===!1&&r.pause&&r.pause()}r.on("data",i);function n(){r.readable&&r.resume&&r.resume()}e.on("drain",n),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",o),r.on("close",s));var a=!1;function o(){a||(a=!0,e.end())}function s(){a||(a=!0,typeof e.destroy=="function"&&e.destroy())}function h(l){if(f(),b.listenerCount(this,"error")===0)throw l}r.on("error",h),e.on("error",h);function f(){r.removeListener("data",i),e.removeListener("drain",n),r.removeListener("end",o),r.removeListener("close",s),r.removeListener("error",h),e.removeListener("error",h),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e};var bn={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function hf(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function le(e,t,r,i,n){if(t.subarray&&e.subarray){e.set(t.subarray(r,r+i),n);return}for(var a=0;a<i;a++)e[n+a]=t[r+a]}var Bt=Uint8Array,X=Uint16Array,Zt=Int32Array,cf=4,yn=0,xn=1,uf=2;function Ve(e){for(var t=e.length;--t>=0;)e[t]=0}var df=0,En=1,pf=2,_f=3,wf=258,Cr=29,ft=256,lt=ft+1+Cr,Xe=30,Or=19,kn=2*lt+1,Ie=15,Ir=16,gf=7,Mr=256,Sn=16,Rn=17,An=18,Dr=[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],jt=[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],vf=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Tn=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],mf=512,he=new Array((lt+2)*2);Ve(he);var ht=new Array(Xe*2);Ve(ht);var ct=new Array(mf);Ve(ct);var ut=new Array(wf-_f+1);Ve(ut);var Fr=new Array(Cr);Ve(Fr);var $t=new Array(Xe);Ve($t);function Nr(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}var Ln,Cn,On;function Pr(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function In(e){return e<256?ct[e]:ct[256+(e>>>7)]}function dt(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function K(e,t,r){e.bi_valid>Ir-r?(e.bi_buf|=t<<e.bi_valid&65535,dt(e,e.bi_buf),e.bi_buf=t>>Ir-e.bi_valid,e.bi_valid+=r-Ir):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function re(e,t,r){K(e,r[t*2],r[t*2+1])}function Mn(e,t){var r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1}function bf(e){e.bi_valid===16?(dt(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function yf(e,t){var r=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,h=t.stat_desc.max_length,f,l,d,p,u,g,S=0;for(p=0;p<=Ie;p++)e.bl_count[p]=0;for(r[e.heap[e.heap_max]*2+1]=0,f=e.heap_max+1;f<kn;f++)l=e.heap[f],p=r[r[l*2+1]*2+1]+1,p>h&&(p=h,S++),r[l*2+1]=p,!(l>i)&&(e.bl_count[p]++,u=0,l>=s&&(u=o[l-s]),g=r[l*2],e.opt_len+=g*(p+u),a&&(e.static_len+=g*(n[l*2+1]+u)));if(S!==0){do{for(p=h-1;e.bl_count[p]===0;)p--;e.bl_count[p]--,e.bl_count[p+1]+=2,e.bl_count[h]--,S-=2}while(S>0);for(p=h;p!==0;p--)for(l=e.bl_count[p];l!==0;)d=e.heap[--f],!(d>i)&&(r[d*2+1]!==p&&(e.opt_len+=(p-r[d*2+1])*r[d*2],r[d*2+1]=p),l--)}}function Dn(e,t,r){var i=new Array(Ie+1),n=0,a,o;for(a=1;a<=Ie;a++)i[a]=n=n+r[a-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=Mn(i[s]++,s))}}function xf(){var e,t,r,i,n,a=new Array(Ie+1);for(r=0,i=0;i<Cr-1;i++)for(Fr[i]=r,e=0;e<1<<Dr[i];e++)ut[r++]=i;for(ut[r-1]=i,n=0,i=0;i<16;i++)for($t[i]=n,e=0;e<1<<jt[i];e++)ct[n++]=i;for(n>>=7;i<Xe;i++)for($t[i]=n<<7,e=0;e<1<<jt[i]-7;e++)ct[256+n++]=i;for(t=0;t<=Ie;t++)a[t]=0;for(e=0;e<=143;)he[e*2+1]=8,e++,a[8]++;for(;e<=255;)he[e*2+1]=9,e++,a[9]++;for(;e<=279;)he[e*2+1]=7,e++,a[7]++;for(;e<=287;)he[e*2+1]=8,e++,a[8]++;for(Dn(he,lt+1,a),e=0;e<Xe;e++)ht[e*2+1]=5,ht[e*2]=Mn(e,5);Ln=new Nr(he,Dr,ft+1,lt,Ie),Cn=new Nr(ht,jt,0,Xe,Ie),On=new Nr(new Array(0),vf,0,Or,gf)}function Fn(e){var t;for(t=0;t<lt;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Xe;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Or;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Mr*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Nn(e){e.bi_valid>8?dt(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 Ef(e,t,r,i){Nn(e),dt(e,r),dt(e,~r),le(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function Pn(e,t,r,i){var n=t*2,a=r*2;return e[n]<e[a]||e[n]===e[a]&&i[t]<=i[r]}function zr(e,t,r){for(var i=e.heap[r],n=r<<1;n<=e.heap_len&&(n<e.heap_len&&Pn(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Pn(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i}function zn(e,t,r){var i,n,a=0,o,s;if(e.last_lit!==0)do i=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],n=e.pending_buf[e.l_buf+a],a++,i===0?re(e,n,t):(o=ut[n],re(e,o+ft+1,t),s=Dr[o],s!==0&&(n-=Fr[o],K(e,n,s)),i--,o=In(i),re(e,o,r),s=jt[o],s!==0&&(i-=$t[o],K(e,i,s)));while(a<e.last_lit);re(e,Mr,t)}function Ur(e,t){var r=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,h=-1,f;for(e.heap_len=0,e.heap_max=kn,o=0;o<a;o++)r[o*2]!==0?(e.heap[++e.heap_len]=h=o,e.depth[o]=0):r[o*2+1]=0;for(;e.heap_len<2;)f=e.heap[++e.heap_len]=h<2?++h:0,r[f*2]=1,e.depth[f]=0,e.opt_len--,n&&(e.static_len-=i[f*2+1]);for(t.max_code=h,o=e.heap_len>>1;o>=1;o--)zr(e,r,o);f=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],zr(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,r[f*2]=r[o*2]+r[s*2],e.depth[f]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,r[o*2+1]=r[s*2+1]=f,e.heap[1]=f++,zr(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],yf(e,t),Dn(r,h,e.bl_count)}function Un(e,t,r){var i,n=-1,a,o=t[0*2+1],s=0,h=7,f=4;for(o===0&&(h=138,f=3),t[(r+1)*2+1]=65535,i=0;i<=r;i++)a=o,o=t[(i+1)*2+1],!(++s<h&&a===o)&&(s<f?e.bl_tree[a*2]+=s:a!==0?(a!==n&&e.bl_tree[a*2]++,e.bl_tree[Sn*2]++):s<=10?e.bl_tree[Rn*2]++:e.bl_tree[An*2]++,s=0,n=a,o===0?(h=138,f=3):a===o?(h=6,f=3):(h=7,f=4))}function Bn(e,t,r){var i,n=-1,a,o=t[0*2+1],s=0,h=7,f=4;for(o===0&&(h=138,f=3),i=0;i<=r;i++)if(a=o,o=t[(i+1)*2+1],!(++s<h&&a===o)){if(s<f)do re(e,a,e.bl_tree);while(--s!==0);else a!==0?(a!==n&&(re(e,a,e.bl_tree),s--),re(e,Sn,e.bl_tree),K(e,s-3,2)):s<=10?(re(e,Rn,e.bl_tree),K(e,s-3,3)):(re(e,An,e.bl_tree),K(e,s-11,7));s=0,n=a,o===0?(h=138,f=3):a===o?(h=6,f=3):(h=7,f=4)}}function kf(e){var t;for(Un(e,e.dyn_ltree,e.l_desc.max_code),Un(e,e.dyn_dtree,e.d_desc.max_code),Ur(e,e.bl_desc),t=Or-1;t>=3&&e.bl_tree[Tn[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Sf(e,t,r,i){var n;for(K(e,t-257,5),K(e,r-1,5),K(e,i-4,4),n=0;n<i;n++)K(e,e.bl_tree[Tn[n]*2+1],3);Bn(e,e.dyn_ltree,t-1),Bn(e,e.dyn_dtree,r-1)}function Rf(e){var t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return yn;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return xn;for(r=32;r<ft;r++)if(e.dyn_ltree[r*2]!==0)return xn;return yn}var Zn=!1;function Af(e){Zn||(xf(),Zn=!0),e.l_desc=new Pr(e.dyn_ltree,Ln),e.d_desc=new Pr(e.dyn_dtree,Cn),e.bl_desc=new Pr(e.bl_tree,On),e.bi_buf=0,e.bi_valid=0,Fn(e)}function jn(e,t,r,i){K(e,(df<<1)+(i?1:0),3),Ef(e,t,r)}function Tf(e){K(e,En<<1,3),re(e,Mr,he),bf(e)}function Lf(e,t,r,i){var n,a,o=0;e.level>0?(e.strm.data_type===uf&&(e.strm.data_type=Rf(e)),Ur(e,e.l_desc),Ur(e,e.d_desc),o=kf(e),n=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=n&&(n=a)):n=a=r+5,r+4<=n&&t!==-1?jn(e,t,r,i):e.strategy===cf||a===n?(K(e,(En<<1)+(i?1:0),3),zn(e,he,ht)):(K(e,(pf<<1)+(i?1:0),3),Sf(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),zn(e,e.dyn_ltree,e.dyn_dtree)),Fn(e),i&&Nn(e)}function me(e,t,r){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=r&255,e.last_lit++,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(ut[r]+ft+1)*2]++,e.dyn_dtree[In(t)*2]++),e.last_lit===e.lit_bufsize-1}function Br(e,t,r,i){for(var n=e&65535|0,a=e>>>16&65535|0,o=0;r!==0;){o=r>2e3?2e3:r,r-=o;do n=n+t[i++]|0,a=a+n|0;while(--o);n%=65521,a%=65521}return n|a<<16|0}function Cf(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t}var Of=Cf();function B(e,t,r,i){var n=Of,a=i+r;e^=-1;for(var o=i;o<a;o++)e=e>>>8^n[(e^t[o])&255];return e^-1}var Me=0,If=1,Mf=3,be=4,$n=5,ye=0,Hn=1,xe=-2,Df=-3,Zr=-5,Ff=-1,Nf=1,Ht=2,Pf=3,zf=4,Uf=2,jr=8,Bf=9,Zf=29,jf=256,$r=jf+1+Zf,$f=30,Hf=19,Kf=2*$r+1,Wf=15,T=3,Ee=258,J=Ee+T+1,Yf=32,Hr=42,Kr=69,Kt=73,Wt=91,Yt=103,De=113,pt=666,P=1,_t=2,Fe=3,Je=4,qf=3;function ke(e,t){return e.msg=bn[t],t}function Kn(e){return(e<<1)-(e>4?9:0)}function Ne(e){for(var t=e.length;--t>=0;)e[t]=0}function Se(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(le(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,t.pending===0&&(t.pending_out=0))}function Z(e,t){Lf(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Se(e.strm)}function R(e,t){e.pending_buf[e.pending++]=t}function wt(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function Gf(e,t,r,i){var n=e.avail_in;return n>i&&(n=i),n===0?0:(e.avail_in-=n,le(t,e.input,e.next_in,n,r),e.state.wrap===1?e.adler=Br(e.adler,t,n,r):e.state.wrap===2&&(e.adler=B(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)}function Wn(e,t){var r=e.max_chain_length,i=e.strstart,n,a,o=e.prev_length,s=e.nice_match,h=e.strstart>e.w_size-J?e.strstart-(e.w_size-J):0,f=e.window,l=e.w_mask,d=e.prev,p=e.strstart+Ee,u=f[i+o-1],g=f[i+o];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do if(n=t,!(f[n+o]!==g||f[n+o-1]!==u||f[n]!==f[i]||f[++n]!==f[i+1])){i+=2,n++;do;while(f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&f[++i]===f[++n]&&i<p);if(a=Ee-(p-i),i=p-Ee,a>o){if(e.match_start=t,o=a,a>=s)break;u=f[i+o-1],g=f[i+o]}}while((t=d[t&l])>h&&--r!==0);return o<=e.lookahead?o:e.lookahead}function gt(e){var t=e.w_size,r,i,n,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-J)){le(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,i=e.hash_size,r=i;do n=e.head[--r],e.head[r]=n>=t?n-t:0;while(--i);i=t,r=i;do n=e.prev[--r],e.prev[r]=n>=t?n-t:0;while(--i);a+=t}if(e.strm.avail_in===0)break;if(i=Gf(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=i,e.lookahead+e.insert>=T)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+T-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<T)););}while(e.lookahead<J&&e.strm.avail_in!==0)}function Vf(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(gt(e),e.lookahead===0&&t===Me)return P;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+r;if((e.strstart===0||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,Z(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-J&&(Z(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):(e.strstart>e.block_start&&(Z(e,!1),e.strm.avail_out===0),P)}function Wr(e,t){for(var r,i;;){if(e.lookahead<J){if(gt(e),e.lookahead<J&&t===Me)return P;if(e.lookahead===0)break}if(r=0,e.lookahead>=T&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-J&&(e.match_length=Wn(e,r)),e.match_length>=T)if(i=me(e,e.strstart-e.match_start,e.match_length-T),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=T){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-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(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Z(e,!1),e.strm.avail_out===0))return P}return e.insert=e.strstart<T-1?e.strstart:T-1,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):e.last_lit&&(Z(e,!1),e.strm.avail_out===0)?P:_t}function Qe(e,t){for(var r,i,n;;){if(e.lookahead<J){if(gt(e),e.lookahead<J&&t===Me)return P;if(e.lookahead===0)break}if(r=0,e.lookahead>=T&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-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=T-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-J&&(e.match_length=Wn(e,r),e.match_length<=5&&(e.strategy===Nf||e.match_length===T&&e.strstart-e.match_start>4096)&&(e.match_length=T-1)),e.prev_length>=T&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-T,i=me(e,e.strstart-1-e.prev_match,e.prev_length-T),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+T-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(--e.prev_length!==0);if(e.match_available=0,e.match_length=T-1,e.strstart++,i&&(Z(e,!1),e.strm.avail_out===0))return P}else if(e.match_available){if(i=me(e,0,e.window[e.strstart-1]),i&&Z(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return P}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=me(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<T-1?e.strstart:T-1,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):e.last_lit&&(Z(e,!1),e.strm.avail_out===0)?P:_t}function Xf(e,t){for(var r,i,n,a,o=e.window;;){if(e.lookahead<=Ee){if(gt(e),e.lookahead<=Ee&&t===Me)return P;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=T&&e.strstart>0&&(n=e.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){a=e.strstart+Ee;do;while(i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&n<a);e.match_length=Ee-(a-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=T?(r=me(e,1,e.match_length-T),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Z(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):e.last_lit&&(Z(e,!1),e.strm.avail_out===0)?P:_t}function Jf(e,t){for(var r;;){if(e.lookahead===0&&(gt(e),e.lookahead===0)){if(t===Me)return P;break}if(e.match_length=0,r=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Z(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(Z(e,!0),e.strm.avail_out===0?Fe:Je):e.last_lit&&(Z(e,!1),e.strm.avail_out===0)?P:_t}function ie(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}var et;et=[new ie(0,0,0,0,Vf),new ie(4,4,8,4,Wr),new ie(4,5,16,8,Wr),new ie(4,6,32,32,Wr),new ie(4,4,16,16,Qe),new ie(8,16,32,32,Qe),new ie(8,16,128,128,Qe),new ie(8,32,128,256,Qe),new ie(32,128,258,1024,Qe),new ie(32,258,258,4096,Qe)];function Qf(e){e.window_size=2*e.w_size,Ne(e.head),e.max_lazy_match=et[e.level].max_lazy,e.good_match=et[e.level].good_length,e.nice_match=et[e.level].nice_length,e.max_chain_length=et[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=T-1,e.match_available=0,e.ins_h=0}function el(){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=jr,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 X(Kf*2),this.dyn_dtree=new X((2*$f+1)*2),this.bl_tree=new X((2*Hf+1)*2),Ne(this.dyn_ltree),Ne(this.dyn_dtree),Ne(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new X(Wf+1),this.heap=new X(2*$r+1),Ne(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new X(2*$r+1),Ne(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 tl(e){var t;return!e||!e.state?ke(e,xe):(e.total_in=e.total_out=0,e.data_type=Uf,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Hr:De,e.adler=t.wrap===2?0:1,t.last_flush=Me,Af(t),ye)}function Yn(e){var t=tl(e);return t===ye&&Qf(e.state),t}function rl(e,t,r,i,n,a){if(!e)return xe;var o=1;if(t===Ff&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>Bf||r!==jr||i<8||i>15||t<0||t>9||a<0||a>zf)return ke(e,xe);i===8&&(i=9);var s=new el;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=n+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+T-1)/T),s.window=new Bt(s.w_size*2),s.head=new X(s.hash_size),s.prev=new X(s.w_size),s.lit_bufsize=1<<n+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Bt(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=a,s.method=r,Yn(e)}function il(e,t){var r,i,n,a;if(!e||!e.state||t>$n||t<0)return e?ke(e,xe):xe;if(i=e.state,!e.output||!e.input&&e.avail_in!==0||i.status===pt&&t!==be)return ke(e,e.avail_out===0?Zr:xe);if(i.strm=e,r=i.last_flush,i.last_flush=t,i.status===Hr)if(i.wrap===2)e.adler=0,R(i,31),R(i,139),R(i,8),i.gzhead?(R(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),R(i,i.gzhead.time&255),R(i,i.gzhead.time>>8&255),R(i,i.gzhead.time>>16&255),R(i,i.gzhead.time>>24&255),R(i,i.level===9?2:i.strategy>=Ht||i.level<2?4:0),R(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(R(i,i.gzhead.extra.length&255),R(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=B(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Kr):(R(i,0),R(i,0),R(i,0),R(i,0),R(i,0),R(i,i.level===9?2:i.strategy>=Ht||i.level<2?4:0),R(i,qf),i.status=De);else{var o=jr+(i.w_bits-8<<4)<<8,s=-1;i.strategy>=Ht||i.level<2?s=0:i.level<6?s=1:i.level===6?s=2:s=3,o|=s<<6,i.strstart!==0&&(o|=Yf),o+=31-o%31,i.status=De,wt(i,o),i.strstart!==0&&(wt(i,e.adler>>>16),wt(i,e.adler&65535)),e.adler=1}if(i.status===Kr)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),Se(e),n=i.pending,i.pending===i.pending_buf_size));)R(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Kt)}else i.status=Kt;if(i.status===Kt)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),Se(e),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}i.gzindex<i.gzhead.name.length?a=i.gzhead.name.charCodeAt(i.gzindex++)&255:a=0,R(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),a===0&&(i.gzindex=0,i.status=Wt)}else i.status=Wt;if(i.status===Wt)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),Se(e),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}i.gzindex<i.gzhead.comment.length?a=i.gzhead.comment.charCodeAt(i.gzindex++)&255:a=0,R(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=B(e.adler,i.pending_buf,i.pending-n,n)),a===0&&(i.status=Yt)}else i.status=Yt;if(i.status===Yt&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Se(e),i.pending+2<=i.pending_buf_size&&(R(i,e.adler&255),R(i,e.adler>>8&255),e.adler=0,i.status=De)):i.status=De),i.pending!==0){if(Se(e),e.avail_out===0)return i.last_flush=-1,ye}else if(e.avail_in===0&&Kn(t)<=Kn(r)&&t!==be)return ke(e,Zr);if(i.status===pt&&e.avail_in!==0)return ke(e,Zr);if(e.avail_in!==0||i.lookahead!==0||t!==Me&&i.status!==pt){var h=i.strategy===Ht?Jf(i,t):i.strategy===Pf?Xf(i,t):et[i.level].func(i,t);if((h===Fe||h===Je)&&(i.status=pt),h===P||h===Fe)return e.avail_out===0&&(i.last_flush=-1),ye;if(h===_t&&(t===If?Tf(i):t!==$n&&(jn(i,0,0,!1),t===Mf&&(Ne(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Se(e),e.avail_out===0))return i.last_flush=-1,ye}return t!==be?ye:i.wrap<=0?Hn:(i.wrap===2?(R(i,e.adler&255),R(i,e.adler>>8&255),R(i,e.adler>>16&255),R(i,e.adler>>24&255),R(i,e.total_in&255),R(i,e.total_in>>8&255),R(i,e.total_in>>16&255),R(i,e.total_in>>24&255)):(wt(i,e.adler>>>16),wt(i,e.adler&65535)),Se(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?ye:Hn)}function nl(e){var t;return!e||!e.state?xe:(t=e.state.status,t!==Hr&&t!==Kr&&t!==Kt&&t!==Wt&&t!==Yt&&t!==De&&t!==pt?ke(e,xe):(e.state=null,t===De?ke(e,Df):ye))}var qt=30,al=12;function ol(e,t){var r,i,n,a,o,s,h,f,l,d,p,u,g,S,y,v,k,E,_,A,z,m,I,L,x;r=e.state,i=e.next_in,L=e.input,n=i+(e.avail_in-5),a=e.next_out,x=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),h=r.dmax,f=r.wsize,l=r.whave,d=r.wnext,p=r.window,u=r.hold,g=r.bits,S=r.lencode,y=r.distcode,v=(1<<r.lenbits)-1,k=(1<<r.distbits)-1;e:do{g<15&&(u+=L[i++]<<g,g+=8,u+=L[i++]<<g,g+=8),E=S[u&v];t:for(;;){if(_=E>>>24,u>>>=_,g-=_,_=E>>>16&255,_===0)x[a++]=E&65535;else if(_&16){A=E&65535,_&=15,_&&(g<_&&(u+=L[i++]<<g,g+=8),A+=u&(1<<_)-1,u>>>=_,g-=_),g<15&&(u+=L[i++]<<g,g+=8,u+=L[i++]<<g,g+=8),E=y[u&k];r:for(;;){if(_=E>>>24,u>>>=_,g-=_,_=E>>>16&255,_&16){if(z=E&65535,_&=15,g<_&&(u+=L[i++]<<g,g+=8,g<_&&(u+=L[i++]<<g,g+=8)),z+=u&(1<<_)-1,z>h){e.msg="invalid distance too far back",r.mode=qt;break e}if(u>>>=_,g-=_,_=a-o,z>_){if(_=z-_,_>l&&r.sane){e.msg="invalid distance too far back",r.mode=qt;break e}if(m=0,I=p,d===0){if(m+=f-_,_<A){A-=_;do x[a++]=p[m++];while(--_);m=a-z,I=x}}else if(d<_){if(m+=f+d-_,_-=d,_<A){A-=_;do x[a++]=p[m++];while(--_);if(m=0,d<A){_=d,A-=_;do x[a++]=p[m++];while(--_);m=a-z,I=x}}}else if(m+=d-_,_<A){A-=_;do x[a++]=p[m++];while(--_);m=a-z,I=x}for(;A>2;)x[a++]=I[m++],x[a++]=I[m++],x[a++]=I[m++],A-=3;A&&(x[a++]=I[m++],A>1&&(x[a++]=I[m++]))}else{m=a-z;do x[a++]=x[m++],x[a++]=x[m++],x[a++]=x[m++],A-=3;while(A>2);A&&(x[a++]=x[m++],A>1&&(x[a++]=x[m++]))}}else if(_&64){e.msg="invalid distance code",r.mode=qt;break e}else{E=y[(E&65535)+(u&(1<<_)-1)];continue r}break}}else if(_&64)if(_&32){r.mode=al;break e}else{e.msg="invalid literal/length code",r.mode=qt;break e}else{E=S[(E&65535)+(u&(1<<_)-1)];continue t}break}}while(i<n&&a<s);A=g>>3,i-=A,g-=A<<3,u&=(1<<g)-1,e.next_in=i,e.next_out=a,e.avail_in=i<n?5+(n-i):5-(i-n),e.avail_out=a<s?257+(s-a):257-(a-s),r.hold=u,r.bits=g}var tt=15,qn=852,Gn=592,Vn=0,Yr=1,Xn=2,sl=[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],fl=[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],ll=[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],hl=[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];function vt(e,t,r,i,n,a,o,s){var h=s.bits,f=0,l=0,d=0,p=0,u=0,g=0,S=0,y=0,v=0,k=0,E,_,A,z,m,I=null,L=0,x,N=new X(tt+1),Ae=new X(tt+1),kt=null,ri=0,ii,St,Rt;for(f=0;f<=tt;f++)N[f]=0;for(l=0;l<i;l++)N[t[r+l]]++;for(u=h,p=tt;p>=1&&N[p]===0;p--);if(u>p&&(u=p),p===0)return n[a++]=1<<24|64<<16|0,n[a++]=1<<24|64<<16|0,s.bits=1,0;for(d=1;d<p&&N[d]===0;d++);for(u<d&&(u=d),y=1,f=1;f<=tt;f++)if(y<<=1,y-=N[f],y<0)return-1;if(y>0&&(e===Vn||p!==1))return-1;for(Ae[1]=0,f=1;f<tt;f++)Ae[f+1]=Ae[f]+N[f];for(l=0;l<i;l++)t[r+l]!==0&&(o[Ae[t[r+l]]++]=l);if(e===Vn?(I=kt=o,x=19):e===Yr?(I=sl,L-=257,kt=fl,ri-=257,x=256):(I=ll,kt=hl,x=-1),k=0,l=0,f=d,m=a,g=u,S=0,A=-1,v=1<<u,z=v-1,e===Yr&&v>qn||e===Xn&&v>Gn)return 1;for(;;){ii=f-S,o[l]<x?(St=0,Rt=o[l]):o[l]>x?(St=kt[ri+o[l]],Rt=I[L+o[l]]):(St=96,Rt=0),E=1<<f-S,_=1<<g,d=_;do _-=E,n[m+(k>>S)+_]=ii<<24|St<<16|Rt|0;while(_!==0);for(E=1<<f-1;k&E;)E>>=1;if(E!==0?(k&=E-1,k+=E):k=0,l++,--N[f]===0){if(f===p)break;f=t[r+o[l]]}if(f>u&&(k&z)!==A){for(S===0&&(S=u),m+=d,g=f-S,y=1<<g;g+S<p&&(y-=N[g+S],!(y<=0));)g++,y<<=1;if(v+=1<<g,e===Yr&&v>qn||e===Xn&&v>Gn)return 1;A=k&z,n[A]=u<<24|g<<16|m-a|0}}return k!==0&&(n[m+k]=f-S<<24|64<<16|0),s.bits=u,0}var cl=0,Jn=1,Qn=2,ea=4,ul=5,Gt=6,mt=0,dl=1,pl=2,Re=-2,_l=-3,wl=-4,gl=-5,ta=8,ra=1,ia=2,na=3,aa=4,oa=5,sa=6,fa=7,la=8,ha=9,ca=10,ua=11,ce=12,qr=13,da=14,Gr=15,pa=16,_a=17,wa=18,ga=19,Vt=20,Xt=21,va=22,ma=23,ba=24,ya=25,xa=26,Vr=27,Ea=28,ka=29,M=30,vl=31,ml=32,bl=852,yl=592;function Sa(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function xl(){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 X(320),this.work=new X(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function El(e){var t;return!e||!e.state?Re:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=ra,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Zt(bl),t.distcode=t.distdyn=new Zt(yl),t.sane=1,t.back=-1,mt)}function Ra(e){var t;return!e||!e.state?Re:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,El(e))}function kl(e,t){var r,i;return!e||!e.state||(i=e.state,t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Re:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,Ra(e))}function Sl(e,t){var r,i;return e?(i=new xl,e.state=i,i.window=null,r=kl(e,t),r!==mt&&(e.state=null),r):Re}var Aa=!0,Xr,Jr;function Rl(e){if(Aa){var t;for(Xr=new Zt(512),Jr=new Zt(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(vt(Jn,e.lens,0,288,Xr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;vt(Qn,e.lens,0,32,Jr,0,e.work,{bits:5}),Aa=!1}e.lencode=Xr,e.lenbits=9,e.distcode=Jr,e.distbits=5}function Al(e,t,r,i){var n,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Bt(a.wsize)),i>=a.wsize?(le(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>i&&(n=i),le(a.window,t,r-i,n,a.wnext),i-=n,i?(le(a.window,t,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0}function Tl(e,t){var r,i,n,a,o,s,h,f,l,d,p,u,g,S,y=0,v,k,E,_,A,z,m,I,L=new Bt(4),x,N,Ae=[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&&e.avail_in!==0)return Re;r=e.state,r.mode===ce&&(r.mode=qr),o=e.next_out,n=e.output,h=e.avail_out,a=e.next_in,i=e.input,s=e.avail_in,f=r.hold,l=r.bits,d=s,p=h,I=mt;e:for(;;)switch(r.mode){case ra:if(r.wrap===0){r.mode=qr;break}for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(r.wrap&2&&f===35615){r.check=0,L[0]=f&255,L[1]=f>>>8&255,r.check=B(r.check,L,2,0),f=0,l=0,r.mode=ia;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((f&255)<<8)+(f>>8))%31){e.msg="incorrect header check",r.mode=M;break}if((f&15)!==ta){e.msg="unknown compression method",r.mode=M;break}if(f>>>=4,l-=4,m=(f&15)+8,r.wbits===0)r.wbits=m;else if(m>r.wbits){e.msg="invalid window size",r.mode=M;break}r.dmax=1<<m,e.adler=r.check=1,r.mode=f&512?ca:ce,f=0,l=0;break;case ia:for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(r.flags=f,(r.flags&255)!==ta){e.msg="unknown compression method",r.mode=M;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=M;break}r.head&&(r.head.text=f>>8&1),r.flags&512&&(L[0]=f&255,L[1]=f>>>8&255,r.check=B(r.check,L,2,0)),f=0,l=0,r.mode=na;case na:for(;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.head&&(r.head.time=f),r.flags&512&&(L[0]=f&255,L[1]=f>>>8&255,L[2]=f>>>16&255,L[3]=f>>>24&255,r.check=B(r.check,L,4,0)),f=0,l=0,r.mode=aa;case aa:for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.head&&(r.head.xflags=f&255,r.head.os=f>>8),r.flags&512&&(L[0]=f&255,L[1]=f>>>8&255,r.check=B(r.check,L,2,0)),f=0,l=0,r.mode=oa;case oa:if(r.flags&1024){for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.length=f,r.head&&(r.head.extra_len=f),r.flags&512&&(L[0]=f&255,L[1]=f>>>8&255,r.check=B(r.check,L,2,0)),f=0,l=0}else r.head&&(r.head.extra=null);r.mode=sa;case sa:if(r.flags&1024&&(u=r.length,u>s&&(u=s),u&&(r.head&&(m=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),le(r.head.extra,i,a,u,m)),r.flags&512&&(r.check=B(r.check,i,u,a)),s-=u,a+=u,r.length-=u),r.length))break e;r.length=0,r.mode=fa;case fa:if(r.flags&2048){if(s===0)break e;u=0;do m=i[a+u++],r.head&&m&&r.length<65536&&(r.head.name+=String.fromCharCode(m));while(m&&u<s);if(r.flags&512&&(r.check=B(r.check,i,u,a)),s-=u,a+=u,m)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=la;case la:if(r.flags&4096){if(s===0)break e;u=0;do m=i[a+u++],r.head&&m&&r.length<65536&&(r.head.comment+=String.fromCharCode(m));while(m&&u<s);if(r.flags&512&&(r.check=B(r.check,i,u,a)),s-=u,a+=u,m)break e}else r.head&&(r.head.comment=null);r.mode=ha;case ha:if(r.flags&512){for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(f!==(r.check&65535)){e.msg="header crc mismatch",r.mode=M;break}f=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=ce;break;case ca:for(;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}e.adler=r.check=Sa(f),f=0,l=0,r.mode=ua;case ua:if(r.havedict===0)return e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,pl;e.adler=r.check=1,r.mode=ce;case ce:if(t===ul||t===Gt)break e;case qr:if(r.last){f>>>=l&7,l-=l&7,r.mode=Vr;break}for(;l<3;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}switch(r.last=f&1,f>>>=1,l-=1,f&3){case 0:r.mode=da;break;case 1:if(Rl(r),r.mode=Vt,t===Gt){f>>>=2,l-=2;break e}break;case 2:r.mode=_a;break;case 3:e.msg="invalid block type",r.mode=M}f>>>=2,l-=2;break;case da:for(f>>>=l&7,l-=l&7;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if((f&65535)!==(f>>>16^65535)){e.msg="invalid stored block lengths",r.mode=M;break}if(r.length=f&65535,f=0,l=0,r.mode=Gr,t===Gt)break e;case Gr:r.mode=pa;case pa:if(u=r.length,u){if(u>s&&(u=s),u>h&&(u=h),u===0)break e;le(n,i,a,u,o),s-=u,a+=u,h-=u,o+=u,r.length-=u;break}r.mode=ce;break;case _a:for(;l<14;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(r.nlen=(f&31)+257,f>>>=5,l-=5,r.ndist=(f&31)+1,f>>>=5,l-=5,r.ncode=(f&15)+4,f>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=M;break}r.have=0,r.mode=wa;case wa:for(;r.have<r.ncode;){for(;l<3;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.lens[Ae[r.have++]]=f&7,f>>>=3,l-=3}for(;r.have<19;)r.lens[Ae[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},I=vt(cl,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,I){e.msg="invalid code lengths set",r.mode=M;break}r.have=0,r.mode=ga;case ga:for(;r.have<r.nlen+r.ndist;){for(;y=r.lencode[f&(1<<r.lenbits)-1],v=y>>>24,k=y>>>16&255,E=y&65535,!(v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(E<16)f>>>=v,l-=v,r.lens[r.have++]=E;else{if(E===16){for(N=v+2;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(f>>>=v,l-=v,r.have===0){e.msg="invalid bit length repeat",r.mode=M;break}m=r.lens[r.have-1],u=3+(f&3),f>>>=2,l-=2}else if(E===17){for(N=v+3;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}f>>>=v,l-=v,m=0,u=3+(f&7),f>>>=3,l-=3}else{for(N=v+7;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}f>>>=v,l-=v,m=0,u=11+(f&127),f>>>=7,l-=7}if(r.have+u>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=M;break}for(;u--;)r.lens[r.have++]=m}}if(r.mode===M)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=M;break}if(r.lenbits=9,x={bits:r.lenbits},I=vt(Jn,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,I){e.msg="invalid literal/lengths set",r.mode=M;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},I=vt(Qn,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,I){e.msg="invalid distances set",r.mode=M;break}if(r.mode=Vt,t===Gt)break e;case Vt:r.mode=Xt;case Xt:if(s>=6&&h>=258){e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,ol(e,p),o=e.next_out,n=e.output,h=e.avail_out,a=e.next_in,i=e.input,s=e.avail_in,f=r.hold,l=r.bits,r.mode===ce&&(r.back=-1);break}for(r.back=0;y=r.lencode[f&(1<<r.lenbits)-1],v=y>>>24,k=y>>>16&255,E=y&65535,!(v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(k&&!(k&240)){for(_=v,A=k,z=E;y=r.lencode[z+((f&(1<<_+A)-1)>>_)],v=y>>>24,k=y>>>16&255,E=y&65535,!(_+v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}f>>>=_,l-=_,r.back+=_}if(f>>>=v,l-=v,r.back+=v,r.length=E,k===0){r.mode=xa;break}if(k&32){r.back=-1,r.mode=ce;break}if(k&64){e.msg="invalid literal/length code",r.mode=M;break}r.extra=k&15,r.mode=va;case va:if(r.extra){for(N=r.extra;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=ma;case ma:for(;y=r.distcode[f&(1<<r.distbits)-1],v=y>>>24,k=y>>>16&255,E=y&65535,!(v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(!(k&240)){for(_=v,A=k,z=E;y=r.distcode[z+((f&(1<<_+A)-1)>>_)],v=y>>>24,k=y>>>16&255,E=y&65535,!(_+v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}f>>>=_,l-=_,r.back+=_}if(f>>>=v,l-=v,r.back+=v,k&64){e.msg="invalid distance code",r.mode=M;break}r.offset=E,r.extra=k&15,r.mode=ba;case ba:if(r.extra){for(N=r.extra;l<N;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=M;break}r.mode=ya;case ya:if(h===0)break e;if(u=p-h,r.offset>u){if(u=r.offset-u,u>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=M;break}u>r.wnext?(u-=r.wnext,g=r.wsize-u):g=r.wnext-u,u>r.length&&(u=r.length),S=r.window}else S=n,g=o-r.offset,u=r.length;u>h&&(u=h),h-=u,r.length-=u;do n[o++]=S[g++];while(--u);r.length===0&&(r.mode=Xt);break;case xa:if(h===0)break e;n[o++]=r.length,h--,r.mode=Xt;break;case Vr:if(r.wrap){for(;l<32;){if(s===0)break e;s--,f|=i[a++]<<l,l+=8}if(p-=h,e.total_out+=p,r.total+=p,p&&(e.adler=r.check=r.flags?B(r.check,n,p,o-p):Br(r.check,n,p,o-p)),p=h,(r.flags?f:Sa(f))!==r.check){e.msg="incorrect data check",r.mode=M;break}f=0,l=0}r.mode=Ea;case Ea:if(r.wrap&&r.flags){for(;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(f!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=M;break}f=0,l=0}r.mode=ka;case ka:I=dl;break e;case M:I=_l;break e;case vl:return wl;case ml:default:return Re}return e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,(r.wsize||p!==e.avail_out&&r.mode<M&&(r.mode<Vr||t!==ea))&&Al(e,e.output,e.next_out,p-e.avail_out),d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,r.total+=p,r.wrap&&p&&(e.adler=r.check=r.flags?B(r.check,n,p,e.next_out-p):Br(r.check,n,p,e.next_out-p)),e.data_type=r.bits+(r.last?64:0)+(r.mode===ce?128:0)+(r.mode===Vt||r.mode===Gr?256:0),(d===0&&p===0||t===ea)&&I===mt&&(I=gl),I}function Ll(e){if(!e||!e.state)return Re;var t=e.state;return t.window&&(t.window=null),e.state=null,mt}var Qr=0,rt=1,Jt=2,bt=3,Qt=4,it=5,yt=6,xt=7,Ta=0,La=1,Ca=2,Oa=3,ei=4,Ia=5,Cl=6,er=0,Ma=1,Da=2,Ol=-1,Il=-2,Ml=-3,Fa=-5,Dl=0,Fl=1,Nl=9,Pl=-1,zl=1,Ul=2,Bl=3,Zl=4,jl=0,$l=0,Hl=1,Kl=2,Na=8;function Q(e){if(e<rt||e>xt)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}Q.prototype.init=function(e,t,r,i,n){this.windowBits=e,this.level=t,this.memLevel=r,this.strategy=i,(this.mode===bt||this.mode===Qt)&&(this.windowBits+=16),this.mode===xt&&(this.windowBits+=32),(this.mode===it||this.mode===yt)&&(this.windowBits=-this.windowBits),this.strm=new hf;var a;switch(this.mode){case rt:case bt:case it:a=rl(this.strm,this.level,Na,this.windowBits,this.memLevel,this.strategy);break;case Jt:case Qt:case yt:case xt:a=Sl(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(a!==er){this._error(a);return}this.write_in_progress=!1,this.init_done=!0},Q.prototype.params=function(){throw new Error("deflateParams Not supported")},Q.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(this.mode===Qr)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},Q.prototype.write=function(e,t,r,i,n,a,o){this._writeCheck(),this.write_in_progress=!0;var s=this;return se.nextTick(function(){s.write_in_progress=!1;var h=s._write(e,t,r,i,n,a,o);s.callback(h[0],h[1]),s.pending_close&&s.close()}),this};function Wl(e,t){for(var r=0;r<e.length;r++)this[t+r]=e[r]}Q.prototype.writeSync=function(e,t,r,i,n,a,o){return this._writeCheck(),this._write(e,t,r,i,n,a,o)},Q.prototype._write=function(e,t,r,i,n,a,o){if(this.write_in_progress=!0,e!==Ta&&e!==La&&e!==Ca&&e!==Oa&&e!==ei&&e!==Ia)throw new Error("Invalid flush value");t==null&&(t=new c(0),i=0,r=0),n._set?n.set=n._set:n.set=Wl;var s=this.strm;s.avail_in=i,s.input=t,s.next_in=r,s.avail_out=o,s.output=n,s.next_out=a;var h;switch(this.mode){case rt:case bt:case it:h=il(s,e);break;case xt:case Jt:case Qt:case yt:h=Tl(s,e);break;default:throw new Error("Unknown mode "+this.mode)}return this._checkError(h,s,e)||this._error(h),this.write_in_progress=!1,[s.avail_in,s.avail_out]},Q.prototype._checkError=function(e,t,r){switch(e){case er:case Fa:if(t.avail_out!==0&&r===ei)return!1;break;case Ma:break;case Da:return!1;default:return!1}return!0},Q.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}this.pending_close=!1,this.mode===rt||this.mode===bt||this.mode===it?nl(this.strm):Ll(this.strm),this.mode=Qr};var tr;Q.prototype.reset=function(){switch(this.mode){case rt:case it:tr=Yn(this.strm);break;case Jt:case yt:tr=Ra(this.strm);break}tr!==er&&this._error(tr)},Q.prototype._error=function(e){this.onerror(bn[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var Pa=Object.freeze({__proto__:null,DEFLATE:rt,DEFLATERAW:it,GUNZIP:Qt,GZIP:bt,INFLATE:Jt,INFLATERAW:yt,NONE:Qr,UNZIP:xt,Z_BEST_COMPRESSION:Nl,Z_BEST_SPEED:Fl,Z_BINARY:$l,Z_BLOCK:Ia,Z_BUF_ERROR:Fa,Z_DATA_ERROR:Ml,Z_DEFAULT_COMPRESSION:Pl,Z_DEFAULT_STRATEGY:jl,Z_DEFLATED:Na,Z_ERRNO:Ol,Z_FILTERED:zl,Z_FINISH:ei,Z_FIXED:Zl,Z_FULL_FLUSH:Oa,Z_HUFFMAN_ONLY:Ul,Z_NEED_DICT:Da,Z_NO_COMPRESSION:Dl,Z_NO_FLUSH:Ta,Z_OK:er,Z_PARTIAL_FLUSH:La,Z_RLE:Bl,Z_STREAM_END:Ma,Z_STREAM_ERROR:Il,Z_SYNC_FLUSH:Ca,Z_TEXT:Hl,Z_TREES:Cl,Z_UNKNOWN:Kl,Zlib:Q});function Yl(e,t){if(!e)throw new Error(t)}var w={};Object.keys(Pa).forEach(function(e){w[e]=Pa[e]}),w.Z_MIN_WINDOWBITS=8,w.Z_MAX_WINDOWBITS=15,w.Z_DEFAULT_WINDOWBITS=15,w.Z_MIN_CHUNK=64,w.Z_MAX_CHUNK=1/0,w.Z_DEFAULT_CHUNK=16*1024,w.Z_MIN_MEMLEVEL=1,w.Z_MAX_MEMLEVEL=9,w.Z_DEFAULT_MEMLEVEL=8,w.Z_MIN_LEVEL=-1,w.Z_MAX_LEVEL=9,w.Z_DEFAULT_LEVEL=w.Z_DEFAULT_COMPRESSION;var Et={Z_OK:w.Z_OK,Z_STREAM_END:w.Z_STREAM_END,Z_NEED_DICT:w.Z_NEED_DICT,Z_ERRNO:w.Z_ERRNO,Z_STREAM_ERROR:w.Z_STREAM_ERROR,Z_DATA_ERROR:w.Z_DATA_ERROR,Z_MEM_ERROR:w.Z_MEM_ERROR,Z_BUF_ERROR:w.Z_BUF_ERROR,Z_VERSION_ERROR:w.Z_VERSION_ERROR};Object.keys(Et).forEach(function(e){Et[Et[e]]=e});function ql(e){return new Ue(e)}function Gl(e){return new Be(e)}function Vl(e){return new $e(e)}function Xl(e){return new He(e)}function Jl(e){return new Ze(e)}function Ql(e){return new je(e)}function eh(e){return new Ke(e)}function th(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ue(t),e,r)}function rh(e,t){return ze(new Ue(t),e)}function ih(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ze(t),e,r)}function nh(e,t){return ze(new Ze(t),e)}function ah(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new $e(t),e,r)}function oh(e,t){return ze(new $e(t),e)}function sh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ke(t),e,r)}function fh(e,t){return ze(new Ke(t),e)}function lh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Be(t),e,r)}function hh(e,t){return ze(new Be(t),e)}function ch(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new je(t),e,r)}function uh(e,t){return ze(new je(t),e)}function dh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new He(t),e,r)}function ph(e,t){return ze(new He(t),e)}function Pe(e,t,r){var i=[],n=0;e.on("error",o),e.on("end",s),e.end(t),a();function a(){for(var h;(h=e.read())!==null;)i.push(h),n+=h.length;e.once("readable",a)}function o(h){e.removeListener("end",s),e.removeListener("readable",a),r(h)}function s(){var h=c.concat(i,n);i=[],r(null,h),e.close()}}function ze(e,t){if(typeof t=="string"&&(t=new c(t)),!c.isBuffer(t))throw new TypeError("Not a string or buffer");var r=w.Z_FINISH;return e._processChunk(t,r)}function Ue(e){if(!(this instanceof Ue))return new Ue(e);D.call(this,e,w.DEFLATE)}function Be(e){if(!(this instanceof Be))return new Be(e);D.call(this,e,w.INFLATE)}function Ze(e){if(!(this instanceof Ze))return new Ze(e);D.call(this,e,w.GZIP)}function je(e){if(!(this instanceof je))return new je(e);D.call(this,e,w.GUNZIP)}function $e(e){if(!(this instanceof $e))return new $e(e);D.call(this,e,w.DEFLATERAW)}function He(e){if(!(this instanceof He))return new He(e);D.call(this,e,w.INFLATERAW)}function Ke(e){if(!(this instanceof Ke))return new Ke(e);D.call(this,e,w.UNZIP)}function D(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||w.Z_DEFAULT_CHUNK,V.call(this,e),e.flush&&e.flush!==w.Z_NO_FLUSH&&e.flush!==w.Z_PARTIAL_FLUSH&&e.flush!==w.Z_SYNC_FLUSH&&e.flush!==w.Z_FULL_FLUSH&&e.flush!==w.Z_FINISH&&e.flush!==w.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||w.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<w.Z_MIN_CHUNK||e.chunkSize>w.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<w.Z_MIN_WINDOWBITS||e.windowBits>w.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<w.Z_MIN_LEVEL||e.level>w.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<w.Z_MIN_MEMLEVEL||e.memLevel>w.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=w.Z_FILTERED&&e.strategy!=w.Z_HUFFMAN_ONLY&&e.strategy!=w.Z_RLE&&e.strategy!=w.Z_FIXED&&e.strategy!=w.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!c.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new w.Zlib(t);var r=this;this._hadError=!1,this._binding.onerror=function(a,o){r._binding=null,r._hadError=!0;var s=new Error(a);s.errno=o,s.code=Et[o],r.emit("error",s)};var i=w.Z_DEFAULT_COMPRESSION;typeof e.level=="number"&&(i=e.level);var n=w.Z_DEFAULT_STRATEGY;typeof e.strategy=="number"&&(n=e.strategy),this._binding.init(e.windowBits||w.Z_DEFAULT_WINDOWBITS,i,e.memLevel||w.Z_DEFAULT_MEMLEVEL,n,e.dictionary),this._buffer=new c(this._chunkSize),this._offset=0,this._closed=!1,this._level=i,this._strategy=n,this.once("end",this.close)}j(D,V),D.prototype.params=function(e,t,r){if(e<w.Z_MIN_LEVEL||e>w.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=w.Z_FILTERED&&t!=w.Z_HUFFMAN_ONLY&&t!=w.Z_RLE&&t!=w.Z_FIXED&&t!=w.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var i=this;this.flush(w.Z_SYNC_FLUSH,function(){i._binding.params(e,t),i._hadError||(i._level=e,i._strategy=t,r&&r())})}else se.nextTick(r)},D.prototype.reset=function(){return this._binding.reset()},D.prototype._flush=function(e){this._transform(new c(0),"",e)},D.prototype.flush=function(e,t){var r=this._writableState;if((typeof e=="function"||e===void 0&&!t)&&(t=e,e=w.Z_FULL_FLUSH),r.ended)t&&se.nextTick(t);else if(r.ending)t&&this.once("end",t);else if(r.needDrain){var i=this;this.once("drain",function(){i.flush(t)})}else this._flushFlag=e,this.write(new c(0),"",t)},D.prototype.close=function(e){if(e&&se.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;se.nextTick(function(){t.emit("close")})}},D.prototype._transform=function(e,t,r){var i,n=this._writableState,a=n.ending||n.ended,o=a&&(!e||n.length===e.length);if(!e===null&&!c.isBuffer(e))return r(new Error("invalid input"));o?i=w.Z_FINISH:(i=this._flushFlag,e.length>=n.length&&(this._flushFlag=this._opts.flush||w.Z_NO_FLUSH)),this._processChunk(e,i,r)},D.prototype._processChunk=function(e,t,r){var i=e&&e.length,n=this._chunkSize-this._offset,a=0,o=this,s=typeof r=="function";if(!s){var h=[],f=0,l;this.on("error",function(S){l=S});do var d=this._binding.writeSync(t,e,a,i,this._buffer,this._offset,n);while(!this._hadError&&g(d[0],d[1]));if(this._hadError)throw l;var p=c.concat(h,f);return this.close(),p}var u=this._binding.write(t,e,a,i,this._buffer,this._offset,n);u.buffer=e,u.callback=g;function g(S,y){if(!o._hadError){var v=n-y;if(Yl(v>=0,"have should not go down"),v>0){var k=o._buffer.slice(o._offset,o._offset+v);o._offset+=v,s?o.push(k):(h.push(k),f+=k.length)}if((y===0||o._offset>=o._chunkSize)&&(n=o._chunkSize,o._offset=0,o._buffer=new c(o._chunkSize)),y===0){if(a+=i-S,i=S,!s)return!0;var E=o._binding.write(t,e,a,i,o._buffer,o._offset,o._chunkSize);E.callback=g,E.buffer=e;return}if(!s)return!1;r()}}},j(Ue,D),j(Be,D),j(Ze,D),j(je,D),j($e,D),j(He,D),j(Ke,D);var za={codes:Et,createDeflate:ql,createInflate:Gl,createDeflateRaw:Vl,createInflateRaw:Xl,createGzip:Jl,createGunzip:Ql,createUnzip:eh,deflate:th,deflateSync:rh,gzip:ih,gzipSync:nh,deflateRaw:ah,deflateRawSync:oh,unzip:sh,unzipSync:fh,inflate:lh,inflateSync:hh,gunzip:ch,gunzipSync:uh,inflateRaw:dh,inflateRawSync:ph,Deflate:Ue,Inflate:Be,Gzip:Ze,Gunzip:je,DeflateRaw:$e,InflateRaw:He,Unzip:Ke,Zlib:D};class Ua extends hr{constructor({client:t,keyPrefix:r="cache"}){super(),this.client=t,this.keyPrefix=r}async _set(t,r){let i=JSON.stringify(r);const n=i.length;return i=za.gzipSync(i).toString("base64"),this.client.putObject({key:W(this.keyPrefix,t),body:i,contentEncoding:"gzip",contentType:"application/gzip",metadata:{compressor:"zlib",compressed:"true","client-id":this.client.id,"length-serialized":String(n),"length-compressed":String(i.length),"compression-gain":(i.length/n).toFixed(2)}})}async _get(t){const{Body:r}=await this.client.getObject(W(this.keyPrefix,t));let i=await lr(r);return i=Buffer.from(i,"base64"),i=za.unzipSync(i).toString(),JSON.parse(i)}async _del(t){return await this.client.deleteObject(W(this.keyPrefix,t)),!0}async _clear(t=""){const r=await this.client.getAllKeys({prefix:W(this.keyPrefix,t)});await this.client.deleteObjects(r)}}class Ba extends b{async setup(t){}async start(){}async stop(){}beforeSetup(){this.emit("plugin.beforeSetup",new Date)}afterSetup(){this.emit("plugin.afterSetup",new Date)}beforeStart(){this.emit("plugin.beforeStart",new Date)}afterStart(){this.emit("plugin.afterStart",new Date)}beforeStop(){this.emit("plugin.beforeStop",new Date)}afterStop(){this.emit("plugin.afterStop",new Date)}}const _h={setup(e){},start(){},stop(){}},wh={async setup(e){this.client=e.client,this.map={PutObjectCommand:"put",GetObjectCommand:"get",HeadObjectCommand:"get",DeleteObjectCommand:"delete",DeleteObjectsCommand:"delete",ListObjectsV2Command:"list"},this.costs={total:0,prices:{put:.005/1e3,copy:.005/1e3,list:.005/1e3,post:.005/1e3,get:4e-4/1e3,select:4e-4/1e3,delete:4e-4/1e3},requests:{total:0,put:0,post:0,copy:0,list:0,get:0,select:0,delete:0},events:{total:0,PutObjectCommand:0,GetObjectCommand:0,HeadObjectCommand:0,DeleteObjectCommand:0,DeleteObjectsCommand:0,ListObjectsV2Command:0}},this.client.costs=JSON.parse(JSON.stringify(this.costs))},async start(){this.client.on("command.response",e=>this.addRequest(e,this.map[e]))},addRequest(e,t){this.costs.events[e]++,this.costs.events.total++,this.costs.requests.total++,this.costs.requests[t]++,this.costs.total+=this.costs.prices[t],this.client.costs.events[e]++,this.client.costs.events.total++,this.client.costs.requests.total++,this.client.costs.requests[t]++,this.client.costs.total+=this.client.costs.prices[t]}};class gh extends Ba{constructor(t={}){super(),this.driver=t.driver}async setup(t){this.database=t,this.driver||(this.driver=new Ua({keyPrefix:"cache",client:t.client})),this.installDatabaseProxy();for(const r of Object.values(t.resources))this.installResourcesProxies(r)}async start(){}async stop(){}installDatabaseProxy(){const t=this.installResourcesProxies.bind(this);this.database._createResource=this.database.createResource,this.database.createResource=async function(...r){const i=await this._createResource(...r);return t(i),i}}installResourcesProxies(t){t.cache=this.driver;let r=`resource=${t.name}`;this.driver.keyPrefix&&(this.driver.keyPrefix=W(this.driver.keyPrefix,r)),t.cacheKeyFor=async function({params:i={},action:n="list"}){let a=Object.keys(i).sort().map(o=>`${o}:${i[o]}`).join("|")||"empty";return a=await yi(a),a=W(r,`action=${n}`,`${a}.json.gz`),a},t._count=t.count,t._listIds=t.listIds,t._getMany=t.getMany,t._getAll=t.getAll,t._page=t.page,t.count=async function(){const i=await this.cacheKeyFor({action:"count"});try{const a=await this.cache.get(i);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const n=await t._count();return await this.cache.set(i,n),n},t.listIds=async function(){const i=await this.cacheKeyFor({action:"listIds"});try{const a=await this.cache.get(i);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const n=await t._listIds();return await this.cache.set(i,n),n},t.getMany=async function(i){const n=await this.cacheKeyFor({action:"getMany",params:{ids:i}});try{const o=await this.cache.get(n);if(o)return o}catch(o){if(o.name!=="NoSuchKey")throw o}const a=await t._getMany(i);return await this.cache.set(n,a),a},t.getAll=async function(){const i=await this.cacheKeyFor({action:"getAll"});try{const a=await this.cache.get(i);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const n=await t._getAll();return await this.cache.set(i,n),n},t.page=async function({offset:i,size:n}){const a=await this.cacheKeyFor({action:"page",params:{offset:i,size:n}});try{const s=await this.cache.get(a);if(s)return s}catch(s){if(s.name!=="NoSuchKey")throw s}const o=await t._page({offset:i,size:n});return await this.cache.set(a,o),o},t._insert=t.insert,t._update=t.update,t._delete=t.delete,t._deleteMany=t.deleteMany,t.insert=async function(...i){const n=await t._insert(...i);return await this.cache.clear(r),n},t.update=async function(...i){const n=await t._update(...i);return await this.cache.clear(r),n},t.delete=async function(...i){const n=await t._delete(...i);return await this.cache.clear(r),n},t.deleteMany=async function(...i){const n=await t._deleteMany(...i);return await this.cache.clear(r),n}}}var vh=Object.freeze({__proto__:null});exports.BaseError=We,exports.Cache=hr,exports.CachePlugin=gh,exports.Client=bi,exports.ConnectionString=mi,exports.CostsPlugin=wh,exports.Database=Oi,exports.ErrorMap=wi,exports.InvalidResourceItem=Tt,exports.MemoryCache=lo,exports.MissingMetadata=pi,exports.NoSuchBucket=ui,exports.NoSuchKey=or,exports.NotFound=di,exports.Plugin=Ba,exports.PluginObject=_h,exports.ResourceIdsPageReader=Ai,exports.ResourceIdsReader=Ri,exports.ResourceReader=Ti,exports.ResourceWriter=Li,exports.S3Cache=Ua,exports.S3_DEFAULT_ENDPOINT=vi,exports.S3_DEFAULT_REGION=gi,exports.S3db=fo,exports.UnknownError=_i,exports.Validator=ki,exports.ValidatorManager=Si,exports.decrypt=xi,exports.encrypt=sr,exports.sha256=yi,exports.streamToString=lr;
|