s3db.js 3.3.1 → 4.0.1
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/README.md +99 -857
- package/dist/s3db.cjs.js +5449 -2028
- package/dist/s3db.cjs.min.js +15 -7
- package/dist/s3db.d.ts +133 -0
- package/dist/s3db.es.js +5453 -2032
- package/dist/s3db.es.min.js +15 -7
- package/dist/s3db.iife.js +5450 -2030
- package/dist/s3db.iife.min.js +15 -7
- package/package.json +36 -16
- package/UNLICENSE +0 -24
- package/docker-compose.yml +0 -18
- package/jest.config.js +0 -22
- package/rollup.config.js +0 -77
- package/scripts/prefix-files-istanbul-ignore.js +0 -18
package/dist/s3db.iife.min.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
|
-
|
|
2
|
+
var S3DB=function(P,ji,M,ce,le,Ni,Yt,Df,Ff){"use strict";function Bi(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var Mf=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,jr=function(e){return Mf.exec(e).slice(1)};function Nr(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)continue;e=n+"/"+e,t=n.charAt(0)==="/"}return e=Bi(Br(e.split("/"),function(i){return!!i}),!t).join("/"),(t?"/":"")+e||"."}function Ui(e){var t=$i(e),r=zf(e,-1)==="/";return e=Bi(Br(e.split("/"),function(n){return!!n}),!t).join("/"),!e&&!t&&(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function $i(e){return e.charAt(0)==="/"}function we(){var e=Array.prototype.slice.call(arguments,0);return Ui(Br(e,function(t,r){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function Lf(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 n=r(e.split("/")),i=r(t.split("/")),a=Math.min(n.length,i.length),o=a,s=0;s<a;s++)if(n[s]!==i[s]){o=s;break}for(var c=[],s=o;s<n.length;s++)c.push("..");return c=c.concat(i.slice(o)),c.join("/")}var jf="/",Nf=":";function Bf(e){var t=jr(e),r=t[0],n=t[1];return!r&&!n?".":(n&&(n=n.substr(0,n.length-1)),r+n)}function Uf(e,t){var r=jr(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r}function $f(e){return jr(e)[3]}var ue={extname:$f,basename:Uf,dirname:Bf,sep:jf,delimiter:Nf,relative:Lf,join:we,isAbsolute:$i,normalize:Ui,resolve:Nr};function Br(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n<e.length;n++)t(e[n],n,e)&&r.push(e[n]);return r}var zf="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)};const zi=ji.customAlphabet(ji.urlAlphabet,22);var Ur;function Te(){}Te.prototype=Object.create(null);function R(){R.init.call(this)}R.EventEmitter=R,R.usingDomains=!1,R.prototype.domain=void 0,R.prototype._events=void 0,R.prototype._maxListeners=void 0,R.defaultMaxListeners=10,R.init=function(){this.domain=null,R.usingDomains&&Ur.active&&!(this instanceof Ur.Domain)&&(this.domain=Ur.active),(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new Te,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},R.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 Zi(e){return e._maxListeners===void 0?R.defaultMaxListeners:e._maxListeners}R.prototype.getMaxListeners=function(){return Zi(this)};function Zf(e,t,r){if(t)e.call(r);else for(var n=e.length,i=At(e,n),a=0;a<n;++a)i[a].call(r)}function qf(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,a=At(e,i),o=0;o<i;++o)a[o].call(r,n)}function Hf(e,t,r,n,i){if(t)e.call(r,n,i);else for(var a=e.length,o=At(e,a),s=0;s<a;++s)o[s].call(r,n,i)}function Kf(e,t,r,n,i,a){if(t)e.call(r,n,i,a);else for(var o=e.length,s=At(e,o),c=0;c<o;++c)s[c].call(r,n,i,a)}function Wf(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,a=At(e,i),o=0;o<i;++o)a[o].apply(r,n)}R.prototype.emit=function(t){var r,n,i,a,o,s,c,f=t==="error";if(s=this._events,s)f=f&&s.error==null;else if(!f)return!1;if(c=this.domain,f){if(r=arguments[1],c)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=c,r.domainThrown=!1,c.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(n=s[t],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:Zf(n,d,this);break;case 2:qf(n,d,this,arguments[1]);break;case 3:Hf(n,d,this,arguments[1],arguments[2]);break;case 4:Kf(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),o=1;o<i;o++)a[o-1]=arguments[o];Wf(n,d,this,a)}return!0};function qi(e,t,r,n){var i,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 Te,e._eventsCount=0),!o)o=a[t]=r,++e._eventsCount;else if(typeof o=="function"?o=a[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=Zi(e),i&&i>0&&o.length>i)){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,Vf(s)}return e}function Vf(e){typeof console.warn=="function"?console.warn(e):console.log(e)}R.prototype.addListener=function(t,r){return qi(this,t,r,!1)},R.prototype.on=R.prototype.addListener,R.prototype.prependListener=function(t,r){return qi(this,t,r,!0)};function Hi(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}R.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},R.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},R.prototype.removeListener=function(t,r){var n,i,a,o,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[t],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new Te:(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(a=-1,o=n.length;o-- >0;)if(n[o]===r||n[o].listener&&n[o].listener===r){s=n[o].listener,a=o;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new Te,this;delete i[t]}else Gf(n,a);i.removeListener&&this.emit("removeListener",t,s||r)}return this},R.prototype.off=function(e,t){return this.removeListener(e,t)},R.prototype.removeAllListeners=function(t){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new Te,this._eventsCount=0):n[t]&&(--this._eventsCount===0?this._events=new Te:delete n[t]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,o;a<i.length;++a)o=i[a],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=new Te,this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r)do this.removeListener(t,r[r.length-1]);while(r[0]);return this},R.prototype.listeners=function(t){var r,n,i=this._events;return i?(r=i[t],r?typeof r=="function"?n=[r.listener||r]:n=Yf(r):n=[]):n=[],n},R.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Ki.call(e,t)},R.prototype.listenerCount=Ki;function Ki(e){var t=this._events;if(t){var r=t[e];if(typeof r=="function")return 1;if(r)return r.length}return 0}R.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function Gf(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}function At(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}function Yf(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}class lt extends Error{constructor({verbose:t,bucket:r,message:n,...i}){t&&(n=n+`
|
|
3
3
|
|
|
4
4
|
Verbose:
|
|
5
5
|
|
|
6
|
-
${JSON.stringify(
|
|
7
|
-
${JSON.stringify(n,null,2)}`}),this.resourceName=r,this.attributes=i,this.validation=n}}class pi extends Ye{}const _i={NotFound:ui,NoSuchKey:sr,UnknownError:pi,NoSuchBucket:ci,MissingMetadata:di,InvalidResourceItem:Rt},wi="us-east-1",gi="https://s3.us-east-1.amazonaws.com";class vi{constructor(t){let r;try{r=new URL(t)}catch{throw new Error("Invalid connection string: "+t)}this.region=wi,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=gi,["/","",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 mi extends y{constructor({verbose:t=!1,id:r=null,AwsS3Client:i,connectionString:n,parallelism:a=10}){super(),this.verbose=t,this.id=r??ii.nanoid(7),this.parallelism=a,this.config=new vi(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 pe.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=_i[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?ae.join(this.config.keyPrefix,t):t,Metadata:{...r},Body:n||"",ContentType:i,ContentEncoding:a};try{const s=await this.sendCommand(new pe.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:ae.join(this.config.keyPrefix,t)};try{const i=await this.sendCommand(new pe.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?ae.join(this.config.keyPrefix,t):t};try{const i=await this.client.send(new pe.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?ae.join(this.config.keyPrefix,r):r,CopySource:ae.join(this.config.bucket,this.config.keyPrefix?ae.join(this.config.keyPrefix,t):t)};try{const n=await this.client.send(new pe.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?ae.join(this.config.keyPrefix,t):t};try{const i=await this.sendCommand(new pe.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 de.PromisePool.for(r).withConcurrency(this.parallelism).process(async o=>{const s={Bucket:this.config.bucket,Delete:{Objects:o.map(h=>({Key:this.config.keyPrefix?ae.join(this.config.keyPrefix,h):h}))}};try{return await this.sendCommand(new pe.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?ae.join(this.config.keyPrefix,t||""):t||""};try{const a=await this.sendCommand(new pe.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 de.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 At(){let e;if(process)try{const{webcrypto:t}=await import("crypto");e=t}catch{throw new Error("Crypto API not available")}else window&&(e=window.crypto);if(!e)throw new Error("Could not load any crypto library");return e}async function yi(e){const t=await At(),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 fr(e,t){const r=await At(),i=r.getRandomValues(new Uint8Array(16)),n=await xi(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),oo(f)}async function bi(e,t){const r=await At(),i=so(e),n=i.slice(0,16),a=i.slice(16,28),o=i.slice(28),s=await xi(t,n),h=await r.subtle.decrypt({name:"AES-GCM",iv:a},s,o);return new TextDecoder().decode(h)}async function xi(e,t){const r=await At(),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 oo(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 so(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 lr(e,t,r){if(!this.passphrase)return t.push({actual:e,type:"encryptionKeyMissing"}),e;try{return await fr(String(e),this.passphrase)}catch(i){t.push({actual:e,type:"encryptionProblem",error:i})}return e}class Ei extends ja{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?lr: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?lr:void 0}),this.alias("secretNumber",{type:"number",custom:this.autoEncrypt?lr:void 0})}}const ki=new Proxy(Ei,{instance:null,construct(e,t){return this.instance||(this.instance=new e(...t)),this.instance}}),fo={trim:e=>e.trim(),encrypt:(e,{passphrase:t})=>fr(e,t),decrypt:(e,{passphrase:t})=>bi(e,t),toString:e=>String(e),fromArray:(e,{separator:t})=>(e||[]).join(t),toArray:(e,{separator:t})=>(e||"").split(t),toJSON:e=>JSON.stringify(e),fromJSON:e=>JSON.parse(e),toNumber:e=>O.isString(e)?e.includes(".")?parseFloat(e):parseInt(e):e,toBool:e=>[!0,1,"true","1","yes","y"].includes(e),fromBool:e=>[!0,1,"true","1","yes","y"].includes(e)?"1":"0"};class hr{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 ki({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=St.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=St.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,"fromBool"),this.addHook("afterUnmap",r,"toBool")))}static import(t){let{map:r,name:i,options:n,version:a,attributes:o}=O.isString(t)?JSON.parse(t):t;return new hr({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!==void 0&&O.set(t,i,await fo[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=St.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"),St.unflatten(i)}}class Si extends y{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new ir.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 Ri extends Si{enqueue(t){this.controller.enqueue(t),this.emit("page",t)}}class Ai extends y{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.input=new Ri({resource:this.resource}),this.output=new ir.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 de.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async i=>{const n=await this.resource.get(i);return r.enqueue(n),n})}}class Ti extends y{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new ir.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 de.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 cr(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 Li extends y{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.observers=s,this.parallelism=a,this.passphrase=o??"secret",this.options={cache:!1,autoDecrypt:!0,timestamps:!1,...i},i.timestamps&&(n.createdAt="string",n.updatedAt="string"),this.schema=new hr({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}){this.options.timestamps&&(r.createdAt=new Date().toISOString(),r.updatedAt=new Date().toISOString());const{errors:i,isValid:n,data:a}=await this.validate(r);if(!n)throw new Rt({bucket:this.client.config.bucket,resourceName:this.name,attributes:r,validation:i});!t&&t!==0&&(t=ii.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._lastModified=r.LastModified,r.VersionId&&(i._versionId=r.VersionId),r.Expiration&&(i._expiresAt=r.Expiration),this.emit("get",i),i}async exists(t){try{return await this.client.headObject(Y(`resource=${this.name}`,`id=${t}`)),!0}catch{return!1}}async update(t,r){const i=await this.get(t);this.options.timestamps&&(r.updatedAt=new Date().toISOString());const n=O.merge(i,r);delete n.id;const{isValid:a,errors:o,data:s}=await this.validate(n);if(!a)throw new Rt({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 upsert({id:t,...r}){return await this.exists(t)?this.update(t,r):this.insert({id:t,...r})}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 de.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 de.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 de.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 de.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 Ai({resource:this}).build()}writable(){return new Ti({resource:this}).build()}}class Ci extends y{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 mi({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 cr(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 Li({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 Li({name:t,attributes:r,observers:[this],client:this.client,options:{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 lo extends Ci{}class ur extends y{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 ho extends ur{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 qe=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},te=[],G=[],co=typeof Uint8Array<"u"?Uint8Array:Array,dr=!1;function Ii(){dr=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)te[t]=e[t],G[e.charCodeAt(t)]=t;G[45]=62,G[95]=63}function uo(e){dr||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 co(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=G[e.charCodeAt(t)]<<18|G[e.charCodeAt(t+1)]<<12|G[e.charCodeAt(t+2)]<<6|G[e.charCodeAt(t+3)],o[h++]=n>>16&255,o[h++]=n>>8&255,o[h++]=n&255;return a===2?(n=G[e.charCodeAt(t)]<<2|G[e.charCodeAt(t+1)]>>4,o[h++]=n&255):a===1&&(n=G[e.charCodeAt(t)]<<10|G[e.charCodeAt(t+1)]<<4|G[e.charCodeAt(t+2)]>>2,o[h++]=n>>8&255,o[h++]=n&255),o}function po(e){return te[e>>18&63]+te[e>>12&63]+te[e>>6&63]+te[e&63]}function _o(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(po(i));return n.join("")}function Oi(e){dr||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(_o(e,s,s+o>h?h:s+o));return i===1?(t=e[r-1],n+=te[t>>2],n+=te[t<<4&63],n+="=="):i===2&&(t=(e[r-2]<<8)+e[r-1],n+=te[t>>10],n+=te[t>>4&63],n+=te[t<<2&63],n+="="),a.push(n),a.join("")}function Tt(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 Mi(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 wo={}.toString,Di=Array.isArray||function(e){return wo.call(e)=="[object Array]"};/*!
|
|
6
|
+
${JSON.stringify(i,null,2)}`),super(n),typeof Error.captureStackTrace=="function"?Error.captureStackTrace(this,this.constructor):this.stack=new Error(n).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 Wi extends lt{constructor({bucket:t,...r}){super({...r,bucket:t,message:`Bucket does not exists [bucket:${t}]`})}}class $r extends lt{constructor({bucket:t,key:r,...n}){super({...n,bucket:t,message:`Key [${r}] does not exists [bucket:${t}/${r}]`}),this.key=r}}class Vi extends $r{}class Gi extends lt{constructor({bucket:t,...r}){super({...r,bucket:t,message:`Missing metadata for bucket [bucket:${t}]`})}}class Jt extends lt{constructor({bucket:t,resourceName:r,attributes:n,validation:i}){super({bucket:t,message:`This item is not valid. Resource=${r} [bucket:${t}].
|
|
7
|
+
${JSON.stringify(i,null,2)}`}),this.resourceName=r,this.attributes=n,this.validation=i}}class Yi extends lt{}const Ji={NotFound:Vi,NoSuchKey:$r,UnknownError:Yi,NoSuchBucket:Wi,MissingMetadata:Gi,InvalidResourceItem:Jt},Xi="us-east-1",Qi="https://s3.us-east-1.amazonaws.com";class ea{constructor(t){let r;try{r=new URL(t)}catch{throw new Error("Invalid connection string: "+t)}this.region=Xi,r.protocol==="s3:"?this.defineS3(r):this.defineMinio(r);for(const[n,i]of r.searchParams.entries())this[n]=i}defineS3(t){if(this.bucket=t.hostname,this.accessKeyId=t.username,this.secretAccessKey=t.password,this.endpoint=Qi,["/","",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,...n]=t.pathname.split("/");this.bucket=r,this.keyPrefix=[...n||[]].join("/")}}}class ta extends R{constructor({verbose:t=!1,id:r=null,AwsS3Client:n,connectionString:i,parallelism:a=10}){super(),this.verbose=t,this.id=r??zi(),this.parallelism=a,this.config=new ea(i),this.client=n||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 le.S3Client(t)}async sendCommand(t){this.emit("command.request",t.constructor.name,t.input);const r=console.warn;try{console.warn=i=>{i.includes("Stream of unknown length")||r(i)}}catch(i){console.error(i)}const n=await this.client.send(t);this.emit("command.response",t.constructor.name,n,t.input);try{console.warn=r}catch(i){console.error(i)}return n}errorProxy(t,r){this.verbose&&(r.bucket=this.config.bucket,r.config=this.config,r.verbose=this.verbose),t.data=r;const n=Ji[t.name];return n?new n(r):t}async putObject({key:t,metadata:r,contentType:n,body:i,contentEncoding:a}){const o={Bucket:this.config.bucket,Key:this.config.keyPrefix?ue.join(this.config.keyPrefix,t):t,Metadata:{...r},Body:i||"",ContentType:n,ContentEncoding:a};try{const s=await this.sendCommand(new le.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:ue.join(this.config.keyPrefix,t)};try{const n=await this.sendCommand(new le.GetObjectCommand(r));return this.emit("getObject",n,r),n}catch(n){throw this.errorProxy(n,{key:t,command:r})}}async headObject(t){const r={Bucket:this.config.bucket,Key:this.config.keyPrefix?ue.join(this.config.keyPrefix,t):t};try{const n=await this.client.send(new le.HeadObjectCommand(r));return this.emit("headObject",n,r),n}catch(n){throw this.errorProxy(n,{key:t,command:r})}}async copyObject({from:t,to:r}){const n={Bucket:this.config.bucket,Key:this.config.keyPrefix?ue.join(this.config.keyPrefix,r):r,CopySource:ue.join(this.config.bucket,this.config.keyPrefix?ue.join(this.config.keyPrefix,t):t)};try{const i=await this.client.send(new le.CopyObjectCommand(n));return this.emit("copyObject",i,n),i}catch(i){throw this.errorProxy(i,{from:t,to:r,command:n})}}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?ue.join(this.config.keyPrefix,t):t};try{const n=await this.sendCommand(new le.DeleteObjectCommand(r));return this.emit("deleteObject",n,r),n}catch(n){throw this.errorProxy(n,{key:t,command:r})}}async deleteObjects(t){const r=M.chunk(t,1e3),{results:n,errors:i}=await ce.PromisePool.for(r).withConcurrency(this.parallelism).process(async o=>{const s={Bucket:this.config.bucket,Delete:{Objects:o.map(c=>({Key:this.config.keyPrefix?ue.join(this.config.keyPrefix,c):c}))}};try{return await this.sendCommand(new le.DeleteObjectsCommand(s))}catch(c){throw this.errorProxy(c,{keys:o,command:s})}}),a={deleted:n,notFound:i};return this.emit("deleteObjects",a,t),a}async deleteAll({prefix:t}={}){let r,n=0;do{const i=new le.ListObjectsV2Command({Bucket:this.config.bucket,Prefix:this.config.keyPrefix?ue.join(this.config.keyPrefix,t):t,ContinuationToken:r}),a=await this.client.send(i);if(a.Contents&&a.Contents.length>0){const o=new le.DeleteObjectsCommand({Bucket:this.config.bucket,Delete:{Objects:a.Contents.map(f=>({Key:f.Key}))}}),s=await this.client.send(o),c=s.Deleted?s.Deleted.length:0;n+=c,this.emit("deleteAll",{prefix:t,batch:c,total:n})}r=a.IsTruncated?a.NextContinuationToken:void 0}while(r);return this.emit("deleteAllComplete",{prefix:t,totalDeleted:n}),n}async moveObject({from:t,to:r}){try{return await this.copyObject({from:t,to:r}),await this.deleteObject(t),!0}catch(n){throw this.errorProxy(n,{from:t,to:r,command:options})}}async listObjects({prefix:t,maxKeys:r=1e3,continuationToken:n}={}){const i={Bucket:this.config.bucket,MaxKeys:r,ContinuationToken:n,Prefix:this.config.keyPrefix?ue.join(this.config.keyPrefix,t||""):t||""};try{const a=await this.sendCommand(new le.ListObjectsV2Command(i));return this.emit("listObjects",a,i),a}catch(a){throw this.errorProxy(a,{command:i})}}async count({prefix:t}={}){let r=0,n=!0,i;for(;n;){const a={prefix:t,continuationToken:i},o=await this.listObjects(a);r+=o.KeyCount||0,n=o.IsTruncated||!1,i=o.NextContinuationToken}return this.emit("count",r,{prefix:t}),r}async getAllKeys({prefix:t}={}){let r=[],n=!0,i;for(;n;){const a={prefix:t,continuationToken:i},o=await this.listObjects(a);o.Contents&&(r=r.concat(o.Contents.map(s=>s.Key))),n=o.IsTruncated||!1,i=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:n=1e3}=t;if(n===0)return null;let i=!0,a,o=0;for(;i;){let s=n<1e3?n:n-o>1e3?1e3:n-o;const c={prefix:r,maxKeys:s,continuationToken:a},f=await this.listObjects(c);if(f.Contents&&(o+=f.Contents.length),i=f.IsTruncated||!1,a=f.NextContinuationToken,o>=n)break}return this.emit("getContinuationTokenAfterOffset",a||null,t),a||null}async getKeysPage(t={}){const{prefix:r,offset:n=0,amount:i=100}=t;let a=[],o=!0,s;for(n>0&&(s=await this.getContinuationTokenAfterOffset({prefix:r,offset:n}));o;){const c={prefix:r,continuationToken:s},f=await this.listObjects(c);if(f.Contents&&(a=a.concat(f.Contents.map(l=>l.Key))),o=f.IsTruncated||!1,s=f.NextContinuationToken,a.length>i){a=a.splice(0,i);break}}return this.config.keyPrefix&&(a=a.map(c=>c.replace(this.config.keyPrefix,"")).map(c=>c.startsWith("/")?c.replace("/",""):c)),this.emit("getKeysPage",a,t),a}async moveAllObjects({prefixFrom:t,prefixTo:r}){const n=await this.getAllKeys({prefix:t}),{results:i,errors:a}=await ce.PromisePool.for(n).withConcurrency(this.parallelism).process(async o=>{const s=o.replace(t,r);try{return await this.moveObject({from:o,to:s}),s}catch(c){throw this.errorProxy(c,{from:o,to:s})}});if(this.emit("moveAllObjects",{results:i,errors:a},{prefixFrom:t,prefixTo:r}),a.length>0)throw new Error("Some objects could not be moved");return i}}async function Xt(){let e;if(typeof process<"u")try{const{webcrypto:t}=await import("crypto");e=t}catch{throw new Error("Crypto API not available")}else typeof window<"u"&&(e=window.crypto);if(!e)throw new Error("Could not load any crypto library");return e}async function ra(e){const t=await Xt(),n=new TextEncoder().encode(e),i=await t.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("")}async function zr(e,t){const r=await Xt(),n=r.getRandomValues(new Uint8Array(16)),i=await ia(t,n),a=r.getRandomValues(new Uint8Array(12)),s=new TextEncoder().encode(e),c=await r.subtle.encrypt({name:"AES-GCM",iv:a},i,s),f=new Uint8Array(n.length+a.length+c.byteLength);return f.set(n),f.set(a,n.length),f.set(new Uint8Array(c),n.length+a.length),Jf(f)}async function na(e,t){const r=await Xt(),n=Xf(e),i=n.slice(0,16),a=n.slice(16,28),o=n.slice(28),s=await ia(t,i),c=await r.subtle.decrypt({name:"AES-GCM",iv:a},s,o);return new TextDecoder().decode(c)}async function ia(e,t){const r=await Xt(),i=new TextEncoder().encode(e),a=await r.subtle.importKey("raw",i,{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 Jf(e){if(typeof process<"u")return Buffer.from(e).toString("base64");{const t=String.fromCharCode.apply(null,new Uint8Array(e));return window.btoa(t)}}function Xf(e){if(typeof process<"u")return new Uint8Array(Buffer.from(e,"base64"));{const t=window.atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}}function Qf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qt={},Zr,aa;function ec(){if(aa)return Zr;aa=1;var e,t,r={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
8
|
+
`,r:"\r",t:" "},n;function i(u){throw{name:"SyntaxError",message:u,at:e,text:n}}function a(u){return u&&u!==t&&i("Expected '"+u+"' instead of '"+t+"'"),t=n.charAt(e),e+=1,t}function o(){var u,p="";for(t==="-"&&(p="-",a("-"));t>="0"&&t<="9";)p+=t,a();if(t===".")for(p+=".";a()&&t>="0"&&t<="9";)p+=t;if(t==="e"||t==="E")for(p+=t,a(),(t==="-"||t==="+")&&(p+=t,a());t>="0"&&t<="9";)p+=t,a();return u=Number(p),isFinite(u)||i("Bad number"),u}function s(){var u,p,g="",_;if(t==='"')for(;a();){if(t==='"')return a(),g;if(t==="\\")if(a(),t==="u"){for(_=0,p=0;p<4&&(u=parseInt(a(),16),!!isFinite(u));p+=1)_=_*16+u;g+=String.fromCharCode(_)}else if(typeof r[t]=="string")g+=r[t];else break;else g+=t}i("Bad string")}function c(){for(;t&&t<=" ";)a()}function f(){switch(t){case"t":return a("t"),a("r"),a("u"),a("e"),!0;case"f":return a("f"),a("a"),a("l"),a("s"),a("e"),!1;case"n":return a("n"),a("u"),a("l"),a("l"),null;default:i("Unexpected '"+t+"'")}}function l(){var u=[];if(t==="["){if(a("["),c(),t==="]")return a("]"),u;for(;t;){if(u.push(h()),c(),t==="]")return a("]"),u;a(","),c()}}i("Bad array")}function d(){var u,p={};if(t==="{"){if(a("{"),c(),t==="}")return a("}"),p;for(;t;){if(u=s(),c(),a(":"),Object.prototype.hasOwnProperty.call(p,u)&&i('Duplicate key "'+u+'"'),p[u]=h(),c(),t==="}")return a("}"),p;a(","),c()}}i("Bad object")}function h(){switch(c(),t){case"{":return d();case"[":return l();case'"':return s();case"-":return o();default:return t>="0"&&t<="9"?o():f()}}return Zr=function(u,p){var g;return n=u,e=0,t=" ",g=h(),c(),t&&i("Syntax error"),typeof p=="function"?function _(w,x){var S,v,A=w[x];if(A&&typeof A=="object")for(S in h)Object.prototype.hasOwnProperty.call(A,S)&&(v=_(A,S),typeof v>"u"?delete A[S]:A[S]=v);return p.call(w,x,A)}({"":g},""):g},Zr}var qr,oa;function tc(){if(oa)return qr;oa=1;var e=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,t,r,n={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},i;function a(s){return e.lastIndex=0,e.test(s)?'"'+s.replace(e,function(c){var f=n[c];return typeof f=="string"?f:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+s+'"'}function o(s,c){var f,l,d,h,u=t,p,g=c[s];switch(g&&typeof g=="object"&&typeof g.toJSON=="function"&&(g=g.toJSON(s)),typeof i=="function"&&(g=i.call(c,s,g)),typeof g){case"string":return a(g);case"number":return isFinite(g)?String(g):"null";case"boolean":case"null":return String(g);case"object":if(!g)return"null";if(t+=r,p=[],Object.prototype.toString.apply(g)==="[object Array]"){for(h=g.length,f=0;f<h;f+=1)p[f]=o(f,g)||"null";return d=p.length===0?"[]":t?`[
|
|
9
|
+
`+t+p.join(`,
|
|
10
|
+
`+t)+`
|
|
11
|
+
`+u+"]":"["+p.join(",")+"]",t=u,d}if(i&&typeof i=="object")for(h=i.length,f=0;f<h;f+=1)l=i[f],typeof l=="string"&&(d=o(l,g),d&&p.push(a(l)+(t?": ":":")+d));else for(l in g)Object.prototype.hasOwnProperty.call(g,l)&&(d=o(l,g),d&&p.push(a(l)+(t?": ":":")+d));return d=p.length===0?"{}":t?`{
|
|
12
|
+
`+t+p.join(`,
|
|
13
|
+
`+t)+`
|
|
14
|
+
`+u+"}":"{"+p.join(",")+"}",t=u,d}}return qr=function(s,c,f){var l;if(t="",r="",typeof f=="number")for(l=0;l<f;l+=1)r+=" ";else typeof f=="string"&&(r=f);if(i=c,c&&typeof c!="function"&&(typeof c!="object"||typeof c.length!="number"))throw new Error("JSON.stringify");return o("",{"":s})},qr}var sa;function rc(){return sa||(sa=1,Qt.parse=ec(),Qt.stringify=tc()),Qt}var Hr,fa;function nc(){if(fa)return Hr;fa=1;var e={}.toString;return Hr=Array.isArray||function(t){return e.call(t)=="[object Array]"},Hr}var Kr,ca;function la(){if(ca)return Kr;ca=1;var e=Object.prototype.toString;return Kr=function(r){var n=e.call(r),i=n==="[object Arguments]";return i||(i=n!=="[object Array]"&&r!==null&&typeof r=="object"&&typeof r.length=="number"&&r.length>=0&&e.call(r.callee)==="[object Function]"),i},Kr}var Wr,ua;function ic(){if(ua)return Wr;ua=1;var e;if(!Object.keys){var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=la(),i=Object.prototype.propertyIsEnumerable,a=!i.call({toString:null},"toString"),o=i.call(function(){},"prototype"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(h){var u=h.constructor;return u&&u.prototype===h},f={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},l=function(){if(typeof window>"u")return!1;for(var h in window)try{if(!f["$"+h]&&t.call(window,h)&&window[h]!==null&&typeof window[h]=="object")try{c(window[h])}catch{return!0}}catch{return!0}return!1}(),d=function(h){if(typeof window>"u"||!l)return c(h);try{return c(h)}catch{return!1}};e=function(u){var p=u!==null&&typeof u=="object",g=r.call(u)==="[object Function]",_=n(u),w=p&&r.call(u)==="[object String]",x=[];if(!p&&!g&&!_)throw new TypeError("Object.keys called on a non-object");var S=o&&g;if(w&&u.length>0&&!t.call(u,0))for(var v=0;v<u.length;++v)x.push(String(v));if(_&&u.length>0)for(var A=0;A<u.length;++A)x.push(String(A));else for(var T in u)!(S&&T==="prototype")&&t.call(u,T)&&x.push(String(T));if(a)for(var b=d(u),E=0;E<s.length;++E)!(b&&s[E]==="constructor")&&t.call(u,s[E])&&x.push(s[E]);return x}}return Wr=e,Wr}var Vr,ha;function ac(){if(ha)return Vr;ha=1;var e=Array.prototype.slice,t=la(),r=Object.keys,n=r?function(o){return r(o)}:ic(),i=Object.keys;return n.shim=function(){if(Object.keys){var o=function(){var s=Object.keys(arguments);return s&&s.length===arguments.length}(1,2);o||(Object.keys=function(c){return t(c)?i(e.call(c)):i(c)})}else Object.keys=n;return Object.keys||n},Vr=n,Vr}var Gr={exports:{}},Yr,da;function pa(){return da||(da=1,Yr=Object),Yr}var Jr,ya;function oc(){return ya||(ya=1,Jr=Error),Jr}var Xr,ga;function sc(){return ga||(ga=1,Xr=EvalError),Xr}var Qr,va;function fc(){return va||(va=1,Qr=RangeError),Qr}var en,_a;function cc(){return _a||(_a=1,en=ReferenceError),en}var tn,wa;function ba(){return wa||(wa=1,tn=SyntaxError),tn}var rn,ma;function er(){return ma||(ma=1,rn=TypeError),rn}var nn,Ea;function lc(){return Ea||(Ea=1,nn=URIError),nn}var an,xa;function uc(){return xa||(xa=1,an=Math.abs),an}var on,Sa;function hc(){return Sa||(Sa=1,on=Math.floor),on}var sn,Aa;function dc(){return Aa||(Aa=1,sn=Math.max),sn}var fn,ka;function pc(){return ka||(ka=1,fn=Math.min),fn}var cn,Ra;function yc(){return Ra||(Ra=1,cn=Math.pow),cn}var ln,Oa;function gc(){return Oa||(Oa=1,ln=Math.round),ln}var un,Ta;function vc(){return Ta||(Ta=1,un=Number.isNaN||function(t){return t!==t}),un}var hn,Pa;function _c(){if(Pa)return hn;Pa=1;var e=vc();return hn=function(r){return e(r)||r===0?r:r<0?-1:1},hn}var dn,Ia;function wc(){return Ia||(Ia=1,dn=Object.getOwnPropertyDescriptor),dn}var pn,Ca;function tr(){if(Ca)return pn;Ca=1;var e=wc();if(e)try{e([],"length")}catch{e=null}return pn=e,pn}var yn,Da;function rr(){if(Da)return yn;Da=1;var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return yn=e,yn}var gn,Fa;function bc(){return Fa||(Fa=1,gn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var a in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(t,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0}),gn}var vn,Ma;function mc(){if(Ma)return vn;Ma=1;var e=typeof Symbol<"u"&&Symbol,t=bc();return vn=function(){return typeof e!="function"||typeof Symbol!="function"||typeof e("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},vn}var _n,La;function ja(){return La||(La=1,_n=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),_n}var wn,Na;function Ba(){if(Na)return wn;Na=1;var e=pa();return wn=e.getPrototypeOf||null,wn}var bn,Ua;function Ec(){if(Ua)return bn;Ua=1;var e="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,n="[object Function]",i=function(c,f){for(var l=[],d=0;d<c.length;d+=1)l[d]=c[d];for(var h=0;h<f.length;h+=1)l[h+c.length]=f[h];return l},a=function(c,f){for(var l=[],d=f,h=0;d<c.length;d+=1,h+=1)l[h]=c[d];return l},o=function(s,c){for(var f="",l=0;l<s.length;l+=1)f+=s[l],l+1<s.length&&(f+=c);return f};return bn=function(c){var f=this;if(typeof f!="function"||t.apply(f)!==n)throw new TypeError(e+f);for(var l=a(arguments,1),d,h=function(){if(this instanceof d){var w=f.apply(this,i(l,arguments));return Object(w)===w?w:this}return f.apply(c,i(l,arguments))},u=r(0,f.length-l.length),p=[],g=0;g<u;g++)p[g]="$"+g;if(d=Function("binder","return function ("+o(p,",")+"){ return binder.apply(this,arguments); }")(h),f.prototype){var _=function(){};_.prototype=f.prototype,d.prototype=new _,_.prototype=null}return d},bn}var mn,$a;function kt(){if($a)return mn;$a=1;var e=Ec();return mn=Function.prototype.bind||e,mn}var En,za;function xn(){return za||(za=1,En=Function.prototype.call),En}var Sn,Za;function An(){return Za||(Za=1,Sn=Function.prototype.apply),Sn}var kn,qa;function xc(){return qa||(qa=1,kn=typeof Reflect<"u"&&Reflect&&Reflect.apply),kn}var Rn,Ha;function Ka(){if(Ha)return Rn;Ha=1;var e=kt(),t=An(),r=xn(),n=xc();return Rn=n||e.call(r,t),Rn}var On,Wa;function Tn(){if(Wa)return On;Wa=1;var e=kt(),t=er(),r=xn(),n=Ka();return On=function(a){if(a.length<1||typeof a[0]!="function")throw new t("a function is required");return n(e,r,a)},On}var Pn,Va;function Sc(){if(Va)return Pn;Va=1;var e=Tn(),t=tr(),r;try{r=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var n=!!r&&t&&t(Object.prototype,"__proto__"),i=Object,a=i.getPrototypeOf;return Pn=n&&typeof n.get=="function"?e([n.get]):typeof a=="function"?function(s){return a(s==null?s:i(s))}:!1,Pn}var In,Ga;function Ac(){if(Ga)return In;Ga=1;var e=ja(),t=Ba(),r=Sc();return In=e?function(i){return e(i)}:t?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return t(i)}:r?function(i){return r(i)}:null,In}var Cn,Ya;function kc(){if(Ya)return Cn;Ya=1;var e=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=kt();return Cn=r.call(e,t),Cn}var Dn,Ja;function Xa(){if(Ja)return Dn;Ja=1;var e,t=pa(),r=oc(),n=sc(),i=fc(),a=cc(),o=ba(),s=er(),c=lc(),f=uc(),l=hc(),d=dc(),h=pc(),u=yc(),p=gc(),g=_c(),_=Function,w=function(ve){try{return _('"use strict"; return ('+ve+").constructor;")()}catch{}},x=tr(),S=rr(),v=function(){throw new s},A=x?function(){try{return arguments.callee,v}catch{try{return x(arguments,"callee").get}catch{return v}}}():v,T=mc()(),b=Ac(),E=Ba(),O=ja(),k=An(),F=xn(),K={},G=typeof Uint8Array>"u"||!b?e:b(Uint8Array),oe={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?e:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?e:ArrayBuffer,"%ArrayIteratorPrototype%":T&&b?b([][Symbol.iterator]()):e,"%AsyncFromSyncIteratorPrototype%":e,"%AsyncFunction%":K,"%AsyncGenerator%":K,"%AsyncGeneratorFunction%":K,"%AsyncIteratorPrototype%":K,"%Atomics%":typeof Atomics>"u"?e:Atomics,"%BigInt%":typeof BigInt>"u"?e:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?e:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?e:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?e:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":typeof Float16Array>"u"?e:Float16Array,"%Float32Array%":typeof Float32Array>"u"?e:Float32Array,"%Float64Array%":typeof Float64Array>"u"?e:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?e:FinalizationRegistry,"%Function%":_,"%GeneratorFunction%":K,"%Int8Array%":typeof Int8Array>"u"?e:Int8Array,"%Int16Array%":typeof Int16Array>"u"?e:Int16Array,"%Int32Array%":typeof Int32Array>"u"?e:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":T&&b?b(b([][Symbol.iterator]())):e,"%JSON%":typeof JSON=="object"?JSON:e,"%Map%":typeof Map>"u"?e:Map,"%MapIteratorPrototype%":typeof Map>"u"||!T||!b?e:b(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":t,"%Object.getOwnPropertyDescriptor%":x,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?e:Promise,"%Proxy%":typeof Proxy>"u"?e:Proxy,"%RangeError%":i,"%ReferenceError%":a,"%Reflect%":typeof Reflect>"u"?e:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?e:Set,"%SetIteratorPrototype%":typeof Set>"u"||!T||!b?e:b(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?e:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":T&&b?b(""[Symbol.iterator]()):e,"%Symbol%":T?Symbol:e,"%SyntaxError%":o,"%ThrowTypeError%":A,"%TypedArray%":G,"%TypeError%":s,"%Uint8Array%":typeof Uint8Array>"u"?e:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?e:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?e:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?e:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap>"u"?e:WeakMap,"%WeakRef%":typeof WeakRef>"u"?e:WeakRef,"%WeakSet%":typeof WeakSet>"u"?e:WeakSet,"%Function.prototype.call%":F,"%Function.prototype.apply%":k,"%Object.defineProperty%":S,"%Object.getPrototypeOf%":E,"%Math.abs%":f,"%Math.floor%":l,"%Math.max%":d,"%Math.min%":h,"%Math.pow%":u,"%Math.round%":p,"%Math.sign%":g,"%Reflect.getPrototypeOf%":O};if(b)try{null.error}catch(ve){var st=b(b(ve));oe["%Error.prototype%"]=st}var Q=function ve(B){var V;if(B==="%AsyncFunction%")V=w("async function () {}");else if(B==="%GeneratorFunction%")V=w("function* () {}");else if(B==="%AsyncGeneratorFunction%")V=w("async function* () {}");else if(B==="%AsyncGenerator%"){var U=ve("%AsyncGeneratorFunction%");U&&(V=U.prototype)}else if(B==="%AsyncIteratorPrototype%"){var Y=ve("%AsyncGenerator%");Y&&b&&(V=b(Y.prototype))}return oe[B]=V,V},ge={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ft=kt(),ct=kc(),Vt=ft.call(F,Array.prototype.concat),up=ft.call(k,Array.prototype.splice),Cf=ft.call(F,String.prototype.replace),Ir=ft.call(F,String.prototype.slice),hp=ft.call(F,RegExp.prototype.exec),dp=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,pp=/\\(\\)?/g,yp=function(B){var V=Ir(B,0,1),U=Ir(B,-1);if(V==="%"&&U!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(U==="%"&&V!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var Y=[];return Cf(B,dp,function(_e,St,ee,Cr){Y[Y.length]=ee?Cf(Cr,pp,"$1"):St||_e}),Y},gp=function(B,V){var U=B,Y;if(ct(ge,U)&&(Y=ge[U],U="%"+Y[0]+"%"),ct(oe,U)){var _e=oe[U];if(_e===K&&(_e=Q(U)),typeof _e>"u"&&!V)throw new s("intrinsic "+B+" exists, but is not available. Please file an issue!");return{alias:Y,name:U,value:_e}}throw new o("intrinsic "+B+" does not exist!")};return Dn=function(B,V){if(typeof B!="string"||B.length===0)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof V!="boolean")throw new s('"allowMissing" argument must be a boolean');if(hp(/^%?[^%]*%?$/,B)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var U=yp(B),Y=U.length>0?U[0]:"",_e=gp("%"+Y+"%",V),St=_e.name,ee=_e.value,Cr=!1,Li=_e.alias;Li&&(Y=Li[0],up(U,Vt([0,1],Li)));for(var Dr=1,Gt=!0;Dr<U.length;Dr+=1){var Oe=U[Dr],Fr=Ir(Oe,0,1),Mr=Ir(Oe,-1);if((Fr==='"'||Fr==="'"||Fr==="`"||Mr==='"'||Mr==="'"||Mr==="`")&&Fr!==Mr)throw new o("property names with quotes must have matching quotes");if((Oe==="constructor"||!Gt)&&(Cr=!0),Y+="."+Oe,St="%"+Y+"%",ct(oe,St))ee=oe[St];else if(ee!=null){if(!(Oe in ee)){if(!V)throw new s("base intrinsic for "+B+" exists, but the property is not available.");return}if(x&&Dr+1>=U.length){var Lr=x(ee,Oe);Gt=!!Lr,Gt&&"get"in Lr&&!("originalValue"in Lr.get)?ee=Lr.get:ee=ee[Oe]}else Gt=ct(ee,Oe),ee=ee[Oe];Gt&&!Cr&&(oe[St]=ee)}}return ee},Dn}var Fn,Qa;function Rc(){if(Qa)return Fn;Qa=1;var e=rr(),t=ba(),r=er(),n=tr();return Fn=function(a,o,s){if(!a||typeof a!="object"&&typeof a!="function")throw new r("`obj` must be an object or a function`");if(typeof o!="string"&&typeof o!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var c=arguments.length>3?arguments[3]:null,f=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,d=arguments.length>6?arguments[6]:!1,h=!!n&&n(a,o);if(e)e(a,o,{configurable:l===null&&h?h.configurable:!l,enumerable:c===null&&h?h.enumerable:!c,value:s,writable:f===null&&h?h.writable:!f});else if(d||!c&&!f&&!l)a[o]=s;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Fn}var Mn,eo;function Oc(){if(eo)return Mn;eo=1;var e=rr(),t=function(){return!!e};return t.hasArrayLengthDefineBug=function(){if(!e)return null;try{return e([],"length",{value:1}).length!==1}catch{return!0}},Mn=t,Mn}var Ln,to;function Tc(){if(to)return Ln;to=1;var e=Xa(),t=Rc(),r=Oc()(),n=tr(),i=er(),a=e("%Math.floor%");return Ln=function(s,c){if(typeof s!="function")throw new i("`fn` is not a function");if(typeof c!="number"||c<0||c>4294967295||a(c)!==c)throw new i("`length` must be a positive 32-bit integer");var f=arguments.length>2&&!!arguments[2],l=!0,d=!0;if("length"in s&&n){var h=n(s,"length");h&&!h.configurable&&(l=!1),h&&!h.writable&&(d=!1)}return(l||d||!f)&&(r?t(s,"length",c,!0,!0):t(s,"length",c)),s},Ln}var jn,ro;function Pc(){if(ro)return jn;ro=1;var e=kt(),t=An(),r=Ka();return jn=function(){return r(e,t,arguments)},jn}var no;function Ic(){return no||(no=1,function(e){var t=Tc(),r=rr(),n=Tn(),i=Pc();e.exports=function(o){var s=n(arguments),c=o.length-(arguments.length-1);return t(s,1+(c>0?c:0),!0)},r?r(e.exports,"apply",{value:i}):e.exports.apply=i}(Gr)),Gr.exports}var Nn,io;function Cc(){if(io)return Nn;io=1;var e=Xa(),t=Tn(),r=t([e("%String.prototype.indexOf%")]);return Nn=function(i,a){var o=e(i,!!a);return typeof o=="function"&&r(i,".prototype.")>-1?t([o]):o},Nn}var Bn,ao;function Dc(){if(ao)return Bn;ao=1;var e=(typeof JSON<"u"?JSON:rc()).stringify,t=nc(),r=ac(),n=Ic(),i=Cc(),a=i("Array.prototype.join"),o=i("Array.prototype.indexOf"),s=i("Array.prototype.splice"),c=i("Array.prototype.sort"),f=function(h,u){for(var p="",g=0;g<h;g+=1)p+=u;return p},l=function(d,h,u){return u};return Bn=function(h){var u=arguments.length>1?arguments[1]:void 0,p=u&&u.space||"";typeof p=="number"&&(p=f(p," "));var g=!!u&&typeof u.cycles=="boolean"&&u.cycles,_=u&&u.replacer?n(u.replacer):l;if(u&&typeof u.collapseEmpty<"u"&&typeof u.collapseEmpty!="boolean")throw new TypeError("`collapseEmpty` must be a boolean, if provided");var w=!!u&&u.collapseEmpty,x=typeof u=="function"?u:u&&u.cmp,S=x&&function(A){var T=x.length>2&&function(E){return A[E]};return function(b,E){return x({key:b,value:A[b]},{key:E,value:A[E]},T?{__proto__:null,get:T}:void 0)}},v=[];return function A(T,b,E,O){var k=p?`
|
|
15
|
+
`+f(O,p):"",F=p?": ":":";if(E&&E.toJSON&&typeof E.toJSON=="function"&&(E=E.toJSON()),E=_(T,b,E),E!==void 0){if(typeof E!="object"||E===null)return e(E);var K=function(ct,Vt){return w&&ct.length===0?Vt:(Vt==="[]"?"[":"{")+a(ct,",")+k+(Vt==="[]"?"]":"}")};if(t(E)){for(var Q=[],G=0;G<E.length;G++){var oe=A(E,G,E[G],O+1)||e(null);Q[Q.length]=k+p+oe}return K(Q,"[]")}if(o(v,E)!==-1){if(g)return e("__cycle__");throw new TypeError("Converting circular structure to JSON")}else v[v.length]=E;for(var st=c(r(E),S&&S(E)),Q=[],G=0;G<st.length;G++){var b=st[G],ge=A(E,b,E[b],O+1);if(ge){var ft=e(b)+F+ge;Q[Q.length]=k+p+ft}}return s(v,o(v,E),1),K(Q,"{}")}}({"":h},"",h,0)},Bn}var Fc=Dc(),oo=Qf(Fc);async function Un(e,t,r){if(!this.passphrase)return t.push({actual:e,type:"encryptionKeyMissing"}),e;try{return await zr(String(e),this.passphrase)}catch(n){t.push({actual:e,type:"encryptionProblem",error:n})}return e}class so extends Df{constructor({options:t,passphrase:r,autoEncrypt:n=!0}={}){super(M.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=n,this.alias("secret",{type:"string",custom:this.autoEncrypt?Un: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?Un:void 0}),this.alias("secretNumber",{type:"number",custom:this.autoEncrypt?Un:void 0})}}const fo=new Proxy(so,{instance:null,construct(e,t){return this.instance||(this.instance=new e(...t)),this.instance}}),co={trim:e=>e.trim(),encrypt:(e,{passphrase:t})=>zr(e,t),decrypt:(e,{passphrase:t})=>na(e,t),toString:e=>String(e),fromArray:(e,{separator:t})=>e==null||!Array.isArray(e)?e:e.length===0?"[]":e.map(n=>typeof n=="string"?n.replace(/\\/g,"\\\\").replace(new RegExp(`\\${t}`,"g"),`\\${t}`):String(n)).join(t),toArray:(e,{separator:t})=>{if(e==null)return e;if(e==="[]")return[];if(e==="")return[];const r=[];let n="",i=0;const a=String(e);for(;i<a.length;)a[i]==="\\"&&i+1<a.length?a[i+1]===t?(n+=t,i+=2):a[i+1]==="\\"?(n+="\\",i+=2):(n+=a[i],i++):a[i]===t?(r.push(n),n="",i++):(n+=a[i],i++);return r.push(n),r},toJSON:e=>JSON.stringify(e),fromJSON:e=>JSON.parse(e),toNumber:e=>M.isString(e)?e.includes(".")?parseFloat(e):parseInt(e):e,toBool:e=>[!0,1,"true","1","yes","y"].includes(e),fromBool:e=>[!0,1,"true","1","yes","y"].includes(e)?"1":"0"};class nr{constructor(t){const{map:r,name:n,attributes:i,passphrase:a,version:o=1,options:s={}}=t;if(this.name=n,this.version=o,this.attributes=i||{},this.passphrase=a??"secret",this.options=M.merge({},this.defaultOptions(),s),this.validator=new fo({autoEncrypt:!1}).compile(M.merge({$$async:!0},M.cloneDeep(this.attributes))),this.options.generateAutoHooks&&this.generateAutoHooks(),!M.isEmpty(r))this.map=r,this.reversedMap=M.invert(r);else{const c=Yt.flatten(this.attributes,{safe:!0}),f=Object.keys(c).filter(h=>!h.includes("$$")),l=this.extractObjectKeys(this.attributes),d=[...new Set([...f,...l])];this.reversedMap={...d},this.map=M.invert(this.reversedMap)}}defaultOptions(){return{autoEncrypt:!0,autoDecrypt:!0,arraySeparator:"|",generateAutoHooks:!0,hooks:{beforeMap:{},afterMap:{},beforeUnmap:{},afterUnmap:{}}}}addHook(t,r,n){this.options.hooks[t][r]||(this.options.hooks[t][r]=[]),this.options.hooks[t][r]=M.uniq([...this.options.hooks[t][r],n])}extractObjectKeys(t,r=""){const n=[];for(const[i,a]of Object.entries(t)){if(i.startsWith("$$"))continue;const o=r?`${r}.${i}`:i;typeof a=="object"&&a!==null&&!Array.isArray(a)&&(n.push(o),a.$$type==="object"&&n.push(...this.extractObjectKeys(a,o)))}return n}generateAutoHooks(){const t=Yt.flatten(M.cloneDeep(this.attributes),{safe:!0});for(const[r,n]of Object.entries(t))n.includes("array")?(this.addHook("beforeMap",r,"fromArray"),this.addHook("afterUnmap",r,"toArray")):(n.includes("secret")&&(this.options.autoEncrypt&&this.addHook("beforeMap",r,"encrypt"),this.options.autoDecrypt&&this.addHook("afterUnmap",r,"decrypt")),n.includes("number")&&(this.addHook("beforeMap",r,"toString"),this.addHook("afterUnmap",r,"toNumber")),n.includes("boolean")&&(this.addHook("beforeMap",r,"fromBool"),this.addHook("afterUnmap",r,"toBool")))}static import(t){let{map:r,name:n,options:i,version:a,attributes:o}=M.isString(t)?JSON.parse(t):t;return new nr({map:r,name:n,options:i,version:a,attributes:o})}export(){const t={version:this.version,name:this.name,options:this.options,attributes:M.cloneDeep(this.attributes),map:this.map};for(const[r,n]of Object.entries(this.attributes))typeof n!="string"?t.attributes[r]=JSON.stringify(n):t.attributes[r]=n;return t}async applyHooksActions(t,r){for(const[n,i]of Object.entries(this.options.hooks[r]))for(const a of i){const o=M.get(t,n);o!==void 0&&typeof co[a]=="function"&&M.set(t,n,await co[a](o,{passphrase:this.passphrase,separator:this.options.arraySeparator}))}}async validate(t,{mutateOriginal:r=!1}={}){let n=r?t:M.cloneDeep(t);return await this.validator(n)}async mapper(t){const r=Yt.flatten(M.cloneDeep(t),{safe:!0});await this.applyHooksActions(r,"beforeMap");const n={_v:this.version+""};for(const[i,a]of Object.entries(r))n[this.map[i]]=a;return await this.applyHooksActions(n,"afterMap"),n}async unmapper(t){const r=M.cloneDeep(t);delete r._v,await this.applyHooksActions(r,"beforeUnmap");const n={};for(const[i,a]of Object.entries(r))n[this.reversedMap[i]]=a;return await this.applyHooksActions(n,"afterUnmap"),Yt.unflatten(n)}}var ut=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},he=[],ne=[],Mc=typeof Uint8Array<"u"?Uint8Array:Array,$n=!1;function lo(){$n=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)he[t]=e[t],ne[e.charCodeAt(t)]=t;ne[45]=62,ne[95]=63}function Lc(e){$n||lo();var t,r,n,i,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 Mc(s*3/4-a),n=a>0?s-4:s;var c=0;for(t=0,r=0;t<n;t+=4,r+=3)i=ne[e.charCodeAt(t)]<<18|ne[e.charCodeAt(t+1)]<<12|ne[e.charCodeAt(t+2)]<<6|ne[e.charCodeAt(t+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return a===2?(i=ne[e.charCodeAt(t)]<<2|ne[e.charCodeAt(t+1)]>>4,o[c++]=i&255):a===1&&(i=ne[e.charCodeAt(t)]<<10|ne[e.charCodeAt(t+1)]<<4|ne[e.charCodeAt(t+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function jc(e){return he[e>>18&63]+he[e>>12&63]+he[e>>6&63]+he[e&63]}function Nc(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16)+(e[a+1]<<8)+e[a+2],i.push(jc(n));return i.join("")}function uo(e){$n||lo();for(var t,r=e.length,n=r%3,i="",a=[],o=16383,s=0,c=r-n;s<c;s+=o)a.push(Nc(e,s,s+o>c?c:s+o));return n===1?(t=e[r-1],i+=he[t>>2],i+=he[t<<4&63],i+="=="):n===2&&(t=(e[r-2]<<8)+e[r-1],i+=he[t>>10],i+=he[t>>4&63],i+=he[t<<2&63],i+="="),a.push(i),a.join("")}function ir(e,t,r,n,i){var a,o,s=i*8-n-1,c=(1<<s)-1,f=c>>1,l=-7,d=r?i-1:0,h=r?-1:1,u=e[t+d];for(d+=h,a=u&(1<<-l)-1,u>>=-l,l+=s;l>0;a=a*256+e[t+d],d+=h,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=n;l>0;o=o*256+e[t+d],d+=h,l-=8);if(a===0)a=1-f;else{if(a===c)return o?NaN:(u?-1:1)*(1/0);o=o+Math.pow(2,n),a=a-f}return(u?-1:1)*o*Math.pow(2,a-n)}function ho(e,t,r,n,i,a){var o,s,c,f=a*8-i-1,l=(1<<f)-1,d=l>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,u=n?0:a-1,p=n?1:-1,g=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*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?t+=h/c:t+=h*Math.pow(2,1-d),t*c>=2&&(o++,c/=2),o+d>=l?(s=0,o=l):o+d>=1?(s=(t*c-1)*Math.pow(2,i),o=o+d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;e[r+u]=s&255,u+=p,s/=256,i-=8);for(o=o<<i|s,f+=i;f>0;e[r+u]=o&255,u+=p,o/=256,f-=8);e[r+u-p]|=g*128}var Bc={}.toString,po=Array.isArray||function(e){return Bc.call(e)=="[object Array]"};/*!
|
|
8
16
|
* The buffer module from node.js, for the browser.
|
|
9
17
|
*
|
|
10
18
|
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
11
19
|
* @license MIT
|
|
12
|
-
*/var go=50;c.TYPED_ARRAY_SUPPORT=qe.TYPED_ARRAY_SUPPORT!==void 0?qe.TYPED_ARRAY_SUPPORT:!0,Lt();function Lt(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function oe(e,t){if(Lt()<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 pr(this,e)}return Fi(this,e,t,r)}c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e};function Fi(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?yo(e,t,r,i):typeof t=="string"?mo(e,t,r):bo(e,t)}c.from=function(e,t,r){return Fi(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 Ni(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 vo(e,t,r,i){return Ni(t),t<=0?oe(e,t):r!==void 0?typeof i=="string"?oe(e,t).fill(r,i):oe(e,t).fill(r):oe(e,t)}c.alloc=function(e,t,r){return vo(null,e,t,r)};function pr(e,t){if(Ni(t),e=oe(e,t<0?0:wr(t)|0),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}c.allocUnsafe=function(e){return pr(null,e)},c.allocUnsafeSlow=function(e){return pr(null,e)};function mo(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=Pi(t,r)|0;e=oe(e,i);var n=e.write(t,r);return n!==i&&(e=e.slice(0,n)),e}function _r(e,t){var r=t.length<0?0:wr(t.length)|0;e=oe(e,r);for(var i=0;i<r;i+=1)e[i]=t[i]&255;return e}function yo(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=_r(e,t),e}function bo(e,t){if(re(t)){var r=wr(t.length)|0;return e=oe(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"||Bo(t.length)?oe(e,0):_r(e,t);if(t.type==="Buffer"&&Di(t.data))return _r(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function wr(e){if(e>=Lt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Lt().toString(16)+" bytes");return e|0}c.isBuffer=Zo;function re(e){return!!(e!=null&&e._isBuffer)}c.compare=function(t,r){if(!re(t)||!re(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(!Di(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(!re(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,a),a+=o.length}return n};function Pi(e,t){if(re(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 Ot(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Wi(e).length;default:if(i)return Ot(e).length;t=(""+t).toLowerCase(),i=!0}}c.byteLength=Pi;function xo(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 Zi(this,t,r);case"ascii":return Co(this,t,r);case"latin1":case"binary":return Io(this,t,r);case"base64":return To(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mo(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?Zi(this,0,t):xo.apply(this,arguments)},c.prototype.equals=function(t){if(!re(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=go;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(!re(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 zi(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)),re(t))return t.length===0?-1:Ui(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):Ui(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function Ui(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 zi(this,t,r,i,!0)},c.prototype.lastIndexOf=function(t,r,i){return zi(this,t,r,i,!1)};function Eo(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 ko(e,t,r,i){return Mt(Ot(t,e.length-r),e,r,i)}function Bi(e,t,r,i){return Mt(zo(t),e,r,i)}function So(e,t,r,i){return Bi(e,t,r,i)}function Ro(e,t,r,i){return Mt(Wi(t),e,r,i)}function Ao(e,t,r,i){return Mt(Uo(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 Eo(this,t,r,i);case"utf8":case"utf-8":return ko(this,t,r,i);case"ascii":return Bi(this,t,r,i);case"latin1":case"binary":return So(this,t,r,i);case"base64":return Ro(this,t,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ao(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 To(e,t,r){return t===0&&r===e.length?Oi(e):Oi(e.slice(t,r))}function Zi(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 Lo(i)}var ji=4096;function Lo(e){var t=e.length;if(t<=ji)return String.fromCharCode.apply(String,e);for(var r="",i=0;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=ji));return r}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]&127);return i}function Io(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+=Po(e[a]);return n}function Mo(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),Tt(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,r){return r||U(t,4,this.length),Tt(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,r){return r||U(t,8,this.length),Tt(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,r){return r||U(t,8,this.length),Tt(this,t,!1,52,8)};function K(e,t,r,i,n,a){if(!re(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;K(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;K(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||K(this,t,r,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};function Ct(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||K(this,t,r,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):Ct(this,t,r,!0),r+2},c.prototype.writeUInt16BE=function(t,r,i){return t=+t,r=r|0,i||K(this,t,r,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):Ct(this,t,r,!1),r+2};function It(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||K(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):It(this,t,r,!0),r+4},c.prototype.writeUInt32BE=function(t,r,i){return t=+t,r=r|0,i||K(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):It(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);K(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);K(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||K(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||K(this,t,r,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):Ct(this,t,r,!0),r+2},c.prototype.writeInt16BE=function(t,r,i){return t=+t,r=r|0,i||K(this,t,r,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):Ct(this,t,r,!1),r+2},c.prototype.writeInt32LE=function(t,r,i){return t=+t,r=r|0,i||K(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):It(this,t,r,!0),r+4},c.prototype.writeInt32BE=function(t,r,i){return t=+t,r=r|0,i||K(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):It(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 Hi(e,t,r,i,n){return n||$i(e,t,r,4),Mi(e,t,r,i,23,4),r+4}c.prototype.writeFloatLE=function(t,r,i){return Hi(this,t,r,!0,i)},c.prototype.writeFloatBE=function(t,r,i){return Hi(this,t,r,!1,i)};function Ki(e,t,r,i,n){return n||$i(e,t,r,8),Mi(e,t,r,i,52,8),r+8}c.prototype.writeDoubleLE=function(t,r,i){return Ki(this,t,r,!0,i)},c.prototype.writeDoubleBE=function(t,r,i){return Ki(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=re(t)?t:Ot(new c(t,n).toString()),h=s.length;for(o=0;o<i-r;++o)this[o+r]=s[o%h]}return this};var Do=/[^+\/0-9A-Za-z-_]/g;function Fo(e){if(e=No(e).replace(Do,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function No(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Po(e){return e<16?"0"+e.toString(16):e.toString(16)}function Ot(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 zo(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Uo(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 Wi(e){return uo(Fo(e))}function Mt(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 Bo(e){return e!==e}function Zo(e){return e!=null&&(!!e._isBuffer||Yi(e)||jo(e))}function Yi(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function jo(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Yi(e.slice(0,0))}function qi(){throw new Error("setTimeout has not been defined")}function Gi(){throw new Error("clearTimeout has not been defined")}var we=qi,ge=Gi;typeof qe.setTimeout=="function"&&(we=setTimeout),typeof qe.clearTimeout=="function"&&(ge=clearTimeout);function Vi(e){if(we===setTimeout)return setTimeout(e,0);if((we===qi||!we)&&setTimeout)return we=setTimeout,setTimeout(e,0);try{return we(e,0)}catch{try{return we.call(null,e,0)}catch{return we.call(this,e,0)}}}function $o(e){if(ge===clearTimeout)return clearTimeout(e);if((ge===Gi||!ge)&&clearTimeout)return ge=clearTimeout,clearTimeout(e);try{return ge(e)}catch{try{return ge.call(null,e)}catch{return ge.call(this,e)}}}var se=[],Ge=!1,Le,Dt=-1;function Ho(){!Ge||!Le||(Ge=!1,Le.length?se=Le.concat(se):Dt=-1,se.length&&Xi())}function Xi(){if(!Ge){var e=Vi(Ho);Ge=!0;for(var t=se.length;t;){for(Le=se,se=[];++Dt<t;)Le&&Le[Dt].run();Dt=-1,t=se.length}Le=null,Ge=!1,$o(e)}}function q(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];se.push(new Ji(e,t)),se.length===1&&!Ge&&Vi(Xi)}function Ji(e,t){this.fun=e,this.array=t}Ji.prototype.run=function(){this.fun.apply(null,this.array)};var Ko="browser",Wo="browser",Yo=!0,qo={},Go=[],Vo="",Xo={},Jo={},Qo={};function Ce(){}var es=Ce,ts=Ce,rs=Ce,is=Ce,ns=Ce,as=Ce,os=Ce;function ss(e){throw new Error("process.binding is not supported")}function fs(){return"/"}function ls(e){throw new Error("process.chdir is not supported")}function hs(){return 0}var Ve=qe.performance||{},cs=Ve.now||Ve.mozNow||Ve.msNow||Ve.oNow||Ve.webkitNow||function(){return new Date().getTime()};function us(e){var t=cs.call(Ve)*.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 ds=new Date;function ps(){var e=new Date,t=e-ds;return t/1e3}var fe={nextTick:q,title:Ko,browser:Yo,env:qo,argv:Go,version:Vo,versions:Xo,on:es,addListener:ts,once:rs,off:is,removeListener:ns,removeAllListeners:as,emit:os,binding:ss,cwd:fs,chdir:ls,umask:hs,hrtime:us,platform:Wo,release:Jo,config:Qo,uptime:ps},$;typeof Object.create=="function"?$=function(t,r){t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:$=function(t,r){t.super_=r;var i=function(){};i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t};var _s=/%[sdj%]/g;function ws(e){if(!br(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(ve(arguments[r]));return t.join(" ")}for(var r=1,i=arguments,n=i.length,a=String(e).replace(_s,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])yr(o)||!ot(o)?a+=" "+o:a+=" "+ve(o);return a}function Qi(e,t){if(me(qe.process))return function(){return Qi(e,t).apply(this,arguments)};if(fe.noDeprecation===!0)return e;var r=!1;function i(){if(!r){if(fe.throwDeprecation)throw new Error(t);fe.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return i}var Ft={},gr;function gs(e){if(me(gr)&&(gr=fe.env.NODE_DEBUG||""),e=e.toUpperCase(),!Ft[e])if(new RegExp("\\b"+e+"\\b","i").test(gr)){var t=0;Ft[e]=function(){var r=ws.apply(null,arguments);console.error("%s %d: %s",e,t,r)}}else Ft[e]=function(){};return Ft[e]}function ve(e,t){var r={seen:[],stylize:ms};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),en(t)?r.showHidden=t:t&&Rs(r,t),me(r.showHidden)&&(r.showHidden=!1),me(r.depth)&&(r.depth=2),me(r.colors)&&(r.colors=!1),me(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=vs),Nt(r,e,r.depth)}ve.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]},ve.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function vs(e,t){var r=ve.styles[t];return r?"\x1B["+ve.colors[r][0]+"m"+e+"\x1B["+ve.colors[r][1]+"m":e}function ms(e,t){return e}function ys(e){var t={};return e.forEach(function(r,i){t[r]=!0}),t}function Nt(e,t,r){if(e.customInspect&&t&&kr(t.inspect)&&t.inspect!==ve&&!(t.constructor&&t.constructor.prototype===t)){var i=t.inspect(r,e);return br(i)||(i=Nt(e,i,r)),i}var n=bs(e,t);if(n)return n;var a=Object.keys(t),o=ys(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),Er(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return vr(t);if(a.length===0){if(kr(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(xr(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(tn(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Er(t))return vr(t)}var h="",f=!1,l=["{","}"];if(ks(t)&&(f=!0,l=["[","]"]),kr(t)){var d=t.name?": "+t.name:"";h=" [Function"+d+"]"}if(xr(t)&&(h=" "+RegExp.prototype.toString.call(t)),tn(t)&&(h=" "+Date.prototype.toUTCString.call(t)),Er(t)&&(h=" "+vr(t)),a.length===0&&(!f||t.length==0))return l[0]+h+l[1];if(r<0)return xr(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var p;return f?p=xs(e,t,r,o,a):p=a.map(function(u){return mr(e,t,r,o,u,f)}),e.seen.pop(),Es(p,h,l)}function bs(e,t){if(me(t))return e.stylize("undefined","undefined");if(br(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(Ss(t))return e.stylize(""+t,"number");if(en(t))return e.stylize(""+t,"boolean");if(yr(t))return e.stylize("null","null")}function vr(e){return"["+Error.prototype.toString.call(e)+"]"}function xs(e,t,r,i,n){for(var a=[],o=0,s=t.length;o<s;++o)rn(t,String(o))?a.push(mr(e,t,r,i,String(o),!0)):a.push("");return n.forEach(function(h){h.match(/^\d+$/)||a.push(mr(e,t,r,i,h,!0))}),a}function mr(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")),rn(i,n)||(o="["+n+"]"),s||(e.seen.indexOf(h.value)<0?(yr(r)?s=Nt(e,h.value,null):s=Nt(e,h.value,r-1),s.indexOf(`
|
|
20
|
+
*/var Uc=50;y.TYPED_ARRAY_SUPPORT=ut.TYPED_ARRAY_SUPPORT!==void 0?ut.TYPED_ARRAY_SUPPORT:!0,ar();function ar(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function be(e,t){if(ar()<t)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=y.prototype):(e===null&&(e=new y(t)),e.length=t),e}function y(e,t,r){if(!y.TYPED_ARRAY_SUPPORT&&!(this instanceof y))return new y(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 zn(this,e)}return yo(this,e,t,r)}y.poolSize=8192,y._augment=function(e){return e.__proto__=y.prototype,e};function yo(e,t,r,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?Zc(e,t,r,n):typeof t=="string"?zc(e,t,r):qc(e,t)}y.from=function(e,t,r){return yo(null,e,t,r)},y.TYPED_ARRAY_SUPPORT&&(y.prototype.__proto__=Uint8Array.prototype,y.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&y[Symbol.species]);function go(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 $c(e,t,r,n){return go(t),t<=0?be(e,t):r!==void 0?typeof n=="string"?be(e,t).fill(r,n):be(e,t).fill(r):be(e,t)}y.alloc=function(e,t,r){return $c(null,e,t,r)};function zn(e,t){if(go(t),e=be(e,t<0?0:qn(t)|0),!y.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}y.allocUnsafe=function(e){return zn(null,e)},y.allocUnsafeSlow=function(e){return zn(null,e)};function zc(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!y.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=vo(t,r)|0;e=be(e,n);var i=e.write(t,r);return i!==n&&(e=e.slice(0,i)),e}function Zn(e,t){var r=t.length<0?0:qn(t.length)|0;e=be(e,r);for(var n=0;n<r;n+=1)e[n]=t[n]&255;return e}function Zc(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return r===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,n),y.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=y.prototype):e=Zn(e,t),e}function qc(e,t){if(de(t)){var r=qn(t.length)|0;return e=be(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"||cl(t.length)?be(e,0):Zn(e,t);if(t.type==="Buffer"&&po(t.data))return Zn(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function qn(e){if(e>=ar())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ar().toString(16)+" bytes");return e|0}y.isBuffer=ll;function de(e){return!!(e!=null&&e._isBuffer)}y.compare=function(t,r){if(!de(t)||!de(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var n=t.length,i=r.length,a=0,o=Math.min(n,i);a<o;++a)if(t[a]!==r[a]){n=t[a],i=r[a];break}return n<i?-1:i<n?1:0},y.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}},y.concat=function(t,r){if(!po(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return y.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var i=y.allocUnsafe(r),a=0;for(n=0;n<t.length;++n){var o=t[n];if(!de(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,a),a+=o.length}return i};function vo(e,t){if(de(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 n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return fr(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ko(e).length;default:if(n)return fr(e).length;t=(""+t).toLowerCase(),n=!0}}y.byteLength=vo;function Hc(e,t,r){var n=!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 tl(this,t,r);case"utf8":case"utf-8":return mo(this,t,r);case"ascii":return Qc(this,t,r);case"latin1":case"binary":return el(this,t,r);case"base64":return Jc(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return rl(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}y.prototype._isBuffer=!0;function ze(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}y.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)ze(this,r,r+1);return this},y.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)ze(this,r,r+3),ze(this,r+1,r+2);return this},y.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)ze(this,r,r+7),ze(this,r+1,r+6),ze(this,r+2,r+5),ze(this,r+3,r+4);return this},y.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?mo(this,0,t):Hc.apply(this,arguments)},y.prototype.equals=function(t){if(!de(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:y.compare(this,t)===0},y.prototype.inspect=function(){var t="",r=Uc;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},y.prototype.compare=function(t,r,n,i,a){if(!de(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===t)return 0;for(var o=a-i,s=n-r,c=Math.min(o,s),f=this.slice(i,a),l=t.slice(r,n),d=0;d<c;++d)if(f[d]!==l[d]){o=f[d],s=l[d];break}return o<s?-1:s<o?1:0};function _o(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=y.from(t,n)),de(t))return t.length===0?-1:wo(e,t,r,n,i);if(typeof t=="number")return t=t&255,y.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):wo(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function wo(e,t,r,n,i){var a=1,o=e.length,s=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,r/=2}function c(u,p){return a===1?u[p]:u.readUInt16BE(p*a)}var f;if(i){var l=-1;for(f=r;f<o;f++)if(c(e,f)===c(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,h=0;h<s;h++)if(c(e,f+h)!==c(t,h)){d=!1;break}if(d)return f}return-1}y.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1},y.prototype.indexOf=function(t,r,n){return _o(this,t,r,n,!0)},y.prototype.lastIndexOf=function(t,r,n){return _o(this,t,r,n,!1)};function Kc(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o<n;++o){var s=parseInt(t.substr(o*2,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function Wc(e,t,r,n){return cr(fr(t,e.length-r),e,r,n)}function bo(e,t,r,n){return cr(sl(t),e,r,n)}function Vc(e,t,r,n){return bo(e,t,r,n)}function Gc(e,t,r,n){return cr(ko(t),e,r,n)}function Yc(e,t,r,n){return cr(fl(t,e.length-r),e,r,n)}y.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-r;if((n===void 0||n>a)&&(n=a),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Kc(this,t,r,n);case"utf8":case"utf-8":return Wc(this,t,r,n);case"ascii":return bo(this,t,r,n);case"latin1":case"binary":return Vc(this,t,r,n);case"base64":return Gc(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yc(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Jc(e,t,r){return t===0&&r===e.length?uo(e):uo(e.slice(t,r))}function mo(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var a=e[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(i+s<=r){var c,f,l,d;switch(s){case 1:a<128&&(o=a);break;case 2:c=e[i+1],(c&192)===128&&(d=(a&31)<<6|c&63,d>127&&(o=d));break;case 3:c=e[i+1],f=e[i+2],(c&192)===128&&(f&192)===128&&(d=(a&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=e[i+1],f=e[i+2],l=e[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(d=(a&15)<<18|(c&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=s}return Xc(n)}var Eo=4096;function Xc(e){var t=e.length;if(t<=Eo)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Eo));return r}function Qc(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function el(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function tl(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",a=t;a<r;++a)i+=ol(e[a]);return i}function rl(e,t,r){for(var n=e.slice(t,r),i="",a=0;a<n.length;a+=2)i+=String.fromCharCode(n[a]+n[a+1]*256);return i}y.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var i;if(y.TYPED_ARRAY_SUPPORT)i=this.subarray(t,r),i.__proto__=y.prototype;else{var a=r-t;i=new y(a,void 0);for(var o=0;o<a;++o)i[o]=this[o+t]}return i};function z(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")}y.prototype.readUIntLE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t],a=1,o=0;++o<r&&(a*=256);)i+=this[t+o]*a;return i},y.prototype.readUIntBE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t+--r],a=1;r>0&&(a*=256);)i+=this[t+--r]*a;return i},y.prototype.readUInt8=function(t,r){return r||z(t,1,this.length),this[t]},y.prototype.readUInt16LE=function(t,r){return r||z(t,2,this.length),this[t]|this[t+1]<<8},y.prototype.readUInt16BE=function(t,r){return r||z(t,2,this.length),this[t]<<8|this[t+1]},y.prototype.readUInt32LE=function(t,r){return r||z(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},y.prototype.readUInt32BE=function(t,r){return r||z(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},y.prototype.readIntLE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=this[t],a=1,o=0;++o<r&&(a*=256);)i+=this[t+o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*r)),i},y.prototype.readIntBE=function(t,r,n){t=t|0,r=r|0,n||z(t,r,this.length);for(var i=r,a=1,o=this[t+--i];i>0&&(a*=256);)o+=this[t+--i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o},y.prototype.readInt8=function(t,r){return r||z(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},y.prototype.readInt16LE=function(t,r){r||z(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},y.prototype.readInt16BE=function(t,r){r||z(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},y.prototype.readInt32LE=function(t,r){return r||z(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},y.prototype.readInt32BE=function(t,r){return r||z(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},y.prototype.readFloatLE=function(t,r){return r||z(t,4,this.length),ir(this,t,!0,23,4)},y.prototype.readFloatBE=function(t,r){return r||z(t,4,this.length),ir(this,t,!1,23,4)},y.prototype.readDoubleLE=function(t,r){return r||z(t,8,this.length),ir(this,t,!0,52,8)},y.prototype.readDoubleBE=function(t,r){return r||z(t,8,this.length),ir(this,t,!1,52,8)};function J(e,t,r,n,i,a){if(!de(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}y.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var a=Math.pow(2,8*n)-1;J(this,t,r,n,a,0)}var o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n},y.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var a=Math.pow(2,8*n)-1;J(this,t,r,n,a,0)}var o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n},y.prototype.writeUInt8=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,1,255,0),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};function or(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i<a;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}y.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):or(this,t,r,!0),r+2},y.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):or(this,t,r,!1),r+2};function sr(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i<a;++i)e[r+i]=t>>>(n?i:3-i)*8&255}y.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):sr(this,t,r,!0),r+4},y.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):sr(this,t,r,!1),r+4},y.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r|0,!i){var a=Math.pow(2,8*n-1);J(this,t,r,n,a-1,-a)}var o=0,s=1,c=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&c===0&&this[r+o-1]!==0&&(c=1),this[r+o]=(t/s>>0)-c&255;return r+n},y.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r|0,!i){var a=Math.pow(2,8*n-1);J(this,t,r,n,a-1,-a)}var o=n-1,s=1,c=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(t/s>>0)-c&255;return r+n},y.prototype.writeInt8=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,1,127,-128),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1},y.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):or(this,t,r,!0),r+2},y.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):or(this,t,r,!1),r+2},y.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,4,2147483647,-2147483648),y.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):sr(this,t,r,!0),r+4},y.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r|0,n||J(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):sr(this,t,r,!1),r+4};function xo(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function So(e,t,r,n,i){return i||xo(e,t,r,4),ho(e,t,r,n,23,4),r+4}y.prototype.writeFloatLE=function(t,r,n){return So(this,t,r,!0,n)},y.prototype.writeFloatBE=function(t,r,n){return So(this,t,r,!1,n)};function Ao(e,t,r,n,i){return i||xo(e,t,r,8),ho(e,t,r,n,52,8),r+8}y.prototype.writeDoubleLE=function(t,r,n){return Ao(this,t,r,!0,n)},y.prototype.writeDoubleBE=function(t,r,n){return Ao(this,t,r,!1,n)},y.prototype.copy=function(t,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);var a=i-n,o;if(this===t&&n<r&&r<i)for(o=a-1;o>=0;--o)t[o+r]=this[o+n];else if(a<1e3||!y.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)t[o+r]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+a),r);return a},y.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var a=t.charCodeAt(0);a<256&&(t=a)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!y.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{var s=de(t)?t:fr(new y(t,i).toString()),c=s.length;for(o=0;o<n-r;++o)this[o+r]=s[o%c]}return this};var nl=/[^+\/0-9A-Za-z-_]/g;function il(e){if(e=al(e).replace(nl,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function al(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function ol(e){return e<16?"0"+e.toString(16):e.toString(16)}function fr(e,t){t=t||1/0;for(var r,n=e.length,i=null,a=[],o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=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 sl(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function fl(e,t){for(var r,n,i,a=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,a.push(i),a.push(n);return a}function ko(e){return Lc(il(e))}function cr(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function cl(e){return e!==e}function ll(e){return e!=null&&(!!e._isBuffer||Ro(e)||ul(e))}function Ro(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function ul(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Ro(e.slice(0,0))}function Oo(){throw new Error("setTimeout has not been defined")}function To(){throw new Error("clearTimeout has not been defined")}var Pe=Oo,Ie=To;typeof ut.setTimeout=="function"&&(Pe=setTimeout),typeof ut.clearTimeout=="function"&&(Ie=clearTimeout);function Po(e){if(Pe===setTimeout)return setTimeout(e,0);if((Pe===Oo||!Pe)&&setTimeout)return Pe=setTimeout,setTimeout(e,0);try{return Pe(e,0)}catch{try{return Pe.call(null,e,0)}catch{return Pe.call(this,e,0)}}}function hl(e){if(Ie===clearTimeout)return clearTimeout(e);if((Ie===To||!Ie)&&clearTimeout)return Ie=clearTimeout,clearTimeout(e);try{return Ie(e)}catch{try{return Ie.call(null,e)}catch{return Ie.call(this,e)}}}var me=[],ht=!1,Ze,lr=-1;function dl(){!ht||!Ze||(ht=!1,Ze.length?me=Ze.concat(me):lr=-1,me.length&&Io())}function Io(){if(!ht){var e=Po(dl);ht=!0;for(var t=me.length;t;){for(Ze=me,me=[];++lr<t;)Ze&&Ze[lr].run();lr=-1,t=me.length}Ze=null,ht=!1,hl(e)}}function te(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];me.push(new Co(e,t)),me.length===1&&!ht&&Po(Io)}function Co(e,t){this.fun=e,this.array=t}Co.prototype.run=function(){this.fun.apply(null,this.array)};var pl="browser",yl="browser",gl=!0,vl={},_l=[],wl="",bl={},ml={},El={};function qe(){}var xl=qe,Sl=qe,Al=qe,kl=qe,Rl=qe,Ol=qe,Tl=qe;function Pl(e){throw new Error("process.binding is not supported")}function Il(){return"/"}function Cl(e){throw new Error("process.chdir is not supported")}function Dl(){return 0}var dt=ut.performance||{},Fl=dt.now||dt.mozNow||dt.msNow||dt.oNow||dt.webkitNow||function(){return new Date().getTime()};function Ml(e){var t=Fl.call(dt)*.001,r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r=r-e[0],n=n-e[1],n<0&&(r--,n+=1e9)),[r,n]}var Ll=new Date;function jl(){var e=new Date,t=e-Ll;return t/1e3}var Ee={nextTick:te,title:pl,browser:gl,env:vl,argv:_l,version:wl,versions:bl,on:xl,addListener:Sl,once:Al,off:kl,removeListener:Rl,removeAllListeners:Ol,emit:Tl,binding:Pl,cwd:Il,chdir:Cl,umask:Dl,hrtime:Ml,platform:yl,release:ml,config:El,uptime:jl},W;typeof Object.create=="function"?W=function(t,r){t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:W=function(t,r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t};var Nl=/%[sdj%]/g;function Bl(e){if(!Gn(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Ce(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,a=String(e).replace(Nl,function(s){if(s==="%%")return"%";if(r>=i)return s;switch(s){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return s}}),o=n[r];r<i;o=n[++r])Vn(o)||!Rt(o)?a+=" "+o:a+=" "+Ce(o);return a}function Do(e,t){if(De(ut.process))return function(){return Do(e,t).apply(this,arguments)};if(Ee.noDeprecation===!0)return e;var r=!1;function n(){if(!r){if(Ee.throwDeprecation)throw new Error(t);Ee.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n}var ur={},Hn;function Ul(e){if(De(Hn)&&(Hn=Ee.env.NODE_DEBUG||""),e=e.toUpperCase(),!ur[e])if(new RegExp("\\b"+e+"\\b","i").test(Hn)){var t=0;ur[e]=function(){var r=Bl.apply(null,arguments);console.error("%s %d: %s",e,t,r)}}else ur[e]=function(){};return ur[e]}function Ce(e,t){var r={seen:[],stylize:zl};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),Fo(t)?r.showHidden=t:t&&Gl(r,t),De(r.showHidden)&&(r.showHidden=!1),De(r.depth)&&(r.depth=2),De(r.colors)&&(r.colors=!1),De(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=$l),hr(r,e,r.depth)}Ce.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]},Ce.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function $l(e,t){var r=Ce.styles[t];return r?"\x1B["+Ce.colors[r][0]+"m"+e+"\x1B["+Ce.colors[r][1]+"m":e}function zl(e,t){return e}function Zl(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function hr(e,t,r){if(e.customInspect&&t&&Xn(t.inspect)&&t.inspect!==Ce&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Gn(n)||(n=hr(e,n,r)),n}var i=ql(e,t);if(i)return i;var a=Object.keys(t),o=Zl(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),Jn(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return Kn(t);if(a.length===0){if(Xn(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(Yn(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Mo(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Jn(t))return Kn(t)}var c="",f=!1,l=["{","}"];if(Wl(t)&&(f=!0,l=["[","]"]),Xn(t)){var d=t.name?": "+t.name:"";c=" [Function"+d+"]"}if(Yn(t)&&(c=" "+RegExp.prototype.toString.call(t)),Mo(t)&&(c=" "+Date.prototype.toUTCString.call(t)),Jn(t)&&(c=" "+Kn(t)),a.length===0&&(!f||t.length==0))return l[0]+c+l[1];if(r<0)return Yn(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var h;return f?h=Hl(e,t,r,o,a):h=a.map(function(u){return Wn(e,t,r,o,u,f)}),e.seen.pop(),Kl(h,c,l)}function ql(e,t){if(De(t))return e.stylize("undefined","undefined");if(Gn(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(Vl(t))return e.stylize(""+t,"number");if(Fo(t))return e.stylize(""+t,"boolean");if(Vn(t))return e.stylize("null","null")}function Kn(e){return"["+Error.prototype.toString.call(e)+"]"}function Hl(e,t,r,n,i){for(var a=[],o=0,s=t.length;o<s;++o)Lo(t,String(o))?a.push(Wn(e,t,r,n,String(o),!0)):a.push("");return i.forEach(function(c){c.match(/^\d+$/)||a.push(Wn(e,t,r,n,c,!0))}),a}function Wn(e,t,r,n,i,a){var o,s,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?c.set?s=e.stylize("[Getter/Setter]","special"):s=e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),Lo(n,i)||(o="["+i+"]"),s||(e.seen.indexOf(c.value)<0?(Vn(r)?s=hr(e,c.value,null):s=hr(e,c.value,r-1),s.indexOf(`
|
|
13
21
|
`)>-1&&(a?s=s.split(`
|
|
14
22
|
`).map(function(f){return" "+f}).join(`
|
|
15
23
|
`).substr(2):s=`
|
|
16
24
|
`+s.split(`
|
|
17
25
|
`).map(function(f){return" "+f}).join(`
|
|
18
|
-
`))):s=e.stylize("[Circular]","special")),
|
|
19
|
-
`)>=0,
|
|
26
|
+
`))):s=e.stylize("[Circular]","special")),De(o)){if(a&&i.match(/^\d+$/))return s;o=JSON.stringify(""+i),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 Kl(e,t,r){var n=e.reduce(function(i,a){return a.indexOf(`
|
|
27
|
+
`)>=0,i+a.replace(/\u001b\[\d\d?m/g,"").length+1},0);return n>60?r[0]+(t===""?"":t+`
|
|
20
28
|
`)+" "+e.join(`,
|
|
21
|
-
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function ks(e){return Array.isArray(e)}function en(e){return typeof e=="boolean"}function yr(e){return e===null}function Ss(e){return typeof e=="number"}function br(e){return typeof e=="string"}function me(e){return e===void 0}function xr(e){return ot(e)&&Sr(e)==="[object RegExp]"}function ot(e){return typeof e=="object"&&e!==null}function tn(e){return ot(e)&&Sr(e)==="[object Date]"}function Er(e){return ot(e)&&(Sr(e)==="[object Error]"||e instanceof Error)}function kr(e){return typeof e=="function"}function Sr(e){return Object.prototype.toString.call(e)}function Rs(e,t){if(!t||!ot(t))return e;for(var r=Object.keys(t),i=r.length;i--;)e[r[i]]=t[r[i]];return e}function rn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ie(){this.head=null,this.tail=null,this.length=0}Ie.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},Ie.prototype.unshift=function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length},Ie.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}},Ie.prototype.clear=function(){this.head=this.tail=null,this.length=0},Ie.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},Ie.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 As=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 Ts(e){if(e&&!As(e))throw new Error("Unknown encoding: "+e)}function st(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),Ts(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Cs;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Is;break;default:this.write=Ls;return}this.charBuffer=new c(6),this.charReceived=0,this.charLength=0}st.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},st.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},st.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 Ls(e){return e.toString(this.encoding)}function Cs(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Is(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}N.ReadableState=nn;var C=gs("stream");$(N,y);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 Ms(e,t){return e.listeners(t).length}function nn(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof V&&(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 Ie,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 st(e.encoding),this.encoding=e.encoding)}function N(e){if(!(this instanceof N))return new N(e);this._readableState=new nn(e,this),this.readable=!0,e&&typeof e.read=="function"&&(this._read=e.read),y.call(this)}N.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="")),an(this,r,e,t,!1)},N.prototype.unshift=function(e){var t=this._readableState;return an(this,t,e,"",!0)},N.prototype.isPaused=function(){return this._readableState.flowing===!1};function an(e,t,r,i,n){var a=Ns(t,r);if(a)e.emit("error",a);else if(r===null)t.reading=!1,Ps(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&&Pt(e))),zs(e,t)}else n||(t.reading=!1);return Ds(t)}function Ds(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}N.prototype.setEncoding=function(e){return this._readableState.decoder=new st(e),this._readableState.encoding=e,this};var on=8388608;function Fs(e){return e>=on?e=on:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function sn(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=Fs(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}N.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?Ar(this):Pt(this),null;if(e=sn(e,t),e===0&&t.ended)return t.length===0&&Ar(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=sn(r,t)));var n;return e>0?n=ln(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&&Ar(this)),n!==null&&this.emit("data",n),n};function Ns(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 Ps(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,Pt(e)}}function Pt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(C("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?q(fn,e):fn(e))}function fn(e){C("emit readable"),e.emit("readable"),Rr(e)}function zs(e,t){t.readingMore||(t.readingMore=!0,q(Us,e,t))}function Us(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}N.prototype._read=function(e){this.emit("error",new Error("not implemented"))},N.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?q(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=Bs(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&&hn(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),b(),e.removeListener("error",u),Ms(e,"error")===0&&e.emit("error",v)}Os(e,"error",u);function g(){e.removeListener("finish",S),b()}e.once("close",g);function S(){C("onfinish"),e.removeListener("close",g),b()}e.once("finish",S);function b(){C("unpipe"),r.unpipe(e)}return e.emit("pipe",r),i.flowing||(C("pipe resume"),r.resume()),e};function Bs(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,Rr(e))}}N.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=hn(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)},N.prototype.on=function(e,t){var r=y.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&&Pt(this):q(Zs,this))}return r},N.prototype.addListener=N.prototype.on;function Zs(e){C("readable nexttick read 0"),e.read(0)}N.prototype.resume=function(){var e=this._readableState;return e.flowing||(C("resume"),e.flowing=!0,js(this,e)),this};function js(e,t){t.resumeScheduled||(t.resumeScheduled=!0,q($s,e,t))}function $s(e,t){t.reading||(C("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Rr(e),t.flowing&&!t.reading&&e.read(0)}N.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 Rr(e){var t=e._readableState;for(C("flow",t.flowing);t.flowing&&e.read()!==null;);}N.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 qs(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},N._fromList=ln;function ln(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?Ks(e,t):Ws(e,t),i}function Ks(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 Ws(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 Ar(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,q(Ys,t,e))}function Ys(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qs(e,t){for(var r=0,i=e.length;r<i;r++)t(e[r],r)}function hn(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}H.WritableState=Tr,$(H,y);function Gs(){}function Vs(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function Tr(e,t){Object.defineProperty(this,"buffer",{get:Qi(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof V&&(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){nf(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 wn(this)}Tr.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 V))return new H(e);this._writableState=new Tr(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev)),y.call(this)}H.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function Xs(e,t){var r=new Error("write after end");e.emit("error",r),q(t,r)}function Js(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),q(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=Gs),i.ended?Xs(this,r):Js(this,i,e,r)&&(i.pendingcb++,n=ef(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&&un(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 Qs(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=c.from(t,r)),t}function ef(e,t,r,i,n){r=Qs(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 Vs(r,i,n),s?s.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Lr(e,t,!1,a,r,i,n);return o}function Lr(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 tf(e,t,r,i,n){--t.pendingcb,r?q(n,i):n(i),e._writableState.errorEmitted=!0,e.emit("error",i)}function rf(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function nf(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(rf(r),t)tf(e,r,i,t,n);else{var a=dn(r);!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&un(e,r),i?q(cn,e,r,a,n):cn(e,r,a,n)}}function cn(e,t,r,i){r||af(e,t),t.pendingcb--,i(),_n(e,t)}function af(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function un(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;Lr(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 wn(t)}else{for(;r;){var s=r.chunk,h=r.encoding,f=r.callback,l=t.objectMode?1:s.length;if(Lr(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&&of(this,i,r)};function dn(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function pn(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function _n(e,t){var r=dn(t);return r&&(t.pendingcb===0?(pn(e,t),t.finished=!0,e.emit("finish")):pn(e,t)),r}function of(e,t,r){t.ending=!0,_n(e,t),r&&(t.finished?q(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function wn(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}}$(V,N);for(var gn=Object.keys(H.prototype),Cr=0;Cr<gn.length;Cr++){var Ir=gn[Cr];V.prototype[Ir]||(V.prototype[Ir]=H.prototype[Ir])}function V(e){if(!(this instanceof V))return new V(e);N.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",sf)}function sf(){this.allowHalfOpen||this._writableState.ended||q(ff,this)}function ff(e){e.end()}$(X,V);function lf(e){this.afterTransform=function(t,r){return hf(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function hf(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 X(e){if(!(this instanceof X))return new X(e);V.call(this,e),this._transformState=new lf(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){vn(t,r)}):vn(t)})}X.prototype.push=function(e,t){return this._transformState.needTransform=!1,V.prototype.push.call(this,e,t)},X.prototype._transform=function(e,t,r){throw new Error("Not implemented")},X.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)}},X.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 vn(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)}$(ft,X);function ft(e){if(!(this instanceof ft))return new ft(e);X.call(this,e)}ft.prototype._transform=function(e,t,r){r(null,e)},$(le,y),le.Readable=N,le.Writable=H,le.Duplex=V,le.Transform=X,le.PassThrough=ft,le.Stream=le;function le(){y.call(this)}le.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(),y.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 mn={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 cf(){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 he(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 zt=Uint8Array,J=Uint16Array,Ut=Int32Array,uf=4,yn=0,bn=1,df=2;function Xe(e){for(var t=e.length;--t>=0;)e[t]=0}var pf=0,xn=1,_f=2,wf=3,gf=258,Or=29,lt=256,ht=lt+1+Or,Je=30,Mr=19,En=2*ht+1,Oe=15,Dr=16,vf=7,Fr=256,kn=16,Sn=17,Rn=18,Nr=[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],Bt=[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],mf=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],An=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],yf=512,ce=new Array((ht+2)*2);Xe(ce);var ct=new Array(Je*2);Xe(ct);var ut=new Array(yf);Xe(ut);var dt=new Array(gf-wf+1);Xe(dt);var Pr=new Array(Or);Xe(Pr);var Zt=new Array(Je);Xe(Zt);function zr(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 Tn,Ln,Cn;function Ur(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function In(e){return e<256?ut[e]:ut[256+(e>>>7)]}function pt(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function W(e,t,r){e.bi_valid>Dr-r?(e.bi_buf|=t<<e.bi_valid&65535,pt(e,e.bi_buf),e.bi_buf=t>>Dr-e.bi_valid,e.bi_valid+=r-Dr):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function ie(e,t,r){W(e,r[t*2],r[t*2+1])}function On(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?(pt(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 xf(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<=Oe;p++)e.bl_count[p]=0;for(r[e.heap[e.heap_max]*2+1]=0,f=e.heap_max+1;f<En;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 Mn(e,t,r){var i=new Array(Oe+1),n=0,a,o;for(a=1;a<=Oe;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]=On(i[s]++,s))}}function Ef(){var e,t,r,i,n,a=new Array(Oe+1);for(r=0,i=0;i<Or-1;i++)for(Pr[i]=r,e=0;e<1<<Nr[i];e++)dt[r++]=i;for(dt[r-1]=i,n=0,i=0;i<16;i++)for(Zt[i]=n,e=0;e<1<<Bt[i];e++)ut[n++]=i;for(n>>=7;i<Je;i++)for(Zt[i]=n<<7,e=0;e<1<<Bt[i]-7;e++)ut[256+n++]=i;for(t=0;t<=Oe;t++)a[t]=0;for(e=0;e<=143;)ce[e*2+1]=8,e++,a[8]++;for(;e<=255;)ce[e*2+1]=9,e++,a[9]++;for(;e<=279;)ce[e*2+1]=7,e++,a[7]++;for(;e<=287;)ce[e*2+1]=8,e++,a[8]++;for(Mn(ce,ht+1,a),e=0;e<Je;e++)ct[e*2+1]=5,ct[e*2]=On(e,5);Tn=new zr(ce,Nr,lt+1,ht,Oe),Ln=new zr(ct,Bt,0,Je,Oe),Cn=new zr(new Array(0),mf,0,Mr,vf)}function Dn(e){var t;for(t=0;t<ht;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Je;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Mr;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Fr*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Fn(e){e.bi_valid>8?pt(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 kf(e,t,r,i){Fn(e),pt(e,r),pt(e,~r),he(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function Nn(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 Br(e,t,r){for(var i=e.heap[r],n=r<<1;n<=e.heap_len&&(n<e.heap_len&&Nn(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Nn(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i}function Pn(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?ie(e,n,t):(o=dt[n],ie(e,o+lt+1,t),s=Nr[o],s!==0&&(n-=Pr[o],W(e,n,s)),i--,o=In(i),ie(e,o,r),s=Bt[o],s!==0&&(i-=Zt[o],W(e,i,s)));while(a<e.last_lit);ie(e,Fr,t)}function Zr(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=En,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--)Br(e,r,o);f=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Br(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++,Br(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],xf(e,t),Mn(r,h,e.bl_count)}function zn(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[kn*2]++):s<=10?e.bl_tree[Sn*2]++:e.bl_tree[Rn*2]++,s=0,n=a,o===0?(h=138,f=3):a===o?(h=6,f=3):(h=7,f=4))}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),i=0;i<=r;i++)if(a=o,o=t[(i+1)*2+1],!(++s<h&&a===o)){if(s<f)do ie(e,a,e.bl_tree);while(--s!==0);else a!==0?(a!==n&&(ie(e,a,e.bl_tree),s--),ie(e,kn,e.bl_tree),W(e,s-3,2)):s<=10?(ie(e,Sn,e.bl_tree),W(e,s-3,3)):(ie(e,Rn,e.bl_tree),W(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 Sf(e){var t;for(zn(e,e.dyn_ltree,e.l_desc.max_code),zn(e,e.dyn_dtree,e.d_desc.max_code),Zr(e,e.bl_desc),t=Mr-1;t>=3&&e.bl_tree[An[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Rf(e,t,r,i){var n;for(W(e,t-257,5),W(e,r-1,5),W(e,i-4,4),n=0;n<i;n++)W(e,e.bl_tree[An[n]*2+1],3);Un(e,e.dyn_ltree,t-1),Un(e,e.dyn_dtree,r-1)}function Af(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 bn;for(r=32;r<lt;r++)if(e.dyn_ltree[r*2]!==0)return bn;return yn}var Bn=!1;function Tf(e){Bn||(Ef(),Bn=!0),e.l_desc=new Ur(e.dyn_ltree,Tn),e.d_desc=new Ur(e.dyn_dtree,Ln),e.bl_desc=new Ur(e.bl_tree,Cn),e.bi_buf=0,e.bi_valid=0,Dn(e)}function Zn(e,t,r,i){W(e,(pf<<1)+(i?1:0),3),kf(e,t,r)}function Lf(e){W(e,xn<<1,3),ie(e,Fr,ce),bf(e)}function Cf(e,t,r,i){var n,a,o=0;e.level>0?(e.strm.data_type===df&&(e.strm.data_type=Af(e)),Zr(e,e.l_desc),Zr(e,e.d_desc),o=Sf(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?Zn(e,t,r,i):e.strategy===uf||a===n?(W(e,(xn<<1)+(i?1:0),3),Pn(e,ce,ct)):(W(e,(_f<<1)+(i?1:0),3),Rf(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Pn(e,e.dyn_ltree,e.dyn_dtree)),Dn(e),i&&Fn(e)}function ye(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[(dt[r]+lt+1)*2]++,e.dyn_dtree[In(t)*2]++),e.last_lit===e.lit_bufsize-1}function jr(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 If(){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=If();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,Mf=1,Df=3,be=4,jn=5,xe=0,$n=1,Ee=-2,Ff=-3,$r=-5,Nf=-1,Pf=1,jt=2,zf=3,Uf=4,Bf=2,Hr=8,Zf=9,jf=29,$f=256,Kr=$f+1+jf,Hf=30,Kf=19,Wf=2*Kr+1,Yf=15,L=3,ke=258,Q=ke+L+1,qf=32,Wr=42,Yr=69,$t=73,Ht=91,Kt=103,De=113,_t=666,P=1,wt=2,Fe=3,Qe=4,Gf=3;function Se(e,t){return e.msg=mn[t],t}function Hn(e){return(e<<1)-(e>4?9:0)}function Ne(e){for(var t=e.length;--t>=0;)e[t]=0}function Re(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(he(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 j(e,t){Cf(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Re(e.strm)}function A(e,t){e.pending_buf[e.pending++]=t}function gt(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function Vf(e,t,r,i){var n=e.avail_in;return n>i&&(n=i),n===0?0:(e.avail_in-=n,he(t,e.input,e.next_in,n,r),e.state.wrap===1?e.adler=jr(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 Kn(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-Q?e.strstart-(e.w_size-Q):0,f=e.window,l=e.w_mask,d=e.prev,p=e.strstart+ke,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=ke-(p-i),i=p-ke,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 vt(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-Q)){he(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=Vf(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=i,e.lookahead+e.insert>=L)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+L-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<L)););}while(e.lookahead<Q&&e.strm.avail_in!==0)}function Xf(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(vt(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,j(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-Q&&(j(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(j(e,!0),e.strm.avail_out===0?Fe:Qe):(e.strstart>e.block_start&&(j(e,!1),e.strm.avail_out===0),P)}function qr(e,t){for(var r,i;;){if(e.lookahead<Q){if(vt(e),e.lookahead<Q&&t===Me)return P;if(e.lookahead===0)break}if(r=0,e.lookahead>=L&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+L-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-Q&&(e.match_length=Kn(e,r)),e.match_length>=L)if(i=ye(e,e.strstart-e.match_start,e.match_length-L),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=L){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+L-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=ye(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(j(e,!1),e.strm.avail_out===0))return P}return e.insert=e.strstart<L-1?e.strstart:L-1,t===be?(j(e,!0),e.strm.avail_out===0?Fe:Qe):e.last_lit&&(j(e,!1),e.strm.avail_out===0)?P:wt}function et(e,t){for(var r,i,n;;){if(e.lookahead<Q){if(vt(e),e.lookahead<Q&&t===Me)return P;if(e.lookahead===0)break}if(r=0,e.lookahead>=L&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+L-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=L-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Q&&(e.match_length=Kn(e,r),e.match_length<=5&&(e.strategy===Pf||e.match_length===L&&e.strstart-e.match_start>4096)&&(e.match_length=L-1)),e.prev_length>=L&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-L,i=ye(e,e.strstart-1-e.prev_match,e.prev_length-L),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+L-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=L-1,e.strstart++,i&&(j(e,!1),e.strm.avail_out===0))return P}else if(e.match_available){if(i=ye(e,0,e.window[e.strstart-1]),i&&j(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=ye(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<L-1?e.strstart:L-1,t===be?(j(e,!0),e.strm.avail_out===0?Fe:Qe):e.last_lit&&(j(e,!1),e.strm.avail_out===0)?P:wt}function Jf(e,t){for(var r,i,n,a,o=e.window;;){if(e.lookahead<=ke){if(vt(e),e.lookahead<=ke&&t===Me)return P;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=L&&e.strstart>0&&(n=e.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){a=e.strstart+ke;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=ke-(a-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=L?(r=ye(e,1,e.match_length-L),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=ye(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(j(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(j(e,!0),e.strm.avail_out===0?Fe:Qe):e.last_lit&&(j(e,!1),e.strm.avail_out===0)?P:wt}function Qf(e,t){for(var r;;){if(e.lookahead===0&&(vt(e),e.lookahead===0)){if(t===Me)return P;break}if(e.match_length=0,r=ye(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(j(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===be?(j(e,!0),e.strm.avail_out===0?Fe:Qe):e.last_lit&&(j(e,!1),e.strm.avail_out===0)?P:wt}function ne(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 tt;tt=[new ne(0,0,0,0,Xf),new ne(4,4,8,4,qr),new ne(4,5,16,8,qr),new ne(4,6,32,32,qr),new ne(4,4,16,16,et),new ne(8,16,32,32,et),new ne(8,16,128,128,et),new ne(8,32,128,256,et),new ne(32,128,258,1024,et),new ne(32,258,258,4096,et)];function el(e){e.window_size=2*e.w_size,Ne(e.head),e.max_lazy_match=tt[e.level].max_lazy,e.good_match=tt[e.level].good_length,e.nice_match=tt[e.level].nice_length,e.max_chain_length=tt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=L-1,e.match_available=0,e.ins_h=0}function tl(){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=Hr,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 J(Wf*2),this.dyn_dtree=new J((2*Hf+1)*2),this.bl_tree=new J((2*Kf+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 J(Yf+1),this.heap=new J(2*Kr+1),Ne(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new J(2*Kr+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 rl(e){var t;return!e||!e.state?Se(e,Ee):(e.total_in=e.total_out=0,e.data_type=Bf,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Wr:De,e.adler=t.wrap===2?0:1,t.last_flush=Me,Tf(t),xe)}function Wn(e){var t=rl(e);return t===xe&&el(e.state),t}function il(e,t,r,i,n,a){if(!e)return Ee;var o=1;if(t===Nf&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>Zf||r!==Hr||i<8||i>15||t<0||t>9||a<0||a>Uf)return Se(e,Ee);i===8&&(i=9);var s=new tl;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+L-1)/L),s.window=new zt(s.w_size*2),s.head=new J(s.hash_size),s.prev=new J(s.w_size),s.lit_bufsize=1<<n+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new zt(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,Wn(e)}function nl(e,t){var r,i,n,a;if(!e||!e.state||t>jn||t<0)return e?Se(e,Ee):Ee;if(i=e.state,!e.output||!e.input&&e.avail_in!==0||i.status===_t&&t!==be)return Se(e,e.avail_out===0?$r:Ee);if(i.strm=e,r=i.last_flush,i.last_flush=t,i.status===Wr)if(i.wrap===2)e.adler=0,A(i,31),A(i,139),A(i,8),i.gzhead?(A(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)),A(i,i.gzhead.time&255),A(i,i.gzhead.time>>8&255),A(i,i.gzhead.time>>16&255),A(i,i.gzhead.time>>24&255),A(i,i.level===9?2:i.strategy>=jt||i.level<2?4:0),A(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(A(i,i.gzhead.extra.length&255),A(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=Yr):(A(i,0),A(i,0),A(i,0),A(i,0),A(i,0),A(i,i.level===9?2:i.strategy>=jt||i.level<2?4:0),A(i,Gf),i.status=De);else{var o=Hr+(i.w_bits-8<<4)<<8,s=-1;i.strategy>=jt||i.level<2?s=0:i.level<6?s=1:i.level===6?s=2:s=3,o|=s<<6,i.strstart!==0&&(o|=qf),o+=31-o%31,i.status=De,gt(i,o),i.strstart!==0&&(gt(i,e.adler>>>16),gt(i,e.adler&65535)),e.adler=1}if(i.status===Yr)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)),Re(e),n=i.pending,i.pending===i.pending_buf_size));)A(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=$t)}else i.status=$t;if(i.status===$t)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)),Re(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,A(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=Ht)}else i.status=Ht;if(i.status===Ht)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)),Re(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,A(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=Kt)}else i.status=Kt;if(i.status===Kt&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Re(e),i.pending+2<=i.pending_buf_size&&(A(i,e.adler&255),A(i,e.adler>>8&255),e.adler=0,i.status=De)):i.status=De),i.pending!==0){if(Re(e),e.avail_out===0)return i.last_flush=-1,xe}else if(e.avail_in===0&&Hn(t)<=Hn(r)&&t!==be)return Se(e,$r);if(i.status===_t&&e.avail_in!==0)return Se(e,$r);if(e.avail_in!==0||i.lookahead!==0||t!==Me&&i.status!==_t){var h=i.strategy===jt?Qf(i,t):i.strategy===zf?Jf(i,t):tt[i.level].func(i,t);if((h===Fe||h===Qe)&&(i.status=_t),h===P||h===Fe)return e.avail_out===0&&(i.last_flush=-1),xe;if(h===wt&&(t===Mf?Lf(i):t!==jn&&(Zn(i,0,0,!1),t===Df&&(Ne(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Re(e),e.avail_out===0))return i.last_flush=-1,xe}return t!==be?xe:i.wrap<=0?$n:(i.wrap===2?(A(i,e.adler&255),A(i,e.adler>>8&255),A(i,e.adler>>16&255),A(i,e.adler>>24&255),A(i,e.total_in&255),A(i,e.total_in>>8&255),A(i,e.total_in>>16&255),A(i,e.total_in>>24&255)):(gt(i,e.adler>>>16),gt(i,e.adler&65535)),Re(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?xe:$n)}function al(e){var t;return!e||!e.state?Ee:(t=e.state.status,t!==Wr&&t!==Yr&&t!==$t&&t!==Ht&&t!==Kt&&t!==De&&t!==_t?Se(e,Ee):(e.state=null,t===De?Se(e,Ff):xe))}var Wt=30,ol=12;function sl(e,t){var r,i,n,a,o,s,h,f,l,d,p,u,g,S,b,v,k,E,_,T,Z,m,M,I,x;r=e.state,i=e.next_in,I=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,b=r.distcode,v=(1<<r.lenbits)-1,k=(1<<r.distbits)-1;e:do{g<15&&(u+=I[i++]<<g,g+=8,u+=I[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){T=E&65535,_&=15,_&&(g<_&&(u+=I[i++]<<g,g+=8),T+=u&(1<<_)-1,u>>>=_,g-=_),g<15&&(u+=I[i++]<<g,g+=8,u+=I[i++]<<g,g+=8),E=b[u&k];r:for(;;){if(_=E>>>24,u>>>=_,g-=_,_=E>>>16&255,_&16){if(Z=E&65535,_&=15,g<_&&(u+=I[i++]<<g,g+=8,g<_&&(u+=I[i++]<<g,g+=8)),Z+=u&(1<<_)-1,Z>h){e.msg="invalid distance too far back",r.mode=Wt;break e}if(u>>>=_,g-=_,_=a-o,Z>_){if(_=Z-_,_>l&&r.sane){e.msg="invalid distance too far back",r.mode=Wt;break e}if(m=0,M=p,d===0){if(m+=f-_,_<T){T-=_;do x[a++]=p[m++];while(--_);m=a-Z,M=x}}else if(d<_){if(m+=f+d-_,_-=d,_<T){T-=_;do x[a++]=p[m++];while(--_);if(m=0,d<T){_=d,T-=_;do x[a++]=p[m++];while(--_);m=a-Z,M=x}}}else if(m+=d-_,_<T){T-=_;do x[a++]=p[m++];while(--_);m=a-Z,M=x}for(;T>2;)x[a++]=M[m++],x[a++]=M[m++],x[a++]=M[m++],T-=3;T&&(x[a++]=M[m++],T>1&&(x[a++]=M[m++]))}else{m=a-Z;do x[a++]=x[m++],x[a++]=x[m++],x[a++]=x[m++],T-=3;while(T>2);T&&(x[a++]=x[m++],T>1&&(x[a++]=x[m++]))}}else if(_&64){e.msg="invalid distance code",r.mode=Wt;break e}else{E=b[(E&65535)+(u&(1<<_)-1)];continue r}break}}else if(_&64)if(_&32){r.mode=ol;break e}else{e.msg="invalid literal/length code",r.mode=Wt;break e}else{E=S[(E&65535)+(u&(1<<_)-1)];continue t}break}}while(i<n&&a<s);T=g>>3,i-=T,g-=T<<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 rt=15,Yn=852,qn=592,Gn=0,Gr=1,Vn=2,fl=[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],ll=[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],hl=[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],cl=[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 mt(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,b=0,v=0,k=0,E,_,T,Z,m,M=null,I=0,x,z=new J(rt+1),We=new J(rt+1),er=null,Ba=0,Za,tr,rr;for(f=0;f<=rt;f++)z[f]=0;for(l=0;l<i;l++)z[t[r+l]]++;for(u=h,p=rt;p>=1&&z[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&&z[d]===0;d++);for(u<d&&(u=d),b=1,f=1;f<=rt;f++)if(b<<=1,b-=z[f],b<0)return-1;if(b>0&&(e===Gn||p!==1))return-1;for(We[1]=0,f=1;f<rt;f++)We[f+1]=We[f]+z[f];for(l=0;l<i;l++)t[r+l]!==0&&(o[We[t[r+l]]++]=l);if(e===Gn?(M=er=o,x=19):e===Gr?(M=fl,I-=257,er=ll,Ba-=257,x=256):(M=hl,er=cl,x=-1),k=0,l=0,f=d,m=a,g=u,S=0,T=-1,v=1<<u,Z=v-1,e===Gr&&v>Yn||e===Vn&&v>qn)return 1;for(;;){Za=f-S,o[l]<x?(tr=0,rr=o[l]):o[l]>x?(tr=er[Ba+o[l]],rr=M[I+o[l]]):(tr=96,rr=0),E=1<<f-S,_=1<<g,d=_;do _-=E,n[m+(k>>S)+_]=Za<<24|tr<<16|rr|0;while(_!==0);for(E=1<<f-1;k&E;)E>>=1;if(E!==0?(k&=E-1,k+=E):k=0,l++,--z[f]===0){if(f===p)break;f=t[r+o[l]]}if(f>u&&(k&Z)!==T){for(S===0&&(S=u),m+=d,g=f-S,b=1<<g;g+S<p&&(b-=z[g+S],!(b<=0));)g++,b<<=1;if(v+=1<<g,e===Gr&&v>Yn||e===Vn&&v>qn)return 1;T=k&Z,n[T]=u<<24|g<<16|m-a|0}}return k!==0&&(n[m+k]=f-S<<24|64<<16|0),s.bits=u,0}var ul=0,Xn=1,Jn=2,Qn=4,dl=5,Yt=6,yt=0,pl=1,_l=2,Ae=-2,wl=-3,gl=-4,vl=-5,ea=8,ta=1,ra=2,ia=3,na=4,aa=5,oa=6,sa=7,fa=8,la=9,ha=10,ca=11,ue=12,Vr=13,ua=14,Xr=15,da=16,pa=17,_a=18,wa=19,qt=20,Gt=21,ga=22,va=23,ma=24,ya=25,ba=26,Jr=27,xa=28,Ea=29,D=30,ml=31,yl=32,bl=852,xl=592;function ka(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function El(){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 J(320),this.work=new J(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function kl(e){var t;return!e||!e.state?Ae:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=ta,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Ut(bl),t.distcode=t.distdyn=new Ut(xl),t.sane=1,t.back=-1,yt)}function Sa(e){var t;return!e||!e.state?Ae:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,kl(e))}function Sl(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))?Ae:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,Sa(e))}function Rl(e,t){var r,i;return e?(i=new El,e.state=i,i.window=null,r=Sl(e,t),r!==yt&&(e.state=null),r):Ae}var Ra=!0,Qr,ei;function Al(e){if(Ra){var t;for(Qr=new Ut(512),ei=new Ut(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(mt(Xn,e.lens,0,288,Qr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;mt(Jn,e.lens,0,32,ei,0,e.work,{bits:5}),Ra=!1}e.lencode=Qr,e.lenbits=9,e.distcode=ei,e.distbits=5}function Tl(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 zt(a.wsize)),i>=a.wsize?(he(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),he(a.window,t,r-i,n,a.wnext),i-=n,i?(he(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 Ll(e,t){var r,i,n,a,o,s,h,f,l,d,p,u,g,S,b=0,v,k,E,_,T,Z,m,M,I=new zt(4),x,z,We=[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 Ae;r=e.state,r.mode===ue&&(r.mode=Vr),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,M=yt;e:for(;;)switch(r.mode){case ta:if(r.wrap===0){r.mode=Vr;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,I[0]=f&255,I[1]=f>>>8&255,r.check=B(r.check,I,2,0),f=0,l=0,r.mode=ra;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=D;break}if((f&15)!==ea){e.msg="unknown compression method",r.mode=D;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=D;break}r.dmax=1<<m,e.adler=r.check=1,r.mode=f&512?ha:ue,f=0,l=0;break;case ra:for(;l<16;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(r.flags=f,(r.flags&255)!==ea){e.msg="unknown compression method",r.mode=D;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=D;break}r.head&&(r.head.text=f>>8&1),r.flags&512&&(I[0]=f&255,I[1]=f>>>8&255,r.check=B(r.check,I,2,0)),f=0,l=0,r.mode=ia;case ia:for(;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.head&&(r.head.time=f),r.flags&512&&(I[0]=f&255,I[1]=f>>>8&255,I[2]=f>>>16&255,I[3]=f>>>24&255,r.check=B(r.check,I,4,0)),f=0,l=0,r.mode=na;case na: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&&(I[0]=f&255,I[1]=f>>>8&255,r.check=B(r.check,I,2,0)),f=0,l=0,r.mode=aa;case aa: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&&(I[0]=f&255,I[1]=f>>>8&255,r.check=B(r.check,I,2,0)),f=0,l=0}else r.head&&(r.head.extra=null);r.mode=oa;case oa: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)),he(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=sa;case sa: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=fa;case fa: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=la;case la: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=D;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=ue;break;case ha:for(;l<32;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}e.adler=r.check=ka(f),f=0,l=0,r.mode=ca;case ca: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,_l;e.adler=r.check=1,r.mode=ue;case ue:if(t===dl||t===Yt)break e;case Vr:if(r.last){f>>>=l&7,l-=l&7,r.mode=Jr;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=ua;break;case 1:if(Al(r),r.mode=qt,t===Yt){f>>>=2,l-=2;break e}break;case 2:r.mode=pa;break;case 3:e.msg="invalid block type",r.mode=D}f>>>=2,l-=2;break;case ua: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=D;break}if(r.length=f&65535,f=0,l=0,r.mode=Xr,t===Yt)break e;case Xr:r.mode=da;case da:if(u=r.length,u){if(u>s&&(u=s),u>h&&(u=h),u===0)break e;he(n,i,a,u,o),s-=u,a+=u,h-=u,o+=u,r.length-=u;break}r.mode=ue;break;case pa: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=D;break}r.have=0,r.mode=_a;case _a:for(;r.have<r.ncode;){for(;l<3;){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}r.lens[We[r.have++]]=f&7,f>>>=3,l-=3}for(;r.have<19;)r.lens[We[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},M=mt(ul,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,M){e.msg="invalid code lengths set",r.mode=D;break}r.have=0,r.mode=wa;case wa:for(;r.have<r.nlen+r.ndist;){for(;b=r.lencode[f&(1<<r.lenbits)-1],v=b>>>24,k=b>>>16&255,E=b&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(z=v+2;l<z;){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=D;break}m=r.lens[r.have-1],u=3+(f&3),f>>>=2,l-=2}else if(E===17){for(z=v+3;l<z;){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(z=v+7;l<z;){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=D;break}for(;u--;)r.lens[r.have++]=m}}if(r.mode===D)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=D;break}if(r.lenbits=9,x={bits:r.lenbits},M=mt(Xn,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,M){e.msg="invalid literal/lengths set",r.mode=D;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},M=mt(Jn,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,M){e.msg="invalid distances set",r.mode=D;break}if(r.mode=qt,t===Yt)break e;case qt:r.mode=Gt;case Gt: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,sl(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===ue&&(r.back=-1);break}for(r.back=0;b=r.lencode[f&(1<<r.lenbits)-1],v=b>>>24,k=b>>>16&255,E=b&65535,!(v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(k&&!(k&240)){for(_=v,T=k,Z=E;b=r.lencode[Z+((f&(1<<_+T)-1)>>_)],v=b>>>24,k=b>>>16&255,E=b&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=ba;break}if(k&32){r.back=-1,r.mode=ue;break}if(k&64){e.msg="invalid literal/length code",r.mode=D;break}r.extra=k&15,r.mode=ga;case ga:if(r.extra){for(z=r.extra;l<z;){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=va;case va:for(;b=r.distcode[f&(1<<r.distbits)-1],v=b>>>24,k=b>>>16&255,E=b&65535,!(v<=l);){if(s===0)break e;s--,f+=i[a++]<<l,l+=8}if(!(k&240)){for(_=v,T=k,Z=E;b=r.distcode[Z+((f&(1<<_+T)-1)>>_)],v=b>>>24,k=b>>>16&255,E=b&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=D;break}r.offset=E,r.extra=k&15,r.mode=ma;case ma:if(r.extra){for(z=r.extra;l<z;){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=D;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=D;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=Gt);break;case ba:if(h===0)break e;n[o++]=r.length,h--,r.mode=Gt;break;case Jr: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):jr(r.check,n,p,o-p)),p=h,(r.flags?f:ka(f))!==r.check){e.msg="incorrect data check",r.mode=D;break}f=0,l=0}r.mode=xa;case xa: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=D;break}f=0,l=0}r.mode=Ea;case Ea:M=pl;break e;case D:M=wl;break e;case ml:return gl;case yl:default:return Ae}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<D&&(r.mode<Jr||t!==Qn))&&Tl(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):jr(r.check,n,p,e.next_out-p)),e.data_type=r.bits+(r.last?64:0)+(r.mode===ue?128:0)+(r.mode===qt||r.mode===Xr?256:0),(d===0&&p===0||t===Qn)&&M===yt&&(M=vl),M}function Cl(e){if(!e||!e.state)return Ae;var t=e.state;return t.window&&(t.window=null),e.state=null,yt}var ti=0,it=1,Vt=2,bt=3,Xt=4,nt=5,xt=6,Et=7,Aa=0,Ta=1,La=2,Ca=3,ri=4,Ia=5,Il=6,Jt=0,Oa=1,Ma=2,Ol=-1,Ml=-2,Dl=-3,Da=-5,Fl=0,Nl=1,Pl=9,zl=-1,Ul=1,Bl=2,Zl=3,jl=4,$l=0,Hl=0,Kl=1,Wl=2,Fa=8;function ee(e){if(e<it||e>Et)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}ee.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===Xt)&&(this.windowBits+=16),this.mode===Et&&(this.windowBits+=32),(this.mode===nt||this.mode===xt)&&(this.windowBits=-this.windowBits),this.strm=new cf;var a;switch(this.mode){case it:case bt:case nt:a=il(this.strm,this.level,Fa,this.windowBits,this.memLevel,this.strategy);break;case Vt:case Xt:case xt:case Et:a=Rl(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(a!==Jt){this._error(a);return}this.write_in_progress=!1,this.init_done=!0},ee.prototype.params=function(){throw new Error("deflateParams Not supported")},ee.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(this.mode===ti)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")},ee.prototype.write=function(e,t,r,i,n,a,o){this._writeCheck(),this.write_in_progress=!0;var s=this;return fe.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 Yl(e,t){for(var r=0;r<e.length;r++)this[t+r]=e[r]}ee.prototype.writeSync=function(e,t,r,i,n,a,o){return this._writeCheck(),this._write(e,t,r,i,n,a,o)},ee.prototype._write=function(e,t,r,i,n,a,o){if(this.write_in_progress=!0,e!==Aa&&e!==Ta&&e!==La&&e!==Ca&&e!==ri&&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=Yl;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 it:case bt:case nt:h=nl(s,e);break;case Et:case Vt:case Xt:case xt:h=Ll(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]},ee.prototype._checkError=function(e,t,r){switch(e){case Jt:case Da:if(t.avail_out!==0&&r===ri)return!1;break;case Oa:break;case Ma:return!1;default:return!1}return!0},ee.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}this.pending_close=!1,this.mode===it||this.mode===bt||this.mode===nt?al(this.strm):Cl(this.strm),this.mode=ti};var Qt;ee.prototype.reset=function(){switch(this.mode){case it:case nt:Qt=Wn(this.strm);break;case Vt:case xt:Qt=Sa(this.strm);break}Qt!==Jt&&this._error(Qt)},ee.prototype._error=function(e){this.onerror(mn[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var Na=Object.freeze({__proto__:null,DEFLATE:it,DEFLATERAW:nt,GUNZIP:Xt,GZIP:bt,INFLATE:Vt,INFLATERAW:xt,NONE:ti,UNZIP:Et,Z_BEST_COMPRESSION:Pl,Z_BEST_SPEED:Nl,Z_BINARY:Hl,Z_BLOCK:Ia,Z_BUF_ERROR:Da,Z_DATA_ERROR:Dl,Z_DEFAULT_COMPRESSION:zl,Z_DEFAULT_STRATEGY:$l,Z_DEFLATED:Fa,Z_ERRNO:Ol,Z_FILTERED:Ul,Z_FINISH:ri,Z_FIXED:jl,Z_FULL_FLUSH:Ca,Z_HUFFMAN_ONLY:Bl,Z_NEED_DICT:Ma,Z_NO_COMPRESSION:Fl,Z_NO_FLUSH:Aa,Z_OK:Jt,Z_PARTIAL_FLUSH:Ta,Z_RLE:Zl,Z_STREAM_END:Oa,Z_STREAM_ERROR:Ml,Z_SYNC_FLUSH:La,Z_TEXT:Kl,Z_TREES:Il,Z_UNKNOWN:Wl,Zlib:ee});function ql(e,t){if(!e)throw new Error(t)}var w={};Object.keys(Na).forEach(function(e){w[e]=Na[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 kt={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(kt).forEach(function(e){kt[kt[e]]=e});function Gl(e){return new Ue(e)}function Vl(e){return new Be(e)}function Xl(e){return new $e(e)}function Jl(e){return new He(e)}function Ql(e){return new Ze(e)}function eh(e){return new je(e)}function th(e){return new Ke(e)}function rh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ue(t),e,r)}function ih(e,t){return ze(new Ue(t),e)}function nh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ze(t),e,r)}function ah(e,t){return ze(new Ze(t),e)}function oh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new $e(t),e,r)}function sh(e,t){return ze(new $e(t),e)}function fh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Ke(t),e,r)}function lh(e,t){return ze(new Ke(t),e)}function hh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new Be(t),e,r)}function ch(e,t){return ze(new Be(t),e)}function uh(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new je(t),e,r)}function dh(e,t){return ze(new je(t),e)}function ph(e,t,r){return typeof t=="function"&&(r=t,t={}),Pe(new He(t),e,r)}function _h(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);F.call(this,e,w.DEFLATE)}function Be(e){if(!(this instanceof Be))return new Be(e);F.call(this,e,w.INFLATE)}function Ze(e){if(!(this instanceof Ze))return new Ze(e);F.call(this,e,w.GZIP)}function je(e){if(!(this instanceof je))return new je(e);F.call(this,e,w.GUNZIP)}function $e(e){if(!(this instanceof $e))return new $e(e);F.call(this,e,w.DEFLATERAW)}function He(e){if(!(this instanceof He))return new He(e);F.call(this,e,w.INFLATERAW)}function Ke(e){if(!(this instanceof Ke))return new Ke(e);F.call(this,e,w.UNZIP)}function F(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||w.Z_DEFAULT_CHUNK,X.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=kt[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)}$(F,X),F.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 fe.nextTick(r)},F.prototype.reset=function(){return this._binding.reset()},F.prototype._flush=function(e){this._transform(new c(0),"",e)},F.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&&fe.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)},F.prototype.close=function(e){if(e&&fe.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;fe.nextTick(function(){t.emit("close")})}},F.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)},F.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,b){if(!o._hadError){var v=n-b;if(ql(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((b===0||o._offset>=o._chunkSize)&&(n=o._chunkSize,o._offset=0,o._buffer=new c(o._chunkSize)),b===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()}}},$(Ue,F),$(Be,F),$(Ze,F),$(je,F),$($e,F),$(He,F),$(Ke,F);var Pa={codes:kt,createDeflate:Gl,createInflate:Vl,createDeflateRaw:Xl,createInflateRaw:Jl,createGzip:Ql,createGunzip:eh,createUnzip:th,deflate:rh,deflateSync:ih,gzip:nh,gzipSync:ah,deflateRaw:oh,deflateRawSync:sh,unzip:fh,unzipSync:lh,inflate:hh,inflateSync:ch,gunzip:uh,gunzipSync:dh,inflateRaw:ph,inflateRawSync:_h,Deflate:Ue,Inflate:Be,Gzip:Ze,Gunzip:je,DeflateRaw:$e,InflateRaw:He,Unzip:Ke,Zlib:F};class za extends ur{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=Pa.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 cr(r);return i=Buffer.from(i,"base64"),i=Pa.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 Ua extends y{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 wh={setup(e){},start(){},stop(){}},gh={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 vh extends Ua{constructor(t={}){super(),this.driver=t.driver}async setup(t){this.database=t,this.driver||(this.driver=new za({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}}}return R.BaseError=Ye,R.Cache=ur,R.CachePlugin=vh,R.Client=mi,R.ConnectionString=vi,R.CostsPlugin=gh,R.Database=Ci,R.ErrorMap=_i,R.InvalidResourceItem=Rt,R.MemoryCache=ho,R.MissingMetadata=di,R.NoSuchBucket=ci,R.NoSuchKey=sr,R.NotFound=ui,R.Plugin=Ua,R.PluginObject=wh,R.ResourceIdsPageReader=Ri,R.ResourceIdsReader=Si,R.ResourceReader=Ai,R.ResourceWriter=Ti,R.S3Cache=za,R.S3_DEFAULT_ENDPOINT=gi,R.S3_DEFAULT_REGION=wi,R.S3db=lo,R.UnknownError=pi,R.Validator=Ei,R.ValidatorManager=ki,R.decrypt=bi,R.encrypt=fr,R.sha256=yi,R.streamToString=cr,R})({},nanoid,lodashEs,promisePool,clientS3,flat,FastestValidator,web);
|
|
29
|
+
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function Wl(e){return Array.isArray(e)}function Fo(e){return typeof e=="boolean"}function Vn(e){return e===null}function Vl(e){return typeof e=="number"}function Gn(e){return typeof e=="string"}function De(e){return e===void 0}function Yn(e){return Rt(e)&&Qn(e)==="[object RegExp]"}function Rt(e){return typeof e=="object"&&e!==null}function Mo(e){return Rt(e)&&Qn(e)==="[object Date]"}function Jn(e){return Rt(e)&&(Qn(e)==="[object Error]"||e instanceof Error)}function Xn(e){return typeof e=="function"}function Qn(e){return Object.prototype.toString.call(e)}function Gl(e,t){if(!t||!Rt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Lo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function He(){this.head=null,this.tail=null,this.length=0}He.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},He.prototype.unshift=function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length},He.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}},He.prototype.clear=function(){this.head=this.tail=null,this.length=0},He.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},He.prototype.concat=function(e){if(this.length===0)return y.alloc(0);if(this.length===1)return this.head.data;for(var t=y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var Yl=y.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 Jl(e){if(e&&!Yl(e))throw new Error("Unknown encoding: "+e)}function Ot(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),Jl(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Ql;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=eu;break;default:this.write=Xl;return}this.charBuffer=new y(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 i=t.charCodeAt(t.length-1);if(i>=55296&&i<=56319){this.charLength+=this.surrogateSize,t="";continue}if(this.charReceived=this.charLength=0,e.length===0)return t;break}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived),t+=e.toString(this.encoding,0,n);var n=t.length-1,i=t.charCodeAt(n);if(i>=55296&&i<=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,n)}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,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function Xl(e){return e.toString(this.encoding)}function Ql(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function eu(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}N.ReadableState=jo;var D=Ul("stream");W(N,R);function tu(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 ru(e,t){return e.listeners(t).length}function jo(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ie&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new He,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 N(e){if(!(this instanceof N))return new N(e);this._readableState=new jo(e,this),this.readable=!0,e&&typeof e.read=="function"&&(this._read=e.read),R.call(this)}N.prototype.push=function(e,t){var r=this._readableState;return!r.objectMode&&typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=y.from(e,t),t="")),No(this,r,e,t,!1)},N.prototype.unshift=function(e){var t=this._readableState;return No(this,t,e,"",!0)},N.prototype.isPaused=function(){return this._readableState.flowing===!1};function No(e,t,r,n,i){var a=au(t,r);if(a)e.emit("error",a);else if(r===null)t.reading=!1,ou(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var c;t.decoder&&!i&&!n&&(r=t.decoder.write(r),c=!t.objectMode&&r.length===0),i||(t.reading=!1),c||(t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&dr(e))),su(e,t)}else i||(t.reading=!1);return nu(t)}function nu(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}N.prototype.setEncoding=function(e){return this._readableState.decoder=new Ot(e),this._readableState.encoding=e,this};var Bo=8388608;function iu(e){return e>=Bo?e=Bo:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Uo(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=iu(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}N.prototype.read=function(e){D("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 D("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?ti(this):dr(this),null;if(e=Uo(e,t),e===0&&t.ended)return t.length===0&&ti(this),null;var n=t.needReadable;D("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,D("length less than watermark",n)),t.ended||t.reading?(n=!1,D("reading or ended",n)):n&&(D("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Uo(r,t)));var i;return e>0?i=zo(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&ti(this)),i!==null&&this.emit("data",i),i};function au(e,t){var r=null;return!y.isBuffer(t)&&typeof t!="string"&&t!==null&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function ou(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,dr(e)}}function dr(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(D("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?te($o,e):$o(e))}function $o(e){D("emit readable"),e.emit("readable"),ei(e)}function su(e,t){t.readingMore||(t.readingMore=!0,te(fu,e,t))}function fu(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(D("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}N.prototype._read=function(e){this.emit("error",new Error("not implemented"))},N.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,D("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||t.end!==!1,a=i?s:l;n.endEmitted?te(a):r.once("end",a),e.on("unpipe",o);function o(w){D("onunpipe"),w===r&&l()}function s(){D("onend"),e.end()}var c=cu(r);e.on("drain",c);var f=!1;function l(){D("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",c),e.removeListener("error",u),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",l),r.removeListener("data",h),f=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var d=!1;r.on("data",h);function h(w){D("ondata"),d=!1;var x=e.write(w);x===!1&&!d&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&Zo(n.pipes,e)!==-1)&&!f&&(D("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function u(w){D("onerror",w),_(),e.removeListener("error",u),ru(e,"error")===0&&e.emit("error",w)}tu(e,"error",u);function p(){e.removeListener("finish",g),_()}e.once("close",p);function g(){D("onfinish"),e.removeListener("close",p),_()}e.once("finish",g);function _(){D("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(D("pipe resume"),r.resume()),e};function cu(e){return function(){var t=e._readableState;D("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&e.listeners("data").length&&(t.flowing=!0,ei(e))}}N.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,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var a=Zo(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)},N.prototype.on=function(e,t){var r=R.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&dr(this):te(lu,this))}return r},N.prototype.addListener=N.prototype.on;function lu(e){D("readable nexttick read 0"),e.read(0)}N.prototype.resume=function(){var e=this._readableState;return e.flowing||(D("resume"),e.flowing=!0,uu(this,e)),this};function uu(e,t){t.resumeScheduled||(t.resumeScheduled=!0,te(hu,e,t))}function hu(e,t){t.reading||(D("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),ei(e),t.flowing&&!t.reading&&e.read(0)}N.prototype.pause=function(){return D("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(D("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function ei(e){var t=e._readableState;for(D("flow",t.flowing);t.flowing&&e.read()!==null;);}N.prototype.wrap=function(e){var t=this._readableState,r=!1,n=this;e.on("end",function(){if(D("wrapped end"),t.decoder&&!t.ended){var o=t.decoder.end();o&&o.length&&n.push(o)}n.push(null)}),e.on("data",function(o){if(D("wrapped data"),t.decoder&&(o=t.decoder.write(o)),!(t.objectMode&&o==null)&&!(!t.objectMode&&(!o||!o.length))){var s=n.push(o);s||(r=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=function(o){return function(){return e[o].apply(e,arguments)}}(i));var a=["error","close","destroy","pause","resume"];return vu(a,function(o){e.on(o,n.emit.bind(n,o))}),n._read=function(o){D("wrapped _read",o),r&&(r=!1,e.resume())},n},N._fromList=zo;function zo(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=du(e,t.buffer,t.decoder),r}function du(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?pu(e,t):yu(e,t),n}function pu(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var a=r.data,o=e>a.length?a.length:e;if(o===a.length?i+=a:i+=a.slice(0,e),e-=o,e===0){o===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(o));break}++n}return t.length-=n,i}function yu(e,t){var r=y.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var a=n.data,o=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,o),e-=o,e===0){o===a.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=a.slice(o));break}++i}return t.length-=i,r}function ti(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,te(gu,t,e))}function gu(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function vu(e,t){for(var r=0,n=e.length;r<n;r++)t(e[r],r)}function Zo(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}q.WritableState=ri,W(q,R);function _u(){}function wu(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function ri(e,t){Object.defineProperty(this,"buffer",{get:Do(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof ie&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16*1024;this.highWaterMark=r||r===0?r:n,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){ku(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 Go(this)}ri.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};function q(e){if(!(this instanceof q)&&!(this instanceof ie))return new q(e);this._writableState=new ri(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev)),R.call(this)}q.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function bu(e,t){var r=new Error("write after end");e.emit("error",r),te(t,r)}function mu(e,t,r,n){var i=!0,a=!1;return r===null?a=new TypeError("May not write null values to stream"):!y.isBuffer(r)&&typeof r!="string"&&r!==void 0&&!t.objectMode&&(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),te(n,a),i=!1),i}q.prototype.write=function(e,t,r){var n=this._writableState,i=!1;return typeof t=="function"&&(r=t,t=null),y.isBuffer(e)?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=_u),n.ended?bu(this,r):mu(this,n,e,r)&&(n.pendingcb++,i=xu(this,n,e,t,r)),i},q.prototype.cork=function(){var e=this._writableState;e.corked++},q.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&Ho(this,e))},q.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 Eu(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=y.from(t,r)),t}function xu(e,t,r,n,i){r=Eu(t,r,n),y.isBuffer(r)&&(n="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 wu(r,n,i),s?s.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else ni(e,t,!1,a,r,n,i);return o}function ni(e,t,r,n,i,a,o){t.writelen=n,t.writecb=o,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function Su(e,t,r,n,i){--t.pendingcb,r?te(i,n):i(n),e._writableState.errorEmitted=!0,e.emit("error",n)}function Au(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function ku(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(Au(r),t)Su(e,r,n,t,i);else{var a=Ko(r);!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Ho(e,r),n?te(qo,e,r,a,i):qo(e,r,a,i)}}function qo(e,t,r,n){r||Ru(e,t),t.pendingcb--,n(),Vo(e,t)}function Ru(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Ho(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var o=0;r;)i[o]=r,r=r.next,o+=1;ni(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new Go(t)}else{for(;r;){var s=r.chunk,c=r.encoding,f=r.callback,l=t.objectMode?1:s.length;if(ni(e,t,!1,l,s,c,f),r=r.next,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=r,t.bufferProcessing=!1}q.prototype._write=function(e,t,r){r(new Error("not implemented"))},q.prototype._writev=null,q.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),!n.ending&&!n.finished&&Ou(this,n,r)};function Ko(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Wo(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Vo(e,t){var r=Ko(t);return r&&(t.pendingcb===0?(Wo(e,t),t.finished=!0,e.emit("finish")):Wo(e,t)),r}function Ou(e,t,r){t.ending=!0,Vo(e,t),r&&(t.finished?te(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function Go(e){var t=this;this.next=null,this.entry=null,this.finish=function(r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}W(ie,N);for(var Yo=Object.keys(q.prototype),ii=0;ii<Yo.length;ii++){var ai=Yo[ii];ie.prototype[ai]||(ie.prototype[ai]=q.prototype[ai])}function ie(e){if(!(this instanceof ie))return new ie(e);N.call(this,e),q.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",Tu)}function Tu(){this.allowHalfOpen||this._writableState.ended||te(Pu,this)}function Pu(e){e.end()}W(re,ie);function Iu(e){this.afterTransform=function(t,r){return Cu(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function Cu(e,t,r){var n=e._transformState;n.transforming=!1;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,r!=null&&e.push(r),i(t);var a=e._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&e._read(a.highWaterMark)}function re(e){if(!(this instanceof re))return new re(e);ie.call(this,e),this._transformState=new Iu(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){Jo(t,r)}):Jo(t)})}re.prototype.push=function(e,t){return this._transformState.needTransform=!1,ie.prototype.push.call(this,e,t)},re.prototype._transform=function(e,t,r){throw new Error("Not implemented")},re.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},re.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 Jo(e,t){if(t)return e.emit("error",t);var r=e._writableState,n=e._transformState;if(r.length)throw new Error("Calling transform done when ws.length != 0");if(n.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}W(Tt,re);function Tt(e){if(!(this instanceof Tt))return new Tt(e);re.call(this,e)}Tt.prototype._transform=function(e,t,r){r(null,e)},W(xe,R),xe.Readable=N,xe.Writable=q,xe.Duplex=ie,xe.Transform=re,xe.PassThrough=Tt,xe.Stream=xe;function xe(){R.call(this)}xe.prototype.pipe=function(e,t){var r=this;function n(l){e.writable&&e.write(l)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!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 c(l){if(f(),R.listenerCount(this,"error")===0)throw l}r.on("error",c),e.on("error",c);function f(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",o),r.removeListener("close",s),r.removeListener("error",c),e.removeListener("error",c),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};class Xo extends R{constructor({resource:t}){super(),this.resource=t,this.client=t.client,this.stream=new Ff.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}),n=r?.Contents.map(i=>i.Key).map(i=>i.replace(this.client.config.keyPrefix,"")).map(i=>i.startsWith("/")?i.replace("/",""):i).map(i=>i.replace(`resource=${this.resource.name}/id=`,""));this.continuationToken=r.NextContinuationToken,this.enqueue(n),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 Qo extends Xo{enqueue(t){this.controller.enqueue(t),this.emit("page",t)}}class es extends R{constructor({resource:t,batchSize:r=10,concurrency:n=5}){if(super(),!t)throw new Error("Resource is required for ResourceReader");this.resource=t,this.client=t.client,this.batchSize=r,this.concurrency=n,this.input=new Qo({resource:this.resource}),this.transform=new re({objectMode:!0,transform:this._transform.bind(this)}),this.input.on("data",i=>{this.transform.write(i)}),this.input.on("end",()=>{this.transform.end()}),this.input.on("error",i=>{this.emit("error",i)}),this.transform.on("data",i=>{this.emit("data",i)}),this.transform.on("end",()=>{this.emit("end")}),this.transform.on("error",i=>{this.emit("error",i)})}build(){return this}async _transform(t,r,n){try{await ce.PromisePool.for(t).withConcurrency(this.concurrency).handleError(async(i,a)=>{this.emit("error",i,a)}).process(async i=>{const a=await this.resource.get(i);return this.push(a),a}),n()}catch(i){n(i)}}resume(){this.input.resume()}}class ts extends R{constructor({resource:t,batchSize:r=10,concurrency:n=5}){super(),this.resource=t,this.client=t.client,this.batchSize=r,this.concurrency=n,this.buffer=[],this.writing=!1,this.writable=new q({objectMode:!0,write:this._write.bind(this)}),this.writable.on("finish",()=>{this.emit("finish")}),this.writable.on("error",i=>{this.emit("error",i)})}build(){return this}write(t){return this.buffer.push(t),this._maybeWrite(),!0}end(){this.ended=!0,this._maybeWrite()}async _maybeWrite(){if(!this.writing&&!(this.buffer.length===0&&!this.ended)){for(this.writing=!0;this.buffer.length>0;){const t=this.buffer.splice(0,this.batchSize);try{await ce.PromisePool.for(t).withConcurrency(this.concurrency).handleError(async(r,n)=>{this.emit("error",r,n)}).process(async r=>{await this.resource.insert(r)})}catch(r){this.emit("error",r)}}this.writing=!1,this.ended&&this.writable.emit("finish")}}async _write(t,r,n){n()}}function Pt(e){return new Promise((t,r)=>{const n=[];e.on("data",i=>n.push(i)),e.on("error",r),e.on("end",()=>t(Buffer.concat(n).toString("utf-8")))})}function It(e){typeof e!="string"&&(e=String(e));let t=0;for(let r=0;r<e.length;r++){const n=e.codePointAt(r);n<=127?t+=1:n<=2047?t+=2:n<=65535?t+=3:n<=1114111&&(t+=4,n>65535&&r++)}return t}function rs(e){return e==null?"":typeof e=="boolean"?e?"1":"0":typeof e=="number"?String(e):typeof e=="string"?e:Array.isArray(e)?e.length===0?"[]":e.map(t=>String(t)).join("|"):typeof e=="object"?JSON.stringify(e):String(e)}function oi(e){const t={};for(const[r,n]of Object.entries(e)){const i=rs(n),a=It(i);t[r]=a}return t}function Ke(e){const t=oi(e);return Object.values(t).reduce((r,n)=>r+n,0)}const Se=2048;async function Du({resource:e,data:t,mappedData:r}){const n=Ke(r);return n>Se&&e.emit("exceedsLimit",{operation:"insert",totalSize:n,limit:Se,excess:n-Se,data:t}),{mappedData:r,body:""}}async function Fu({resource:e,id:t,data:r,mappedData:n}){const i=Ke(n);return i>Se&&e.emit("exceedsLimit",{operation:"update",id:t,totalSize:i,limit:Se,excess:i-Se,data:r}),{mappedData:n,body:""}}async function Mu({resource:e,id:t,data:r,mappedData:n}){const i=Ke(n);return i>Se&&e.emit("exceedsLimit",{operation:"upsert",id:t,totalSize:i,limit:Se,excess:i-Se,data:r}),{mappedData:n,body:""}}async function Lu({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}var ju=Object.freeze({__proto__:null,handleGet:Lu,handleInsert:Du,handleUpdate:Fu,handleUpsert:Mu});const pt=2048;async function Nu({resource:e,data:t,mappedData:r}){const n=Ke(r);if(n>pt)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${n} bytes, limit: ${pt} bytes`);return{mappedData:r,body:""}}async function Bu({resource:e,id:t,data:r,mappedData:n}){const i=Ke(n);if(i>pt)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${i} bytes, limit: ${pt} bytes`);return{mappedData:n,body:""}}async function Uu({resource:e,id:t,data:r,mappedData:n}){const i=Ke(n);if(i>pt)throw new Error(`S3 metadata size exceeds 2KB limit. Current size: ${i} bytes, limit: ${pt} bytes`);return{mappedData:n,body:""}}async function $u({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}var zu=Object.freeze({__proto__:null,handleGet:$u,handleInsert:Nu,handleUpdate:Bu,handleUpsert:Uu});const ns=2048,is="...",as=It(is);async function Zu({resource:e,data:t,mappedData:r}){return si({resource:e,data:t,mappedData:r})}async function qu({resource:e,id:t,data:r,mappedData:n}){return si({resource:e,data:r,mappedData:n})}async function Hu({resource:e,id:t,data:r,mappedData:n}){return si({resource:e,data:r,mappedData:n})}async function Ku({resource:e,metadata:t,body:r}){return{metadata:t,body:r}}function si({resource:e,data:t,mappedData:r}){const n=oi(r),i=Object.entries(n).sort(([,s],[,c])=>s-c),a={};let o=0;for(const[s,c]of i){const f=ns-o;if(c<=f)a[s]=r[s],o+=c;else if(f>as){const l=f-as,d=rs(r[s]);let h="",u=0;for(let p=0;p<d.length;p++){const g=d[p],_=It(g);if(u+_<=l)h+=g,u+=_;else break}a[s]=h+is,o=ns;break}else break}return{mappedData:a,body:""}}var Wu=Object.freeze({__proto__:null,handleGet:Ku,handleInsert:Zu,handleUpdate:qu,handleUpsert:Hu});const os=2048,pr="$overflow",fi="true",Vu=It(pr)+It(fi);async function Gu({resource:e,data:t,mappedData:r}){return ci({resource:e,data:t,mappedData:r})}async function Yu({resource:e,id:t,data:r,mappedData:n}){return ci({resource:e,data:r,mappedData:n})}async function Ju({resource:e,id:t,data:r,mappedData:n}){return ci({resource:e,data:r,mappedData:n})}async function Xu({resource:e,metadata:t,body:r}){if(t[pr]===fi)try{const n=r?JSON.parse(r):{},i={...t};return delete i[pr],{metadata:{...i,...n},body:""}}catch{return{metadata:t,body:r}}return{metadata:t,body:r}}function ci({resource:e,data:t,mappedData:r}){if(Ke(r)<=os)return{mappedData:r,body:""};const i=os-Vu,a=oi(r),o=Object.entries(a).sort(([,d],[,h])=>d-h),s={},c={};let f=0;for(const[d,h]of o)f+h<=i?(s[d]=r[d],f+=h):c[d]=r[d];s[pr]=fi;const l=Object.keys(c).length>0?JSON.stringify(c):"";return{mappedData:s,body:l}}var Qu=Object.freeze({__proto__:null,handleGet:Xu,handleInsert:Gu,handleUpdate:Yu,handleUpsert:Ju});const ss={"user-management":ju,"enforce-limits":zu,"data-truncate":Wu,"body-overflow":Qu};function yt(e){const t=ss[e];if(!t)throw new Error(`Unknown behavior: ${e}. Available behaviors: ${Object.keys(ss).join(", ")}`);return t}const eh="user-management";class fs extends R{constructor({name:t,client:r,version:n="1",options:i={},attributes:a={},parallelism:o=10,passphrase:s="secret",observers:c=[],behavior:f=eh}){if(super(),this.name=t,this.client=r,this.version=n,this.behavior=f,this.observers=c,this.parallelism=o,this.passphrase=s??"secret",this.options={cache:!1,autoDecrypt:!0,timestamps:!1,partitions:{},paranoid:!0,...i},this.hooks={preInsert:[],afterInsert:[],preUpdate:[],afterUpdate:[],preDelete:[],afterDelete:[]},this.attributes=a||{},i.timestamps&&(this.attributes.createdAt="string|optional",this.attributes.updatedAt="string|optional",this.options.partitions.byCreatedDate||(this.options.partitions.byCreatedDate={fields:{createdAt:"date|maxlength:10"}}),this.options.partitions.byUpdatedDate||(this.options.partitions.byUpdatedDate={fields:{updatedAt:"date|maxlength:10"}})),this.schema=new nr({name:t,attributes:this.attributes,passphrase:s,version:this.version,options:this.options}),this.validatePartitions(),this.setupPartitionHooks(),i.hooks){for(const[l,d]of Object.entries(i.hooks))if(Array.isArray(d)&&this.hooks[l])for(const h of d)this.hooks[l].push(h.bind(this))}}export(){const t=this.schema.export();return t.behavior=this.behavior,t}updateAttributes(t){const r=this.attributes;return this.attributes=t,this.options.timestamps&&(t.createdAt="string|optional",t.updatedAt="string|optional",this.options.partitions.byCreatedDate||(this.options.partitions.byCreatedDate={fields:{createdAt:"date|maxlength:10"}}),this.options.partitions.byUpdatedDate||(this.options.partitions.byUpdatedDate={fields:{updatedAt:"date|maxlength:10"}})),this.schema=new nr({name:this.name,attributes:t,passphrase:this.passphrase,version:this.version,options:this.options}),this.validatePartitions(),this.setupPartitionHooks(),{oldAttributes:r,newAttributes:t}}addHook(t,r){this.hooks[t]&&this.hooks[t].push(r.bind(this))}async executeHooks(t,r){if(!this.hooks[t])return r;let n=r;for(const i of this.hooks[t])n=await i(n);return n}setupPartitionHooks(){const t=this.options.partitions;!t||Object.keys(t).length===0||(this.addHook("afterInsert",async r=>(await this.createPartitionReferences(r),r)),this.addHook("afterDelete",async r=>(await this.deletePartitionReferences(r),r)))}async validate(t){const r={original:M.cloneDeep(t),isValid:!1,errors:[]},n=await this.schema.validate(t,{mutateOriginal:!0});return n===!0?r.isValid=!0:r.errors=n,r.data=t,r}validatePartitions(){const t=this.options.partitions;if(!t||Object.keys(t).length===0)return;const r=Object.keys(this.attributes||{});for(const[n,i]of Object.entries(t))if(i.fields){for(const a of Object.keys(i.fields))if(!r.includes(a))throw new Error(`Partition '${n}' uses field '${a}' which does not exist in resource version '${this.version}'. Available fields: ${r.join(", ")}. This version of resource does not have support for this partition.`)}}applyPartitionRule(t,r){if(t==null)return t;let n=t;if(typeof r=="string"&&r.includes("maxlength:")){const i=r.match(/maxlength:(\d+)/);if(i){const a=parseInt(i[1]);typeof n=="string"&&n.length>a&&(n=n.substring(0,a))}}if(r.includes("date")){if(n instanceof Date)n=n.toISOString().split("T")[0];else if(typeof n=="string")try{if(n.includes("T")&&n.includes("Z"))n=n.split("T")[0];else{const i=new Date(n);isNaN(i.getTime())||(n=i.toISOString().split("T")[0])}}catch{}}return n}getResourceKey(t){return we(`resource=${this.name}`,`v=${this.version}`,`id=${t}`)}getPartitionKey(t,r,n){const i=this.options.partitions[t];if(!i)throw new Error(`Partition '${t}' not found`);const a=[],o=Object.entries(i.fields).sort(([s],[c])=>s.localeCompare(c));for(const[s,c]of o){const f=this.applyPartitionRule(n[s],c);if(f==null)return null;a.push(`${s}=${f}`)}return a.length===0?null:we(`resource=${this.name}`,`partition=${t}`,...a,`id=${r}`)}async insert({id:t,...r}){this.options.timestamps&&(r.createdAt=new Date().toISOString(),r.updatedAt=new Date().toISOString());const n=await this.executeHooks("preInsert",r),{errors:i,isValid:a,data:o}=await this.validate(n);if(!a)throw new Jt({bucket:this.client.config.bucket,resourceName:this.name,attributes:n,validation:i});!t&&t!==0&&(t=zi());const s=await this.schema.mapper(o),c=yt(this.behavior),{mappedData:f,body:l}=await c.handleInsert({resource:this,data:o,mappedData:s}),d=this.getResourceKey(t);await this.client.putObject({metadata:f,key:d,body:l});const h=M.merge({id:t},o);return await this.executeHooks("afterInsert",h),this.emit("insert",h),h}async get(t){const r=this.getResourceKey(t),n=await this.client.headObject(r),i=this.extractVersionFromKey(r)||this.version;let o=await(await this.getSchemaForVersion(i)).unmapper(n.Metadata);const s=yt(this.behavior);let c="";if(n.ContentLength>0)try{const d=await this.client.getObject(r);c=await Pt(d.Body)}catch{c=""}const{metadata:f}=await s.handleGet({resource:this,metadata:o,body:c});let l=f;return l.id=t,l._contentLength=n.ContentLength,l._lastModified=n.LastModified,l._hasContent=n.ContentLength>0,l._mimeType=n.ContentType||null,n.VersionId&&(l._versionId=n.VersionId),n.Expiration&&(l._expiresAt=n.Expiration),l._definitionHash=this.getDefinitionHash(),this.emit("get",l),l}async exists(t){try{const r=this.getResourceKey(t);return await this.client.headObject(r),!0}catch{return!1}}async update(t,r){const n=await this.get(t);this.options.timestamps&&(r.updatedAt=new Date().toISOString());const i=await this.executeHooks("preUpdate",r),a=M.merge(n,i);delete a.id;const{isValid:o,errors:s,data:c}=await this.validate(a);if(!o)throw new Jt({bucket:this.client.bucket,resourceName:this.name,attributes:i,validation:s});const f=await this.schema.mapper(c),l=yt(this.behavior),{mappedData:d,body:h}=await l.handleUpdate({resource:this,id:t,data:c,mappedData:f}),u=this.getResourceKey(t);let p,g=h;if(h===""&&this.behavior!=="body-overflow")try{const _=await this.client.getObject(u);if(_.ContentLength>0){const w=Buffer.from(await _.Body.transformToByteArray()),x=w.toString();try{JSON.parse(x)}catch{g=w,p=_.ContentType}}}catch{}return await this.client.putObject({key:u,body:g,contentType:p,metadata:d}),c.id=t,await this.executeHooks("afterUpdate",c),await this.updatePartitionReferences(c),this.emit("update",i,c),c}async delete(t){let r;try{r=await this.get(t)}catch{r={id:t}}await this.executeHooks("preDelete",r);const n=this.getResourceKey(t),i=await this.client.deleteObject(n);return await this.executeHooks("afterDelete",r),this.emit("delete",t),i}async upsert({id:t,...r}){return await this.exists(t)?this.update(t,r):this.insert({id:t,...r})}async count({partition:t=null,partitionValues:r={}}={}){let n;if(t&&Object.keys(r).length>0){const a=this.options.partitions[t];if(!a)throw new Error(`Partition '${t}' not found`);const o=[],s=Object.entries(a.fields).sort(([c],[f])=>c.localeCompare(f));for(const[c,f]of s){const l=r[c];if(l!=null){const d=this.applyPartitionRule(l,f);o.push(`${c}=${d}`)}}o.length>0?n=`resource=${this.name}/partition=${t}/${o.join("/")}`:n=`resource=${this.name}/partition=${t}`}else n=`resource=${this.name}/v=${this.version}`;const i=await this.client.count({prefix:n});return this.emit("count",i),i}async insertMany(t){const{results:r}=await ce.PromisePool.for(t).withConcurrency(this.parallelism).handleError(async(n,i)=>{this.emit("error",n,i),this.observers.map(a=>a.emit("error",this.name,n,i))}).process(async n=>await this.insert(n));return this.emit("insertMany",t.length),r}async deleteMany(t){const r=M.chunk(t.map(i=>this.getResourceKey(i)),1e3),{results:n}=await ce.PromisePool.for(r).withConcurrency(this.parallelism).handleError(async(i,a)=>{this.emit("error",i,a),this.observers.map(o=>o.emit("error",this.name,i,a))}).process(async i=>{const a=await this.client.deleteObjects(i);return i.forEach(o=>{const c=o.split("/").find(l=>l.startsWith("id=")),f=c?c.replace("id=",""):null;f&&(this.emit("deleted",f),this.observers.map(l=>l.emit("deleted",this.name,f)))}),a});return this.emit("deleteMany",t.length),n}async deleteAll(){if(this.options.paranoid!==!1)throw new Error(`deleteAll() is a dangerous operation and requires paranoid: false option. Current paranoid setting: ${this.options.paranoid}`);const t=`resource=${this.name}/v=${this.version}`,r=await this.client.deleteAll({prefix:t});return this.emit("deleteAll",{version:this.version,prefix:t,deletedCount:r}),{deletedCount:r,version:this.version}}async deleteAllData(){if(this.options.paranoid!==!1)throw new Error(`deleteAllData() is a dangerous operation and requires paranoid: false option. Current paranoid setting: ${this.options.paranoid}`);const t=`resource=${this.name}`,r=await this.client.deleteAll({prefix:t});return this.emit("deleteAllData",{resource:this.name,prefix:t,deletedCount:r}),{deletedCount:r,resource:this.name}}async listIds({partition:t=null,partitionValues:r={}}={}){let n;if(t&&Object.keys(r).length>0){const o=this.options.partitions[t];if(!o)throw new Error(`Partition '${t}' not found`);const s=[],c=Object.entries(o.fields).sort(([f],[l])=>f.localeCompare(l));for(const[f,l]of c){const d=r[f];if(d!=null){const h=this.applyPartitionRule(d,l);s.push(`${f}=${h}`)}}s.length>0?n=`resource=${this.name}/partition=${t}/${s.join("/")}`:n=`resource=${this.name}/partition=${t}`}else n=`resource=${this.name}/v=${this.version}`;const a=(await this.client.getAllKeys({prefix:n})).map(o=>{const c=o.split("/").find(f=>f.startsWith("id="));return c?c.replace("id=",""):null}).filter(Boolean);return this.emit("listIds",a.length),a}async listByPartition({partition:t=null,partitionValues:r={}}={},n={}){const{limit:i,offset:a=0}=n;if(!t){let g=(await this.listIds({partition:t,partitionValues:r})).slice(a);i&&(g=g.slice(0,i));const{results:_}=await ce.PromisePool.for(g).withConcurrency(this.parallelism).process(async w=>await this.get(w));return this.emit("listByPartition",{partition:t,partitionValues:r,count:_.length}),_}const o=this.options.partitions[t];if(!o)throw new Error(`Partition '${t}' not found`);const s=[],c=Object.entries(o.fields).sort(([p],[g])=>p.localeCompare(g));for(const[p,g]of c){const _=r[p];if(_!=null){const w=this.applyPartitionRule(_,g);s.push(`${p}=${w}`)}}let f;s.length>0?f=`resource=${this.name}/partition=${t}/${s.join("/")}`:f=`resource=${this.name}/partition=${t}`;let h=(await this.client.getAllKeys({prefix:f})).map(p=>{const _=p.split("/").find(w=>w.startsWith("id="));return _?_.replace("id=",""):null}).filter(Boolean).slice(a);i&&(h=h.slice(0,i));const{results:u}=await ce.PromisePool.for(h).withConcurrency(this.parallelism).process(async p=>await this.getFromPartition(p,t,r));return this.emit("listByPartition",{partition:t,partitionValues:r,count:u.length}),u}async getMany(t){const{results:r}=await ce.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async n=>{this.emit("id",n);const i=await this.get(n);return this.emit("data",i),i});return this.emit("getMany",t.length),r}async getAll(){let t=await this.listIds();if(t.length===0)return[];const{results:r}=await ce.PromisePool.for(t).withConcurrency(this.client.parallelism).process(async n=>await this.get(n));return this.emit("getAll",r.length),r}async page(t=0,r=100,{partition:n=null,partitionValues:i={}}={}){const a=await this.listIds({partition:n,partitionValues:i}),o=a.length,s=Math.ceil(o/r),c=a.slice(t*r,(t+1)*r),l={items:await Promise.all(c.map(d=>this.get(d))),totalItems:o,page:t,pageSize:r,totalPages:s};return this.emit("page",l),l}readable(){return new es({resource:this}).build()}writable(){return new ts({resource:this}).build()}async setContent(t,r,n="application/octet-stream"){if(!Buffer.isBuffer(r))throw new Error("Content must be a Buffer");const i=this.getResourceKey(t);let a={};try{a=(await this.client.headObject(i)).Metadata||{}}catch{}const o=await this.client.putObject({key:i,body:r,contentType:n,metadata:a});return this.emit("setContent",t,r.length,n),o}async content(t){const r=this.getResourceKey(t);try{const n=await this.client.getObject(r),i=Buffer.from(await n.Body.transformToByteArray()),a=n.ContentType||null;return this.emit("content",t,i.length,a),{buffer:i,contentType:a}}catch(n){if(n.name==="NoSuchKey")return{buffer:null,contentType:null};throw n}}async hasContent(t){const r=this.getResourceKey(t);try{return(await this.client.headObject(r)).ContentLength>0}catch{return!1}}async deleteContent(t){const r=this.getResourceKey(t),i=(await this.client.headObject(r)).Metadata||{},a=await this.client.putObject({key:r,body:"",metadata:i});return this.emit("deleteContent",t),a}getDefinitionHash(){const t=this.schema.export(),r=oo(t);return`sha256:${Ni.createHash("sha256").update(r).digest("hex")}`}extractVersionFromKey(t){const n=t.split("/").find(i=>i.startsWith("v="));return n?n.replace("v=",""):null}async getSchemaForVersion(t){return this.schema}async createPartitionReferences(t){const r=this.options.partitions;if(!(!r||Object.keys(r).length===0))for(const[n,i]of Object.entries(r)){const a=this.getPartitionKey(n,t.id,t);if(a){const o=await this.schema.mapper(t),s=yt(this.behavior),{mappedData:c,body:f}=await s.handleInsert({resource:this,data:t,mappedData:o}),l={...c,_version:this.version};await this.client.putObject({key:a,metadata:l,body:f})}}}async deletePartitionReferences(t){const r=this.options.partitions;if(!r||Object.keys(r).length===0)return;const n=[];for(const[i,a]of Object.entries(r)){const o=this.getPartitionKey(i,t.id,t);o&&n.push(o)}if(n.length>0)try{await this.client.deleteObjects(n)}catch(i){console.warn("Some partition objects could not be deleted:",i.message)}}async query(t={}){const r=await this.getAll();return Object.keys(t).length===0?r:r.filter(n=>Object.entries(t).every(([i,a])=>n[i]===a))}async updatePartitionReferences(t){const r=this.options.partitions;if(!(!r||Object.keys(r).length===0))for(const[n,i]of Object.entries(r)){const a=this.getPartitionKey(n,t.id,t);if(a){const o=await this.schema.mapper(t),s=yt(this.behavior),{mappedData:c,body:f}=await s.handleUpdate({resource:this,id:t.id,data:t,mappedData:o}),l={...c,_version:this.version};try{await this.client.putObject({key:a,metadata:l,body:f})}catch(d){console.warn(`Partition object could not be updated for ${n}:`,d.message)}}}}async getFromPartition(t,r,n={}){const i=this.options.partitions[r];if(!i)throw new Error(`Partition '${r}' not found`);const a=[],o=Object.entries(i.fields).sort(([_],[w])=>_.localeCompare(w));for(const[_,w]of o){const x=n[_];if(x!=null){const S=this.applyPartitionRule(x,w);a.push(`${_}=${S}`)}}if(a.length===0)throw new Error(`No partition values provided for partition '${r}'`);const s=we(`resource=${this.name}`,`partition=${r}`,...a,`id=${t}`),c=await this.client.headObject(s),f=c.Metadata?._version||this.version;let d=await(await this.getSchemaForVersion(f)).unmapper(c.Metadata);const h=yt(this.behavior);let u="";if(c.ContentLength>0)try{const _=await this.client.getObject(s);u=await Pt(_.Body)}catch{u=""}const{metadata:p}=await h.handleGet({resource:this,metadata:d,body:u});let g=p;return g.id=t,g._contentLength=c.ContentLength,g._lastModified=c.LastModified,g._hasContent=c.ContentLength>0,g._mimeType=c.ContentType||null,g._partition=r,g._partitionValues=n,c.VersionId&&(g._versionId=c.VersionId),c.Expiration&&(g._expiresAt=c.Expiration),g._definitionHash=this.getDefinitionHash(),this.emit("getFromPartition",g),g}}class cs extends R{constructor(t){super(),this.version="1",this.s3dbVersion=(()=>{try{return"4.0.1"}catch{return"latest"}})(),this.resources={},this.savedMetadata=null,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 ta({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 n=await this.client.getObject("s3db.json");t=JSON.parse(await Pt(n?.Body))}else t=this.blankMetadataStructure(),await this.uploadMetadataFile();this.savedMetadata=t;const r=this.detectDefinitionChanges(t);for(const[n,i]of Object.entries(t.resources||{})){const a=i.currentVersion||"v0",o=i.versions?.[a];o&&(this.resources[n]=new fs({name:n,client:this.client,version:a,options:{...o.options,partitions:i.partitions||o.options?.partitions||{}},attributes:o.attributes,behavior:o.behavior||"user-management",parallelism:this.parallelism,passphrase:this.passphrase,observers:[this]}))}r.length>0&&this.emit("resourceDefinitionsChanged",{changes:r,metadata:this.savedMetadata}),this.emit("connected",new Date)}detectDefinitionChanges(t){const r=[];for(const[n,i]of Object.entries(this.resources)){const a=this.generateDefinitionHash(i.export()),o=t.resources?.[n];if(!o)r.push({type:"new",resourceName:n,currentHash:a,savedHash:null});else{const s=o.currentVersion||"v0",f=o.versions?.[s]?.hash;f!==a&&r.push({type:"changed",resourceName:n,currentHash:a,savedHash:f,fromVersion:s,toVersion:this.getNextVersion(o.versions)})}}for(const[n,i]of Object.entries(t.resources||{}))if(!this.resources[n]){const a=i.currentVersion||"v0",o=i.versions?.[a];r.push({type:"deleted",resourceName:n,currentHash:null,savedHash:o?.hash,deletedVersion:a})}return r}generateDefinitionHash(t){const r=oo(t);return`sha256:${Ni.createHash("sha256").update(r).digest("hex")}`}getNextVersion(t={}){const r=Object.keys(t).filter(i=>i.startsWith("v")).map(i=>parseInt(i.substring(1))).filter(i=>!isNaN(i));return`v${(r.length>0?Math.max(...r):-1)+1}`}async startPlugins(){const t=this;if(!M.isEmpty(this.plugins)){const r=this.plugins.map(a=>M.isFunction(a)?new a(this):a),n=r.map(async a=>{a.beforeSetup&&await a.beforeSetup(),await a.setup(t),a.afterSetup&&await a.afterSetup()});await Promise.all(n);const i=r.map(async a=>{a.beforeStart&&await a.beforeStart(),await a.start(),a.afterStart&&await a.afterStart()});await Promise.all(i)}}async uploadMetadataFile(){const t={version:this.version,s3dbVersion:this.s3dbVersion,lastUpdated:new Date().toISOString(),resources:{}};Object.entries(this.resources).forEach(([r,n])=>{const i=n.export(),a=this.generateDefinitionHash(i),o=this.savedMetadata?.resources?.[r],s=o?.currentVersion||"v0",c=o?.versions?.[s];let f,l;!c||c.hash!==a?(f=this.getNextVersion(o?.versions),l=!0):(f=s,l=!1),t.resources[r]={currentVersion:f,partitions:i.options?.partitions||{},versions:{...o?.versions,[f]:{hash:a,attributes:i.attributes,options:i.options,behavior:i.behavior||"user-management",createdAt:l?new Date().toISOString():c?.createdAt}}},n.version!==f&&(n.version=f,n.emit("versionUpdated",{oldVersion:s,newVersion:f}))}),await this.client.putObject({key:"s3db.json",body:JSON.stringify(t,null,2),contentType:"application/json"}),this.savedMetadata=t,this.emit("metadataUploaded",t)}blankMetadataStructure(){return{version:"1",s3dbVersion:this.s3dbVersion,resources:{}}}async createResource({name:t,attributes:r,options:n={},behavior:i="user-management"}){if(this.resources[t]){const c=this.resources[t];return Object.assign(c.options,{cache:this.cache,...n}),i&&(c.behavior=i),c.updateAttributes(r),await this.uploadMetadataFile(),this.emit("s3db.resourceUpdated",t),c}const o=this.savedMetadata?.resources?.[t]?.currentVersion||"v0",s=new fs({name:t,attributes:r,behavior:i,observers:[this],client:this.client,version:o,options:{cache:this.cache,...n}});return this.resources[t]=s,await this.uploadMetadataFile(),this.emit("s3db.resourceCreated",t),s}resource(t){return this.resources[t]?this.resources[t]:Promise.reject(`resource ${t} does not exist`)}async listResources(){return Object.keys(this.resources).map(t=>({name:t}))}async getResource(t){if(!this.resources[t])throw new Error(`Resource not found: ${t}`);return this.resources[t]}get config(){return{version:this.version,s3dbVersion:this.s3dbVersion,bucket:this.bucket,keyPrefix:this.keyPrefix,parallelism:this.parallelism,verbose:this.verbose}}isConnected(){return!!this.savedMetadata}}class th extends cs{}class li extends R{constructor(t={}){super(),this.config=t}async _set(t,r){}async _get(t){}async _del(t){}async _clear(t){}validateKey(t){if(t==null||typeof t!="string"||!t)throw new Error("Invalid key")}async set(t,r){return this.validateKey(t),await this._set(t,r),this.emit("set",r),r}async get(t){this.validateKey(t);const r=await this._get(t);return this.emit("get",r),r}async del(t){this.validateKey(t);const r=await this._del(t);return this.emit("delete",r),r}async delete(t){return this.del(t)}async clear(){const t=await this._clear();return this.emit("clear",t),t}}class rh extends li{constructor(t={}){super(t),this.cache={},this.meta={},this.maxSize=t.maxSize||0,this.ttl=t.ttl||0}async _set(t,r){if(this.maxSize>0&&Object.keys(this.cache).length>=this.maxSize){const n=Object.entries(this.meta).sort((i,a)=>i[1].ts-a[1].ts)[0]?.[0];n&&(delete this.cache[n],delete this.meta[n])}return this.cache[t]=r,this.meta[t]={ts:Date.now()},r}async _get(t){if(!Object.prototype.hasOwnProperty.call(this.cache,t))return null;if(this.ttl>0){const r=Date.now(),n=this.meta[t];if(n&&r-n.ts>this.ttl*1e3)return delete this.cache[t],delete this.meta[t],null}return this.cache[t]}async _del(t){return delete this.cache[t],delete this.meta[t],!0}async _clear(){return this.cache={},this.meta={},!0}async size(){return Object.keys(this.cache).length}async keys(){return Object.keys(this.cache)}}var ls={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 nh(){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 Ae(e,t,r,n,i){if(t.subarray&&e.subarray){e.set(t.subarray(r,r+n),i);return}for(var a=0;a<n;a++)e[i+a]=t[r+a]}var yr=Uint8Array,ae=Uint16Array,gr=Int32Array,ih=4,us=0,hs=1,ah=2;function gt(e){for(var t=e.length;--t>=0;)e[t]=0}var oh=0,ds=1,sh=2,fh=3,ch=258,ui=29,Ct=256,Dt=Ct+1+ui,vt=30,hi=19,ps=2*Dt+1,We=15,di=16,lh=7,pi=256,ys=16,gs=17,vs=18,yi=[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],vr=[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],uh=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],_s=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],hh=512,ke=new Array((Dt+2)*2);gt(ke);var Ft=new Array(vt*2);gt(Ft);var Mt=new Array(hh);gt(Mt);var Lt=new Array(ch-fh+1);gt(Lt);var gi=new Array(ui);gt(gi);var _r=new Array(vt);gt(_r);function vi(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}var ws,bs,ms;function _i(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Es(e){return e<256?Mt[e]:Mt[256+(e>>>7)]}function jt(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function X(e,t,r){e.bi_valid>di-r?(e.bi_buf|=t<<e.bi_valid&65535,jt(e,e.bi_buf),e.bi_buf=t>>di-e.bi_valid,e.bi_valid+=r-di):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function pe(e,t,r){X(e,r[t*2],r[t*2+1])}function xs(e,t){var r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1}function dh(e){e.bi_valid===16?(jt(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 ph(e,t){var r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,f,l,d,h,u,p,g=0;for(h=0;h<=We;h++)e.bl_count[h]=0;for(r[e.heap[e.heap_max]*2+1]=0,f=e.heap_max+1;f<ps;f++)l=e.heap[f],h=r[r[l*2+1]*2+1]+1,h>c&&(h=c,g++),r[l*2+1]=h,!(l>n)&&(e.bl_count[h]++,u=0,l>=s&&(u=o[l-s]),p=r[l*2],e.opt_len+=p*(h+u),a&&(e.static_len+=p*(i[l*2+1]+u)));if(g!==0){do{for(h=c-1;e.bl_count[h]===0;)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[c]--,g-=2}while(g>0);for(h=c;h!==0;h--)for(l=e.bl_count[h];l!==0;)d=e.heap[--f],!(d>n)&&(r[d*2+1]!==h&&(e.opt_len+=(h-r[d*2+1])*r[d*2],r[d*2+1]=h),l--)}}function Ss(e,t,r){var n=new Array(We+1),i=0,a,o;for(a=1;a<=We;a++)n[a]=i=i+r[a-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=xs(n[s]++,s))}}function yh(){var e,t,r,n,i,a=new Array(We+1);for(r=0,n=0;n<ui-1;n++)for(gi[n]=r,e=0;e<1<<yi[n];e++)Lt[r++]=n;for(Lt[r-1]=n,i=0,n=0;n<16;n++)for(_r[n]=i,e=0;e<1<<vr[n];e++)Mt[i++]=n;for(i>>=7;n<vt;n++)for(_r[n]=i<<7,e=0;e<1<<vr[n]-7;e++)Mt[256+i++]=n;for(t=0;t<=We;t++)a[t]=0;for(e=0;e<=143;)ke[e*2+1]=8,e++,a[8]++;for(;e<=255;)ke[e*2+1]=9,e++,a[9]++;for(;e<=279;)ke[e*2+1]=7,e++,a[7]++;for(;e<=287;)ke[e*2+1]=8,e++,a[8]++;for(Ss(ke,Dt+1,a),e=0;e<vt;e++)Ft[e*2+1]=5,Ft[e*2]=xs(e,5);ws=new vi(ke,yi,Ct+1,Dt,We),bs=new vi(Ft,vr,0,vt,We),ms=new vi(new Array(0),uh,0,hi,lh)}function As(e){var t;for(t=0;t<Dt;t++)e.dyn_ltree[t*2]=0;for(t=0;t<vt;t++)e.dyn_dtree[t*2]=0;for(t=0;t<hi;t++)e.bl_tree[t*2]=0;e.dyn_ltree[pi*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function ks(e){e.bi_valid>8?jt(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 gh(e,t,r,n){ks(e),jt(e,r),jt(e,~r),Ae(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function Rs(e,t,r,n){var i=t*2,a=r*2;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]}function wi(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&Rs(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Rs(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function Os(e,t,r){var n,i,a=0,o,s;if(e.last_lit!==0)do n=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],i=e.pending_buf[e.l_buf+a],a++,n===0?pe(e,i,t):(o=Lt[i],pe(e,o+Ct+1,t),s=yi[o],s!==0&&(i-=gi[o],X(e,i,s)),n--,o=Es(n),pe(e,o,r),s=vr[o],s!==0&&(n-=_r[o],X(e,n,s)));while(a<e.last_lit);pe(e,pi,t)}function bi(e,t){var r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,f;for(e.heap_len=0,e.heap_max=ps,o=0;o<a;o++)r[o*2]!==0?(e.heap[++e.heap_len]=c=o,e.depth[o]=0):r[o*2+1]=0;for(;e.heap_len<2;)f=e.heap[++e.heap_len]=c<2?++c:0,r[f*2]=1,e.depth[f]=0,e.opt_len--,i&&(e.static_len-=n[f*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)wi(e,r,o);f=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],wi(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++,wi(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],ph(e,t),Ss(r,c,e.bl_count)}function Ts(e,t,r){var n,i=-1,a,o=t[0*2+1],s=0,c=7,f=4;for(o===0&&(c=138,f=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)a=o,o=t[(n+1)*2+1],!(++s<c&&a===o)&&(s<f?e.bl_tree[a*2]+=s:a!==0?(a!==i&&e.bl_tree[a*2]++,e.bl_tree[ys*2]++):s<=10?e.bl_tree[gs*2]++:e.bl_tree[vs*2]++,s=0,i=a,o===0?(c=138,f=3):a===o?(c=6,f=3):(c=7,f=4))}function Ps(e,t,r){var n,i=-1,a,o=t[0*2+1],s=0,c=7,f=4;for(o===0&&(c=138,f=3),n=0;n<=r;n++)if(a=o,o=t[(n+1)*2+1],!(++s<c&&a===o)){if(s<f)do pe(e,a,e.bl_tree);while(--s!==0);else a!==0?(a!==i&&(pe(e,a,e.bl_tree),s--),pe(e,ys,e.bl_tree),X(e,s-3,2)):s<=10?(pe(e,gs,e.bl_tree),X(e,s-3,3)):(pe(e,vs,e.bl_tree),X(e,s-11,7));s=0,i=a,o===0?(c=138,f=3):a===o?(c=6,f=3):(c=7,f=4)}}function vh(e){var t;for(Ts(e,e.dyn_ltree,e.l_desc.max_code),Ts(e,e.dyn_dtree,e.d_desc.max_code),bi(e,e.bl_desc),t=hi-1;t>=3&&e.bl_tree[_s[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function _h(e,t,r,n){var i;for(X(e,t-257,5),X(e,r-1,5),X(e,n-4,4),i=0;i<n;i++)X(e,e.bl_tree[_s[i]*2+1],3);Ps(e,e.dyn_ltree,t-1),Ps(e,e.dyn_dtree,r-1)}function wh(e){var t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return us;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return hs;for(r=32;r<Ct;r++)if(e.dyn_ltree[r*2]!==0)return hs;return us}var Is=!1;function bh(e){Is||(yh(),Is=!0),e.l_desc=new _i(e.dyn_ltree,ws),e.d_desc=new _i(e.dyn_dtree,bs),e.bl_desc=new _i(e.bl_tree,ms),e.bi_buf=0,e.bi_valid=0,As(e)}function Cs(e,t,r,n){X(e,(oh<<1)+(n?1:0),3),gh(e,t,r)}function mh(e){X(e,ds<<1,3),pe(e,pi,ke),dh(e)}function Eh(e,t,r,n){var i,a,o=0;e.level>0?(e.strm.data_type===ah&&(e.strm.data_type=wh(e)),bi(e,e.l_desc),bi(e,e.d_desc),o=vh(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&t!==-1?Cs(e,t,r,n):e.strategy===ih||a===i?(X(e,(ds<<1)+(n?1:0),3),Os(e,ke,Ft)):(X(e,(sh<<1)+(n?1:0),3),_h(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Os(e,e.dyn_ltree,e.dyn_dtree)),As(e),n&&ks(e)}function Fe(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[(Lt[r]+Ct+1)*2]++,e.dyn_dtree[Es(t)*2]++),e.last_lit===e.lit_bufsize-1}function mi(e,t,r,n){for(var i=e&65535|0,a=e>>>16&65535|0,o=0;r!==0;){o=r>2e3?2e3:r,r-=o;do i=i+t[n++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}function xh(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t}var Sh=xh();function Z(e,t,r,n){var i=Sh,a=n+r;e^=-1;for(var o=n;o<a;o++)e=e>>>8^i[(e^t[o])&255];return e^-1}var Ve=0,Ah=1,kh=3,Me=4,Ds=5,Le=0,Fs=1,je=-2,Rh=-3,Ei=-5,Oh=-1,Th=1,wr=2,Ph=3,Ih=4,Ch=2,xi=8,Dh=9,Fh=29,Mh=256,Si=Mh+1+Fh,Lh=30,jh=19,Nh=2*Si+1,Bh=15,C=3,Ne=258,se=Ne+C+1,Uh=32,Ai=42,ki=69,br=73,mr=91,Er=103,Ge=113,Nt=666,$=1,Bt=2,Ye=3,_t=4,$h=3;function Be(e,t){return e.msg=ls[t],t}function Ms(e){return(e<<1)-(e>4?9:0)}function Je(e){for(var t=e.length;--t>=0;)e[t]=0}function Ue(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(Ae(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 H(e,t){Eh(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ue(e.strm)}function I(e,t){e.pending_buf[e.pending++]=t}function Ut(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function zh(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),i===0?0:(e.avail_in-=i,Ae(t,e.input,e.next_in,i,r),e.state.wrap===1?e.adler=mi(e.adler,t,i,r):e.state.wrap===2&&(e.adler=Z(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function Ls(e,t){var r=e.max_chain_length,n=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-se?e.strstart-(e.w_size-se):0,f=e.window,l=e.w_mask,d=e.prev,h=e.strstart+Ne,u=f[n+o-1],p=f[n+o];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do if(i=t,!(f[i+o]!==p||f[i+o-1]!==u||f[i]!==f[n]||f[++i]!==f[n+1])){n+=2,i++;do;while(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]===f[++i]&&n<h);if(a=Ne-(h-n),n=h-Ne,a>o){if(e.match_start=t,o=a,a>=s)break;u=f[n+o-1],p=f[n+o]}}while((t=d[t&l])>c&&--r!==0);return o<=e.lookahead?o:e.lookahead}function $t(e){var t=e.w_size,r,n,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-se)){Ae(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,n=e.hash_size,r=n;do i=e.head[--r],e.head[r]=i>=t?i-t:0;while(--n);n=t,r=n;do i=e.prev[--r],e.prev[r]=i>=t?i-t:0;while(--n);a+=t}if(e.strm.avail_in===0)break;if(n=zh(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=C)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+C-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<C)););}while(e.lookahead<se&&e.strm.avail_in!==0)}function Zh(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if($t(e),e.lookahead===0&&t===Ve)return $;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((e.strstart===0||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,H(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-se&&(H(e,!1),e.strm.avail_out===0))return $}return e.insert=0,t===Me?(H(e,!0),e.strm.avail_out===0?Ye:_t):(e.strstart>e.block_start&&(H(e,!1),e.strm.avail_out===0),$)}function Ri(e,t){for(var r,n;;){if(e.lookahead<se){if($t(e),e.lookahead<se&&t===Ve)return $;if(e.lookahead===0)break}if(r=0,e.lookahead>=C&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+C-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-se&&(e.match_length=Ls(e,r)),e.match_length>=C)if(n=Fe(e,e.strstart-e.match_start,e.match_length-C),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=C){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+C-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 n=Fe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(H(e,!1),e.strm.avail_out===0))return $}return e.insert=e.strstart<C-1?e.strstart:C-1,t===Me?(H(e,!0),e.strm.avail_out===0?Ye:_t):e.last_lit&&(H(e,!1),e.strm.avail_out===0)?$:Bt}function wt(e,t){for(var r,n,i;;){if(e.lookahead<se){if($t(e),e.lookahead<se&&t===Ve)return $;if(e.lookahead===0)break}if(r=0,e.lookahead>=C&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+C-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=C-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-se&&(e.match_length=Ls(e,r),e.match_length<=5&&(e.strategy===Th||e.match_length===C&&e.strstart-e.match_start>4096)&&(e.match_length=C-1)),e.prev_length>=C&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-C,n=Fe(e,e.strstart-1-e.prev_match,e.prev_length-C),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+C-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=C-1,e.strstart++,n&&(H(e,!1),e.strm.avail_out===0))return $}else if(e.match_available){if(n=Fe(e,0,e.window[e.strstart-1]),n&&H(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return $}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Fe(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<C-1?e.strstart:C-1,t===Me?(H(e,!0),e.strm.avail_out===0?Ye:_t):e.last_lit&&(H(e,!1),e.strm.avail_out===0)?$:Bt}function qh(e,t){for(var r,n,i,a,o=e.window;;){if(e.lookahead<=Ne){if($t(e),e.lookahead<=Ne&&t===Ve)return $;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=C&&e.strstart>0&&(i=e.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){a=e.strstart+Ne;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<a);e.match_length=Ne-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=C?(r=Fe(e,1,e.match_length-C),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Fe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(H(e,!1),e.strm.avail_out===0))return $}return e.insert=0,t===Me?(H(e,!0),e.strm.avail_out===0?Ye:_t):e.last_lit&&(H(e,!1),e.strm.avail_out===0)?$:Bt}function Hh(e,t){for(var r;;){if(e.lookahead===0&&($t(e),e.lookahead===0)){if(t===Ve)return $;break}if(e.match_length=0,r=Fe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(H(e,!1),e.strm.avail_out===0))return $}return e.insert=0,t===Me?(H(e,!0),e.strm.avail_out===0?Ye:_t):e.last_lit&&(H(e,!1),e.strm.avail_out===0)?$:Bt}function ye(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var bt;bt=[new ye(0,0,0,0,Zh),new ye(4,4,8,4,Ri),new ye(4,5,16,8,Ri),new ye(4,6,32,32,Ri),new ye(4,4,16,16,wt),new ye(8,16,32,32,wt),new ye(8,16,128,128,wt),new ye(8,32,128,256,wt),new ye(32,128,258,1024,wt),new ye(32,258,258,4096,wt)];function Kh(e){e.window_size=2*e.w_size,Je(e.head),e.max_lazy_match=bt[e.level].max_lazy,e.good_match=bt[e.level].good_length,e.nice_match=bt[e.level].nice_length,e.max_chain_length=bt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=C-1,e.match_available=0,e.ins_h=0}function Wh(){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=xi,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 ae(Nh*2),this.dyn_dtree=new ae((2*Lh+1)*2),this.bl_tree=new ae((2*jh+1)*2),Je(this.dyn_ltree),Je(this.dyn_dtree),Je(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new ae(Bh+1),this.heap=new ae(2*Si+1),Je(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new ae(2*Si+1),Je(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 Vh(e){var t;return!e||!e.state?Be(e,je):(e.total_in=e.total_out=0,e.data_type=Ch,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Ai:Ge,e.adler=t.wrap===2?0:1,t.last_flush=Ve,bh(t),Le)}function js(e){var t=Vh(e);return t===Le&&Kh(e.state),t}function Gh(e,t,r,n,i,a){if(!e)return je;var o=1;if(t===Oh&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>Dh||r!==xi||n<8||n>15||t<0||t>9||a<0||a>Ih)return Be(e,je);n===8&&(n=9);var s=new Wh;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+C-1)/C),s.window=new yr(s.w_size*2),s.head=new ae(s.hash_size),s.prev=new ae(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new yr(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,js(e)}function Yh(e,t){var r,n,i,a;if(!e||!e.state||t>Ds||t<0)return e?Be(e,je):je;if(n=e.state,!e.output||!e.input&&e.avail_in!==0||n.status===Nt&&t!==Me)return Be(e,e.avail_out===0?Ei:je);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===Ai)if(n.wrap===2)e.adler=0,I(n,31),I(n,139),I(n,8),n.gzhead?(I(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),I(n,n.gzhead.time&255),I(n,n.gzhead.time>>8&255),I(n,n.gzhead.time>>16&255),I(n,n.gzhead.time>>24&255),I(n,n.level===9?2:n.strategy>=wr||n.level<2?4:0),I(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(I(n,n.gzhead.extra.length&255),I(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Z(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=ki):(I(n,0),I(n,0),I(n,0),I(n,0),I(n,0),I(n,n.level===9?2:n.strategy>=wr||n.level<2?4:0),I(n,$h),n.status=Ge);else{var o=xi+(n.w_bits-8<<4)<<8,s=-1;n.strategy>=wr||n.level<2?s=0:n.level<6?s=1:n.level===6?s=2:s=3,o|=s<<6,n.strstart!==0&&(o|=Uh),o+=31-o%31,n.status=Ge,Ut(n,o),n.strstart!==0&&(Ut(n,e.adler>>>16),Ut(n,e.adler&65535)),e.adler=1}if(n.status===ki)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),Ue(e),i=n.pending,n.pending===n.pending_buf_size));)I(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=br)}else n.status=br;if(n.status===br)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),Ue(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.name.length?a=n.gzhead.name.charCodeAt(n.gzindex++)&255:a=0,I(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.gzindex=0,n.status=mr)}else n.status=mr;if(n.status===mr)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),Ue(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.comment.length?a=n.gzhead.comment.charCodeAt(n.gzindex++)&255:a=0,I(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(e.adler=Z(e.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.status=Er)}else n.status=Er;if(n.status===Er&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Ue(e),n.pending+2<=n.pending_buf_size&&(I(n,e.adler&255),I(n,e.adler>>8&255),e.adler=0,n.status=Ge)):n.status=Ge),n.pending!==0){if(Ue(e),e.avail_out===0)return n.last_flush=-1,Le}else if(e.avail_in===0&&Ms(t)<=Ms(r)&&t!==Me)return Be(e,Ei);if(n.status===Nt&&e.avail_in!==0)return Be(e,Ei);if(e.avail_in!==0||n.lookahead!==0||t!==Ve&&n.status!==Nt){var c=n.strategy===wr?Hh(n,t):n.strategy===Ph?qh(n,t):bt[n.level].func(n,t);if((c===Ye||c===_t)&&(n.status=Nt),c===$||c===Ye)return e.avail_out===0&&(n.last_flush=-1),Le;if(c===Bt&&(t===Ah?mh(n):t!==Ds&&(Cs(n,0,0,!1),t===kh&&(Je(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Ue(e),e.avail_out===0))return n.last_flush=-1,Le}return t!==Me?Le:n.wrap<=0?Fs:(n.wrap===2?(I(n,e.adler&255),I(n,e.adler>>8&255),I(n,e.adler>>16&255),I(n,e.adler>>24&255),I(n,e.total_in&255),I(n,e.total_in>>8&255),I(n,e.total_in>>16&255),I(n,e.total_in>>24&255)):(Ut(n,e.adler>>>16),Ut(n,e.adler&65535)),Ue(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Le:Fs)}function Jh(e){var t;return!e||!e.state?je:(t=e.state.status,t!==Ai&&t!==ki&&t!==br&&t!==mr&&t!==Er&&t!==Ge&&t!==Nt?Be(e,je):(e.state=null,t===Ge?Be(e,Rh):Le))}var xr=30,Xh=12;function Qh(e,t){var r,n,i,a,o,s,c,f,l,d,h,u,p,g,_,w,x,S,v,A,T,b,E,O,k;r=e.state,n=e.next_in,O=e.input,i=n+(e.avail_in-5),a=e.next_out,k=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),c=r.dmax,f=r.wsize,l=r.whave,d=r.wnext,h=r.window,u=r.hold,p=r.bits,g=r.lencode,_=r.distcode,w=(1<<r.lenbits)-1,x=(1<<r.distbits)-1;e:do{p<15&&(u+=O[n++]<<p,p+=8,u+=O[n++]<<p,p+=8),S=g[u&w];t:for(;;){if(v=S>>>24,u>>>=v,p-=v,v=S>>>16&255,v===0)k[a++]=S&65535;else if(v&16){A=S&65535,v&=15,v&&(p<v&&(u+=O[n++]<<p,p+=8),A+=u&(1<<v)-1,u>>>=v,p-=v),p<15&&(u+=O[n++]<<p,p+=8,u+=O[n++]<<p,p+=8),S=_[u&x];r:for(;;){if(v=S>>>24,u>>>=v,p-=v,v=S>>>16&255,v&16){if(T=S&65535,v&=15,p<v&&(u+=O[n++]<<p,p+=8,p<v&&(u+=O[n++]<<p,p+=8)),T+=u&(1<<v)-1,T>c){e.msg="invalid distance too far back",r.mode=xr;break e}if(u>>>=v,p-=v,v=a-o,T>v){if(v=T-v,v>l&&r.sane){e.msg="invalid distance too far back",r.mode=xr;break e}if(b=0,E=h,d===0){if(b+=f-v,v<A){A-=v;do k[a++]=h[b++];while(--v);b=a-T,E=k}}else if(d<v){if(b+=f+d-v,v-=d,v<A){A-=v;do k[a++]=h[b++];while(--v);if(b=0,d<A){v=d,A-=v;do k[a++]=h[b++];while(--v);b=a-T,E=k}}}else if(b+=d-v,v<A){A-=v;do k[a++]=h[b++];while(--v);b=a-T,E=k}for(;A>2;)k[a++]=E[b++],k[a++]=E[b++],k[a++]=E[b++],A-=3;A&&(k[a++]=E[b++],A>1&&(k[a++]=E[b++]))}else{b=a-T;do k[a++]=k[b++],k[a++]=k[b++],k[a++]=k[b++],A-=3;while(A>2);A&&(k[a++]=k[b++],A>1&&(k[a++]=k[b++]))}}else if((v&64)===0){S=_[(S&65535)+(u&(1<<v)-1)];continue r}else{e.msg="invalid distance code",r.mode=xr;break e}break}}else if((v&64)===0){S=g[(S&65535)+(u&(1<<v)-1)];continue t}else if(v&32){r.mode=Xh;break e}else{e.msg="invalid literal/length code",r.mode=xr;break e}break}}while(n<i&&a<s);A=p>>3,n-=A,p-=A<<3,u&=(1<<p)-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=a<s?257+(s-a):257-(a-s),r.hold=u,r.bits=p}var mt=15,Ns=852,Bs=592,Us=0,Oi=1,$s=2,ed=[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],td=[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],rd=[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],nd=[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 zt(e,t,r,n,i,a,o,s){var c=s.bits,f=0,l=0,d=0,h=0,u=0,p=0,g=0,_=0,w=0,x=0,S,v,A,T,b,E=null,O=0,k,F=new ae(mt+1),K=new ae(mt+1),G=null,oe=0,st,Q,ge;for(f=0;f<=mt;f++)F[f]=0;for(l=0;l<n;l++)F[t[r+l]]++;for(u=c,h=mt;h>=1&&F[h]===0;h--);if(u>h&&(u=h),h===0)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(d=1;d<h&&F[d]===0;d++);for(u<d&&(u=d),_=1,f=1;f<=mt;f++)if(_<<=1,_-=F[f],_<0)return-1;if(_>0&&(e===Us||h!==1))return-1;for(K[1]=0,f=1;f<mt;f++)K[f+1]=K[f]+F[f];for(l=0;l<n;l++)t[r+l]!==0&&(o[K[t[r+l]]++]=l);if(e===Us?(E=G=o,k=19):e===Oi?(E=ed,O-=257,G=td,oe-=257,k=256):(E=rd,G=nd,k=-1),x=0,l=0,f=d,b=a,p=u,g=0,A=-1,w=1<<u,T=w-1,e===Oi&&w>Ns||e===$s&&w>Bs)return 1;for(;;){st=f-g,o[l]<k?(Q=0,ge=o[l]):o[l]>k?(Q=G[oe+o[l]],ge=E[O+o[l]]):(Q=96,ge=0),S=1<<f-g,v=1<<p,d=v;do v-=S,i[b+(x>>g)+v]=st<<24|Q<<16|ge|0;while(v!==0);for(S=1<<f-1;x&S;)S>>=1;if(S!==0?(x&=S-1,x+=S):x=0,l++,--F[f]===0){if(f===h)break;f=t[r+o[l]]}if(f>u&&(x&T)!==A){for(g===0&&(g=u),b+=d,p=f-g,_=1<<p;p+g<h&&(_-=F[p+g],!(_<=0));)p++,_<<=1;if(w+=1<<p,e===Oi&&w>Ns||e===$s&&w>Bs)return 1;A=x&T,i[A]=u<<24|p<<16|b-a|0}}return x!==0&&(i[b+x]=f-g<<24|4194304|0),s.bits=u,0}var id=0,zs=1,Zs=2,qs=4,ad=5,Sr=6,Zt=0,od=1,sd=2,$e=-2,fd=-3,cd=-4,ld=-5,Hs=8,Ks=1,Ws=2,Vs=3,Gs=4,Ys=5,Js=6,Xs=7,Qs=8,ef=9,tf=10,rf=11,Re=12,Ti=13,nf=14,Pi=15,af=16,of=17,sf=18,ff=19,Ar=20,kr=21,cf=22,lf=23,uf=24,hf=25,df=26,Ii=27,pf=28,yf=29,L=30,ud=31,hd=32,dd=852,pd=592;function gf(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function yd(){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 ae(320),this.work=new ae(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function gd(e){var t;return!e||!e.state?$e:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Ks,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new gr(dd),t.distcode=t.distdyn=new gr(pd),t.sane=1,t.back=-1,Zt)}function vf(e){var t;return!e||!e.state?$e:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,gd(e))}function vd(e,t){var r,n;return!e||!e.state||(n=e.state,t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?$e:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,vf(e))}function _d(e,t){var r,n;return e?(n=new yd,e.state=n,n.window=null,r=vd(e,t),r!==Zt&&(e.state=null),r):$e}var _f=!0,Ci,Di;function wd(e){if(_f){var t;for(Ci=new gr(512),Di=new gr(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(zt(zs,e.lens,0,288,Ci,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;zt(Zs,e.lens,0,32,Di,0,e.work,{bits:5}),_f=!1}e.lencode=Ci,e.lenbits=9,e.distcode=Di,e.distbits=5}function bd(e,t,r,n){var i,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new yr(a.wsize)),n>=a.wsize?(Ae(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),Ae(a.window,t,r-n,i,a.wnext),n-=i,n?(Ae(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function md(e,t){var r,n,i,a,o,s,c,f,l,d,h,u,p,g,_=0,w,x,S,v,A,T,b,E,O=new yr(4),k,F,K=[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 $e;r=e.state,r.mode===Re&&(r.mode=Ti),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,f=r.hold,l=r.bits,d=s,h=c,E=Zt;e:for(;;)switch(r.mode){case Ks:if(r.wrap===0){r.mode=Ti;break}for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(r.wrap&2&&f===35615){r.check=0,O[0]=f&255,O[1]=f>>>8&255,r.check=Z(r.check,O,2,0),f=0,l=0,r.mode=Ws;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=L;break}if((f&15)!==Hs){e.msg="unknown compression method",r.mode=L;break}if(f>>>=4,l-=4,b=(f&15)+8,r.wbits===0)r.wbits=b;else if(b>r.wbits){e.msg="invalid window size",r.mode=L;break}r.dmax=1<<b,e.adler=r.check=1,r.mode=f&512?tf:Re,f=0,l=0;break;case Ws:for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(r.flags=f,(r.flags&255)!==Hs){e.msg="unknown compression method",r.mode=L;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=L;break}r.head&&(r.head.text=f>>8&1),r.flags&512&&(O[0]=f&255,O[1]=f>>>8&255,r.check=Z(r.check,O,2,0)),f=0,l=0,r.mode=Vs;case Vs:for(;l<32;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.time=f),r.flags&512&&(O[0]=f&255,O[1]=f>>>8&255,O[2]=f>>>16&255,O[3]=f>>>24&255,r.check=Z(r.check,O,4,0)),f=0,l=0,r.mode=Gs;case Gs:for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=f&255,r.head.os=f>>8),r.flags&512&&(O[0]=f&255,O[1]=f>>>8&255,r.check=Z(r.check,O,2,0)),f=0,l=0,r.mode=Ys;case Ys:if(r.flags&1024){for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.length=f,r.head&&(r.head.extra_len=f),r.flags&512&&(O[0]=f&255,O[1]=f>>>8&255,r.check=Z(r.check,O,2,0)),f=0,l=0}else r.head&&(r.head.extra=null);r.mode=Js;case Js:if(r.flags&1024&&(u=r.length,u>s&&(u=s),u&&(r.head&&(b=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),Ae(r.head.extra,n,a,u,b)),r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,r.length-=u),r.length))break e;r.length=0,r.mode=Xs;case Xs:if(r.flags&2048){if(s===0)break e;u=0;do b=n[a+u++],r.head&&b&&r.length<65536&&(r.head.name+=String.fromCharCode(b));while(b&&u<s);if(r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,b)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=Qs;case Qs:if(r.flags&4096){if(s===0)break e;u=0;do b=n[a+u++],r.head&&b&&r.length<65536&&(r.head.comment+=String.fromCharCode(b));while(b&&u<s);if(r.flags&512&&(r.check=Z(r.check,n,u,a)),s-=u,a+=u,b)break e}else r.head&&(r.head.comment=null);r.mode=ef;case ef:if(r.flags&512){for(;l<16;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(f!==(r.check&65535)){e.msg="header crc mismatch",r.mode=L;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=Re;break;case tf:for(;l<32;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}e.adler=r.check=gf(f),f=0,l=0,r.mode=rf;case rf:if(r.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,sd;e.adler=r.check=1,r.mode=Re;case Re:if(t===ad||t===Sr)break e;case Ti:if(r.last){f>>>=l&7,l-=l&7,r.mode=Ii;break}for(;l<3;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}switch(r.last=f&1,f>>>=1,l-=1,f&3){case 0:r.mode=nf;break;case 1:if(wd(r),r.mode=Ar,t===Sr){f>>>=2,l-=2;break e}break;case 2:r.mode=of;break;case 3:e.msg="invalid block type",r.mode=L}f>>>=2,l-=2;break;case nf:for(f>>>=l&7,l-=l&7;l<32;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if((f&65535)!==(f>>>16^65535)){e.msg="invalid stored block lengths",r.mode=L;break}if(r.length=f&65535,f=0,l=0,r.mode=Pi,t===Sr)break e;case Pi:r.mode=af;case af:if(u=r.length,u){if(u>s&&(u=s),u>c&&(u=c),u===0)break e;Ae(i,n,a,u,o),s-=u,a+=u,c-=u,o+=u,r.length-=u;break}r.mode=Re;break;case of:for(;l<14;){if(s===0)break e;s--,f+=n[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=L;break}r.have=0,r.mode=sf;case sf:for(;r.have<r.ncode;){for(;l<3;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}r.lens[K[r.have++]]=f&7,f>>>=3,l-=3}for(;r.have<19;)r.lens[K[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,k={bits:r.lenbits},E=zt(id,r.lens,0,19,r.lencode,0,r.work,k),r.lenbits=k.bits,E){e.msg="invalid code lengths set",r.mode=L;break}r.have=0,r.mode=ff;case ff:for(;r.have<r.nlen+r.ndist;){for(;_=r.lencode[f&(1<<r.lenbits)-1],w=_>>>24,x=_>>>16&255,S=_&65535,!(w<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(S<16)f>>>=w,l-=w,r.lens[r.have++]=S;else{if(S===16){for(F=w+2;l<F;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(f>>>=w,l-=w,r.have===0){e.msg="invalid bit length repeat",r.mode=L;break}b=r.lens[r.have-1],u=3+(f&3),f>>>=2,l-=2}else if(S===17){for(F=w+3;l<F;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}f>>>=w,l-=w,b=0,u=3+(f&7),f>>>=3,l-=3}else{for(F=w+7;l<F;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}f>>>=w,l-=w,b=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=L;break}for(;u--;)r.lens[r.have++]=b}}if(r.mode===L)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=L;break}if(r.lenbits=9,k={bits:r.lenbits},E=zt(zs,r.lens,0,r.nlen,r.lencode,0,r.work,k),r.lenbits=k.bits,E){e.msg="invalid literal/lengths set",r.mode=L;break}if(r.distbits=6,r.distcode=r.distdyn,k={bits:r.distbits},E=zt(Zs,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,k),r.distbits=k.bits,E){e.msg="invalid distances set",r.mode=L;break}if(r.mode=Ar,t===Sr)break e;case Ar:r.mode=kr;case kr:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,Qh(e,h),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,f=r.hold,l=r.bits,r.mode===Re&&(r.back=-1);break}for(r.back=0;_=r.lencode[f&(1<<r.lenbits)-1],w=_>>>24,x=_>>>16&255,S=_&65535,!(w<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(x&&(x&240)===0){for(v=w,A=x,T=S;_=r.lencode[T+((f&(1<<v+A)-1)>>v)],w=_>>>24,x=_>>>16&255,S=_&65535,!(v+w<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}f>>>=v,l-=v,r.back+=v}if(f>>>=w,l-=w,r.back+=w,r.length=S,x===0){r.mode=df;break}if(x&32){r.back=-1,r.mode=Re;break}if(x&64){e.msg="invalid literal/length code",r.mode=L;break}r.extra=x&15,r.mode=cf;case cf:if(r.extra){for(F=r.extra;l<F;){if(s===0)break e;s--,f+=n[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=lf;case lf:for(;_=r.distcode[f&(1<<r.distbits)-1],w=_>>>24,x=_>>>16&255,S=_&65535,!(w<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if((x&240)===0){for(v=w,A=x,T=S;_=r.distcode[T+((f&(1<<v+A)-1)>>v)],w=_>>>24,x=_>>>16&255,S=_&65535,!(v+w<=l);){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}f>>>=v,l-=v,r.back+=v}if(f>>>=w,l-=w,r.back+=w,x&64){e.msg="invalid distance code",r.mode=L;break}r.offset=S,r.extra=x&15,r.mode=uf;case uf:if(r.extra){for(F=r.extra;l<F;){if(s===0)break e;s--,f+=n[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=L;break}r.mode=hf;case hf:if(c===0)break e;if(u=h-c,r.offset>u){if(u=r.offset-u,u>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=L;break}u>r.wnext?(u-=r.wnext,p=r.wsize-u):p=r.wnext-u,u>r.length&&(u=r.length),g=r.window}else g=i,p=o-r.offset,u=r.length;u>c&&(u=c),c-=u,r.length-=u;do i[o++]=g[p++];while(--u);r.length===0&&(r.mode=kr);break;case df:if(c===0)break e;i[o++]=r.length,c--,r.mode=kr;break;case Ii:if(r.wrap){for(;l<32;){if(s===0)break e;s--,f|=n[a++]<<l,l+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=r.flags?Z(r.check,i,h,o-h):mi(r.check,i,h,o-h)),h=c,(r.flags?f:gf(f))!==r.check){e.msg="incorrect data check",r.mode=L;break}f=0,l=0}r.mode=pf;case pf:if(r.wrap&&r.flags){for(;l<32;){if(s===0)break e;s--,f+=n[a++]<<l,l+=8}if(f!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=L;break}f=0,l=0}r.mode=yf;case yf:E=od;break e;case L:E=fd;break e;case ud:return cd;case hd:default:return $e}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=f,r.bits=l,(r.wsize||h!==e.avail_out&&r.mode<L&&(r.mode<Ii||t!==qs))&&bd(e,e.output,e.next_out,h-e.avail_out),d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=r.flags?Z(r.check,i,h,e.next_out-h):mi(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Re?128:0)+(r.mode===Ar||r.mode===Pi?256:0),(d===0&&h===0||t===qs)&&E===Zt&&(E=ld),E}function Ed(e){if(!e||!e.state)return $e;var t=e.state;return t.window&&(t.window=null),e.state=null,Zt}var Fi=0,Et=1,Rr=2,qt=3,Or=4,xt=5,Ht=6,Kt=7,wf=0,bf=1,mf=2,Ef=3,Mi=4,xf=5,xd=6,Tr=0,Sf=1,Af=2,Sd=-1,Ad=-2,kd=-3,kf=-5,Rd=0,Od=1,Td=9,Pd=-1,Id=1,Cd=2,Dd=3,Fd=4,Md=0,Ld=0,jd=1,Nd=2,Rf=8;function fe(e){if(e<Et||e>Kt)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}fe.prototype.init=function(e,t,r,n,i){this.windowBits=e,this.level=t,this.memLevel=r,this.strategy=n,(this.mode===qt||this.mode===Or)&&(this.windowBits+=16),this.mode===Kt&&(this.windowBits+=32),(this.mode===xt||this.mode===Ht)&&(this.windowBits=-this.windowBits),this.strm=new nh;var a;switch(this.mode){case Et:case qt:case xt:a=Gh(this.strm,this.level,Rf,this.windowBits,this.memLevel,this.strategy);break;case Rr:case Or:case Ht:case Kt:a=_d(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(a!==Tr){this._error(a);return}this.write_in_progress=!1,this.init_done=!0},fe.prototype.params=function(){throw new Error("deflateParams Not supported")},fe.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(this.mode===Fi)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")},fe.prototype.write=function(e,t,r,n,i,a,o){this._writeCheck(),this.write_in_progress=!0;var s=this;return Ee.nextTick(function(){s.write_in_progress=!1;var c=s._write(e,t,r,n,i,a,o);s.callback(c[0],c[1]),s.pending_close&&s.close()}),this};function Bd(e,t){for(var r=0;r<e.length;r++)this[t+r]=e[r]}fe.prototype.writeSync=function(e,t,r,n,i,a,o){return this._writeCheck(),this._write(e,t,r,n,i,a,o)},fe.prototype._write=function(e,t,r,n,i,a,o){if(this.write_in_progress=!0,e!==wf&&e!==bf&&e!==mf&&e!==Ef&&e!==Mi&&e!==xf)throw new Error("Invalid flush value");t==null&&(t=new y(0),n=0,r=0),i._set?i.set=i._set:i.set=Bd;var s=this.strm;s.avail_in=n,s.input=t,s.next_in=r,s.avail_out=o,s.output=i,s.next_out=a;var c;switch(this.mode){case Et:case qt:case xt:c=Yh(s,e);break;case Kt:case Rr:case Or:case Ht:c=md(s,e);break;default:throw new Error("Unknown mode "+this.mode)}return this._checkError(c,s,e)||this._error(c),this.write_in_progress=!1,[s.avail_in,s.avail_out]},fe.prototype._checkError=function(e,t,r){switch(e){case Tr:case kf:if(t.avail_out!==0&&r===Mi)return!1;break;case Sf:break;case Af:return!1;default:return!1}return!0},fe.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}this.pending_close=!1,this.mode===Et||this.mode===qt||this.mode===xt?Jh(this.strm):Ed(this.strm),this.mode=Fi};var Pr;fe.prototype.reset=function(){switch(this.mode){case Et:case xt:Pr=js(this.strm);break;case Rr:case Ht:Pr=vf(this.strm);break}Pr!==Tr&&this._error(Pr)},fe.prototype._error=function(e){this.onerror(ls[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var Of=Object.freeze({__proto__:null,DEFLATE:Et,DEFLATERAW:xt,GUNZIP:Or,GZIP:qt,INFLATE:Rr,INFLATERAW:Ht,NONE:Fi,UNZIP:Kt,Z_BEST_COMPRESSION:Td,Z_BEST_SPEED:Od,Z_BINARY:Ld,Z_BLOCK:xf,Z_BUF_ERROR:kf,Z_DATA_ERROR:kd,Z_DEFAULT_COMPRESSION:Pd,Z_DEFAULT_STRATEGY:Md,Z_DEFLATED:Rf,Z_ERRNO:Sd,Z_FILTERED:Id,Z_FINISH:Mi,Z_FIXED:Fd,Z_FULL_FLUSH:Ef,Z_HUFFMAN_ONLY:Cd,Z_NEED_DICT:Af,Z_NO_COMPRESSION:Rd,Z_NO_FLUSH:wf,Z_OK:Tr,Z_PARTIAL_FLUSH:bf,Z_RLE:Dd,Z_STREAM_END:Sf,Z_STREAM_ERROR:Ad,Z_SYNC_FLUSH:mf,Z_TEXT:jd,Z_TREES:xd,Z_UNKNOWN:Nd,Zlib:fe});function Ud(e,t){if(!e)throw new Error(t)}var m={};Object.keys(Of).forEach(function(e){m[e]=Of[e]}),m.Z_MIN_WINDOWBITS=8,m.Z_MAX_WINDOWBITS=15,m.Z_DEFAULT_WINDOWBITS=15,m.Z_MIN_CHUNK=64,m.Z_MAX_CHUNK=1/0,m.Z_DEFAULT_CHUNK=16384,m.Z_MIN_MEMLEVEL=1,m.Z_MAX_MEMLEVEL=9,m.Z_DEFAULT_MEMLEVEL=8,m.Z_MIN_LEVEL=-1,m.Z_MAX_LEVEL=9,m.Z_DEFAULT_LEVEL=m.Z_DEFAULT_COMPRESSION;var Wt={Z_OK:m.Z_OK,Z_STREAM_END:m.Z_STREAM_END,Z_NEED_DICT:m.Z_NEED_DICT,Z_ERRNO:m.Z_ERRNO,Z_STREAM_ERROR:m.Z_STREAM_ERROR,Z_DATA_ERROR:m.Z_DATA_ERROR,Z_MEM_ERROR:m.Z_MEM_ERROR,Z_BUF_ERROR:m.Z_BUF_ERROR,Z_VERSION_ERROR:m.Z_VERSION_ERROR};Object.keys(Wt).forEach(function(e){Wt[Wt[e]]=e});function $d(e){return new et(e)}function zd(e){return new tt(e)}function Zd(e){return new it(e)}function qd(e){return new at(e)}function Hd(e){return new rt(e)}function Kd(e){return new nt(e)}function Wd(e){return new ot(e)}function Vd(e,t,r){return typeof t=="function"&&(r=t,t={}),Xe(new et(t),e,r)}function Gd(e,t){return Qe(new et(t),e)}function Yd(e,t,r){return typeof t=="function"&&(r=t,t={}),Xe(new rt(t),e,r)}function Jd(e,t){return Qe(new rt(t),e)}function Xd(e,t,r){return typeof t=="function"&&(r=t,t={}),Xe(new it(t),e,r)}function Qd(e,t){return Qe(new it(t),e)}function ep(e,t,r){return typeof t=="function"&&(r=t,t={}),Xe(new ot(t),e,r)}function tp(e,t){return Qe(new ot(t),e)}function rp(e,t,r){return typeof t=="function"&&(r=t,t={}),Xe(new tt(t),e,r)}function np(e,t){return Qe(new tt(t),e)}function ip(e,t,r){return typeof t=="function"&&(r=t,t={}),Xe(new nt(t),e,r)}function ap(e,t){return Qe(new nt(t),e)}function op(e,t,r){return typeof t=="function"&&(r=t,t={}),Xe(new at(t),e,r)}function sp(e,t){return Qe(new at(t),e)}function Xe(e,t,r){var n=[],i=0;e.on("error",o),e.on("end",s),e.end(t),a();function a(){for(var c;(c=e.read())!==null;)n.push(c),i+=c.length;e.once("readable",a)}function o(c){e.removeListener("end",s),e.removeListener("readable",a),r(c)}function s(){var c=y.concat(n,i);n=[],r(null,c),e.close()}}function Qe(e,t){if(typeof t=="string"&&(t=new y(t)),!y.isBuffer(t))throw new TypeError("Not a string or buffer");var r=m.Z_FINISH;return e._processChunk(t,r)}function et(e){if(!(this instanceof et))return new et(e);j.call(this,e,m.DEFLATE)}function tt(e){if(!(this instanceof tt))return new tt(e);j.call(this,e,m.INFLATE)}function rt(e){if(!(this instanceof rt))return new rt(e);j.call(this,e,m.GZIP)}function nt(e){if(!(this instanceof nt))return new nt(e);j.call(this,e,m.GUNZIP)}function it(e){if(!(this instanceof it))return new it(e);j.call(this,e,m.DEFLATERAW)}function at(e){if(!(this instanceof at))return new at(e);j.call(this,e,m.INFLATERAW)}function ot(e){if(!(this instanceof ot))return new ot(e);j.call(this,e,m.UNZIP)}function j(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||m.Z_DEFAULT_CHUNK,re.call(this,e),e.flush&&e.flush!==m.Z_NO_FLUSH&&e.flush!==m.Z_PARTIAL_FLUSH&&e.flush!==m.Z_SYNC_FLUSH&&e.flush!==m.Z_FULL_FLUSH&&e.flush!==m.Z_FINISH&&e.flush!==m.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||m.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<m.Z_MIN_CHUNK||e.chunkSize>m.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<m.Z_MIN_WINDOWBITS||e.windowBits>m.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<m.Z_MIN_LEVEL||e.level>m.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<m.Z_MIN_MEMLEVEL||e.memLevel>m.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=m.Z_FILTERED&&e.strategy!=m.Z_HUFFMAN_ONLY&&e.strategy!=m.Z_RLE&&e.strategy!=m.Z_FIXED&&e.strategy!=m.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!y.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new m.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=Wt[o],r.emit("error",s)};var n=m.Z_DEFAULT_COMPRESSION;typeof e.level=="number"&&(n=e.level);var i=m.Z_DEFAULT_STRATEGY;typeof e.strategy=="number"&&(i=e.strategy),this._binding.init(e.windowBits||m.Z_DEFAULT_WINDOWBITS,n,e.memLevel||m.Z_DEFAULT_MEMLEVEL,i,e.dictionary),this._buffer=new y(this._chunkSize),this._offset=0,this._closed=!1,this._level=n,this._strategy=i,this.once("end",this.close)}W(j,re),j.prototype.params=function(e,t,r){if(e<m.Z_MIN_LEVEL||e>m.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=m.Z_FILTERED&&t!=m.Z_HUFFMAN_ONLY&&t!=m.Z_RLE&&t!=m.Z_FIXED&&t!=m.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var n=this;this.flush(m.Z_SYNC_FLUSH,function(){n._binding.params(e,t),n._hadError||(n._level=e,n._strategy=t,r&&r())})}else Ee.nextTick(r)},j.prototype.reset=function(){return this._binding.reset()},j.prototype._flush=function(e){this._transform(new y(0),"",e)},j.prototype.flush=function(e,t){var r=this._writableState;if((typeof e=="function"||e===void 0&&!t)&&(t=e,e=m.Z_FULL_FLUSH),r.ended)t&&Ee.nextTick(t);else if(r.ending)t&&this.once("end",t);else if(r.needDrain){var n=this;this.once("drain",function(){n.flush(t)})}else this._flushFlag=e,this.write(new y(0),"",t)},j.prototype.close=function(e){if(e&&Ee.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;Ee.nextTick(function(){t.emit("close")})}},j.prototype._transform=function(e,t,r){var n,i=this._writableState,a=i.ending||i.ended,o=a&&(!e||i.length===e.length);if(!e===null&&!y.isBuffer(e))return r(new Error("invalid input"));o?n=m.Z_FINISH:(n=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||m.Z_NO_FLUSH)),this._processChunk(e,n,r)},j.prototype._processChunk=function(e,t,r){var n=e&&e.length,i=this._chunkSize-this._offset,a=0,o=this,s=typeof r=="function";if(!s){var c=[],f=0,l;this.on("error",function(g){l=g});do var d=this._binding.writeSync(t,e,a,n,this._buffer,this._offset,i);while(!this._hadError&&p(d[0],d[1]));if(this._hadError)throw l;var h=y.concat(c,f);return this.close(),h}var u=this._binding.write(t,e,a,n,this._buffer,this._offset,i);u.buffer=e,u.callback=p;function p(g,_){if(!o._hadError){var w=i-_;if(Ud(w>=0,"have should not go down"),w>0){var x=o._buffer.slice(o._offset,o._offset+w);o._offset+=w,s?o.push(x):(c.push(x),f+=x.length)}if((_===0||o._offset>=o._chunkSize)&&(i=o._chunkSize,o._offset=0,o._buffer=new y(o._chunkSize)),_===0){if(a+=n-g,n=g,!s)return!0;var S=o._binding.write(t,e,a,n,o._buffer,o._offset,o._chunkSize);S.callback=p,S.buffer=e;return}if(!s)return!1;r()}}},W(et,j),W(tt,j),W(rt,j),W(nt,j),W(it,j),W(at,j),W(ot,j);var Tf={codes:Wt,createDeflate:$d,createInflate:zd,createDeflateRaw:Zd,createInflateRaw:qd,createGzip:Hd,createGunzip:Kd,createUnzip:Wd,deflate:Vd,deflateSync:Gd,gzip:Yd,gzipSync:Jd,deflateRaw:Xd,deflateRawSync:Qd,unzip:ep,unzipSync:tp,inflate:rp,inflateSync:np,gunzip:ip,gunzipSync:ap,inflateRaw:op,inflateRawSync:sp,Deflate:et,Inflate:tt,Gzip:rt,Gunzip:nt,DeflateRaw:it,InflateRaw:at,Unzip:ot,Zlib:j};class Pf extends li{constructor({client:t,keyPrefix:r="cache",ttl:n=0,prefix:i=void 0}){super({client:t,keyPrefix:r,ttl:n,prefix:i}),this.client=t,this.keyPrefix=r,this.config.ttl=n,this.config.client=t,this.config.prefix=i!==void 0?i:r+(r.endsWith("/")?"":"/")}async _set(t,r){let n=JSON.stringify(r);const i=n.length;return n=Tf.gzipSync(n).toString("base64"),this.client.putObject({key:we(this.keyPrefix,t),body:n,contentEncoding:"gzip",contentType:"application/gzip",metadata:{compressor:"zlib",compressed:"true","client-id":this.client.id,"length-serialized":String(i),"length-compressed":String(n.length),"compression-gain":(n.length/i).toFixed(2)}})}async _get(t){try{const{Body:r}=await this.client.getObject(we(this.keyPrefix,t));let n=await Pt(r);return n=Buffer.from(n,"base64"),n=Tf.unzipSync(n).toString(),JSON.parse(n)}catch(r){if(r.name==="NoSuchKey"||r.name==="NotFound")return null;throw r}}async _del(t){return await this.client.deleteObject(we(this.keyPrefix,t)),!0}async _clear(){const t=await this.client.getAllKeys({prefix:this.keyPrefix});for(const r of t)await this.client.deleteObject(r)}async size(){return(await this.keys()).length}async keys(){const t=await this.client.getAllKeys({prefix:this.keyPrefix}),r=this.keyPrefix.endsWith("/")?this.keyPrefix:this.keyPrefix+"/";return t.map(n=>n.startsWith(r)?n.slice(r.length):n)}}class If extends R{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 fp={setup(e){},start(){},stop(){}},cp={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 lp extends If{constructor(t={}){super(),this.driver=t.driver}async setup(t){this.database=t,this.driver||(this.driver=new Pf({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 n=await this._createResource(...r);return t(n),n}}installResourcesProxies(t){t.cache=this.driver;let r=`resource=${t.name}`;this.driver.keyPrefix&&(this.driver.keyPrefix=we(this.driver.keyPrefix,r)),t.cacheKeyFor=async function({params:n={},action:i="list"}){let a=Object.keys(n).sort().map(o=>`${o}:${n[o]}`).join("|")||"empty";return a=await ra(a),a=we(r,`action=${i}`,`${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 n=await this.cacheKeyFor({action:"count"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._count();return await this.cache.set(n,i),i},t.listIds=async function(){const n=await this.cacheKeyFor({action:"listIds"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._listIds();return await this.cache.set(n,i),i},t.getMany=async function(n){const i=await this.cacheKeyFor({action:"getMany",params:{ids:n}});try{const o=await this.cache.get(i);if(o)return o}catch(o){if(o.name!=="NoSuchKey")throw o}const a=await t._getMany(n);return await this.cache.set(i,a),a},t.getAll=async function(){const n=await this.cacheKeyFor({action:"getAll"});try{const a=await this.cache.get(n);if(a)return a}catch(a){if(a.name!=="NoSuchKey")throw a}const i=await t._getAll();return await this.cache.set(n,i),i},t.page=async function({offset:n,size:i}){const a=await this.cacheKeyFor({action:"page",params:{offset:n,size:i}});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:n,size:i});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(...n){const i=await t._insert(...n);return await this.cache.clear(r),i},t.update=async function(...n){const i=await t._update(...n);return await this.cache.clear(r),i},t.delete=async function(...n){const i=await t._delete(...n);return await this.cache.clear(r),i},t.deleteMany=async function(...n){const i=await t._deleteMany(...n);return await this.cache.clear(r),i}}}return P.BaseError=lt,P.Cache=li,P.CachePlugin=lp,P.Client=ta,P.ConnectionString=ea,P.CostsPlugin=cp,P.Database=cs,P.ErrorMap=Ji,P.InvalidResourceItem=Jt,P.MemoryCache=rh,P.MissingMetadata=Gi,P.NoSuchBucket=Wi,P.NoSuchKey=$r,P.NotFound=Vi,P.Plugin=If,P.PluginObject=fp,P.ResourceIdsPageReader=Qo,P.ResourceIdsReader=Xo,P.ResourceReader=es,P.ResourceWriter=ts,P.S3Cache=Pf,P.S3_DEFAULT_ENDPOINT=Qi,P.S3_DEFAULT_REGION=Xi,P.S3db=th,P.UnknownError=Yi,P.Validator=so,P.ValidatorManager=fo,P.decrypt=na,P.encrypt=zr,P.sha256=ra,P.streamToString=Pt,P}({},nanoid,lodashEs,promisePool,clientS3,crypto,flat,FastestValidator,web);
|