@simon_he/translate
Version:
A fast, robust, and lightweight translation library supporting 5 translation services (Google, Bing, DeepL, MyMemory, Lingva) with automatic fallback, batch processing, caching, and full TypeScript support.
1 lines • 167 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var Fc=Object.create;var ts=Object.defineProperty;var Bc=Object.getOwnPropertyDescriptor;var zc=Object.getOwnPropertyNames;var $c=Object.getPrototypeOf,Gc=Object.prototype.hasOwnProperty;var E=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Wc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of zc(t))!Gc.call(e,s)&&s!==r&&ts(e,s,{get:()=>t[s],enumerable:!(n=Bc(t,s))||n.enumerable});return e};var Kc=(e,t,r)=>(r=e!=null?Fc($c(e)):{},Wc(t||!e||!e.__esModule?ts(r,"default",{value:e,enumerable:!0}):r,e));var ae=w((oe,mt)=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});var rs=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Vc(e){return rs.includes(e)}var Jc=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Blob","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","FormData","URLSearchParams","HTMLElement",...rs];function Yc(e){return Jc.includes(e)}var Xc=["null","undefined","string","number","bigint","boolean","symbol"];function Qc(e){return Xc.includes(e)}function Ce(e){return t=>typeof t===e}var{toString:ns}=Object.prototype,We=e=>{let t=ns.call(e).slice(8,-1);if(/HTML\w+Element/.test(t)&&c.domElement(e))return"HTMLElement";if(Yc(t))return t},R=e=>t=>We(t)===e;function c(e){if(e===null)return"null";switch(typeof e){case"undefined":return"undefined";case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"function":return"Function";case"bigint":return"bigint";case"symbol":return"symbol";default:}if(c.observable(e))return"Observable";if(c.array(e))return"Array";if(c.buffer(e))return"Buffer";let t=We(e);if(t)return t;if(e instanceof String||e instanceof Boolean||e instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}c.undefined=Ce("undefined");c.string=Ce("string");var Zc=Ce("number");c.number=e=>Zc(e)&&!c.nan(e);c.bigint=Ce("bigint");c.function_=Ce("function");c.null_=e=>e===null;c.class_=e=>c.function_(e)&&e.toString().startsWith("class ");c.boolean=e=>e===!0||e===!1;c.symbol=Ce("symbol");c.numericString=e=>c.string(e)&&!c.emptyStringOrWhitespace(e)&&!Number.isNaN(Number(e));c.array=(e,t)=>Array.isArray(e)?c.function_(t)?e.every(t):!0:!1;c.buffer=e=>{var t,r,n,s;return(s=(n=(r=(t=e)===null||t===void 0?void 0:t.constructor)===null||r===void 0?void 0:r.isBuffer)===null||n===void 0?void 0:n.call(r,e))!==null&&s!==void 0?s:!1};c.blob=e=>R("Blob")(e);c.nullOrUndefined=e=>c.null_(e)||c.undefined(e);c.object=e=>!c.null_(e)&&(typeof e=="object"||c.function_(e));c.iterable=e=>{var t;return c.function_((t=e)===null||t===void 0?void 0:t[Symbol.iterator])};c.asyncIterable=e=>{var t;return c.function_((t=e)===null||t===void 0?void 0:t[Symbol.asyncIterator])};c.generator=e=>{var t,r;return c.iterable(e)&&c.function_((t=e)===null||t===void 0?void 0:t.next)&&c.function_((r=e)===null||r===void 0?void 0:r.throw)};c.asyncGenerator=e=>c.asyncIterable(e)&&c.function_(e.next)&&c.function_(e.throw);c.nativePromise=e=>R("Promise")(e);var eu=e=>{var t,r;return c.function_((t=e)===null||t===void 0?void 0:t.then)&&c.function_((r=e)===null||r===void 0?void 0:r.catch)};c.promise=e=>c.nativePromise(e)||eu(e);c.generatorFunction=R("GeneratorFunction");c.asyncGeneratorFunction=e=>We(e)==="AsyncGeneratorFunction";c.asyncFunction=e=>We(e)==="AsyncFunction";c.boundFunction=e=>c.function_(e)&&!e.hasOwnProperty("prototype");c.regExp=R("RegExp");c.date=R("Date");c.error=R("Error");c.map=e=>R("Map")(e);c.set=e=>R("Set")(e);c.weakMap=e=>R("WeakMap")(e);c.weakSet=e=>R("WeakSet")(e);c.int8Array=R("Int8Array");c.uint8Array=R("Uint8Array");c.uint8ClampedArray=R("Uint8ClampedArray");c.int16Array=R("Int16Array");c.uint16Array=R("Uint16Array");c.int32Array=R("Int32Array");c.uint32Array=R("Uint32Array");c.float32Array=R("Float32Array");c.float64Array=R("Float64Array");c.bigInt64Array=R("BigInt64Array");c.bigUint64Array=R("BigUint64Array");c.arrayBuffer=R("ArrayBuffer");c.sharedArrayBuffer=R("SharedArrayBuffer");c.dataView=R("DataView");c.enumCase=(e,t)=>Object.values(t).includes(e);c.directInstanceOf=(e,t)=>Object.getPrototypeOf(e)===t.prototype;c.urlInstance=e=>R("URL")(e);c.urlString=e=>{if(!c.string(e))return!1;try{return new URL(e),!0}catch (e2){return!1}};c.truthy=e=>!!e;c.falsy=e=>!e;c.nan=e=>Number.isNaN(e);c.primitive=e=>c.null_(e)||Qc(typeof e);c.integer=e=>Number.isInteger(e);c.safeInteger=e=>Number.isSafeInteger(e);c.plainObject=e=>{if(ns.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})};c.typedArray=e=>Vc(We(e));var tu=e=>c.safeInteger(e)&&e>=0;c.arrayLike=e=>!c.nullOrUndefined(e)&&!c.function_(e)&&tu(e.length);c.inRange=(e,t)=>{if(c.number(t))return e>=Math.min(0,t)&&e<=Math.max(t,0);if(c.array(t)&&t.length===2)return e>=Math.min(...t)&&e<=Math.max(...t);throw new TypeError(`Invalid range: ${JSON.stringify(t)}`)};var ru=1,nu=["innerHTML","ownerDocument","style","attributes","nodeValue"];c.domElement=e=>c.object(e)&&e.nodeType===ru&&c.string(e.nodeName)&&!c.plainObject(e)&&nu.every(t=>t in e);c.observable=e=>{var t,r,n,s;return e?e===((r=(t=e)[Symbol.observable])===null||r===void 0?void 0:r.call(t))||e===((s=(n=e)["@@observable"])===null||s===void 0?void 0:s.call(n)):!1};c.nodeStream=e=>c.object(e)&&c.function_(e.pipe)&&!c.observable(e);c.infinite=e=>e===1/0||e===-1/0;var ss=e=>t=>c.integer(t)&&Math.abs(t%2)===e;c.evenInteger=ss(0);c.oddInteger=ss(1);c.emptyArray=e=>c.array(e)&&e.length===0;c.nonEmptyArray=e=>c.array(e)&&e.length>0;c.emptyString=e=>c.string(e)&&e.length===0;var su=e=>c.string(e)&&!/\S/.test(e);c.emptyStringOrWhitespace=e=>c.emptyString(e)||su(e);c.nonEmptyString=e=>c.string(e)&&e.length>0;c.nonEmptyStringAndNotWhitespace=e=>c.string(e)&&!c.emptyStringOrWhitespace(e);c.emptyObject=e=>c.object(e)&&!c.map(e)&&!c.set(e)&&Object.keys(e).length===0;c.nonEmptyObject=e=>c.object(e)&&!c.map(e)&&!c.set(e)&&Object.keys(e).length>0;c.emptySet=e=>c.set(e)&&e.size===0;c.nonEmptySet=e=>c.set(e)&&e.size>0;c.emptyMap=e=>c.map(e)&&e.size===0;c.nonEmptyMap=e=>c.map(e)&&e.size>0;c.propertyKey=e=>c.any([c.string,c.number,c.symbol],e);c.formData=e=>R("FormData")(e);c.urlSearchParams=e=>R("URLSearchParams")(e);var is=(e,t,r)=>{if(!c.function_(t))throw new TypeError(`Invalid predicate: ${JSON.stringify(t)}`);if(r.length===0)throw new TypeError("Invalid number of values");return e.call(r,t)};c.any=(e,...t)=>(c.array(e)?e:[e]).some(n=>is(Array.prototype.some,n,t));c.all=(e,...t)=>is(Array.prototype.every,e,t);var v=(e,t,r,n={})=>{if(!e){let{multipleValues:s}=n,i=s?`received values of types ${[...new Set(r.map(o=>`\`${c(o)}\``))].join(", ")}`:`received value of type \`${c(r)}\``;throw new TypeError(`Expected value which is \`${t}\`, ${i}.`)}};oe.assert={undefined:e=>v(c.undefined(e),"undefined",e),string:e=>v(c.string(e),"string",e),number:e=>v(c.number(e),"number",e),bigint:e=>v(c.bigint(e),"bigint",e),function_:e=>v(c.function_(e),"Function",e),null_:e=>v(c.null_(e),"null",e),class_:e=>v(c.class_(e),"Class",e),boolean:e=>v(c.boolean(e),"boolean",e),symbol:e=>v(c.symbol(e),"symbol",e),numericString:e=>v(c.numericString(e),"string with a number",e),array:(e,t)=>{v(c.array(e),"Array",e),t&&e.forEach(t)},buffer:e=>v(c.buffer(e),"Buffer",e),blob:e=>v(c.blob(e),"Blob",e),nullOrUndefined:e=>v(c.nullOrUndefined(e),"null or undefined",e),object:e=>v(c.object(e),"Object",e),iterable:e=>v(c.iterable(e),"Iterable",e),asyncIterable:e=>v(c.asyncIterable(e),"AsyncIterable",e),generator:e=>v(c.generator(e),"Generator",e),asyncGenerator:e=>v(c.asyncGenerator(e),"AsyncGenerator",e),nativePromise:e=>v(c.nativePromise(e),"native Promise",e),promise:e=>v(c.promise(e),"Promise",e),generatorFunction:e=>v(c.generatorFunction(e),"GeneratorFunction",e),asyncGeneratorFunction:e=>v(c.asyncGeneratorFunction(e),"AsyncGeneratorFunction",e),asyncFunction:e=>v(c.asyncFunction(e),"AsyncFunction",e),boundFunction:e=>v(c.boundFunction(e),"Function",e),regExp:e=>v(c.regExp(e),"RegExp",e),date:e=>v(c.date(e),"Date",e),error:e=>v(c.error(e),"Error",e),map:e=>v(c.map(e),"Map",e),set:e=>v(c.set(e),"Set",e),weakMap:e=>v(c.weakMap(e),"WeakMap",e),weakSet:e=>v(c.weakSet(e),"WeakSet",e),int8Array:e=>v(c.int8Array(e),"Int8Array",e),uint8Array:e=>v(c.uint8Array(e),"Uint8Array",e),uint8ClampedArray:e=>v(c.uint8ClampedArray(e),"Uint8ClampedArray",e),int16Array:e=>v(c.int16Array(e),"Int16Array",e),uint16Array:e=>v(c.uint16Array(e),"Uint16Array",e),int32Array:e=>v(c.int32Array(e),"Int32Array",e),uint32Array:e=>v(c.uint32Array(e),"Uint32Array",e),float32Array:e=>v(c.float32Array(e),"Float32Array",e),float64Array:e=>v(c.float64Array(e),"Float64Array",e),bigInt64Array:e=>v(c.bigInt64Array(e),"BigInt64Array",e),bigUint64Array:e=>v(c.bigUint64Array(e),"BigUint64Array",e),arrayBuffer:e=>v(c.arrayBuffer(e),"ArrayBuffer",e),sharedArrayBuffer:e=>v(c.sharedArrayBuffer(e),"SharedArrayBuffer",e),dataView:e=>v(c.dataView(e),"DataView",e),enumCase:(e,t)=>v(c.enumCase(e,t),"EnumCase",e),urlInstance:e=>v(c.urlInstance(e),"URL",e),urlString:e=>v(c.urlString(e),"string with a URL",e),truthy:e=>v(c.truthy(e),"truthy",e),falsy:e=>v(c.falsy(e),"falsy",e),nan:e=>v(c.nan(e),"NaN",e),primitive:e=>v(c.primitive(e),"primitive",e),integer:e=>v(c.integer(e),"integer",e),safeInteger:e=>v(c.safeInteger(e),"integer",e),plainObject:e=>v(c.plainObject(e),"plain object",e),typedArray:e=>v(c.typedArray(e),"TypedArray",e),arrayLike:e=>v(c.arrayLike(e),"array-like",e),domElement:e=>v(c.domElement(e),"HTMLElement",e),observable:e=>v(c.observable(e),"Observable",e),nodeStream:e=>v(c.nodeStream(e),"Node.js Stream",e),infinite:e=>v(c.infinite(e),"infinite number",e),emptyArray:e=>v(c.emptyArray(e),"empty array",e),nonEmptyArray:e=>v(c.nonEmptyArray(e),"non-empty array",e),emptyString:e=>v(c.emptyString(e),"empty string",e),emptyStringOrWhitespace:e=>v(c.emptyStringOrWhitespace(e),"empty string or whitespace",e),nonEmptyString:e=>v(c.nonEmptyString(e),"non-empty string",e),nonEmptyStringAndNotWhitespace:e=>v(c.nonEmptyStringAndNotWhitespace(e),"non-empty string and not whitespace",e),emptyObject:e=>v(c.emptyObject(e),"empty object",e),nonEmptyObject:e=>v(c.nonEmptyObject(e),"non-empty object",e),emptySet:e=>v(c.emptySet(e),"empty set",e),nonEmptySet:e=>v(c.nonEmptySet(e),"non-empty set",e),emptyMap:e=>v(c.emptyMap(e),"empty map",e),nonEmptyMap:e=>v(c.nonEmptyMap(e),"non-empty map",e),propertyKey:e=>v(c.propertyKey(e),"PropertyKey",e),formData:e=>v(c.formData(e),"FormData",e),urlSearchParams:e=>v(c.urlSearchParams(e),"URLSearchParams",e),evenInteger:e=>v(c.evenInteger(e),"even integer",e),oddInteger:e=>v(c.oddInteger(e),"odd integer",e),directInstanceOf:(e,t)=>v(c.directInstanceOf(e,t),"T",e),inRange:(e,t)=>v(c.inRange(e,t),"in range",e),any:(e,...t)=>v(c.any(e,...t),"predicate returns truthy for any value",t,{multipleValues:!0}),all:(e,...t)=>v(c.all(e,...t),"predicate returns truthy for all values",t,{multipleValues:!0})};Object.defineProperties(c,{class:{value:c.class_},function:{value:c.function_},null:{value:c.null_}});Object.defineProperties(oe.assert,{class:{value:oe.assert.class_},function:{value:oe.assert.function_},null:{value:oe.assert.null_}});oe.default=c;mt.exports=c;mt.exports.default=c;mt.exports.assert=oe.assert});var os=w((zd,ar)=>{"use strict";var yt=class extends Error{constructor(t){super(t||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}},Oe=class{static fn(t){return(...r)=>new Oe((n,s,i)=>{r.push(i),t(...r).then(n,s)})}constructor(t){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((r,n)=>{this._reject=n;let s=a=>{(!this._isCanceled||!o.shouldReject)&&(this._isPending=!1,r(a))},i=a=>{this._isPending=!1,n(a)},o=a=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(a)};return Object.defineProperties(o,{shouldReject:{get:()=>this._rejectOnCancel,set:a=>{this._rejectOnCancel=a}}}),t(s,i,o)})}then(t,r){return this._promise.then(t,r)}catch(t){return this._promise.catch(t)}finally(t){return this._promise.finally(t)}cancel(t){if(!(!this._isPending||this._isCanceled)){if(this._isCanceled=!0,this._cancelHandlers.length>0)try{for(let r of this._cancelHandlers)r()}catch(r){this._reject(r);return}this._rejectOnCancel&&this._reject(new yt(t))}}get isCanceled(){return this._isCanceled}};Object.setPrototypeOf(Oe.prototype,Promise.prototype);ar.exports=Oe;ar.exports.CancelError=yt});var as=w((ur,fr)=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});function iu(e){return e.encrypted}var cr=(e,t)=>{let r;typeof t=="function"?r={connect:t}:r=t;let n=typeof r.connect=="function",s=typeof r.secureConnect=="function",i=typeof r.close=="function",o=()=>{n&&r.connect(),iu(e)&&s&&(e.authorized?r.secureConnect():e.authorizationError||e.once("secureConnect",r.secureConnect)),i&&e.once("close",r.close)};e.writable&&!e.connecting?o():e.connecting?e.once("connect",o):e.destroyed&&i&&r.close(e._hadError)};ur.default=cr;fr.exports=cr;fr.exports.default=cr});var cs=w((hr,dr)=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});var ou=as(),au=E("util"),cu=Number(process.versions.node.split(".")[0]),lr=e=>{if(e.timings)return e.timings;let t={start:Date.now(),socket:void 0,lookup:void 0,connect:void 0,secureConnect:void 0,upload:void 0,response:void 0,end:void 0,error:void 0,abort:void 0,phases:{wait:void 0,dns:void 0,tcp:void 0,tls:void 0,request:void 0,firstByte:void 0,download:void 0,total:void 0}};e.timings=t;let r=a=>{let u=a.emit.bind(a);a.emit=(h,...f)=>(h==="error"&&(t.error=Date.now(),t.phases.total=t.error-t.start,a.emit=u),u(h,...f))};r(e);let n=()=>{t.abort=Date.now(),(!t.response||cu>=13)&&(t.phases.total=Date.now()-t.start)};e.prependOnceListener("abort",n);let s=a=>{if(t.socket=Date.now(),t.phases.wait=t.socket-t.start,au.types.isProxy(a))return;let u=()=>{t.lookup=Date.now(),t.phases.dns=t.lookup-t.socket};a.prependOnceListener("lookup",u),ou.default(a,{connect:()=>{t.connect=Date.now(),t.lookup===void 0&&(a.removeListener("lookup",u),t.lookup=t.connect,t.phases.dns=t.lookup-t.socket),t.phases.tcp=t.connect-t.lookup},secureConnect:()=>{t.secureConnect=Date.now(),t.phases.tls=t.secureConnect-t.connect}})};e.socket?s(e.socket):e.prependOnceListener("socket",s);let i=()=>{var a;t.upload=Date.now(),t.phases.request=t.upload-((a=t.secureConnect)!==null&&a!==void 0?a:t.connect)};return(()=>typeof e.writableFinished=="boolean"?e.writableFinished:e.finished&&e.outputSize===0&&(!e.socket||e.socket.writableLength===0))()?i():e.prependOnceListener("finish",i),e.prependOnceListener("response",a=>{t.response=Date.now(),t.phases.firstByte=t.response-t.upload,a.timings=t,r(a),a.prependOnceListener("end",()=>{t.end=Date.now(),t.phases.download=t.end-t.response,t.phases.total=t.end-t.start}),a.prependOnceListener("aborted",n)}),t};hr.default=lr;dr.exports=lr;dr.exports.default=lr});var ms=w(($d,gr)=>{"use strict";var{V4MAPPED:uu,ADDRCONFIG:fu,ALL:ps,promises:{Resolver:us},lookup:lu}=E("dns"),{promisify:pr}=E("util"),hu=E("os"),Pe=Symbol("cacheableLookupCreateConnection"),mr=Symbol("cacheableLookupInstance"),fs=Symbol("expires"),du=typeof ps=="number",ls=e=>{if(!(e&&typeof e.createConnection=="function"))throw new Error("Expected an Agent instance as the first argument")},pu=e=>{for(let t of e)t.family!==6&&(t.address=`::ffff:${t.address}`,t.family=6)},hs=()=>{let e=!1,t=!1;for(let r of Object.values(hu.networkInterfaces()))for(let n of r)if(!n.internal&&(n.family==="IPv6"?t=!0:e=!0,e&&t))return{has4:e,has6:t};return{has4:e,has6:t}},mu=e=>Symbol.iterator in e,ds={ttl:!0},yu={all:!0},gt=class{constructor({cache:t=new Map,maxTtl:r=1/0,fallbackDuration:n=3600,errorTtl:s=.15,resolver:i=new us,lookup:o=lu}={}){if(this.maxTtl=r,this.errorTtl=s,this._cache=t,this._resolver=i,this._dnsLookup=pr(o),this._resolver instanceof us?(this._resolve4=this._resolver.resolve4.bind(this._resolver),this._resolve6=this._resolver.resolve6.bind(this._resolver)):(this._resolve4=pr(this._resolver.resolve4.bind(this._resolver)),this._resolve6=pr(this._resolver.resolve6.bind(this._resolver))),this._iface=hs(),this._pending={},this._nextRemovalTime=!1,this._hostnamesToFallback=new Set,n<1)this._fallback=!1;else{this._fallback=!0;let a=setInterval(()=>{this._hostnamesToFallback.clear()},n*1e3);a.unref&&a.unref()}this.lookup=this.lookup.bind(this),this.lookupAsync=this.lookupAsync.bind(this)}set servers(t){this.clear(),this._resolver.setServers(t)}get servers(){return this._resolver.getServers()}lookup(t,r,n){if(typeof r=="function"?(n=r,r={}):typeof r=="number"&&(r={family:r}),!n)throw new Error("Callback must be a function.");this.lookupAsync(t,r).then(s=>{r.all?n(null,s):n(null,s.address,s.family,s.expires,s.ttl)},n)}async lookupAsync(t,r={}){typeof r=="number"&&(r={family:r});let n=await this.query(t);if(r.family===6){let s=n.filter(i=>i.family===6);r.hints&uu&&(du&&r.hints&ps||s.length===0)?pu(n):n=s}else r.family===4&&(n=n.filter(s=>s.family===4));if(r.hints&fu){let{_iface:s}=this;n=n.filter(i=>i.family===6?s.has6:s.has4)}if(n.length===0){let s=new Error(`cacheableLookup ENOTFOUND ${t}`);throw s.code="ENOTFOUND",s.hostname=t,s}return r.all?n:n[0]}async query(t){let r=await this._cache.get(t);if(!r){let n=this._pending[t];if(n)r=await n;else{let s=this.queryAndCache(t);this._pending[t]=s;try{r=await s}finally{delete this._pending[t]}}}return r=r.map(n=>({...n})),r}async _resolve(t){let r=async h=>{try{return await h}catch(f){if(f.code==="ENODATA"||f.code==="ENOTFOUND")return[];throw f}},[n,s]=await Promise.all([this._resolve4(t,ds),this._resolve6(t,ds)].map(h=>r(h))),i=0,o=0,a=0,u=Date.now();for(let h of n)h.family=4,h.expires=u+h.ttl*1e3,i=Math.max(i,h.ttl);for(let h of s)h.family=6,h.expires=u+h.ttl*1e3,o=Math.max(o,h.ttl);return n.length>0?s.length>0?a=Math.min(i,o):a=i:a=o,{entries:[...n,...s],cacheTtl:a}}async _lookup(t){try{return{entries:await this._dnsLookup(t,{all:!0}),cacheTtl:0}}catch (e3){return{entries:[],cacheTtl:0}}}async _set(t,r,n){if(this.maxTtl>0&&n>0){n=Math.min(n,this.maxTtl)*1e3,r[fs]=Date.now()+n;try{await this._cache.set(t,r,n)}catch(s){this.lookupAsync=async()=>{let i=new Error("Cache Error. Please recreate the CacheableLookup instance.");throw i.cause=s,i}}mu(this._cache)&&this._tick(n)}}async queryAndCache(t){if(this._hostnamesToFallback.has(t))return this._dnsLookup(t,yu);let r=await this._resolve(t);r.entries.length===0&&this._fallback&&(r=await this._lookup(t),r.entries.length!==0&&this._hostnamesToFallback.add(t));let n=r.entries.length===0?this.errorTtl:r.cacheTtl;return await this._set(t,r.entries,n),r.entries}_tick(t){let r=this._nextRemovalTime;(!r||t<r)&&(clearTimeout(this._removalTimeout),this._nextRemovalTime=t,this._removalTimeout=setTimeout(()=>{this._nextRemovalTime=!1;let n=1/0,s=Date.now();for(let[i,o]of this._cache){let a=o[fs];s>=a?this._cache.delete(i):a<n&&(n=a)}n!==1/0&&this._tick(n-s)},t),this._removalTimeout.unref&&this._removalTimeout.unref())}install(t){if(ls(t),Pe in t)throw new Error("CacheableLookup has been already installed");t[Pe]=t.createConnection,t[mr]=this,t.createConnection=(r,n)=>("lookup"in r||(r.lookup=this.lookup),t[Pe](r,n))}uninstall(t){if(ls(t),t[Pe]){if(t[mr]!==this)throw new Error("The agent is not owned by this CacheableLookup instance");t.createConnection=t[Pe],delete t[Pe],delete t[mr]}}updateInterfaceInfo(){let{_iface:t}=this;this._iface=hs(),(t.has4&&!this._iface.has4||t.has6&&!this._iface.has6)&&this._cache.clear()}clear(t){if(t){this._cache.delete(t);return}this._cache.clear()}};gr.exports=gt;gr.exports.default=gt});var _s=w((Gd,gs)=>{"use strict";var gu="text/plain",_u="us-ascii",ys=(e,t)=>t.some(r=>r instanceof RegExp?r.test(e):r===e),wu=(e,{stripHash:t})=>{let r=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!r)throw new Error(`Invalid URL: ${e}`);let{type:n,data:s,hash:i}=r.groups,o=n.split(";");i=t?"":i;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let u=(o.shift()||"").toLowerCase(),f=[...o.map(l=>{let[d,p=""]=l.split("=").map(y=>y.trim());return d==="charset"&&(p=p.toLowerCase(),p===_u)?"":`${d}${p?`=${p}`:""}`}).filter(Boolean)];return a&&f.push("base64"),(f.length!==0||u&&u!==gu)&&f.unshift(u),`data:${f.join(";")},${a?s.trim():s}${i?`#${i}`:""}`},bu=(e,t)=>{if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return wu(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let r=e.startsWith("//");!r&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let s=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&s.protocol==="https:"&&(s.protocol="http:"),t.forceHttps&&s.protocol==="http:"&&(s.protocol="https:"),t.stripAuthentication&&(s.username="",s.password=""),t.stripHash?s.hash="":t.stripTextFragment&&(s.hash=s.hash.replace(/#?:~:text.*?$/i,"")),s.pathname&&(s.pathname=s.pathname.replace(/(?<!\b(?:[a-z][a-z\d+\-.]{1,50}:))\/{2,}/g,"/")),s.pathname)try{s.pathname=decodeURI(s.pathname)}catch (e4){}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=s.pathname.split("/"),a=o[o.length-1];ys(a,t.removeDirectoryIndex)&&(o=o.slice(0,o.length-1),s.pathname=o.slice(1).join("/")+"/")}if(s.hostname&&(s.hostname=s.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)(?:[a-z\-\d]{1,63})\.(?:[a-z.\-\d]{2,63})$/.test(s.hostname)&&(s.hostname=s.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...s.searchParams.keys()])ys(o,t.removeQueryParameters)&&s.searchParams.delete(o);t.removeQueryParameters===!0&&(s.search=""),t.sortQueryParameters&&s.searchParams.sort(),t.removeTrailingSlash&&(s.pathname=s.pathname.replace(/\/$/,""));let i=e;return e=s.toString(),!t.removeSingleSlash&&s.pathname==="/"&&!i.endsWith("/")&&s.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||s.pathname==="/")&&s.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),r&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e};gs.exports=bu});var vs=w((Wd,bs)=>{bs.exports=ws;function ws(e,t){if(e&&t)return ws(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(n){r[n]=e[n]}),r;function r(){for(var n=new Array(arguments.length),s=0;s<n.length;s++)n[s]=arguments[s];var i=e.apply(this,n),o=n[n.length-1];return typeof i=="function"&&i!==o&&Object.keys(o).forEach(function(a){i[a]=o[a]}),i}}});var br=w((Kd,_r)=>{var Es=vs();_r.exports=Es(_t);_r.exports.strict=Es(Ss);_t.proto=_t(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return _t(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Ss(this)},configurable:!0})});function _t(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Ss(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}});var Cs=w((Vd,xs)=>{var vu=br(),Eu=function(){},Su=function(e){return e.setHeader&&typeof e.abort=="function"},Tu=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3},Ts=function(e,t,r){if(typeof t=="function")return Ts(e,null,t);t||(t={}),r=vu(r||Eu);var n=e._writableState,s=e._readableState,i=t.readable||t.readable!==!1&&e.readable,o=t.writable||t.writable!==!1&&e.writable,a=!1,u=function(){e.writable||h()},h=function(){o=!1,i||r.call(e)},f=function(){i=!1,o||r.call(e)},l=function(m){r.call(e,m?new Error("exited with error code: "+m):null)},d=function(m){r.call(e,m)},p=function(){process.nextTick(y)},y=function(){if(!a){if(i&&!(s&&s.ended&&!s.destroyed))return r.call(e,new Error("premature close"));if(o&&!(n&&n.ended&&!n.destroyed))return r.call(e,new Error("premature close"))}},_=function(){e.req.on("finish",h)};return Su(e)?(e.on("complete",h),e.on("abort",p),e.req?_():e.on("request",_)):o&&!n&&(e.on("end",u),e.on("close",u)),Tu(e)&&e.on("exit",l),e.on("end",f),e.on("finish",h),t.error!==!1&&e.on("error",d),e.on("close",p),function(){a=!0,e.removeListener("complete",h),e.removeListener("abort",p),e.removeListener("request",_),e.req&&e.req.removeListener("finish",h),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",h),e.removeListener("exit",l),e.removeListener("end",f),e.removeListener("error",d),e.removeListener("close",p)}};xs.exports=Ts});var Rs=w((Jd,Ps)=>{var xu=br(),Cu=Cs(),vr=E("fs"),Ke=function(){},Ou=/^v?\.0/.test(process.version),wt=function(e){return typeof e=="function"},Pu=function(e){return!Ou||!vr?!1:(e instanceof(vr.ReadStream||Ke)||e instanceof(vr.WriteStream||Ke))&&wt(e.close)},Ru=function(e){return e.setHeader&&wt(e.abort)},Au=function(e,t,r,n){n=xu(n);var s=!1;e.on("close",function(){s=!0}),Cu(e,{readable:t,writable:r},function(o){if(o)return n(o);s=!0,n()});var i=!1;return function(o){if(!s&&!i){if(i=!0,Pu(e))return e.close(Ke);if(Ru(e))return e.abort();if(wt(e.destroy))return e.destroy();n(o||new Error("stream was destroyed"))}}},Os=function(e){e()},ku=function(e,t){return e.pipe(t)},qu=function(){var e=Array.prototype.slice.call(arguments),t=wt(e[e.length-1]||Ke)&&e.pop()||Ke;if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Error("pump requires two streams per minimum");var r,n=e.map(function(s,i){var o=i<e.length-1,a=i>0;return Au(s,o,a,function(u){r||(r=u),u&&n.forEach(Os),!o&&(n.forEach(Os),t(r))})});return e.reduce(ku)};Ps.exports=qu});var ks=w((Yd,As)=>{"use strict";var{PassThrough:ju}=E("stream");As.exports=e=>{e={...e};let{array:t}=e,{encoding:r}=e,n=r==="buffer",s=!1;t?s=!(r||n):r=r||"utf8",n&&(r=null);let i=new ju({objectMode:s});r&&i.setEncoding(r);let o=0,a=[];return i.on("data",u=>{a.push(u),s?o=a.length:o+=u.length}),i.getBufferedValue=()=>t?a:n?Buffer.concat(a,o):a.join(""),i.getBufferedLength=()=>o,i}});var qs=w((Xd,Re)=>{"use strict";var{constants:Lu}=E("buffer"),Iu=Rs(),Mu=ks(),bt=class extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};async function vt(e,t){if(!e)return Promise.reject(new Error("Expected a stream"));t={maxBuffer:1/0,...t};let{maxBuffer:r}=t,n;return await new Promise((s,i)=>{let o=a=>{a&&n.getBufferedLength()<=Lu.MAX_LENGTH&&(a.bufferedData=n.getBufferedValue()),i(a)};n=Iu(e,Mu(t),a=>{if(a){o(a);return}s()}),n.on("data",()=>{n.getBufferedLength()>r&&o(new bt)})}),n.getBufferedValue()}Re.exports=vt;Re.exports.default=vt;Re.exports.buffer=(e,t)=>vt(e,{...t,encoding:"buffer"});Re.exports.array=(e,t)=>vt(e,{...t,array:!0});Re.exports.MaxBufferError=bt});var Ls=w((Zd,js)=>{"use strict";var Du=new Set([200,203,204,206,300,301,308,404,405,410,414,501]),Nu=new Set([200,203,204,300,301,302,303,307,308,404,405,410,414,501]),Hu=new Set([500,502,503,504]),Uu={date:!0,connection:!0,"keep-alive":!0,"proxy-authenticate":!0,"proxy-authorization":!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0},Fu={"content-length":!0,"content-encoding":!0,"transfer-encoding":!0,"content-range":!0};function be(e){let t=parseInt(e,10);return isFinite(t)?t:0}function Bu(e){return e?Hu.has(e.status):!0}function Er(e){let t={};if(!e)return t;let r=e.trim().split(/,/);for(let n of r){let[s,i]=n.split(/=/,2);t[s.trim()]=i===void 0?!0:i.trim().replace(/^"|"$/g,"")}return t}function zu(e){let t=[];for(let r in e){let n=e[r];t.push(n===!0?r:r+"="+n)}if(t.length)return t.join(", ")}js.exports=class{constructor(t,r,{shared:n,cacheHeuristic:s,immutableMinTimeToLive:i,ignoreCargoCult:o,_fromObject:a}={}){if(a){this._fromObject(a);return}if(!r||!r.headers)throw Error("Response headers missing");this._assertRequestHasHeaders(t),this._responseTime=this.now(),this._isShared=n!==!1,this._cacheHeuristic=s!==void 0?s:.1,this._immutableMinTtl=i!==void 0?i:24*3600*1e3,this._status="status"in r?r.status:200,this._resHeaders=r.headers,this._rescc=Er(r.headers["cache-control"]),this._method="method"in t?t.method:"GET",this._url=t.url,this._host=t.headers.host,this._noAuthorization=!t.headers.authorization,this._reqHeaders=r.headers.vary?t.headers:null,this._reqcc=Er(t.headers["cache-control"]),o&&"pre-check"in this._rescc&&"post-check"in this._rescc&&(delete this._rescc["pre-check"],delete this._rescc["post-check"],delete this._rescc["no-cache"],delete this._rescc["no-store"],delete this._rescc["must-revalidate"],this._resHeaders=Object.assign({},this._resHeaders,{"cache-control":zu(this._rescc)}),delete this._resHeaders.expires,delete this._resHeaders.pragma),r.headers["cache-control"]==null&&/no-cache/.test(r.headers.pragma)&&(this._rescc["no-cache"]=!0)}now(){return Date.now()}storable(){return!!(!this._reqcc["no-store"]&&(this._method==="GET"||this._method==="HEAD"||this._method==="POST"&&this._hasExplicitExpiration())&&Nu.has(this._status)&&!this._rescc["no-store"]&&(!this._isShared||!this._rescc.private)&&(!this._isShared||this._noAuthorization||this._allowsStoringAuthenticated())&&(this._resHeaders.expires||this._rescc["max-age"]||this._isShared&&this._rescc["s-maxage"]||this._rescc.public||Du.has(this._status)))}_hasExplicitExpiration(){return this._isShared&&this._rescc["s-maxage"]||this._rescc["max-age"]||this._resHeaders.expires}_assertRequestHasHeaders(t){if(!t||!t.headers)throw Error("Request headers missing")}satisfiesWithoutRevalidation(t){this._assertRequestHasHeaders(t);let r=Er(t.headers["cache-control"]);return r["no-cache"]||/no-cache/.test(t.headers.pragma)||r["max-age"]&&this.age()>r["max-age"]||r["min-fresh"]&&this.timeToLive()<1e3*r["min-fresh"]||this.stale()&&!(r["max-stale"]&&!this._rescc["must-revalidate"]&&(r["max-stale"]===!0||r["max-stale"]>this.age()-this.maxAge()))?!1:this._requestMatches(t,!1)}_requestMatches(t,r){return(!this._url||this._url===t.url)&&this._host===t.headers.host&&(!t.method||this._method===t.method||r&&t.method==="HEAD")&&this._varyMatches(t)}_allowsStoringAuthenticated(){return this._rescc["must-revalidate"]||this._rescc.public||this._rescc["s-maxage"]}_varyMatches(t){if(!this._resHeaders.vary)return!0;if(this._resHeaders.vary==="*")return!1;let r=this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);for(let n of r)if(t.headers[n]!==this._reqHeaders[n])return!1;return!0}_copyWithoutHopByHopHeaders(t){let r={};for(let n in t)Uu[n]||(r[n]=t[n]);if(t.connection){let n=t.connection.trim().split(/\s*,\s*/);for(let s of n)delete r[s]}if(r.warning){let n=r.warning.split(/,/).filter(s=>!/^\s*1[0-9][0-9]/.test(s));n.length?r.warning=n.join(",").trim():delete r.warning}return r}responseHeaders(){let t=this._copyWithoutHopByHopHeaders(this._resHeaders),r=this.age();return r>3600*24&&!this._hasExplicitExpiration()&&this.maxAge()>3600*24&&(t.warning=(t.warning?`${t.warning}, `:"")+'113 - "rfc7234 5.5.4"'),t.age=`${Math.round(r)}`,t.date=new Date(this.now()).toUTCString(),t}date(){let t=Date.parse(this._resHeaders.date);return isFinite(t)?t:this._responseTime}age(){let t=this._ageValue(),r=(this.now()-this._responseTime)/1e3;return t+r}_ageValue(){return be(this._resHeaders.age)}maxAge(){if(!this.storable()||this._rescc["no-cache"]||this._isShared&&this._resHeaders["set-cookie"]&&!this._rescc.public&&!this._rescc.immutable||this._resHeaders.vary==="*")return 0;if(this._isShared){if(this._rescc["proxy-revalidate"])return 0;if(this._rescc["s-maxage"])return be(this._rescc["s-maxage"])}if(this._rescc["max-age"])return be(this._rescc["max-age"]);let t=this._rescc.immutable?this._immutableMinTtl:0,r=this.date();if(this._resHeaders.expires){let n=Date.parse(this._resHeaders.expires);return Number.isNaN(n)||n<r?0:Math.max(t,(n-r)/1e3)}if(this._resHeaders["last-modified"]){let n=Date.parse(this._resHeaders["last-modified"]);if(isFinite(n)&&r>n)return Math.max(t,(r-n)/1e3*this._cacheHeuristic)}return t}timeToLive(){let t=this.maxAge()-this.age(),r=t+be(this._rescc["stale-if-error"]),n=t+be(this._rescc["stale-while-revalidate"]);return Math.max(0,t,r,n)*1e3}stale(){return this.maxAge()<=this.age()}_useStaleIfError(){return this.maxAge()+be(this._rescc["stale-if-error"])>this.age()}useStaleWhileRevalidate(){return this.maxAge()+be(this._rescc["stale-while-revalidate"])>this.age()}static fromObject(t){return new this(void 0,void 0,{_fromObject:t})}_fromObject(t){if(this._responseTime)throw Error("Reinitialized");if(!t||t.v!==1)throw Error("Invalid serialization");this._responseTime=t.t,this._isShared=t.sh,this._cacheHeuristic=t.ch,this._immutableMinTtl=t.imm!==void 0?t.imm:24*3600*1e3,this._status=t.st,this._resHeaders=t.resh,this._rescc=t.rescc,this._method=t.m,this._url=t.u,this._host=t.h,this._noAuthorization=t.a,this._reqHeaders=t.reqh,this._reqcc=t.reqcc}toObject(){return{v:1,t:this._responseTime,sh:this._isShared,ch:this._cacheHeuristic,imm:this._immutableMinTtl,st:this._status,resh:this._resHeaders,rescc:this._rescc,m:this._method,u:this._url,h:this._host,a:this._noAuthorization,reqh:this._reqHeaders,reqcc:this._reqcc}}revalidationHeaders(t){this._assertRequestHasHeaders(t);let r=this._copyWithoutHopByHopHeaders(t.headers);if(delete r["if-range"],!this._requestMatches(t,!0)||!this.storable())return delete r["if-none-match"],delete r["if-modified-since"],r;if(this._resHeaders.etag&&(r["if-none-match"]=r["if-none-match"]?`${r["if-none-match"]}, ${this._resHeaders.etag}`:this._resHeaders.etag),r["accept-ranges"]||r["if-match"]||r["if-unmodified-since"]||this._method&&this._method!="GET"){if(delete r["if-modified-since"],r["if-none-match"]){let s=r["if-none-match"].split(/,/).filter(i=>!/^\s*W\//.test(i));s.length?r["if-none-match"]=s.join(",").trim():delete r["if-none-match"]}}else this._resHeaders["last-modified"]&&!r["if-modified-since"]&&(r["if-modified-since"]=this._resHeaders["last-modified"]);return r}revalidatedPolicy(t,r){if(this._assertRequestHasHeaders(t),this._useStaleIfError()&&Bu(r))return{modified:!1,matches:!1,policy:this};if(!r||!r.headers)throw Error("Response headers missing");let n=!1;if(r.status!==void 0&&r.status!=304?n=!1:r.headers.etag&&!/^\s*W\//.test(r.headers.etag)?n=this._resHeaders.etag&&this._resHeaders.etag.replace(/^\s*W\//,"")===r.headers.etag:this._resHeaders.etag&&r.headers.etag?n=this._resHeaders.etag.replace(/^\s*W\//,"")===r.headers.etag.replace(/^\s*W\//,""):this._resHeaders["last-modified"]?n=this._resHeaders["last-modified"]===r.headers["last-modified"]:!this._resHeaders.etag&&!this._resHeaders["last-modified"]&&!r.headers.etag&&!r.headers["last-modified"]&&(n=!0),!n)return{policy:new this.constructor(t,r),modified:r.status!=304,matches:!1};let s={};for(let o in this._resHeaders)s[o]=o in r.headers&&!Fu[o]?r.headers[o]:this._resHeaders[o];let i=Object.assign({},r,{status:this._status,method:this._method,headers:s});return{policy:new this.constructor(t,i,{shared:this._isShared,cacheHeuristic:this._cacheHeuristic,immutableMinTimeToLive:this._immutableMinTtl}),modified:!1,matches:!0}}}});var Et=w((ep,Is)=>{"use strict";Is.exports=e=>{let t={};for(let[r,n]of Object.entries(e))t[r.toLowerCase()]=n;return t}});var Ds=w((tp,Ms)=>{"use strict";var $u=E("stream").Readable,Gu=Et(),Sr=class extends $u{constructor(t,r,n,s){if(typeof t!="number")throw new TypeError("Argument `statusCode` should be a number");if(typeof r!="object")throw new TypeError("Argument `headers` should be an object");if(!(n instanceof Buffer))throw new TypeError("Argument `body` should be a buffer");if(typeof s!="string")throw new TypeError("Argument `url` should be a string");super(),this.statusCode=t,this.headers=Gu(r),this.body=n,this.url=s}_read(){this.push(this.body),this.push(null)}};Ms.exports=Sr});var Hs=w((rp,Ns)=>{"use strict";var Wu=["destroy","setTimeout","socket","headers","trailers","rawHeaders","statusCode","httpVersion","httpVersionMinor","httpVersionMajor","rawTrailers","statusMessage"];Ns.exports=(e,t)=>{let r=new Set(Object.keys(e).concat(Wu));for(let n of r)n in t||(t[n]=typeof e[n]=="function"?e[n].bind(e):e[n])}});var Fs=w((np,Us)=>{"use strict";var Ku=E("stream").PassThrough,Vu=Hs(),Ju=e=>{if(!(e&&e.pipe))throw new TypeError("Parameter `response` must be a response stream.");let t=new Ku;return Vu(e,t),e.pipe(t)};Us.exports=Ju});var Bs=w(Tr=>{Tr.stringify=function e(t){if(typeof t>"u")return t;if(t&&Buffer.isBuffer(t))return JSON.stringify(":base64:"+t.toString("base64"));if(t&&t.toJSON&&(t=t.toJSON()),t&&typeof t=="object"){var r="",n=Array.isArray(t);r=n?"[":"{";var s=!0;for(var i in t){var o=typeof t[i]=="function"||!n&&typeof t[i]>"u";Object.hasOwnProperty.call(t,i)&&!o&&(s||(r+=","),s=!1,n?t[i]==null?r+="null":r+=e(t[i]):t[i]!==void 0&&(r+=e(i)+":"+e(t[i])))}return r+=n?"]":"}",r}else return typeof t=="string"?JSON.stringify(/^:/.test(t)?":"+t:t):typeof t>"u"?"null":JSON.stringify(t)};Tr.parse=function(e){return JSON.parse(e,function(t,r){return typeof r=="string"?/^:base64:/.test(r)?Buffer.from(r.substring(8),"base64"):/^:/.test(r)?r.substring(1):r:r})}});var Ws=w((ip,Gs)=>{"use strict";var Yu=E("events"),zs=Bs(),Xu=e=>{let t={redis:"@keyv/redis",rediss:"@keyv/redis",mongodb:"@keyv/mongo",mongo:"@keyv/mongo",sqlite:"@keyv/sqlite",postgresql:"@keyv/postgres",postgres:"@keyv/postgres",mysql:"@keyv/mysql",etcd:"@keyv/etcd",offline:"@keyv/offline",tiered:"@keyv/tiered"};if(e.adapter||e.uri){let r=e.adapter||/^[^:+]*/.exec(e.uri)[0];return new(E(t[r]))(e)}return new Map},$s=["sqlite","postgres","mysql","mongo","redis","tiered"],Cr=class extends Yu{constructor(t,{emitErrors:r=!0,...n}={}){if(super(),this.opts={namespace:"keyv",serialize:zs.stringify,deserialize:zs.parse,...typeof t=="string"?{uri:t}:t,...n},!this.opts.store){let i={...this.opts};this.opts.store=Xu(i)}if(this.opts.compression){let i=this.opts.compression;this.opts.serialize=i.serialize.bind(i),this.opts.deserialize=i.deserialize.bind(i)}typeof this.opts.store.on=="function"&&r&&this.opts.store.on("error",i=>this.emit("error",i)),this.opts.store.namespace=this.opts.namespace;let s=i=>async function*(){for await(let[o,a]of typeof i=="function"?i(this.opts.store.namespace):i){let u=await this.opts.deserialize(a);if(!(this.opts.store.namespace&&!o.includes(this.opts.store.namespace))){if(typeof u.expires=="number"&&Date.now()>u.expires){this.delete(o);continue}yield[this._getKeyUnprefix(o),u.value]}}};typeof this.opts.store[Symbol.iterator]=="function"&&this.opts.store instanceof Map?this.iterator=s(this.opts.store):typeof this.opts.store.iterator=="function"&&this.opts.store.opts&&this._checkIterableAdaptar()&&(this.iterator=s(this.opts.store.iterator.bind(this.opts.store)))}_checkIterableAdaptar(){return $s.includes(this.opts.store.opts.dialect)||$s.findIndex(t=>this.opts.store.opts.url.includes(t))>=0}_getKeyPrefix(t){return`${this.opts.namespace}:${t}`}_getKeyPrefixArray(t){return t.map(r=>`${this.opts.namespace}:${r}`)}_getKeyUnprefix(t){return t.split(":").splice(1).join(":")}get(t,r){let{store:n}=this.opts,s=Array.isArray(t),i=s?this._getKeyPrefixArray(t):this._getKeyPrefix(t);if(s&&n.getMany===void 0){let o=[];for(let a of i)o.push(Promise.resolve().then(()=>n.get(a)).then(u=>typeof u=="string"?this.opts.deserialize(u):this.opts.compression?this.opts.deserialize(u):u).then(u=>{if(u!=null)return typeof u.expires=="number"&&Date.now()>u.expires?this.delete(a).then(()=>{}):r&&r.raw?u:u.value}));return Promise.allSettled(o).then(a=>{let u=[];for(let h of a)u.push(h.value);return u})}return Promise.resolve().then(()=>s?n.getMany(i):n.get(i)).then(o=>typeof o=="string"?this.opts.deserialize(o):this.opts.compression?this.opts.deserialize(o):o).then(o=>{if(o!=null)return s?o.map((a,u)=>{if(typeof a=="string"&&(a=this.opts.deserialize(a)),a!=null){if(typeof a.expires=="number"&&Date.now()>a.expires){this.delete(t[u]).then(()=>{});return}return r&&r.raw?a:a.value}}):typeof o.expires=="number"&&Date.now()>o.expires?this.delete(t).then(()=>{}):r&&r.raw?o:o.value})}set(t,r,n){let s=this._getKeyPrefix(t);typeof n>"u"&&(n=this.opts.ttl),n===0&&(n=void 0);let{store:i}=this.opts;return Promise.resolve().then(()=>{let o=typeof n=="number"?Date.now()+n:null;return typeof r=="symbol"&&this.emit("error","symbol cannot be serialized"),r={value:r,expires:o},this.opts.serialize(r)}).then(o=>i.set(s,o,n)).then(()=>!0)}delete(t){let{store:r}=this.opts;if(Array.isArray(t)){let s=this._getKeyPrefixArray(t);if(r.deleteMany===void 0){let i=[];for(let o of s)i.push(r.delete(o));return Promise.allSettled(i).then(o=>o.every(a=>a.value===!0))}return Promise.resolve().then(()=>r.deleteMany(s))}let n=this._getKeyPrefix(t);return Promise.resolve().then(()=>r.delete(n))}clear(){let{store:t}=this.opts;return Promise.resolve().then(()=>t.clear())}has(t){let r=this._getKeyPrefix(t),{store:n}=this.opts;return Promise.resolve().then(async()=>typeof n.has=="function"?n.has(r):await n.get(r)!==void 0)}disconnect(){let{store:t}=this.opts;if(typeof t.disconnect=="function")return t.disconnect()}};Gs.exports=Cr});var Js=w((ap,Vs)=>{"use strict";var Qu=E("events"),St=E("url"),Zu=_s(),ef=qs(),Or=Ls(),Ks=Ds(),tf=Et(),rf=Fs(),nf=Ws(),Z=class{constructor(t,r){if(typeof t!="function")throw new TypeError("Parameter `request` must be a function");return this.cache=new nf({uri:typeof r=="string"&&r,store:typeof r!="string"&&r,namespace:"cacheable-request"}),this.createCacheableRequest(t)}createCacheableRequest(t){return(r,n)=>{let s;if(typeof r=="string")s=Pr(St.parse(r)),r={};else if(r instanceof St.URL)s=Pr(St.parse(r.toString())),r={};else{let[l,...d]=(r.path||"").split("?"),p=d.length>0?`?${d.join("?")}`:"";s=Pr({...r,pathname:l,search:p})}r={headers:{},method:"GET",cache:!0,strictTtl:!1,automaticFailover:!1,...r,...sf(s)},r.headers=tf(r.headers);let i=new Qu,o=Zu(St.format(s),{stripWWW:!1,removeTrailingSlash:!1,stripAuthentication:!1}),a=`${r.method}:${o}`,u=!1,h=!1,f=l=>{h=!0;let d=!1,p,y=new Promise(m=>{p=()=>{d||(d=!0,m())}}),_=m=>{if(u&&!l.forceRefresh){m.status=m.statusCode;let S=Or.fromObject(u.cachePolicy).revalidatedPolicy(l,m);if(!S.modified){let x=S.policy.responseHeaders();m=new Ks(u.statusCode,x,u.body,u.url),m.cachePolicy=S.policy,m.fromCache=!0}}m.fromCache||(m.cachePolicy=new Or(l,m,l),m.fromCache=!1);let b;l.cache&&m.cachePolicy.storable()?(b=rf(m),(async()=>{try{let S=ef.buffer(m);if(await Promise.race([y,new Promise(fe=>m.once("end",fe))]),d)return;let x=await S,G={cachePolicy:m.cachePolicy.toObject(),url:m.url,statusCode:m.fromCache?u.statusCode:m.statusCode,body:x},Q=l.strictTtl?m.cachePolicy.timeToLive():void 0;l.maxTtl&&(Q=Q?Math.min(Q,l.maxTtl):l.maxTtl),await this.cache.set(a,G,Q)}catch(S){i.emit("error",new Z.CacheError(S))}})()):l.cache&&u&&(async()=>{try{await this.cache.delete(a)}catch(S){i.emit("error",new Z.CacheError(S))}})(),i.emit("response",b||m),typeof n=="function"&&n(b||m)};try{let m=t(l,_);m.once("error",p),m.once("abort",p),i.emit("request",m)}catch(m){i.emit("error",new Z.RequestError(m))}};return(async()=>{let l=async p=>{await Promise.resolve();let y=p.cache?await this.cache.get(a):void 0;if(typeof y>"u")return f(p);let _=Or.fromObject(y.cachePolicy);if(_.satisfiesWithoutRevalidation(p)&&!p.forceRefresh){let m=_.responseHeaders(),b=new Ks(y.statusCode,m,y.body,y.url);b.cachePolicy=_,b.fromCache=!0,i.emit("response",b),typeof n=="function"&&n(b)}else u=y,p.headers=_.revalidationHeaders(p),f(p)},d=p=>i.emit("error",new Z.CacheError(p));this.cache.once("error",d),i.on("response",()=>this.cache.removeListener("error",d));try{await l(r)}catch(p){r.automaticFailover&&!h&&f(r),i.emit("error",new Z.CacheError(p))}})(),i}}};function sf(e){let t={...e};return t.path=`${e.pathname||"/"}${e.search||""}`,delete t.pathname,delete t.search,t}function Pr(e){return{protocol:e.protocol,auth:e.auth,hostname:e.hostname||e.host||"localhost",port:e.port,pathname:e.pathname,search:e.search}}Z.RequestError=class extends Error{constructor(e){super(e.message),this.name="RequestError",Object.assign(this,e)}};Z.CacheError=class extends Error{constructor(e){super(e.message),this.name="CacheError",Object.assign(this,e)}};Vs.exports=Z});var Xs=w((fp,Ys)=>{"use strict";var of=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];Ys.exports=(e,t)=>{if(t._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");let r=new Set(Object.keys(e).concat(of)),n={};for(let s of r)s in t||(n[s]={get(){let i=e[s];return typeof i=="function"?i.bind(e):i},set(i){e[s]=i},enumerable:!0,configurable:!1});return Object.defineProperties(t,n),e.once("aborted",()=>{t.destroy(),t.emit("aborted")}),e.once("close",()=>{e.complete&&t.readable?t.once("end",()=>{t.emit("close")}):t.emit("close")}),t}});var Zs=w((lp,Qs)=>{"use strict";var{Transform:af,PassThrough:cf}=E("stream"),Rr=E("zlib"),uf=Xs();Qs.exports=e=>{let t=(e.headers["content-encoding"]||"").toLowerCase();if(!["gzip","deflate","br"].includes(t))return e;let r=t==="br";if(r&&typeof Rr.createBrotliDecompress!="function")return e.destroy(new Error("Brotli is not supported on Node.js < 12")),e;let n=!0,s=new af({transform(a,u,h){n=!1,h(null,a)},flush(a){a()}}),i=new cf({autoDestroy:!1,destroy(a,u){e.destroy(),u(a)}}),o=r?Rr.createBrotliDecompress():Rr.createUnzip();return o.once("error",a=>{if(n&&!e.readable){i.end();return}i.destroy(a)}),uf(e,i),e.pipe(s).pipe(o).pipe(i),i}});var kr=w((hp,ei)=>{"use strict";var Ar=class{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.onEviction=t.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,r){if(this.cache.set(t,r),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function")for(let[n,s]of this.oldCache.entries())this.onEviction(n,s);this.oldCache=this.cache,this.cache=new Map}}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){let r=this.oldCache.get(t);return this.oldCache.delete(t),this._set(t,r),r}}set(t,r){return this.cache.has(t)?this.cache.set(t,r):this._set(t,r),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t))return this.oldCache.get(t)}delete(t){let r=this.cache.delete(t);return r&&this._size--,this.oldCache.delete(t)||r}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(let[t]of this)yield t}*values(){for(let[,t]of this)yield t}*[Symbol.iterator](){for(let t of this.cache)yield t;for(let t of this.oldCache){let[r]=t;this.cache.has(r)||(yield t)}}get size(){let t=0;for(let r of this.oldCache.keys())this.cache.has(r)||t++;return Math.min(this._size+t,this.maxSize)}};ei.exports=Ar});var jr=w((dp,si)=>{"use strict";var ff=E("events"),lf=E("tls"),hf=E("http2"),df=kr(),K=Symbol("currentStreamsCount"),ti=Symbol("request"),J=Symbol("cachedOriginSet"),Ae=Symbol("gracefullyClosing"),pf=["maxDeflateDynamicTableSize","maxSessionMemory","maxHeaderListPairs","maxOutstandingPings","maxReservedRemoteStreams","maxSendHeaderBlockLength","paddingStrategy","localAddress","path","rejectUnauthorized","minDHSize","ca","cert","clientCertEngine","ciphers","key","pfx","servername","minVersion","maxVersion","secureProtocol","crl","honorCipherOrder","ecdhCurve","dhparam","secureOptions","sessionIdContext"],mf=(e,t,r)=>{let n=0,s=e.length;for(;n<s;){let i=n+s>>>1;r(e[i],t)?n=i+1:s=i}return n},yf=(e,t)=>e.remoteSettings.maxConcurrentStreams>t.remoteSettings.maxConcurrentStreams,qr=(e,t)=>{for(let r of e)r[J].length<t[J].length&&r[J].every(n=>t[J].includes(n))&&r[K]+t[K]<=t.remoteSettings.maxConcurrentStreams&&ni(r)},gf=(e,t)=>{for(let r of e)t[J].length<r[J].length&&t[J].every(n=>r[J].includes(n))&&t[K]+r[K]<=r.remoteSettings.maxConcurrentStreams&&ni(t)},ri=({agent:e,isFree:t})=>{let r={};for(let n in e.sessions){let i=e.sessions[n].filter(o=>{let a=o[ne.kCurrentStreamsCount]<o.remoteSettings.maxConcurrentStreams;return t?a:!a});i.length!==0&&(r[n]=i)}return r},ni=e=>{e[Ae]=!0,e[K]===0&&e.close()},ne=class extends ff{constructor({timeout:t=6e4,maxSessions:r=1/0,maxFreeSessions:n=10,maxCachedTlsSessions:s=100}={}){super(),this.sessions={},this.queue={},this.timeout=t,this.maxSessions=r,this.maxFreeSessions=n,this._freeSessionsCount=0,this._sessionsCount=0,this.settings={enablePush:!1},this.tlsSessionCache=new df({maxSiz