#!/usr/bin/env node const originalEmit = process.emit; process.emit = function (name, data, ...args) { if (name === 'warning' && typeof data === 'object' && data.name === 'DeprecationWarning' && data.message.includes('punycode')) { return false; } return originalEmit.apply(process, [name, data, ...args]); }; var b=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var yt=b((Du,Ti)=>{Ti.exports={name:"@dp/tea-sdk-node",version:"3.0.10",description:"",main:"lib/index.js",keywords:[],author:"",license:"ISC",engines:{node:">=10.0.0"},types:"./lib/index.d.ts",dependencies:{"@types/node":"^12.12.50","@logsdk/node-utils":"^3.0.7"},scripts:{build:"npm run clean && tsc --build tsconfig.build.json",clean:"rm -rf ./lib",watch:"npm run build -- --watch",test:"jest"}}});var Ar=b(ge=>{var xi=ge&&ge.__rest||function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);nObject.assign(Object.assign({},o),{_staging_flag:this.options.isolated}))}}}};ge.default=gt});var qr=b(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.format=void 0;var Ii=/%[sdjo%]/g;function Li(t){return typeof t=="object"&&t!==null}function Mi(t,...e){let r=1,s=arguments,n=s.length,o=String(t).replace(Ii,a=>{if(a==="%%")return"%";if(r>=n)return a;switch(a){case"%s":return String(s[r++]);case"%d":return Number(s[r++]).toString();case"%j":try{return JSON.stringify(s[r++])}catch{return"[Circular]"}default:return a}});for(var i=s[r];r{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.Logger=void 0;var Ui=qr(),Ni={silent:0,error:1,warn:2,verbose:3},Fi={write(t,e){switch(t){case"error":console.error(e);break;case"warn":console.warn(e);break;default:console.log(e)}}},_t=class t{constructor(e){this.product=e,this.levelIndex=1,this.consumer=Fi,this.getLevelIndex=()=>this.levelIndex,this.getConsumer=()=>this.consumer}propagate(e){let r=new t(`${this.product}.${e}`);return r.getLevelIndex=()=>this.levelIndex,r.getConsumer=()=>this.consumer,r}setLevel(e){this.levelIndex=Ni[e]||1}log(e,r,...s){let n=(0,Ui.format)(r,...s);this.getConsumer().write(e,`[${this.product}] [${e}] ${n}`)}error(e,...r){this.getLevelIndex()>=1&&this.log("error",e,...r)}warn(e,...r){this.getLevelIndex()>=2&&this.log("warn",e,...r)}trace(e,...r){this.getLevelIndex()>=3&&this.log("trace",e,...r)}};Ae.Logger=_t});var Hr=b(X=>{"use strict";var Bi=X&&X.__createBinding||(Object.create?(function(t,e,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,n)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]})),zi=X&&X.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Bi(e,t,r)};Object.defineProperty(X,"__esModule",{value:!0});zi(jr(),X)});var Ir=b(W=>{Object.defineProperty(W,"__esModule",{value:!0});W.SDK_VERSION=W.useInspectOption=W.pathMap=void 0;W.pathMap={WEBID_PATH:"/v1/user/webid",SSID_PATH:"/v1/user/ssid",REPORT_PATH:"/v1/list",ET:"/v1/list_test"};W.useInspectOption={sorted:!0,depth:99};W.SDK_VERSION="3.0.10"});var Mr=b(V=>{var $i=V&&V.__rest||function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n{this.plugins.map(s=>{var n;(n=s.beforeConfig)===null||n===void 0||n.call(s,r)}),this.configManager.configure(r),this.plugins.map(s=>{var n;(n=s.afterConfig)===null||n===void 0||n.call(s,r)})},this.logger=new Gi.Logger("Logsdk"),this.logger.setLevel(e.logLevel||"silent"),e.isolated&&this.logger.warn("Global isolation is enabled"),(0,Wi.default)(typeof(e==null?void 0:e.app_id)=="number"),this.configManager=new Vi.default(Object.assign(Object.assign({},e),{logger:this.logger})),this.logger.trace("initialized success with options %o",e),this.logger.trace("initialized sdk version %o",Ki.SDK_VERSION)}composeHookContext(e){let r=this;return{get metaInfo(){return r.meta},logger:this.logger.propagate(e.name),collect:(s,n)=>{this.trigger(Object.assign({events:s.map(o=>Object.assign(Object.assign({},o.extra),{event:o.name,params:JSON.stringify(o.params),time:Math.ceil(Date.now()/1e3)}))},n),{originatedBy:e.name})}}}trigger(...e){let[r,s]=e,n=this.configManager.compose(r,s);this.logger.trace("Composed event %o",n),this.plugins.map(o=>{var i,a;(i=o.beforeSendEvent)===null||i===void 0||i.call(o,n),(a=o.onSendEvent)===null||a===void 0||a.call(o,n)})}use(...e){this.plugins.push(...e),e.map(r=>{var s;(s=r.install)===null||s===void 0||s.call(r,this.composeHookContext(r)),this.logger.trace("Plugin %s installed",r.name)})}collectEvents(e,r,s,n){this.trigger({events:s,user:e,header:r,caller:n||this.configManager.caller})}getConfig(e){return this.configManager.get(e)}collect(e,r,s){let n=Array.isArray(e)?e.map(({name:u,params:l})=>({event:u,params:JSON.stringify(l)})):[{event:e,params:JSON.stringify(r)}],o=(Array.isArray(e)?r:s)||{},{custom:i}=o,a=$i(o,["custom"]);this.plugins.length||this.logger.warn("Dry run since no plugin applied"),this.trigger(Object.assign({events:n.map(u=>Object.assign(Object.assign({},u),{time:Math.ceil(Date.now()/1e3)})),customOfHeader:i},a))}};V.TeaSDK=bt});var F=b((N,qe)=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var Dr=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Qi(t){return Dr.includes(t)}var Xi=["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",...Dr];function Yi(t){return Xi.includes(t)}var Zi=["null","undefined","string","number","bigint","boolean","symbol"];function eo(t){return Zi.includes(t)}function te(t){return e=>typeof e===t}var{toString:Ur}=Object.prototype,_e=t=>{let e=Ur.call(t).slice(8,-1);if(/HTML\w+Element/.test(e)&&c.domElement(t))return"HTMLElement";if(Yi(e))return e},S=t=>e=>_e(e)===t;function c(t){if(t===null)return"null";switch(typeof t){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(t))return"Observable";if(c.array(t))return"Array";if(c.buffer(t))return"Buffer";let e=_e(t);if(e)return e;if(t instanceof String||t instanceof Boolean||t instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}c.undefined=te("undefined");c.string=te("string");var to=te("number");c.number=t=>to(t)&&!c.nan(t);c.bigint=te("bigint");c.function_=te("function");c.null_=t=>t===null;c.class_=t=>c.function_(t)&&t.toString().startsWith("class ");c.boolean=t=>t===!0||t===!1;c.symbol=te("symbol");c.numericString=t=>c.string(t)&&!c.emptyStringOrWhitespace(t)&&!Number.isNaN(Number(t));c.array=(t,e)=>Array.isArray(t)?c.function_(e)?t.every(e):!0:!1;c.buffer=t=>{var e,r,s,n;return(n=(s=(r=(e=t)===null||e===void 0?void 0:e.constructor)===null||r===void 0?void 0:r.isBuffer)===null||s===void 0?void 0:s.call(r,t))!==null&&n!==void 0?n:!1};c.blob=t=>S("Blob")(t);c.nullOrUndefined=t=>c.null_(t)||c.undefined(t);c.object=t=>!c.null_(t)&&(typeof t=="object"||c.function_(t));c.iterable=t=>{var e;return c.function_((e=t)===null||e===void 0?void 0:e[Symbol.iterator])};c.asyncIterable=t=>{var e;return c.function_((e=t)===null||e===void 0?void 0:e[Symbol.asyncIterator])};c.generator=t=>{var e,r;return c.iterable(t)&&c.function_((e=t)===null||e===void 0?void 0:e.next)&&c.function_((r=t)===null||r===void 0?void 0:r.throw)};c.asyncGenerator=t=>c.asyncIterable(t)&&c.function_(t.next)&&c.function_(t.throw);c.nativePromise=t=>S("Promise")(t);var ro=t=>{var e,r;return c.function_((e=t)===null||e===void 0?void 0:e.then)&&c.function_((r=t)===null||r===void 0?void 0:r.catch)};c.promise=t=>c.nativePromise(t)||ro(t);c.generatorFunction=S("GeneratorFunction");c.asyncGeneratorFunction=t=>_e(t)==="AsyncGeneratorFunction";c.asyncFunction=t=>_e(t)==="AsyncFunction";c.boundFunction=t=>c.function_(t)&&!t.hasOwnProperty("prototype");c.regExp=S("RegExp");c.date=S("Date");c.error=S("Error");c.map=t=>S("Map")(t);c.set=t=>S("Set")(t);c.weakMap=t=>S("WeakMap")(t);c.weakSet=t=>S("WeakSet")(t);c.int8Array=S("Int8Array");c.uint8Array=S("Uint8Array");c.uint8ClampedArray=S("Uint8ClampedArray");c.int16Array=S("Int16Array");c.uint16Array=S("Uint16Array");c.int32Array=S("Int32Array");c.uint32Array=S("Uint32Array");c.float32Array=S("Float32Array");c.float64Array=S("Float64Array");c.bigInt64Array=S("BigInt64Array");c.bigUint64Array=S("BigUint64Array");c.arrayBuffer=S("ArrayBuffer");c.sharedArrayBuffer=S("SharedArrayBuffer");c.dataView=S("DataView");c.enumCase=(t,e)=>Object.values(e).includes(t);c.directInstanceOf=(t,e)=>Object.getPrototypeOf(t)===e.prototype;c.urlInstance=t=>S("URL")(t);c.urlString=t=>{if(!c.string(t))return!1;try{return new URL(t),!0}catch{return!1}};c.truthy=t=>!!t;c.falsy=t=>!t;c.nan=t=>Number.isNaN(t);c.primitive=t=>c.null_(t)||eo(typeof t);c.integer=t=>Number.isInteger(t);c.safeInteger=t=>Number.isSafeInteger(t);c.plainObject=t=>{if(Ur.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);return e===null||e===Object.getPrototypeOf({})};c.typedArray=t=>Qi(_e(t));var so=t=>c.safeInteger(t)&&t>=0;c.arrayLike=t=>!c.nullOrUndefined(t)&&!c.function_(t)&&so(t.length);c.inRange=(t,e)=>{if(c.number(e))return t>=Math.min(0,e)&&t<=Math.max(e,0);if(c.array(e)&&e.length===2)return t>=Math.min(...e)&&t<=Math.max(...e);throw new TypeError(`Invalid range: ${JSON.stringify(e)}`)};var no=1,io=["innerHTML","ownerDocument","style","attributes","nodeValue"];c.domElement=t=>c.object(t)&&t.nodeType===no&&c.string(t.nodeName)&&!c.plainObject(t)&&io.every(e=>e in t);c.observable=t=>{var e,r,s,n;return t?t===((r=(e=t)[Symbol.observable])===null||r===void 0?void 0:r.call(e))||t===((n=(s=t)["@@observable"])===null||n===void 0?void 0:n.call(s)):!1};c.nodeStream=t=>c.object(t)&&c.function_(t.pipe)&&!c.observable(t);c.infinite=t=>t===1/0||t===-1/0;var Nr=t=>e=>c.integer(e)&&Math.abs(e%2)===t;c.evenInteger=Nr(0);c.oddInteger=Nr(1);c.emptyArray=t=>c.array(t)&&t.length===0;c.nonEmptyArray=t=>c.array(t)&&t.length>0;c.emptyString=t=>c.string(t)&&t.length===0;var oo=t=>c.string(t)&&!/\S/.test(t);c.emptyStringOrWhitespace=t=>c.emptyString(t)||oo(t);c.nonEmptyString=t=>c.string(t)&&t.length>0;c.nonEmptyStringAndNotWhitespace=t=>c.string(t)&&!c.emptyStringOrWhitespace(t);c.emptyObject=t=>c.object(t)&&!c.map(t)&&!c.set(t)&&Object.keys(t).length===0;c.nonEmptyObject=t=>c.object(t)&&!c.map(t)&&!c.set(t)&&Object.keys(t).length>0;c.emptySet=t=>c.set(t)&&t.size===0;c.nonEmptySet=t=>c.set(t)&&t.size>0;c.emptyMap=t=>c.map(t)&&t.size===0;c.nonEmptyMap=t=>c.map(t)&&t.size>0;c.propertyKey=t=>c.any([c.string,c.number,c.symbol],t);c.formData=t=>S("FormData")(t);c.urlSearchParams=t=>S("URLSearchParams")(t);var Fr=(t,e,r)=>{if(!c.function_(e))throw new TypeError(`Invalid predicate: ${JSON.stringify(e)}`);if(r.length===0)throw new TypeError("Invalid number of values");return t.call(r,e)};c.any=(t,...e)=>(c.array(t)?t:[t]).some(s=>Fr(Array.prototype.some,s,e));c.all=(t,...e)=>Fr(Array.prototype.every,t,e);var _=(t,e,r,s={})=>{if(!t){let{multipleValues:n}=s,o=n?`received values of types ${[...new Set(r.map(i=>`\`${c(i)}\``))].join(", ")}`:`received value of type \`${c(r)}\``;throw new TypeError(`Expected value which is \`${e}\`, ${o}.`)}};N.assert={undefined:t=>_(c.undefined(t),"undefined",t),string:t=>_(c.string(t),"string",t),number:t=>_(c.number(t),"number",t),bigint:t=>_(c.bigint(t),"bigint",t),function_:t=>_(c.function_(t),"Function",t),null_:t=>_(c.null_(t),"null",t),class_:t=>_(c.class_(t),"Class",t),boolean:t=>_(c.boolean(t),"boolean",t),symbol:t=>_(c.symbol(t),"symbol",t),numericString:t=>_(c.numericString(t),"string with a number",t),array:(t,e)=>{_(c.array(t),"Array",t),e&&t.forEach(e)},buffer:t=>_(c.buffer(t),"Buffer",t),blob:t=>_(c.blob(t),"Blob",t),nullOrUndefined:t=>_(c.nullOrUndefined(t),"null or undefined",t),object:t=>_(c.object(t),"Object",t),iterable:t=>_(c.iterable(t),"Iterable",t),asyncIterable:t=>_(c.asyncIterable(t),"AsyncIterable",t),generator:t=>_(c.generator(t),"Generator",t),asyncGenerator:t=>_(c.asyncGenerator(t),"AsyncGenerator",t),nativePromise:t=>_(c.nativePromise(t),"native Promise",t),promise:t=>_(c.promise(t),"Promise",t),generatorFunction:t=>_(c.generatorFunction(t),"GeneratorFunction",t),asyncGeneratorFunction:t=>_(c.asyncGeneratorFunction(t),"AsyncGeneratorFunction",t),asyncFunction:t=>_(c.asyncFunction(t),"AsyncFunction",t),boundFunction:t=>_(c.boundFunction(t),"Function",t),regExp:t=>_(c.regExp(t),"RegExp",t),date:t=>_(c.date(t),"Date",t),error:t=>_(c.error(t),"Error",t),map:t=>_(c.map(t),"Map",t),set:t=>_(c.set(t),"Set",t),weakMap:t=>_(c.weakMap(t),"WeakMap",t),weakSet:t=>_(c.weakSet(t),"WeakSet",t),int8Array:t=>_(c.int8Array(t),"Int8Array",t),uint8Array:t=>_(c.uint8Array(t),"Uint8Array",t),uint8ClampedArray:t=>_(c.uint8ClampedArray(t),"Uint8ClampedArray",t),int16Array:t=>_(c.int16Array(t),"Int16Array",t),uint16Array:t=>_(c.uint16Array(t),"Uint16Array",t),int32Array:t=>_(c.int32Array(t),"Int32Array",t),uint32Array:t=>_(c.uint32Array(t),"Uint32Array",t),float32Array:t=>_(c.float32Array(t),"Float32Array",t),float64Array:t=>_(c.float64Array(t),"Float64Array",t),bigInt64Array:t=>_(c.bigInt64Array(t),"BigInt64Array",t),bigUint64Array:t=>_(c.bigUint64Array(t),"BigUint64Array",t),arrayBuffer:t=>_(c.arrayBuffer(t),"ArrayBuffer",t),sharedArrayBuffer:t=>_(c.sharedArrayBuffer(t),"SharedArrayBuffer",t),dataView:t=>_(c.dataView(t),"DataView",t),enumCase:(t,e)=>_(c.enumCase(t,e),"EnumCase",t),urlInstance:t=>_(c.urlInstance(t),"URL",t),urlString:t=>_(c.urlString(t),"string with a URL",t),truthy:t=>_(c.truthy(t),"truthy",t),falsy:t=>_(c.falsy(t),"falsy",t),nan:t=>_(c.nan(t),"NaN",t),primitive:t=>_(c.primitive(t),"primitive",t),integer:t=>_(c.integer(t),"integer",t),safeInteger:t=>_(c.safeInteger(t),"integer",t),plainObject:t=>_(c.plainObject(t),"plain object",t),typedArray:t=>_(c.typedArray(t),"TypedArray",t),arrayLike:t=>_(c.arrayLike(t),"array-like",t),domElement:t=>_(c.domElement(t),"HTMLElement",t),observable:t=>_(c.observable(t),"Observable",t),nodeStream:t=>_(c.nodeStream(t),"Node.js Stream",t),infinite:t=>_(c.infinite(t),"infinite number",t),emptyArray:t=>_(c.emptyArray(t),"empty array",t),nonEmptyArray:t=>_(c.nonEmptyArray(t),"non-empty array",t),emptyString:t=>_(c.emptyString(t),"empty string",t),emptyStringOrWhitespace:t=>_(c.emptyStringOrWhitespace(t),"empty string or whitespace",t),nonEmptyString:t=>_(c.nonEmptyString(t),"non-empty string",t),nonEmptyStringAndNotWhitespace:t=>_(c.nonEmptyStringAndNotWhitespace(t),"non-empty string and not whitespace",t),emptyObject:t=>_(c.emptyObject(t),"empty object",t),nonEmptyObject:t=>_(c.nonEmptyObject(t),"non-empty object",t),emptySet:t=>_(c.emptySet(t),"empty set",t),nonEmptySet:t=>_(c.nonEmptySet(t),"non-empty set",t),emptyMap:t=>_(c.emptyMap(t),"empty map",t),nonEmptyMap:t=>_(c.nonEmptyMap(t),"non-empty map",t),propertyKey:t=>_(c.propertyKey(t),"PropertyKey",t),formData:t=>_(c.formData(t),"FormData",t),urlSearchParams:t=>_(c.urlSearchParams(t),"URLSearchParams",t),evenInteger:t=>_(c.evenInteger(t),"even integer",t),oddInteger:t=>_(c.oddInteger(t),"odd integer",t),directInstanceOf:(t,e)=>_(c.directInstanceOf(t,e),"T",t),inRange:(t,e)=>_(c.inRange(t,e),"in range",t),any:(t,...e)=>_(c.any(t,...e),"predicate returns truthy for any value",e,{multipleValues:!0}),all:(t,...e)=>_(c.all(t,...e),"predicate returns truthy for all values",e,{multipleValues:!0})};Object.defineProperties(c,{class:{value:c.class_},function:{value:c.function_},null:{value:c.null_}});Object.defineProperties(N.assert,{class:{value:N.assert.class_},function:{value:N.assert.function_},null:{value:N.assert.null_}});N.default=c;qe.exports=c;qe.exports.default=c;qe.exports.assert=N.assert});var Br=b((Wu,wt)=>{"use strict";var je=class extends Error{constructor(e){super(e||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}},He=class t{static fn(e){return(...r)=>new t((s,n,o)=>{r.push(o),e(...r).then(s,n)})}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((r,s)=>{this._reject=s;let n=a=>{(!this._isCanceled||!i.shouldReject)&&(this._isPending=!1,r(a))},o=a=>{this._isPending=!1,s(a)},i=a=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(a)};return Object.defineProperties(i,{shouldReject:{get:()=>this._rejectOnCancel,set:a=>{this._rejectOnCancel=a}}}),e(n,o,i)})}then(e,r){return this._promise.then(e,r)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){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 je(e))}}get isCanceled(){return this._isCanceled}};Object.setPrototypeOf(He.prototype,Promise.prototype);wt.exports=He;wt.exports.CancelError=je});var zr=b((Et,St)=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});function ao(t){return t.encrypted}var vt=(t,e)=>{let r;typeof e=="function"?r={connect:e}:r=e;let s=typeof r.connect=="function",n=typeof r.secureConnect=="function",o=typeof r.close=="function",i=()=>{s&&r.connect(),ao(t)&&n&&(t.authorized?r.secureConnect():t.authorizationError||t.once("secureConnect",r.secureConnect)),o&&t.once("close",r.close)};t.writable&&!t.connecting?i():t.connecting?t.once("connect",i):t.destroyed&&o&&r.close(t._hadError)};Et.default=vt;St.exports=vt;St.exports.default=vt});var $r=b((Ot,Rt)=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});var co=zr(),uo=require("util"),lo=Number(process.versions.node.split(".")[0]),Pt=t=>{if(t.timings)return t.timings;let e={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}};t.timings=e;let r=a=>{let u=a.emit.bind(a);a.emit=(l,...m)=>(l==="error"&&(e.error=Date.now(),e.phases.total=e.error-e.start,a.emit=u),u(l,...m))};r(t);let s=()=>{e.abort=Date.now(),(!e.response||lo>=13)&&(e.phases.total=Date.now()-e.start)};t.prependOnceListener("abort",s);let n=a=>{if(e.socket=Date.now(),e.phases.wait=e.socket-e.start,uo.types.isProxy(a))return;let u=()=>{e.lookup=Date.now(),e.phases.dns=e.lookup-e.socket};a.prependOnceListener("lookup",u),co.default(a,{connect:()=>{e.connect=Date.now(),e.lookup===void 0&&(a.removeListener("lookup",u),e.lookup=e.connect,e.phases.dns=e.lookup-e.socket),e.phases.tcp=e.connect-e.lookup},secureConnect:()=>{e.secureConnect=Date.now(),e.phases.tls=e.secureConnect-e.connect}})};t.socket?n(t.socket):t.prependOnceListener("socket",n);let o=()=>{var a;e.upload=Date.now(),e.phases.request=e.upload-((a=e.secureConnect)!==null&&a!==void 0?a:e.connect)};return(typeof t.writableFinished=="boolean"?t.writableFinished:t.finished&&t.outputSize===0&&(!t.socket||t.socket.writableLength===0))?o():t.prependOnceListener("finish",o),t.prependOnceListener("response",a=>{e.response=Date.now(),e.phases.firstByte=e.response-e.upload,a.timings=e,r(a),a.prependOnceListener("end",()=>{e.end=Date.now(),e.phases.download=e.end-e.response,e.phases.total=e.end-e.start}),a.prependOnceListener("aborted",s)}),e};Ot.default=Pt;Rt.exports=Pt;Rt.exports.default=Pt});var Xr=b((Vu,Tt)=>{"use strict";var{V4MAPPED:ho,ADDRCONFIG:fo,ALL:Qr,promises:{Resolver:Wr},lookup:po}=require("dns"),{promisify:kt}=require("util"),mo=require("os"),re=Symbol("cacheableLookupCreateConnection"),Ct=Symbol("cacheableLookupInstance"),Vr=Symbol("expires"),yo=typeof Qr=="number",Gr=t=>{if(!(t&&typeof t.createConnection=="function"))throw new Error("Expected an Agent instance as the first argument")},go=t=>{for(let e of t)e.family!==6&&(e.address=`::ffff:${e.address}`,e.family=6)},Jr=()=>{let t=!1,e=!1;for(let r of Object.values(mo.networkInterfaces()))for(let s of r)if(!s.internal&&(s.family==="IPv6"?e=!0:t=!0,t&&e))return{has4:t,has6:e};return{has4:t,has6:e}},_o=t=>Symbol.iterator in t,Kr={ttl:!0},bo={all:!0},Ie=class{constructor({cache:e=new Map,maxTtl:r=1/0,fallbackDuration:s=3600,errorTtl:n=.15,resolver:o=new Wr,lookup:i=po}={}){if(this.maxTtl=r,this.errorTtl=n,this._cache=e,this._resolver=o,this._dnsLookup=kt(i),this._resolver instanceof Wr?(this._resolve4=this._resolver.resolve4.bind(this._resolver),this._resolve6=this._resolver.resolve6.bind(this._resolver)):(this._resolve4=kt(this._resolver.resolve4.bind(this._resolver)),this._resolve6=kt(this._resolver.resolve6.bind(this._resolver))),this._iface=Jr(),this._pending={},this._nextRemovalTime=!1,this._hostnamesToFallback=new Set,s<1)this._fallback=!1;else{this._fallback=!0;let a=setInterval(()=>{this._hostnamesToFallback.clear()},s*1e3);a.unref&&a.unref()}this.lookup=this.lookup.bind(this),this.lookupAsync=this.lookupAsync.bind(this)}set servers(e){this.clear(),this._resolver.setServers(e)}get servers(){return this._resolver.getServers()}lookup(e,r,s){if(typeof r=="function"?(s=r,r={}):typeof r=="number"&&(r={family:r}),!s)throw new Error("Callback must be a function.");this.lookupAsync(e,r).then(n=>{r.all?s(null,n):s(null,n.address,n.family,n.expires,n.ttl)},s)}async lookupAsync(e,r={}){typeof r=="number"&&(r={family:r});let s=await this.query(e);if(r.family===6){let n=s.filter(o=>o.family===6);r.hints&ho&&(yo&&r.hints&Qr||n.length===0)?go(s):s=n}else r.family===4&&(s=s.filter(n=>n.family===4));if(r.hints&fo){let{_iface:n}=this;s=s.filter(o=>o.family===6?n.has6:n.has4)}if(s.length===0){let n=new Error(`cacheableLookup ENOTFOUND ${e}`);throw n.code="ENOTFOUND",n.hostname=e,n}return r.all?s:s[0]}async query(e){let r=await this._cache.get(e);if(!r){let s=this._pending[e];if(s)r=await s;else{let n=this.queryAndCache(e);this._pending[e]=n;try{r=await n}finally{delete this._pending[e]}}}return r=r.map(s=>({...s})),r}async _resolve(e){let r=async l=>{try{return await l}catch(m){if(m.code==="ENODATA"||m.code==="ENOTFOUND")return[];throw m}},[s,n]=await Promise.all([this._resolve4(e,Kr),this._resolve6(e,Kr)].map(l=>r(l))),o=0,i=0,a=0,u=Date.now();for(let l of s)l.family=4,l.expires=u+l.ttl*1e3,o=Math.max(o,l.ttl);for(let l of n)l.family=6,l.expires=u+l.ttl*1e3,i=Math.max(i,l.ttl);return s.length>0?n.length>0?a=Math.min(o,i):a=o:a=i,{entries:[...s,...n],cacheTtl:a}}async _lookup(e){try{return{entries:await this._dnsLookup(e,{all:!0}),cacheTtl:0}}catch{return{entries:[],cacheTtl:0}}}async _set(e,r,s){if(this.maxTtl>0&&s>0){s=Math.min(s,this.maxTtl)*1e3,r[Vr]=Date.now()+s;try{await this._cache.set(e,r,s)}catch(n){this.lookupAsync=async()=>{let o=new Error("Cache Error. Please recreate the CacheableLookup instance.");throw o.cause=n,o}}_o(this._cache)&&this._tick(s)}}async queryAndCache(e){if(this._hostnamesToFallback.has(e))return this._dnsLookup(e,bo);let r=await this._resolve(e);r.entries.length===0&&this._fallback&&(r=await this._lookup(e),r.entries.length!==0&&this._hostnamesToFallback.add(e));let s=r.entries.length===0?this.errorTtl:r.cacheTtl;return await this._set(e,r.entries,s),r.entries}_tick(e){let r=this._nextRemovalTime;(!r||e{this._nextRemovalTime=!1;let s=1/0,n=Date.now();for(let[o,i]of this._cache){let a=i[Vr];n>=a?this._cache.delete(o):a("lookup"in r||(r.lookup=this.lookup),e[re](r,s))}uninstall(e){if(Gr(e),e[re]){if(e[Ct]!==this)throw new Error("The agent is not owned by this CacheableLookup instance");e.createConnection=e[re],delete e[re],delete e[Ct]}}updateInterfaceInfo(){let{_iface:e}=this;this._iface=Jr(),(e.has4&&!this._iface.has4||e.has6&&!this._iface.has6)&&this._cache.clear()}clear(e){if(e){this._cache.delete(e);return}this._cache.clear()}};Tt.exports=Ie;Tt.exports.default=Ie});var es=b((Gu,Zr)=>{"use strict";var wo="text/plain",vo="us-ascii",Yr=(t,e)=>e.some(r=>r instanceof RegExp?r.test(t):r===t),Eo=(t,{stripHash:e})=>{let r=/^data:(?[^,]*?),(?[^#]*?)(?:#(?.*))?$/.exec(t);if(!r)throw new Error(`Invalid URL: ${t}`);let{type:s,data:n,hash:o}=r.groups,i=s.split(";");o=e?"":o;let a=!1;i[i.length-1]==="base64"&&(i.pop(),a=!0);let u=(i.shift()||"").toLowerCase(),m=[...i.map(h=>{let[y,p=""]=h.split("=").map(g=>g.trim());return y==="charset"&&(p=p.toLowerCase(),p===vo)?"":`${y}${p?`=${p}`:""}`}).filter(Boolean)];return a&&m.push("base64"),(m.length!==0||u&&u!==wo)&&m.unshift(u),`data:${m.join(";")},${a?n.trim():n}${o?`#${o}`:""}`},So=(t,e)=>{if(e={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,...e},t=t.trim(),/^data:/i.test(t))return Eo(t,e);if(/^view-source:/i.test(t))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let r=t.startsWith("//");!r&&/^\.*\//.test(t)||(t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,e.defaultProtocol));let n=new URL(t);if(e.forceHttp&&e.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(e.forceHttp&&n.protocol==="https:"&&(n.protocol="http:"),e.forceHttps&&n.protocol==="http:"&&(n.protocol="https:"),e.stripAuthentication&&(n.username="",n.password=""),e.stripHash?n.hash="":e.stripTextFragment&&(n.hash=n.hash.replace(/#?:~:text.*?$/i,"")),n.pathname&&(n.pathname=n.pathname.replace(/(?0){let i=n.pathname.split("/"),a=i[i.length-1];Yr(a,e.removeDirectoryIndex)&&(i=i.slice(0,i.length-1),n.pathname=i.slice(1).join("/")+"/")}if(n.hostname&&(n.hostname=n.hostname.replace(/\.$/,""),e.stripWWW&&/^www\.(?!www\.)(?:[a-z\-\d]{1,63})\.(?:[a-z.\-\d]{2,63})$/.test(n.hostname)&&(n.hostname=n.hostname.replace(/^www\./,""))),Array.isArray(e.removeQueryParameters))for(let i of[...n.searchParams.keys()])Yr(i,e.removeQueryParameters)&&n.searchParams.delete(i);e.removeQueryParameters===!0&&(n.search=""),e.sortQueryParameters&&n.searchParams.sort(),e.removeTrailingSlash&&(n.pathname=n.pathname.replace(/\/$/,""));let o=t;return t=n.toString(),!e.removeSingleSlash&&n.pathname==="/"&&!o.endsWith("/")&&n.hash===""&&(t=t.replace(/\/$/,"")),(e.removeTrailingSlash||n.pathname==="/")&&n.hash===""&&e.removeSingleSlash&&(t=t.replace(/\/$/,"")),r&&!e.normalizeProtocol&&(t=t.replace(/^http:\/\//,"//")),e.stripProtocol&&(t=t.replace(/^(?:https?:)?\/\//,"")),t};Zr.exports=So});var ss=b((Ju,rs)=>{rs.exports=ts;function ts(t,e){if(t&&e)return ts(t)(e);if(typeof t!="function")throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(s){r[s]=t[s]}),r;function r(){for(var s=new Array(arguments.length),n=0;n{var ns=ss();xt.exports=ns(Le);xt.exports.strict=ns(is);Le.proto=Le(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Le(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return is(this)},configurable:!0})});function Le(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function is(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},r=t.name||"Function wrapped with `once`";return e.onceError=r+" shouldn't be called more than once",e.called=!1,e}});var cs=b((Qu,as)=>{var Po=At(),Oo=function(){},Ro=global.Bare?queueMicrotask:process.nextTick.bind(process),ko=function(t){return t.setHeader&&typeof t.abort=="function"},Co=function(t){return t.stdio&&Array.isArray(t.stdio)&&t.stdio.length===3},os=function(t,e,r){if(typeof e=="function")return os(t,null,e);e||(e={}),r=Po(r||Oo);var s=t._writableState,n=t._readableState,o=e.readable||e.readable!==!1&&t.readable,i=e.writable||e.writable!==!1&&t.writable,a=!1,u=function(){t.writable||l()},l=function(){i=!1,o||r.call(t)},m=function(){o=!1,i||r.call(t)},h=function(f){r.call(t,f?new Error("exited with error code: "+f):null)},y=function(f){r.call(t,f)},p=function(){Ro(g)},g=function(){if(!a){if(o&&!(n&&n.ended&&!n.destroyed))return r.call(t,new Error("premature close"));if(i&&!(s&&s.ended&&!s.destroyed))return r.call(t,new Error("premature close"))}},w=function(){t.req.on("finish",l)};return ko(t)?(t.on("complete",l),t.on("abort",p),t.req?w():t.on("request",w)):i&&!s&&(t.on("end",u),t.on("close",u)),Co(t)&&t.on("exit",h),t.on("end",m),t.on("finish",l),e.error!==!1&&t.on("error",y),t.on("close",p),function(){a=!0,t.removeListener("complete",l),t.removeListener("abort",p),t.removeListener("request",w),t.req&&t.req.removeListener("finish",l),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",l),t.removeListener("exit",h),t.removeListener("end",m),t.removeListener("error",y),t.removeListener("close",p)}};as.exports=os});var ds=b((Xu,ls)=>{var To=At(),xo=cs(),Me;try{Me=require("fs")}catch{}var be=function(){},Ao=typeof process>"u"?!1:/^v?\.0/.test(process.version),De=function(t){return typeof t=="function"},qo=function(t){return!Ao||!Me?!1:(t instanceof(Me.ReadStream||be)||t instanceof(Me.WriteStream||be))&&De(t.close)},jo=function(t){return t.setHeader&&De(t.abort)},Ho=function(t,e,r,s){s=To(s);var n=!1;t.on("close",function(){n=!0}),xo(t,{readable:e,writable:r},function(i){if(i)return s(i);n=!0,s()});var o=!1;return function(i){if(!n&&!o){if(o=!0,qo(t))return t.close(be);if(jo(t))return t.abort();if(De(t.destroy))return t.destroy();s(i||new Error("stream was destroyed"))}}},us=function(t){t()},Io=function(t,e){return t.pipe(e)},Lo=function(){var t=Array.prototype.slice.call(arguments),e=De(t[t.length-1]||be)&&t.pop()||be;if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Error("pump requires two streams per minimum");var r,s=t.map(function(n,o){var i=o0;return Ho(n,i,a,function(u){r||(r=u),u&&s.forEach(us),!i&&(s.forEach(us),e(r))})});return t.reduce(Io)};ls.exports=Lo});var fs=b((Yu,hs)=>{"use strict";var{PassThrough:Mo}=require("stream");hs.exports=t=>{t={...t};let{array:e}=t,{encoding:r}=t,s=r==="buffer",n=!1;e?n=!(r||s):r=r||"utf8",s&&(r=null);let o=new Mo({objectMode:n});r&&o.setEncoding(r);let i=0,a=[];return o.on("data",u=>{a.push(u),n?i=a.length:i+=u.length}),o.getBufferedValue=()=>e?a:s?Buffer.concat(a,i):a.join(""),o.getBufferedLength=()=>i,o}});var ps=b((Zu,se)=>{"use strict";var{constants:Do}=require("buffer"),Uo=ds(),No=fs(),Ue=class extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};async function Ne(t,e){if(!t)return Promise.reject(new Error("Expected a stream"));e={maxBuffer:1/0,...e};let{maxBuffer:r}=e,s;return await new Promise((n,o)=>{let i=a=>{a&&s.getBufferedLength()<=Do.MAX_LENGTH&&(a.bufferedData=s.getBufferedValue()),o(a)};s=Uo(t,No(e),a=>{if(a){i(a);return}n()}),s.on("data",()=>{s.getBufferedLength()>r&&i(new Ue)})}),s.getBufferedValue()}se.exports=Ne;se.exports.default=Ne;se.exports.buffer=(t,e)=>Ne(t,{...e,encoding:"buffer"});se.exports.array=(t,e)=>Ne(t,{...e,array:!0});se.exports.MaxBufferError=Ue});var ys=b((tl,ms)=>{"use strict";var Fo=new Set([200,203,204,206,300,301,308,404,405,410,414,501]),Bo=new Set([200,203,204,300,301,302,303,307,308,404,405,410,414,501]),zo=new Set([500,502,503,504]),$o={date:!0,connection:!0,"keep-alive":!0,"proxy-authenticate":!0,"proxy-authorization":!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0},Wo={"content-length":!0,"content-encoding":!0,"transfer-encoding":!0,"content-range":!0};function B(t){let e=parseInt(t,10);return isFinite(e)?e:0}function Vo(t){return t?zo.has(t.status):!0}function qt(t){let e={};if(!t)return e;let r=t.trim().split(/,/);for(let s of r){let[n,o]=s.split(/=/,2);e[n.trim()]=o===void 0?!0:o.trim().replace(/^"|"$/g,"")}return e}function Go(t){let e=[];for(let r in t){let s=t[r];e.push(s===!0?r:r+"="+s)}if(e.length)return e.join(", ")}ms.exports=class{constructor(e,r,{shared:s,cacheHeuristic:n,immutableMinTimeToLive:o,ignoreCargoCult:i,_fromObject:a}={}){if(a){this._fromObject(a);return}if(!r||!r.headers)throw Error("Response headers missing");this._assertRequestHasHeaders(e),this._responseTime=this.now(),this._isShared=s!==!1,this._ignoreCargoCult=!!i,this._cacheHeuristic=n!==void 0?n:.1,this._immutableMinTtl=o!==void 0?o:24*3600*1e3,this._status="status"in r?r.status:200,this._resHeaders=r.headers,this._rescc=qt(r.headers["cache-control"]),this._method="method"in e?e.method:"GET",this._url=e.url,this._host=e.headers.host,this._noAuthorization=!e.headers.authorization,this._reqHeaders=r.headers.vary?e.headers:null,this._reqcc=qt(e.headers["cache-control"]),this._ignoreCargoCult&&"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":Go(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())&&Bo.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||Fo.has(this._status)))}_hasExplicitExpiration(){return!!(this._isShared&&this._rescc["s-maxage"]||this._rescc["max-age"]||this._resHeaders.expires)}_assertRequestHasHeaders(e){if(!e||!e.headers)throw Error("Request headers missing")}satisfiesWithoutRevalidation(e){return!this.evaluateRequest(e).revalidation}_evaluateRequestHitResult(e){return{response:{headers:this.responseHeaders()},revalidation:e}}_evaluateRequestRevalidation(e,r){return{synchronous:r,headers:this.revalidationHeaders(e)}}_evaluateRequestMissResult(e){return{response:void 0,revalidation:this._evaluateRequestRevalidation(e,!0)}}evaluateRequest(e){if(this._assertRequestHasHeaders(e),this._rescc["must-revalidate"])return this._evaluateRequestMissResult(e);if(!this._requestMatches(e,!1))return this._evaluateRequestMissResult(e);let r=qt(e.headers["cache-control"]);return r["no-cache"]||/no-cache/.test(e.headers.pragma)?this._evaluateRequestMissResult(e):r["max-age"]&&this.age()>B(r["max-age"])?this._evaluateRequestMissResult(e):r["min-fresh"]&&this.maxAge()-this.age()this.age()-this.maxAge())?this._evaluateRequestHitResult(void 0):this.useStaleWhileRevalidate()?this._evaluateRequestHitResult(this._evaluateRequestRevalidation(e,!1)):this._evaluateRequestMissResult(e):this._evaluateRequestHitResult(void 0)}_requestMatches(e,r){return!!((!this._url||this._url===e.url)&&this._host===e.headers.host&&(!e.method||this._method===e.method||r&&e.method==="HEAD")&&this._varyMatches(e))}_allowsStoringAuthenticated(){return!!(this._rescc["must-revalidate"]||this._rescc.public||this._rescc["s-maxage"])}_varyMatches(e){if(!this._resHeaders.vary)return!0;if(this._resHeaders.vary==="*")return!1;let r=this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);for(let s of r)if(e.headers[s]!==this._reqHeaders[s])return!1;return!0}_copyWithoutHopByHopHeaders(e){let r={};for(let s in e)$o[s]||(r[s]=e[s]);if(e.connection){let s=e.connection.trim().split(/\s*,\s*/);for(let n of s)delete r[n]}if(r.warning){let s=r.warning.split(/,/).filter(n=>!/^\s*1[0-9][0-9]/.test(n));s.length?r.warning=s.join(",").trim():delete r.warning}return r}responseHeaders(){let e=this._copyWithoutHopByHopHeaders(this._resHeaders),r=this.age();return r>3600*24&&!this._hasExplicitExpiration()&&this.maxAge()>3600*24&&(e.warning=(e.warning?`${e.warning}, `:"")+'113 - "rfc7234 5.5.4"'),e.age=`${Math.round(r)}`,e.date=new Date(this.now()).toUTCString(),e}date(){let e=Date.parse(this._resHeaders.date);return isFinite(e)?e:this._responseTime}age(){let e=this._ageValue(),r=(this.now()-this._responseTime)/1e3;return e+r}_ageValue(){return B(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 B(this._rescc["s-maxage"])}if(this._rescc["max-age"])return B(this._rescc["max-age"]);let e=this._rescc.immutable?this._immutableMinTtl:0,r=this.date();if(this._resHeaders.expires){let s=Date.parse(this._resHeaders.expires);return Number.isNaN(s)||ss)return Math.max(e,(r-s)/1e3*this._cacheHeuristic)}return e}timeToLive(){let e=this.maxAge()-this.age(),r=e+B(this._rescc["stale-if-error"]),s=e+B(this._rescc["stale-while-revalidate"]);return Math.round(Math.max(0,e,r,s)*1e3)}stale(){return this.maxAge()<=this.age()}_useStaleIfError(){return this.maxAge()+B(this._rescc["stale-if-error"])>this.age()}useStaleWhileRevalidate(){let e=B(this._rescc["stale-while-revalidate"]);return e>0&&this.maxAge()+e>this.age()}static fromObject(e){return new this(void 0,void 0,{_fromObject:e})}_fromObject(e){if(this._responseTime)throw Error("Reinitialized");if(!e||e.v!==1)throw Error("Invalid serialization");this._responseTime=e.t,this._isShared=e.sh,this._cacheHeuristic=e.ch,this._immutableMinTtl=e.imm!==void 0?e.imm:24*3600*1e3,this._ignoreCargoCult=!!e.icc,this._status=e.st,this._resHeaders=e.resh,this._rescc=e.rescc,this._method=e.m,this._url=e.u,this._host=e.h,this._noAuthorization=e.a,this._reqHeaders=e.reqh,this._reqcc=e.reqcc}toObject(){return{v:1,t:this._responseTime,sh:this._isShared,ch:this._cacheHeuristic,imm:this._immutableMinTtl,icc:this._ignoreCargoCult,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(e){this._assertRequestHasHeaders(e);let r=this._copyWithoutHopByHopHeaders(e.headers);if(delete r["if-range"],!this._requestMatches(e,!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 n=r["if-none-match"].split(/,/).filter(o=>!/^\s*W\//.test(o));n.length?r["if-none-match"]=n.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(e,r){if(this._assertRequestHasHeaders(e),this._useStaleIfError()&&Vo(r))return{policy:this,modified:!1,matches:!0};if(!r||!r.headers)throw Error("Response headers missing");let s=!1;r.status!==void 0&&r.status!=304?s=!1:r.headers.etag&&!/^\s*W\//.test(r.headers.etag)?s=this._resHeaders.etag&&this._resHeaders.etag.replace(/^\s*W\//,"")===r.headers.etag:this._resHeaders.etag&&r.headers.etag?s=this._resHeaders.etag.replace(/^\s*W\//,"")===r.headers.etag.replace(/^\s*W\//,""):this._resHeaders["last-modified"]?s=this._resHeaders["last-modified"]===r.headers["last-modified"]:!this._resHeaders.etag&&!this._resHeaders["last-modified"]&&!r.headers.etag&&!r.headers["last-modified"]&&(s=!0);let n={shared:this._isShared,cacheHeuristic:this._cacheHeuristic,immutableMinTimeToLive:this._immutableMinTtl,ignoreCargoCult:this._ignoreCargoCult};if(!s)return{policy:new this.constructor(e,r,n),modified:r.status!=304,matches:!1};let o={};for(let a in this._resHeaders)o[a]=a in r.headers&&!Wo[a]?r.headers[a]:this._resHeaders[a];let i=Object.assign({},r,{status:this._status,method:this._method,headers:o});return{policy:new this.constructor(e,i,n),modified:!1,matches:!0}}}});var Fe=b((rl,gs)=>{"use strict";gs.exports=t=>{let e={};for(let[r,s]of Object.entries(t))e[r.toLowerCase()]=s;return e}});var bs=b((sl,_s)=>{"use strict";var Jo=require("stream").Readable,Ko=Fe(),jt=class extends Jo{constructor(e,r,s,n){if(typeof e!="number")throw new TypeError("Argument `statusCode` should be a number");if(typeof r!="object")throw new TypeError("Argument `headers` should be an object");if(!(s instanceof Buffer))throw new TypeError("Argument `body` should be a buffer");if(typeof n!="string")throw new TypeError("Argument `url` should be a string");super(),this.statusCode=e,this.headers=Ko(r),this.body=s,this.url=n}_read(){this.push(this.body),this.push(null)}};_s.exports=jt});var vs=b((nl,ws)=>{"use strict";var Qo=["destroy","setTimeout","socket","headers","trailers","rawHeaders","statusCode","httpVersion","httpVersionMinor","httpVersionMajor","rawTrailers","statusMessage"];ws.exports=(t,e)=>{let r=new Set(Object.keys(t).concat(Qo));for(let s of r)s in e||(e[s]=typeof t[s]=="function"?t[s].bind(t):t[s])}});var Ss=b((il,Es)=>{"use strict";var Xo=require("stream").PassThrough,Yo=vs(),Zo=t=>{if(!(t&&t.pipe))throw new TypeError("Parameter `response` must be a response stream.");let e=new Xo;return Yo(t,e),t.pipe(e)};Es.exports=Zo});var Ps=b(Ht=>{Ht.stringify=function t(e){if(typeof e>"u")return e;if(e&&Buffer.isBuffer(e))return JSON.stringify(":base64:"+e.toString("base64"));if(e&&e.toJSON&&(e=e.toJSON()),e&&typeof e=="object"){var r="",s=Array.isArray(e);r=s?"[":"{";var n=!0;for(var o in e){var i=typeof e[o]=="function"||!s&&typeof e[o]>"u";Object.hasOwnProperty.call(e,o)&&!i&&(n||(r+=","),n=!1,s?e[o]==null?r+="null":r+=t(e[o]):e[o]!==void 0&&(r+=t(o)+":"+t(e[o])))}return r+=s?"]":"}",r}else return typeof e=="string"?JSON.stringify(/^:/.test(e)?":"+e:e):typeof e>"u"?"null":JSON.stringify(e)};Ht.parse=function(t){return JSON.parse(t,function(e,r){return typeof r=="string"?/^:base64:/.test(r)?Buffer.from(r.substring(8),"base64"):/^:/.test(r)?r.substring(1):r:r})}});var Cs=b((al,ks)=>{"use strict";var ea=require("events"),Os=Ps(),ta=t=>{let e={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(t.adapter||t.uri){let r=t.adapter||/^[^:+]*/.exec(t.uri)[0];return new(require(e[r]))(t)}return new Map},Rs=["sqlite","postgres","mysql","mongo","redis","tiered"],It=class extends ea{constructor(e,{emitErrors:r=!0,...s}={}){if(super(),this.opts={namespace:"keyv",serialize:Os.stringify,deserialize:Os.parse,...typeof e=="string"?{uri:e}:e,...s},!this.opts.store){let o={...this.opts};this.opts.store=ta(o)}if(this.opts.compression){let o=this.opts.compression;this.opts.serialize=o.serialize.bind(o),this.opts.deserialize=o.deserialize.bind(o)}typeof this.opts.store.on=="function"&&r&&this.opts.store.on("error",o=>this.emit("error",o)),this.opts.store.namespace=this.opts.namespace;let n=o=>async function*(){for await(let[i,a]of typeof o=="function"?o(this.opts.store.namespace):o){let u=await this.opts.deserialize(a);if(!(this.opts.store.namespace&&!i.includes(this.opts.store.namespace))){if(typeof u.expires=="number"&&Date.now()>u.expires){this.delete(i);continue}yield[this._getKeyUnprefix(i),u.value]}}};typeof this.opts.store[Symbol.iterator]=="function"&&this.opts.store instanceof Map?this.iterator=n(this.opts.store):typeof this.opts.store.iterator=="function"&&this.opts.store.opts&&this._checkIterableAdaptar()&&(this.iterator=n(this.opts.store.iterator.bind(this.opts.store)))}_checkIterableAdaptar(){return Rs.includes(this.opts.store.opts.dialect)||Rs.findIndex(e=>this.opts.store.opts.url.includes(e))>=0}_getKeyPrefix(e){return`${this.opts.namespace}:${e}`}_getKeyPrefixArray(e){return e.map(r=>`${this.opts.namespace}:${r}`)}_getKeyUnprefix(e){return e.split(":").splice(1).join(":")}get(e,r){let{store:s}=this.opts,n=Array.isArray(e),o=n?this._getKeyPrefixArray(e):this._getKeyPrefix(e);if(n&&s.getMany===void 0){let i=[];for(let a of o)i.push(Promise.resolve().then(()=>s.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(i).then(a=>{let u=[];for(let l of a)u.push(l.value);return u})}return Promise.resolve().then(()=>n?s.getMany(o):s.get(o)).then(i=>typeof i=="string"?this.opts.deserialize(i):this.opts.compression?this.opts.deserialize(i):i).then(i=>{if(i!=null)return n?i.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(e[u]).then(()=>{});return}return r&&r.raw?a:a.value}}):typeof i.expires=="number"&&Date.now()>i.expires?this.delete(e).then(()=>{}):r&&r.raw?i:i.value})}set(e,r,s){let n=this._getKeyPrefix(e);typeof s>"u"&&(s=this.opts.ttl),s===0&&(s=void 0);let{store:o}=this.opts;return Promise.resolve().then(()=>{let i=typeof s=="number"?Date.now()+s:null;return typeof r=="symbol"&&this.emit("error","symbol cannot be serialized"),r={value:r,expires:i},this.opts.serialize(r)}).then(i=>o.set(n,i,s)).then(()=>!0)}delete(e){let{store:r}=this.opts;if(Array.isArray(e)){let n=this._getKeyPrefixArray(e);if(r.deleteMany===void 0){let o=[];for(let i of n)o.push(r.delete(i));return Promise.allSettled(o).then(i=>i.every(a=>a.value===!0))}return Promise.resolve().then(()=>r.deleteMany(n))}let s=this._getKeyPrefix(e);return Promise.resolve().then(()=>r.delete(s))}clear(){let{store:e}=this.opts;return Promise.resolve().then(()=>e.clear())}has(e){let r=this._getKeyPrefix(e),{store:s}=this.opts;return Promise.resolve().then(async()=>typeof s.has=="function"?s.has(r):await s.get(r)!==void 0)}disconnect(){let{store:e}=this.opts;if(typeof e.disconnect=="function")return e.disconnect()}};ks.exports=It});var As=b((cl,xs)=>{"use strict";var ra=require("events"),Be=require("url"),sa=es(),na=ps(),Lt=ys(),Ts=bs(),ia=Fe(),oa=Ss(),aa=Cs(),we=class t{constructor(e,r){if(typeof e!="function")throw new TypeError("Parameter `request` must be a function");return this.cache=new aa({uri:typeof r=="string"&&r,store:typeof r!="string"&&r,namespace:"cacheable-request"}),this.createCacheableRequest(e)}createCacheableRequest(e){return(r,s)=>{let n;if(typeof r=="string")n=Mt(Be.parse(r)),r={};else if(r instanceof Be.URL)n=Mt(Be.parse(r.toString())),r={};else{let[h,...y]=(r.path||"").split("?"),p=y.length>0?`?${y.join("?")}`:"";n=Mt({...r,pathname:h,search:p})}r={headers:{},method:"GET",cache:!0,strictTtl:!1,automaticFailover:!1,...r,...ca(n)},r.headers=ia(r.headers);let o=new ra,i=sa(Be.format(n),{stripWWW:!1,removeTrailingSlash:!1,stripAuthentication:!1}),a=`${r.method}:${i}`,u=!1,l=!1,m=h=>{l=!0;let y=!1,p,g=new Promise(f=>{p=()=>{y||(y=!0,f())}}),w=f=>{if(u&&!h.forceRefresh){f.status=f.statusCode;let P=Lt.fromObject(u.cachePolicy).revalidatedPolicy(h,f);if(!P.modified){let x=P.policy.responseHeaders();f=new Ts(u.statusCode,x,u.body,u.url),f.cachePolicy=P.policy,f.fromCache=!0}}f.fromCache||(f.cachePolicy=new Lt(h,f,h),f.fromCache=!1);let v;h.cache&&f.cachePolicy.storable()?(v=oa(f),(async()=>{try{let P=na.buffer(f);if(await Promise.race([g,new Promise(pt=>f.once("end",pt))]),y)return;let x=await P,U={cachePolicy:f.cachePolicy.toObject(),url:f.url,statusCode:f.fromCache?u.statusCode:f.statusCode,body:x},ee=h.strictTtl?f.cachePolicy.timeToLive():void 0;h.maxTtl&&(ee=ee?Math.min(ee,h.maxTtl):h.maxTtl),await this.cache.set(a,U,ee)}catch(P){o.emit("error",new t.CacheError(P))}})()):h.cache&&u&&(async()=>{try{await this.cache.delete(a)}catch(P){o.emit("error",new t.CacheError(P))}})(),o.emit("response",v||f),typeof s=="function"&&s(v||f)};try{let f=e(h,w);f.once("error",p),f.once("abort",p),o.emit("request",f)}catch(f){o.emit("error",new t.RequestError(f))}};return(async()=>{let h=async p=>{await Promise.resolve();let g=p.cache?await this.cache.get(a):void 0;if(typeof g>"u")return m(p);let w=Lt.fromObject(g.cachePolicy);if(w.satisfiesWithoutRevalidation(p)&&!p.forceRefresh){let f=w.responseHeaders(),v=new Ts(g.statusCode,f,g.body,g.url);v.cachePolicy=w,v.fromCache=!0,o.emit("response",v),typeof s=="function"&&s(v)}else u=g,p.headers=w.revalidationHeaders(p),m(p)},y=p=>o.emit("error",new t.CacheError(p));this.cache.once("error",y),o.on("response",()=>this.cache.removeListener("error",y));try{await h(r)}catch(p){r.automaticFailover&&!l&&m(r),o.emit("error",new t.CacheError(p))}})(),o}}};function ca(t){let e={...t};return e.path=`${t.pathname||"/"}${t.search||""}`,delete e.pathname,delete e.search,e}function Mt(t){return{protocol:t.protocol,auth:t.auth,hostname:t.hostname||t.host||"localhost",port:t.port,pathname:t.pathname,search:t.search}}we.RequestError=class extends Error{constructor(t){super(t.message),this.name="RequestError",Object.assign(this,t)}};we.CacheError=class extends Error{constructor(t){super(t.message),this.name="CacheError",Object.assign(this,t)}};xs.exports=we});var js=b((dl,qs)=>{"use strict";var ua=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];qs.exports=(t,e)=>{if(e._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");let r=new Set(Object.keys(t).concat(ua)),s={};for(let n of r)n in e||(s[n]={get(){let o=t[n];return typeof o=="function"?o.bind(t):o},set(o){t[n]=o},enumerable:!0,configurable:!1});return Object.defineProperties(e,s),t.once("aborted",()=>{e.destroy(),e.emit("aborted")}),t.once("close",()=>{t.complete&&e.readable?e.once("end",()=>{e.emit("close")}):e.emit("close")}),e}});var Is=b((hl,Hs)=>{"use strict";var{Transform:la,PassThrough:da}=require("stream"),Dt=require("zlib"),ha=js();Hs.exports=t=>{let e=(t.headers["content-encoding"]||"").toLowerCase();if(!["gzip","deflate","br"].includes(e))return t;let r=e==="br";if(r&&typeof Dt.createBrotliDecompress!="function")return t.destroy(new Error("Brotli is not supported on Node.js < 12")),t;let s=!0,n=new la({transform(a,u,l){s=!1,l(null,a)},flush(a){a()}}),o=new da({autoDestroy:!1,destroy(a,u){t.destroy(),u(a)}}),i=r?Dt.createBrotliDecompress():Dt.createUnzip();return i.once("error",a=>{if(s&&!t.readable){o.end();return}o.destroy(a)}),ha(t,o),t.pipe(n).pipe(i).pipe(o),o}});var Nt=b((fl,Ls)=>{"use strict";var Ut=class{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,r){if(this.cache.set(e,r),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function")for(let[s,n]of this.oldCache.entries())this.onEviction(s,n);this.oldCache=this.cache,this.cache=new Map}}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){let r=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,r),r}}set(e,r){return this.cache.has(e)?this.cache.set(e,r):this._set(e,r),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e))return this.oldCache.get(e)}delete(e){let r=this.cache.delete(e);return r&&this._size--,this.oldCache.delete(e)||r}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache)yield e;for(let e of this.oldCache){let[r]=e;this.cache.has(r)||(yield e)}}get size(){let e=0;for(let r of this.oldCache.keys())this.cache.has(r)||e++;return Math.min(this._size+e,this.maxSize)}};Ls.exports=Ut});var Bt=b((pl,Ns)=>{"use strict";var fa=require("events"),pa=require("tls"),ma=require("http2"),ya=Nt(),A=Symbol("currentStreamsCount"),Ms=Symbol("request"),j=Symbol("cachedOriginSet"),ne=Symbol("gracefullyClosing"),ga=["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"],_a=(t,e,r)=>{let s=0,n=t.length;for(;s>>1;r(t[o],e)?s=o+1:n=o}return s},ba=(t,e)=>t.remoteSettings.maxConcurrentStreams>e.remoteSettings.maxConcurrentStreams,Ft=(t,e)=>{for(let r of t)r[j].lengthe[j].includes(s))&&r[A]+e[A]<=e.remoteSettings.maxConcurrentStreams&&Us(r)},wa=(t,e)=>{for(let r of t)e[j].lengthr[j].includes(s))&&e[A]+r[A]<=r.remoteSettings.maxConcurrentStreams&&Us(e)},Ds=({agent:t,isFree:e})=>{let r={};for(let s in t.sessions){let o=t.sessions[s].filter(i=>{let a=i[Y.kCurrentStreamsCount]{t[ne]=!0,t[A]===0&&t.close()},Y=class t extends fa{constructor({timeout:e=6e4,maxSessions:r=1/0,maxFreeSessions:s=10,maxCachedTlsSessions:n=100}={}){super(),this.sessions={},this.queue={},this.timeout=e,this.maxSessions=r,this.maxFreeSessions=s,this._freeSessionsCount=0,this._sessionsCount=0,this.settings={enablePush:!1},this.tlsSessionCache=new ya({maxSize:n})}static normalizeOrigin(e,r){return typeof e=="string"&&(e=new URL(e)),r&&e.hostname!==r&&(e.hostname=r),e.origin}normalizeOptions(e){let r="";if(e)for(let s of ga)e[s]&&(r+=`:${e[s]}`);return r}_tryToCreateNewSession(e,r){if(!(e in this.queue)||!(r in this.queue[e]))return;let s=this.queue[e][r];this._sessionsCount{Array.isArray(s)?(s=[...s],n()):s=[{resolve:n,reject:o}];let i=this.normalizeOptions(r),a=t.normalizeOrigin(e,r&&r.servername);if(a===void 0){for(let{reject:m}of s)m(new TypeError("The `origin` argument needs to be a string or an URL object"));return}if(i in this.sessions){let m=this.sessions[i],h=-1,y=-1,p;for(let g of m){let w=g.remoteSettings.maxConcurrentStreams;if(w=w||g[ne]||g.destroyed)continue;p||(h=w),f>y&&(p=g,y=f)}}if(p){if(s.length!==1){for(let{reject:g}of s){let w=new Error(`Expected the length of listeners to be 1, got ${s.length}. Please report this to https://github.com/szmarczak/http2-wrapper/`);g(w)}return}s[0].resolve(p);return}}if(i in this.queue){if(a in this.queue[i]){this.queue[i][a].listeners.push(...s),this._tryToCreateNewSession(i,a);return}}else this.queue[i]={};let u=()=>{i in this.queue&&this.queue[i][a]===l&&(delete this.queue[i][a],Object.keys(this.queue[i]).length===0&&delete this.queue[i])},l=()=>{let m=`${a}:${i}`,h=!1;try{let y=ma.connect(e,{createConnection:this.createConnection,settings:this.settings,session:this.tlsSessionCache.get(m),...r});y[A]=0,y[ne]=!1;let p=()=>y[A]{this.tlsSessionCache.set(m,f)}),y.once("error",f=>{for(let{reject:v}of s)v(f);this.tlsSessionCache.delete(m)}),y.setTimeout(this.timeout,()=>{y.destroy()}),y.once("close",()=>{if(h){g&&this._freeSessionsCount--,this._sessionsCount--;let f=this.sessions[i];f.splice(f.indexOf(y),1),f.length===0&&delete this.sessions[i]}else{let f=new Error("Session closed without receiving a SETTINGS frame");f.code="HTTP2WRAPPER_NOSETTINGS";for(let{reject:v}of s)v(f);u()}this._tryToCreateNewSession(i,a)});let w=()=>{if(!(!(i in this.queue)||!p())){for(let f of y[j])if(f in this.queue[i]){let{listeners:v}=this.queue[i][f];for(;v.length!==0&&p();)v.shift().resolve(y);let P=this.queue[i];if(P[f].listeners.length===0&&(delete P[f],Object.keys(P).length===0)){delete this.queue[i];break}if(!p())break}}};y.on("origin",()=>{y[j]=y.originSet,p()&&(w(),Ft(this.sessions[i],y))}),y.once("remoteSettings",()=>{if(y.ref(),y.unref(),this._sessionsCount++,l.destroyed){let f=new Error("Agent has been destroyed");for(let v of s)v.reject(f);y.destroy();return}y[j]=y.originSet;{let f=this.sessions;if(i in f){let v=f[i];v.splice(_a(v,y,ba),0,y)}else f[i]=[y]}this._freeSessionsCount+=1,h=!0,this.emit("session",y),w(),u(),y[A]===0&&this._freeSessionsCount>this.maxFreeSessions&&y.close(),s.length!==0&&(this.getSession(a,r,s),s.length=0),y.on("remoteSettings",()=>{w(),Ft(this.sessions[i],y)})}),y[Ms]=y.request,y.request=(f,v)=>{if(y[ne])throw new Error("The session is gracefully closing. No new streams are allowed.");let P=y[Ms](f,v);return y.ref(),++y[A],y[A]===y.remoteSettings.maxConcurrentStreams&&this._freeSessionsCount--,P.once("close",()=>{if(g=p(),--y[A],!y.destroyed&&!y.closed&&(wa(this.sessions[i],y),p()&&!y.closed)){g||(this._freeSessionsCount++,g=!0);let x=y[A]===0;x&&y.unref(),x&&(this._freeSessionsCount>this.maxFreeSessions||y[ne])?y.close():(Ft(this.sessions[i],y),w())}}),P}}catch(y){for(let p of s)p.reject(y);u()}};l.listeners=s,l.completed=!1,l.destroyed=!1,this.queue[i][a]=l,this._tryToCreateNewSession(i,a)})}request(e,r,s,n){return new Promise((o,i)=>{this.getSession(e,r,[{reject:i,resolve:a=>{try{o(a.request(s,n))}catch(u){i(u)}}}])})}createConnection(e,r){return t.connect(e,r)}static connect(e,r){r.ALPNProtocols=["h2"];let s=e.port||443,n=e.hostname||e.host;return typeof r.servername>"u"&&(r.servername=n),pa.connect(s,n,r)}closeFreeSessions(){for(let e of Object.values(this.sessions))for(let r of e)r[A]===0&&r.close()}destroy(e){for(let r of Object.values(this.sessions))for(let s of r)s.destroy(e);for(let r of Object.values(this.queue))for(let s of Object.values(r))s.destroyed=!0;this.queue={}}get freeSessions(){return Ds({agent:this,isFree:!0})}get busySessions(){return Ds({agent:this,isFree:!1})}};Y.kCurrentStreamsCount=A;Y.kGracefullyClosing=ne;Ns.exports={Agent:Y,globalAgent:new Y}});var $t=b((ml,Fs)=>{"use strict";var{Readable:va}=require("stream"),zt=class extends va{constructor(e,r){super({highWaterMark:r,autoDestroy:!1}),this.statusCode=null,this.statusMessage="",this.httpVersion="2.0",this.httpVersionMajor=2,this.httpVersionMinor=0,this.headers={},this.trailers={},this.req=null,this.aborted=!1,this.complete=!1,this.upgrade=null,this.rawHeaders=[],this.rawTrailers=[],this.socket=e,this.connection=e,this._dumped=!1}_destroy(e){this.req._request.destroy(e)}setTimeout(e,r){return this.req.setTimeout(e,r),this}_dump(){this._dumped||(this._dumped=!0,this.removeAllListeners("data"),this.resume())}_read(){this.req&&this.req._request.resume()}};Fs.exports=zt});var Wt=b((yl,Bs)=>{"use strict";Bs.exports=t=>{let e={protocol:t.protocol,hostname:typeof t.hostname=="string"&&t.hostname.startsWith("[")?t.hostname.slice(1,-1):t.hostname,host:t.host,hash:t.hash,search:t.search,pathname:t.pathname,href:t.href,path:`${t.pathname||""}${t.search||""}`};return typeof t.port=="string"&&t.port.length!==0&&(e.port=Number(t.port)),(t.username||t.password)&&(e.auth=`${t.username||""}:${t.password||""}`),e}});var $s=b((gl,zs)=>{"use strict";zs.exports=(t,e,r)=>{for(let s of r)t.on(s,(...n)=>e.emit(s,...n))}});var Vs=b((_l,Ws)=>{"use strict";Ws.exports=t=>{switch(t){case":method":case":scheme":case":authority":case":path":return!0;default:return!1}}});var Js=b((wl,Gs)=>{"use strict";var ie=(t,e,r)=>{Gs.exports[e]=class extends t{constructor(...n){super(typeof r=="string"?r:r(n)),this.name=`${super.name} [${e}]`,this.code=e}}};ie(TypeError,"ERR_INVALID_ARG_TYPE",t=>{let e=t[0].includes(".")?"property":"argument",r=t[1],s=Array.isArray(r);return s&&(r=`${r.slice(0,-1).join(", ")} or ${r.slice(-1)}`),`The "${t[0]}" ${e} must be ${s?"one of":"of"} type ${r}. Received ${typeof t[2]}`});ie(TypeError,"ERR_INVALID_PROTOCOL",t=>`Protocol "${t[0]}" not supported. Expected "${t[1]}"`);ie(Error,"ERR_HTTP_HEADERS_SENT",t=>`Cannot ${t[0]} headers after they are sent to the client`);ie(TypeError,"ERR_INVALID_HTTP_TOKEN",t=>`${t[0]} must be a valid HTTP token [${t[1]}]`);ie(TypeError,"ERR_HTTP_INVALID_HEADER_VALUE",t=>`Invalid value "${t[0]} for header "${t[1]}"`);ie(TypeError,"ERR_INVALID_CHAR",t=>`Invalid character in ${t[0]} [${t[1]}]`)});var Qt=b((vl,tn)=>{"use strict";var Ea=require("http2"),{Writable:Sa}=require("stream"),{Agent:Ks,globalAgent:Pa}=Bt(),Oa=$t(),Ra=Wt(),ka=$s(),Ca=Vs(),{ERR_INVALID_ARG_TYPE:Vt,ERR_INVALID_PROTOCOL:Ta,ERR_HTTP_HEADERS_SENT:Qs,ERR_INVALID_HTTP_TOKEN:xa,ERR_HTTP_INVALID_HEADER_VALUE:Aa,ERR_INVALID_CHAR:qa}=Js(),{HTTP2_HEADER_STATUS:Xs,HTTP2_HEADER_METHOD:Ys,HTTP2_HEADER_PATH:Zs,HTTP2_METHOD_CONNECT:ja}=Ea.constants,T=Symbol("headers"),Gt=Symbol("origin"),Jt=Symbol("session"),en=Symbol("options"),ze=Symbol("flushedHeaders"),ve=Symbol("jobs"),Ha=/^[\^`\-\w!#$%&*+.|~]+$/,Ia=/[^\t\u0020-\u007E\u0080-\u00FF]/,Kt=class extends Sa{constructor(e,r,s){super({autoDestroy:!1});let n=typeof e=="string"||e instanceof URL;if(n&&(e=Ra(e instanceof URL?e:new URL(e))),typeof r=="function"||r===void 0?(s=r,r=n?e:{...e}):r={...e,...r},r.h2session)this[Jt]=r.h2session;else if(r.agent===!1)this.agent=new Ks({maxFreeSessions:0});else if(typeof r.agent>"u"||r.agent===null)typeof r.createConnection=="function"?(this.agent=new Ks({maxFreeSessions:0}),this.agent.createConnection=r.createConnection):this.agent=Pa;else if(typeof r.agent.request=="function")this.agent=r.agent;else throw new Vt("options.agent",["Agent-like Object","undefined","false"],r.agent);if(r.protocol&&r.protocol!=="https:")throw new Ta(r.protocol,"https:");let o=r.port||r.defaultPort||this.agent&&this.agent.defaultPort||443,i=r.hostname||r.host||"localhost";delete r.hostname,delete r.host,delete r.port;let{timeout:a}=r;if(r.timeout=void 0,this[T]=Object.create(null),this[ve]=[],this.socket=null,this.connection=null,this.method=r.method||"GET",this.path=r.path,this.res=null,this.aborted=!1,this.reusedSocket=!1,r.headers)for(let[u,l]of Object.entries(r.headers))this.setHeader(u,l);r.auth&&!("authorization"in this[T])&&(this[T].authorization="Basic "+Buffer.from(r.auth).toString("base64")),r.session=r.tlsSession,r.path=r.socketPath,this[en]=r,o===443?(this[Gt]=`https://${i}`,":authority"in this[T]||(this[T][":authority"]=i)):(this[Gt]=`https://${i}:${o}`,":authority"in this[T]||(this[T][":authority"]=`${i}:${o}`)),a&&this.setTimeout(a),s&&this.once("response",s),this[ze]=!1}get method(){return this[T][Ys]}set method(e){e&&(this[T][Ys]=e.toUpperCase())}get path(){return this[T][Zs]}set path(e){e&&(this[T][Zs]=e)}get _mustNotHaveABody(){return this.method==="GET"||this.method==="HEAD"||this.method==="DELETE"}_write(e,r,s){if(this._mustNotHaveABody){s(new Error("The GET, HEAD and DELETE methods must NOT have a body"));return}this.flushHeaders();let n=()=>this._request.write(e,r,s);this._request?n():this[ve].push(n)}_final(e){if(this.destroyed)return;this.flushHeaders();let r=()=>{if(this._mustNotHaveABody){e();return}this._request.end(e)};this._request?r():this[ve].push(r)}abort(){this.res&&this.res.complete||(this.aborted||process.nextTick(()=>this.emit("abort")),this.aborted=!0,this.destroy())}_destroy(e,r){this.res&&this.res._dump(),this._request&&this._request.destroy(),r(e)}async flushHeaders(){if(this[ze]||this.destroyed)return;this[ze]=!0;let e=this.method===ja,r=s=>{if(this._request=s,this.destroyed){s.destroy();return}e||ka(s,this,["timeout","continue","close","error"]);let n=i=>(...a)=>{!this.writable&&!this.destroyed?i(...a):this.once("finish",()=>{i(...a)})};s.once("response",n((i,a,u)=>{let l=new Oa(this.socket,s.readableHighWaterMark);this.res=l,l.req=this,l.statusCode=i[Xs],l.headers=i,l.rawHeaders=u,l.once("end",()=>{this.aborted?(l.aborted=!0,l.emit("aborted")):(l.complete=!0,l.socket=null,l.connection=null)}),e?(l.upgrade=!0,this.emit("connect",l,s,Buffer.alloc(0))?this.emit("close"):s.destroy()):(s.on("data",m=>{!l._dumped&&!l.push(m)&&s.pause()}),s.once("end",()=>{l.push(null)}),this.emit("response",l)||l._dump())})),s.once("headers",n(i=>this.emit("information",{statusCode:i[Xs]}))),s.once("trailers",n((i,a,u)=>{let{res:l}=this;l.trailers=i,l.rawTrailers=u}));let{socket:o}=s.session;this.socket=o,this.connection=o;for(let i of this[ve])i();this.emit("socket",this.socket)};if(this[Jt])try{r(this[Jt].request(this[T]))}catch(s){this.emit("error",s)}else{this.reusedSocket=!0;try{r(await this.agent.request(this[Gt],this[en],this[T]))}catch(s){this.emit("error",s)}}}getHeader(e){if(typeof e!="string")throw new Vt("name","string",e);return this[T][e.toLowerCase()]}get headersSent(){return this[ze]}removeHeader(e){if(typeof e!="string")throw new Vt("name","string",e);if(this.headersSent)throw new Qs("remove");delete this[T][e.toLowerCase()]}setHeader(e,r){if(this.headersSent)throw new Qs("set");if(typeof e!="string"||!Ha.test(e)&&!Ca(e))throw new xa("Header name",e);if(typeof r>"u")throw new Aa(r,e);if(Ia.test(r))throw new qa("header content",e);this[T][e.toLowerCase()]=r}setNoDelay(){}setSocketKeepAlive(){}setTimeout(e,r){let s=()=>this._request.setTimeout(e,r);return this._request?s():this[ve].push(s),this}get maxHeadersCount(){if(!this.destroyed&&this._request)return this._request.session.localSettings.maxHeaderListSize}set maxHeadersCount(e){}};tn.exports=Kt});var sn=b((El,rn)=>{"use strict";var La=require("tls");rn.exports=(t={},e=La.connect)=>new Promise((r,s)=>{let n=!1,o,i=async()=>{await u,o.off("timeout",a),o.off("error",s),t.resolveSocket?(r({alpnProtocol:o.alpnProtocol,socket:o,timeout:n}),n&&(await Promise.resolve(),o.emit("timeout"))):(o.destroy(),r({alpnProtocol:o.alpnProtocol,timeout:n}))},a=async()=>{n=!0,i()},u=(async()=>{try{o=await e(t,i),o.on("error",s),o.once("timeout",a)}catch(l){s(l)}})()})});var on=b((Sl,nn)=>{"use strict";var Ma=require("net");nn.exports=t=>{let e=t.host,r=t.headers&&t.headers.host;return r&&(r.startsWith("[")?r.indexOf("]")===-1?e=r:e=r.slice(1,-1):e=r.split(":",1)[0]),Ma.isIP(e)?"":e}});var un=b((Pl,Yt)=>{"use strict";var an=require("http"),Xt=require("https"),Da=sn(),Ua=Nt(),Na=Qt(),Fa=on(),Ba=Wt(),$e=new Ua({maxSize:100}),Ee=new Map,cn=(t,e,r)=>{e._httpMessage={shouldKeepAlive:!0};let s=()=>{t.emit("free",e,r)};e.on("free",s);let n=()=>{t.removeSocket(e,r)};e.on("close",n);let o=()=>{t.removeSocket(e,r),e.off("close",n),e.off("free",s),e.off("agentRemove",o)};e.on("agentRemove",o),t.emit("free",e,r)},za=async t=>{let e=`${t.host}:${t.port}:${t.ALPNProtocols.sort()}`;if(!$e.has(e)){if(Ee.has(e))return(await Ee.get(e)).alpnProtocol;let{path:r,agent:s}=t;t.path=t.socketPath;let n=Da(t);Ee.set(e,n);try{let{socket:o,alpnProtocol:i}=await n;if($e.set(e,i),t.path=r,i==="h2")o.destroy();else{let{globalAgent:a}=Xt,u=Xt.Agent.prototype.createConnection;s?s.createConnection===u?cn(s,o,t):o.destroy():a.createConnection===u?cn(a,o,t):o.destroy()}return Ee.delete(e),i}catch(o){throw Ee.delete(e),o}}return $e.get(e)};Yt.exports=async(t,e,r)=>{if((typeof t=="string"||t instanceof URL)&&(t=Ba(new URL(t))),typeof e=="function"&&(r=e,e=void 0),e={ALPNProtocols:["h2","http/1.1"],...t,...e,resolveSocket:!0},!Array.isArray(e.ALPNProtocols)||e.ALPNProtocols.length===0)throw new Error("The `ALPNProtocols` option must be an Array with at least one entry");e.protocol=e.protocol||"https:";let s=e.protocol==="https:";e.host=e.hostname||e.host||"localhost",e.session=e.tlsSession,e.servername=e.servername||Fa(e),e.port=e.port||(s?443:80),e._defaultAgent=s?Xt.globalAgent:an.globalAgent;let n=e.agent;if(n){if(n.addRequest)throw new Error("The `options.agent` object can contain only `http`, `https` or `http2` properties");e.agent=n[s?"https":"http"]}return s&&await za(e)==="h2"?(n&&(e.agent=n.http2),new Na(e,r)):an.request(e,r)};Yt.exports.protocolCache=$e});var dn=b((Ol,ln)=>{"use strict";var $a=require("http2"),Wa=Bt(),Zt=Qt(),Va=$t(),Ga=un(),Ja=(t,e,r)=>new Zt(t,e,r),Ka=(t,e,r)=>{let s=new Zt(t,e,r);return s.end(),s};ln.exports={...$a,ClientRequest:Zt,IncomingMessage:Va,...Wa,request:Ja,get:Ka,auto:Ga}});var tr=b(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});var hn=F();er.default=t=>hn.default.nodeStream(t)&&hn.default.function_(t.getBoundary)});var yn=b(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});var pn=require("fs"),mn=require("util"),fn=F(),Qa=tr(),Xa=mn.promisify(pn.stat);rr.default=async(t,e)=>{if(e&&"content-length"in e)return Number(e["content-length"]);if(!t)return 0;if(fn.default.string(t))return Buffer.byteLength(t);if(fn.default.buffer(t))return t.length;if(Qa.default(t))return mn.promisify(t.getLength.bind(t))();if(t instanceof pn.ReadStream){let{size:r}=await Xa(t.path);return r===0?void 0:r}}});var nr=b(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});function Ya(t,e,r){let s={};for(let n of r)s[n]=(...o)=>{e.emit(n,...o)},t.on(n,s[n]);return()=>{for(let n of r)t.off(n,s[n])}}sr.default=Ya});var gn=b(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.default=()=>{let t=[];return{once(e,r,s){e.once(r,s),t.push({origin:e,event:r,fn:s})},unhandleAll(){for(let e of t){let{origin:r,event:s,fn:n}=e;r.removeListener(s,n)}t.length=0}}}});var bn=b(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.TimeoutError=void 0;var Za=require("net"),ec=gn(),_n=Symbol("reentry"),tc=()=>{},We=class extends Error{constructor(e,r){super(`Timeout awaiting '${r}' for ${e}ms`),this.event=r,this.name="TimeoutError",this.code="ETIMEDOUT"}};Se.TimeoutError=We;Se.default=(t,e,r)=>{if(_n in t)return tc;t[_n]=!0;let s=[],{once:n,unhandleAll:o}=ec.default(),i=(h,y,p)=>{var g;let w=setTimeout(y,h,h,p);(g=w.unref)===null||g===void 0||g.call(w);let f=()=>{clearTimeout(w)};return s.push(f),f},{host:a,hostname:u}=r,l=(h,y)=>{t.destroy(new We(h,y))},m=()=>{for(let h of s)h();o()};if(t.once("error",h=>{if(m(),t.listenerCount("error")===0)throw h}),t.once("close",m),n(t,"response",h=>{n(h,"end",m)}),typeof e.request<"u"&&i(e.request,l,"request"),typeof e.socket<"u"){let h=()=>{l(e.socket,"socket")};t.setTimeout(e.socket,h),s.push(()=>{t.removeListener("timeout",h)})}return n(t,"socket",h=>{var y;let{socketPath:p}=t;if(h.connecting){let g=!!(p??Za.isIP((y=u??a)!==null&&y!==void 0?y:"")!==0);if(typeof e.lookup<"u"&&!g&&typeof h.address().address>"u"){let w=i(e.lookup,l,"lookup");n(h,"lookup",w)}if(typeof e.connect<"u"){let w=()=>i(e.connect,l,"connect");g?n(h,"connect",w()):n(h,"lookup",f=>{f===null&&n(h,"connect",w())})}typeof e.secureConnect<"u"&&r.protocol==="https:"&&n(h,"connect",()=>{let w=i(e.secureConnect,l,"secureConnect");n(h,"secureConnect",w)})}if(typeof e.send<"u"){let g=()=>i(e.send,l,"send");h.connecting?n(h,"connect",()=>{n(t,"upload-complete",g())}):n(t,"upload-complete",g())}}),typeof e.response<"u"&&n(t,"upload-complete",()=>{let h=i(e.response,l,"response");n(t,"response",h)}),m}});var vn=b(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});var wn=F();or.default=t=>{t=t;let e={protocol:t.protocol,hostname:wn.default.string(t.hostname)&&t.hostname.startsWith("[")?t.hostname.slice(1,-1):t.hostname,host:t.host,hash:t.hash,search:t.search,pathname:t.pathname,href:t.href,path:`${t.pathname||""}${t.search||""}`};return wn.default.string(t.port)&&t.port.length>0&&(e.port=Number(t.port)),(t.username||t.password)&&(e.auth=`${t.username||""}:${t.password||""}`),e}});var En=b(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});var rc=require("url"),sc=["protocol","host","hostname","port","pathname","search"];ar.default=(t,e)=>{var r,s;if(e.path){if(e.pathname)throw new TypeError("Parameters `path` and `pathname` are mutually exclusive.");if(e.search)throw new TypeError("Parameters `path` and `search` are mutually exclusive.");if(e.searchParams)throw new TypeError("Parameters `path` and `searchParams` are mutually exclusive.")}if(e.search&&e.searchParams)throw new TypeError("Parameters `search` and `searchParams` are mutually exclusive.");if(!t){if(!e.protocol)throw new TypeError("No URL protocol specified");t=`${e.protocol}//${(s=(r=e.hostname)!==null&&r!==void 0?r:e.host)!==null&&s!==void 0?s:""}`}let n=new rc.URL(t);if(e.path){let o=e.path.indexOf("?");o===-1?e.pathname=e.path:(e.pathname=e.path.slice(0,o),e.search=e.path.slice(o+1)),delete e.path}for(let o of sc)e[o]&&(n[o]=e[o].toString());return n}});var Sn=b(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});var cr=class{constructor(){this.weakMap=new WeakMap,this.map=new Map}set(e,r){typeof e=="object"?this.weakMap.set(e,r):this.map.set(e,r)}get(e){return typeof e=="object"?this.weakMap.get(e):this.map.get(e)}has(e){return typeof e=="object"?this.weakMap.has(e):this.map.has(e)}};ur.default=cr});var dr=b(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});var nc=async t=>{let e=[],r=0;for await(let s of t)e.push(s),r+=Buffer.byteLength(s);return Buffer.isBuffer(e[0])?Buffer.concat(e,r):Buffer.from(e.join(""))};lr.default=nc});var On=b(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.dnsLookupIpVersionToFamily=Z.isDnsLookupIpVersion=void 0;var Pn={auto:0,ipv4:4,ipv6:6};Z.isDnsLookupIpVersion=t=>t in Pn;Z.dnsLookupIpVersionToFamily=t=>{if(Z.isDnsLookupIpVersion(t))return Pn[t];throw new Error("Invalid DNS lookup IP version")}});var hr=b(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.isResponseOk=void 0;Ve.isResponseOk=t=>{let{statusCode:e}=t,r=t.request.options.followRedirect?299:399;return e>=200&&e<=r||e===304}});var kn=b(fr=>{"use strict";Object.defineProperty(fr,"__esModule",{value:!0});var Rn=new Set;fr.default=t=>{Rn.has(t)||(Rn.add(t),process.emitWarning(`Got: ${t}`,{type:"DeprecationWarning"}))}});var Cn=b(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});var O=F(),ic=(t,e)=>{if(O.default.null_(t.encoding))throw new TypeError("To get a Buffer, set `options.responseType` to `buffer` instead");O.assert.any([O.default.string,O.default.undefined],t.encoding),O.assert.any([O.default.boolean,O.default.undefined],t.resolveBodyOnly),O.assert.any([O.default.boolean,O.default.undefined],t.methodRewriting),O.assert.any([O.default.boolean,O.default.undefined],t.isStream),O.assert.any([O.default.string,O.default.undefined],t.responseType),t.responseType===void 0&&(t.responseType="text");let{retry:r}=t;if(e?t.retry={...e.retry}:t.retry={calculateDelay:s=>s.computedValue,limit:0,methods:[],statusCodes:[],errorCodes:[],maxRetryAfter:void 0},O.default.object(r)?(t.retry={...t.retry,...r},t.retry.methods=[...new Set(t.retry.methods.map(s=>s.toUpperCase()))],t.retry.statusCodes=[...new Set(t.retry.statusCodes)],t.retry.errorCodes=[...new Set(t.retry.errorCodes)]):O.default.number(r)&&(t.retry.limit=r),O.default.undefined(t.retry.maxRetryAfter)&&(t.retry.maxRetryAfter=Math.min(...[t.timeout.request,t.timeout.connect].filter(O.default.number))),O.default.object(t.pagination)){e&&(t.pagination={...e.pagination,...t.pagination});let{pagination:s}=t;if(!O.default.function_(s.transform))throw new Error("`options.pagination.transform` must be implemented");if(!O.default.function_(s.shouldContinue))throw new Error("`options.pagination.shouldContinue` must be implemented");if(!O.default.function_(s.filter))throw new TypeError("`options.pagination.filter` must be implemented");if(!O.default.function_(s.paginate))throw new Error("`options.pagination.paginate` must be implemented")}return t.responseType==="json"&&t.headers.accept===void 0&&(t.headers.accept="application/json"),t};pr.default=ic});var Tn=b(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.retryAfterStatusCodes=void 0;Pe.retryAfterStatusCodes=new Set([413,429,503]);var oc=({attemptCount:t,retryOptions:e,error:r,retryAfter:s})=>{if(t>e.limit)return 0;let n=e.methods.includes(r.options.method),o=e.errorCodes.includes(r.code),i=r.response&&e.statusCodes.includes(r.response.statusCode);if(!n||!o&&!i)return 0;if(r.response){if(s)return e.maxRetryAfter===void 0||s>e.maxRetryAfter?0:s;if(r.response.statusCode===413)return 0}let a=Math.random()*100;return 2**(t-1)*1e3+a};Pe.default=oc});var ke=b(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.UnsupportedProtocolError=E.ReadError=E.TimeoutError=E.UploadError=E.CacheError=E.HTTPError=E.MaxRedirectsError=E.RequestError=E.setNonEnumerableProperties=E.knownHookEvents=E.withoutBody=E.kIsNormalizedAlready=void 0;var xn=require("util"),An=require("stream"),ac=require("fs"),G=require("url"),qn=require("http"),mr=require("http"),cc=require("https"),uc=$r(),lc=Xr(),jn=As(),dc=Is(),hc=dn(),fc=Fe(),d=F(),pc=yn(),Hn=tr(),mc=nr(),In=bn(),yc=vn(),Ln=En(),gc=Sn(),_c=dr(),Mn=On(),bc=hr(),J=kn(),wc=Cn(),vc=Tn(),yr,k=Symbol("request"),Ke=Symbol("response"),oe=Symbol("responseSize"),ae=Symbol("downloadedSize"),ce=Symbol("bodySize"),ue=Symbol("uploadedSize"),Ge=Symbol("serverResponsesPiped"),Dn=Symbol("unproxyEvents"),Un=Symbol("isFromCache"),gr=Symbol("cancelTimeouts"),Nn=Symbol("startedReading"),le=Symbol("stopReading"),Je=Symbol("triggerRead"),K=Symbol("body"),Oe=Symbol("jobs"),Fn=Symbol("originalResponse"),Bn=Symbol("retryTimeout");E.kIsNormalizedAlready=Symbol("isNormalizedAlready");var Ec=d.default.string(process.versions.brotli);E.withoutBody=new Set(["GET","HEAD"]);E.knownHookEvents=["init","beforeRequest","beforeRedirect","beforeError","beforeRetry","afterResponse"];function Sc(t){for(let e in t){let r=t[e];if(!d.default.string(r)&&!d.default.number(r)&&!d.default.boolean(r)&&!d.default.null_(r)&&!d.default.undefined(r))throw new TypeError(`The \`searchParams\` value '${String(r)}' must be a string, number, boolean or null`)}}function Pc(t){return d.default.object(t)&&!("statusCode"in t)}var _r=new gc.default,Oc=async t=>new Promise((e,r)=>{let s=n=>{r(n)};t.pending||e(),t.once("error",s),t.once("ready",()=>{t.off("error",s),e()})}),Rc=new Set([300,301,302,303,304,307,308]),kc=["context","body","json","form"];E.setNonEnumerableProperties=(t,e)=>{let r={};for(let s of t)if(s)for(let n of kc)n in s&&(r[n]={writable:!0,configurable:!0,enumerable:!1,value:s[n]});Object.defineProperties(e,r)};var R=class extends Error{constructor(e,r,s){var n,o;if(super(e),Error.captureStackTrace(this,this.constructor),this.name="RequestError",this.code=(n=r.code)!==null&&n!==void 0?n:"ERR_GOT_REQUEST_ERROR",s instanceof rt?(Object.defineProperty(this,"request",{enumerable:!1,value:s}),Object.defineProperty(this,"response",{enumerable:!1,value:s[Ke]}),Object.defineProperty(this,"options",{enumerable:!1,value:s.options})):Object.defineProperty(this,"options",{enumerable:!1,value:s}),this.timings=(o=this.request)===null||o===void 0?void 0:o.timings,d.default.string(r.stack)&&d.default.string(this.stack)){let i=this.stack.indexOf(this.message)+this.message.length,a=this.stack.slice(i).split(` `).reverse(),u=r.stack.slice(r.stack.indexOf(r.message)+r.message.length).split(` `).reverse();for(;u.length!==0&&u[0]===a[0];)a.shift();this.stack=`${this.stack.slice(0,i)}${a.reverse().join(` `)}${u.reverse().join(` `)}`}}};E.RequestError=R;var Qe=class extends R{constructor(e){super(`Redirected ${e.options.maxRedirects} times. Aborting.`,{},e),this.name="MaxRedirectsError",this.code="ERR_TOO_MANY_REDIRECTS"}};E.MaxRedirectsError=Qe;var Xe=class extends R{constructor(e){super(`Response code ${e.statusCode} (${e.statusMessage})`,{},e.request),this.name="HTTPError",this.code="ERR_NON_2XX_3XX_RESPONSE"}};E.HTTPError=Xe;var Ye=class extends R{constructor(e,r){super(e.message,e,r),this.name="CacheError",this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_CACHE_ACCESS":this.code}};E.CacheError=Ye;var Ze=class extends R{constructor(e,r){super(e.message,e,r),this.name="UploadError",this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_UPLOAD":this.code}};E.UploadError=Ze;var et=class extends R{constructor(e,r,s){super(e.message,e,s),this.name="TimeoutError",this.event=e.event,this.timings=r}};E.TimeoutError=et;var Re=class extends R{constructor(e,r){super(e.message,e,r),this.name="ReadError",this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_READING_RESPONSE_STREAM":this.code}};E.ReadError=Re;var tt=class extends R{constructor(e){super(`Unsupported protocol "${e.url.protocol}"`,{},e),this.name="UnsupportedProtocolError",this.code="ERR_UNSUPPORTED_PROTOCOL"}};E.UnsupportedProtocolError=tt;var Cc=["socket","connect","continue","information","upgrade","timeout"],rt=class extends An.Duplex{constructor(e,r={},s){super({autoDestroy:!1,highWaterMark:0}),this[ae]=0,this[ue]=0,this.requestInitialized=!1,this[Ge]=new Set,this.redirects=[],this[le]=!1,this[Je]=!1,this[Oe]=[],this.retryCount=0,this._progressCallbacks=[];let n=()=>this._unlockWrite(),o=()=>this._lockWrite();this.on("pipe",l=>{l.prependListener("data",n),l.on("data",o),l.prependListener("end",n),l.on("end",o)}),this.on("unpipe",l=>{l.off("data",n),l.off("data",o),l.off("end",n),l.off("end",o)}),this.on("pipe",l=>{l instanceof mr.IncomingMessage&&(this.options.headers={...l.headers,...this.options.headers})});let{json:i,body:a,form:u}=r;if((i||a||u)&&this._lockWrite(),E.kIsNormalizedAlready in r)this.options=r;else try{this.options=this.constructor.normalizeArguments(e,r,s)}catch(l){d.default.nodeStream(r.body)&&r.body.destroy(),this.destroy(l);return}(async()=>{var l;try{this.options.body instanceof ac.ReadStream&&await Oc(this.options.body);let{url:m}=this.options;if(!m)throw new TypeError("Missing `url` property");if(this.requestUrl=m.toString(),decodeURI(this.requestUrl),await this._finalizeBody(),await this._makeRequest(),this.destroyed){(l=this[k])===null||l===void 0||l.destroy();return}for(let h of this[Oe])h();this[Oe].length=0,this.requestInitialized=!0}catch(m){if(m instanceof R){this._beforeError(m);return}this.destroyed||this.destroy(m)}})()}static normalizeArguments(e,r,s){var n,o,i,a,u;let l=r;if(d.default.object(e)&&!d.default.urlInstance(e))r={...s,...e,...r};else{if(e&&r&&r.url!==void 0)throw new TypeError("The `url` option is mutually exclusive with the `input` argument");r={...s,...r},e!==void 0&&(r.url=e),d.default.urlInstance(r.url)&&(r.url=new G.URL(r.url.toString()))}if(r.cache===!1&&(r.cache=void 0),r.dnsCache===!1&&(r.dnsCache=void 0),d.assert.any([d.default.string,d.default.undefined],r.method),d.assert.any([d.default.object,d.default.undefined],r.headers),d.assert.any([d.default.string,d.default.urlInstance,d.default.undefined],r.prefixUrl),d.assert.any([d.default.object,d.default.undefined],r.cookieJar),d.assert.any([d.default.object,d.default.string,d.default.undefined],r.searchParams),d.assert.any([d.default.object,d.default.string,d.default.undefined],r.cache),d.assert.any([d.default.object,d.default.number,d.default.undefined],r.timeout),d.assert.any([d.default.object,d.default.undefined],r.context),d.assert.any([d.default.object,d.default.undefined],r.hooks),d.assert.any([d.default.boolean,d.default.undefined],r.decompress),d.assert.any([d.default.boolean,d.default.undefined],r.ignoreInvalidCookies),d.assert.any([d.default.boolean,d.default.undefined],r.followRedirect),d.assert.any([d.default.number,d.default.undefined],r.maxRedirects),d.assert.any([d.default.boolean,d.default.undefined],r.throwHttpErrors),d.assert.any([d.default.boolean,d.default.undefined],r.http2),d.assert.any([d.default.boolean,d.default.undefined],r.allowGetBody),d.assert.any([d.default.string,d.default.undefined],r.localAddress),d.assert.any([Mn.isDnsLookupIpVersion,d.default.undefined],r.dnsLookupIpVersion),d.assert.any([d.default.object,d.default.undefined],r.https),d.assert.any([d.default.boolean,d.default.undefined],r.rejectUnauthorized),r.https&&(d.assert.any([d.default.boolean,d.default.undefined],r.https.rejectUnauthorized),d.assert.any([d.default.function_,d.default.undefined],r.https.checkServerIdentity),d.assert.any([d.default.string,d.default.object,d.default.array,d.default.undefined],r.https.certificateAuthority),d.assert.any([d.default.string,d.default.object,d.default.array,d.default.undefined],r.https.key),d.assert.any([d.default.string,d.default.object,d.default.array,d.default.undefined],r.https.certificate),d.assert.any([d.default.string,d.default.undefined],r.https.passphrase),d.assert.any([d.default.string,d.default.buffer,d.default.array,d.default.undefined],r.https.pfx)),d.assert.any([d.default.object,d.default.undefined],r.cacheOptions),d.default.string(r.method)?r.method=r.method.toUpperCase():r.method="GET",r.headers===(s==null?void 0:s.headers)?r.headers={...r.headers}:r.headers=fc({...s==null?void 0:s.headers,...r.headers}),"slashes"in r)throw new TypeError("The legacy `url.Url` has been deprecated. Use `URL` instead.");if("auth"in r)throw new TypeError("Parameter `auth` is deprecated. Use `username` / `password` instead.");if("searchParams"in r&&r.searchParams&&r.searchParams!==(s==null?void 0:s.searchParams)){let p;if(d.default.string(r.searchParams)||r.searchParams instanceof G.URLSearchParams)p=new G.URLSearchParams(r.searchParams);else{Sc(r.searchParams),p=new G.URLSearchParams;for(let g in r.searchParams){let w=r.searchParams[g];w===null?p.append(g,""):w!==void 0&&p.append(g,w)}}(n=s==null?void 0:s.searchParams)===null||n===void 0||n.forEach((g,w)=>{p.has(w)||p.append(w,g)}),r.searchParams=p}if(r.username=(o=r.username)!==null&&o!==void 0?o:"",r.password=(i=r.password)!==null&&i!==void 0?i:"",d.default.undefined(r.prefixUrl)?r.prefixUrl=(a=s==null?void 0:s.prefixUrl)!==null&&a!==void 0?a:"":(r.prefixUrl=r.prefixUrl.toString(),r.prefixUrl!==""&&!r.prefixUrl.endsWith("/")&&(r.prefixUrl+="/")),d.default.string(r.url)){if(r.url.startsWith("/"))throw new Error("`input` must not start with a slash when using `prefixUrl`");r.url=Ln.default(r.prefixUrl+r.url,r)}else(d.default.undefined(r.url)&&r.prefixUrl!==""||r.protocol)&&(r.url=Ln.default(r.prefixUrl,r));if(r.url){"port"in r&&delete r.port;let{prefixUrl:p}=r;Object.defineProperty(r,"prefixUrl",{set:w=>{let f=r.url;if(!f.href.startsWith(w))throw new Error(`Cannot change \`prefixUrl\` from ${p} to ${w}: ${f.href}`);r.url=new G.URL(w+f.href.slice(p.length)),p=w},get:()=>p});let{protocol:g}=r.url;if(g==="unix:"&&(g="http:",r.url=new G.URL(`http://unix${r.url.pathname}${r.url.search}`)),r.searchParams&&(r.url.search=r.searchParams.toString()),g!=="http:"&&g!=="https:")throw new tt(r);r.username===""?r.username=r.url.username:r.url.username=r.username,r.password===""?r.password=r.url.password:r.url.password=r.password}let{cookieJar:m}=r;if(m){let{setCookie:p,getCookieString:g}=m;d.assert.function_(p),d.assert.function_(g),p.length===4&&g.length===0&&(p=xn.promisify(p.bind(r.cookieJar)),g=xn.promisify(g.bind(r.cookieJar)),r.cookieJar={setCookie:p,getCookieString:g})}let{cache:h}=r;if(h&&(_r.has(h)||_r.set(h,new jn(((p,g)=>{let w=p[k](p,g);return d.default.promise(w)&&(w.once=(f,v)=>{if(f==="error")w.catch(v);else if(f==="abort")(async()=>{try{(await w).once("abort",v)}catch{}})();else throw new Error(`Unknown HTTP2 promise event: ${f}`);return w}),w}),h))),r.cacheOptions={...r.cacheOptions},r.dnsCache===!0)yr||(yr=new lc.default),r.dnsCache=yr;else if(!d.default.undefined(r.dnsCache)&&!r.dnsCache.lookup)throw new TypeError(`Parameter \`dnsCache\` must be a CacheableLookup instance or a boolean, got ${d.default(r.dnsCache)}`);d.default.number(r.timeout)?r.timeout={request:r.timeout}:s&&r.timeout!==s.timeout?r.timeout={...s.timeout,...r.timeout}:r.timeout={...r.timeout},r.context||(r.context={});let y=r.hooks===(s==null?void 0:s.hooks);r.hooks={...r.hooks};for(let p of E.knownHookEvents)if(p in r.hooks)if(d.default.array(r.hooks[p]))r.hooks[p]=[...r.hooks[p]];else throw new TypeError(`Parameter \`${p}\` must be an Array, got ${d.default(r.hooks[p])}`);else r.hooks[p]=[];if(s&&!y)for(let p of E.knownHookEvents)s.hooks[p].length>0&&(r.hooks[p]=[...s.hooks[p],...r.hooks[p]]);if("family"in r&&J.default('"options.family" was never documented, please use "options.dnsLookupIpVersion"'),s!=null&&s.https&&(r.https={...s.https,...r.https}),"rejectUnauthorized"in r&&J.default('"options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized"'),"checkServerIdentity"in r&&J.default('"options.checkServerIdentity" was never documented, please use "options.https.checkServerIdentity"'),"ca"in r&&J.default('"options.ca" was never documented, please use "options.https.certificateAuthority"'),"key"in r&&J.default('"options.key" was never documented, please use "options.https.key"'),"cert"in r&&J.default('"options.cert" was never documented, please use "options.https.certificate"'),"passphrase"in r&&J.default('"options.passphrase" was never documented, please use "options.https.passphrase"'),"pfx"in r&&J.default('"options.pfx" was never documented, please use "options.https.pfx"'),"followRedirects"in r)throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.");if(r.agent){for(let p in r.agent)if(p!=="http"&&p!=="https"&&p!=="http2")throw new TypeError(`Expected the \`options.agent\` properties to be \`http\`, \`https\` or \`http2\`, got \`${p}\``)}return r.maxRedirects=(u=r.maxRedirects)!==null&&u!==void 0?u:0,E.setNonEnumerableProperties([s,l],r),wc.default(r,s)}_lockWrite(){let e=()=>{throw new TypeError("The payload has been already provided")};this.write=e,this.end=e}_unlockWrite(){this.write=super.write,this.end=super.end}async _finalizeBody(){let{options:e}=this,{headers:r}=e,s=!d.default.undefined(e.form),n=!d.default.undefined(e.json),o=!d.default.undefined(e.body),i=s||n||o,a=E.withoutBody.has(e.method)&&!(e.method==="GET"&&e.allowGetBody);if(this._cannotHaveBody=a,i){if(a)throw new TypeError(`The \`${e.method}\` method cannot be used with a body`);if([o,s,n].filter(u=>u).length>1)throw new TypeError("The `body`, `json` and `form` options are mutually exclusive");if(o&&!(e.body instanceof An.Readable)&&!d.default.string(e.body)&&!d.default.buffer(e.body)&&!Hn.default(e.body))throw new TypeError("The `body` option must be a stream.Readable, string or Buffer");if(s&&!d.default.object(e.form))throw new TypeError("The `form` option must be an Object");{let u=!d.default.string(r["content-type"]);o?(Hn.default(e.body)&&u&&(r["content-type"]=`multipart/form-data; boundary=${e.body.getBoundary()}`),this[K]=e.body):s?(u&&(r["content-type"]="application/x-www-form-urlencoded"),this[K]=new G.URLSearchParams(e.form).toString()):(u&&(r["content-type"]="application/json"),this[K]=e.stringifyJson(e.json));let l=await pc.default(this[K],e.headers);d.default.undefined(r["content-length"])&&d.default.undefined(r["transfer-encoding"])&&!a&&!d.default.undefined(l)&&(r["content-length"]=String(l))}}else a?this._lockWrite():this._unlockWrite();this[ce]=Number(r["content-length"])||void 0}async _onResponseBase(e){let{options:r}=this,{url:s}=r;this[Fn]=e,r.decompress&&(e=dc(e));let n=e.statusCode,o=e;o.statusMessage=o.statusMessage?o.statusMessage:qn.STATUS_CODES[n],o.url=r.url.toString(),o.requestUrl=this.requestUrl,o.redirectUrls=this.redirects,o.request=this,o.isFromCache=e.fromCache||!1,o.ip=this.ip,o.retryCount=this.retryCount,this[Un]=o.isFromCache,this[oe]=Number(e.headers["content-length"])||void 0,this[Ke]=e,e.once("end",()=>{this[oe]=this[ae],this.emit("downloadProgress",this.downloadProgress)}),e.once("error",a=>{e.destroy(),this._beforeError(new Re(a,this))}),e.once("aborted",()=>{this._beforeError(new Re({name:"Error",message:"The server aborted pending request",code:"ECONNRESET"},this))}),this.emit("downloadProgress",this.downloadProgress);let i=e.headers["set-cookie"];if(d.default.object(r.cookieJar)&&i){let a=i.map(async u=>r.cookieJar.setCookie(u,s.toString()));r.ignoreInvalidCookies&&(a=a.map(async u=>u.catch(()=>{})));try{await Promise.all(a)}catch(u){this._beforeError(u);return}}if(r.followRedirect&&e.headers.location&&Rc.has(n)){if(e.resume(),this[k]&&(this[gr](),delete this[k],this[Dn]()),(n===303&&r.method!=="GET"&&r.method!=="HEAD"||!r.methodRewriting)&&(r.method="GET","body"in r&&delete r.body,"json"in r&&delete r.json,"form"in r&&delete r.form,this[K]=void 0,delete r.headers["content-length"]),this.redirects.length>=r.maxRedirects){this._beforeError(new Qe(this));return}try{let h=function(y){return y.protocol==="unix:"||y.hostname==="unix"},u=Buffer.from(e.headers.location,"binary").toString(),l=new G.URL(u,s),m=l.toString();if(decodeURI(m),!h(s)&&h(l)){this._beforeError(new R("Cannot redirect to UNIX socket",{},this));return}l.hostname!==s.hostname||l.port!==s.port?("host"in r.headers&&delete r.headers.host,"cookie"in r.headers&&delete r.headers.cookie,"authorization"in r.headers&&delete r.headers.authorization,(r.username||r.password)&&(r.username="",r.password="")):(l.username=r.username,l.password=r.password),this.redirects.push(m),r.url=l;for(let y of r.hooks.beforeRedirect)await y(r,o);this.emit("redirect",o,r),await this._makeRequest()}catch(u){this._beforeError(u);return}return}if(r.isStream&&r.throwHttpErrors&&!bc.isResponseOk(o)){this._beforeError(new Xe(o));return}e.on("readable",()=>{this[Je]&&this._read()}),this.on("resume",()=>{e.resume()}),this.on("pause",()=>{e.pause()}),e.once("end",()=>{this.push(null)}),this.emit("response",e);for(let a of this[Ge])if(!a.headersSent){for(let u in e.headers){let l=r.decompress?u!=="content-encoding":!0,m=e.headers[u];l&&a.setHeader(u,m)}a.statusCode=n}}async _onResponse(e){try{await this._onResponseBase(e)}catch(r){this._beforeError(r)}}_onRequest(e){let{options:r}=this,{timeout:s,url:n}=r;uc.default(e),this[gr]=In.default(e,s,n);let o=r.cache?"cacheableResponse":"response";e.once(o,u=>{this._onResponse(u)}),e.once("error",u=>{var l;e.destroy(),(l=e.res)===null||l===void 0||l.removeAllListeners("end"),u=u instanceof In.TimeoutError?new et(u,this.timings,this):new R(u.message,u,this),this._beforeError(u)}),this[Dn]=mc.default(e,this,Cc),this[k]=e,this.emit("uploadProgress",this.uploadProgress);let i=this[K],a=this.redirects.length===0?this:e;d.default.nodeStream(i)?(i.pipe(a),i.once("error",u=>{this._beforeError(new Ze(u,this))})):(this._unlockWrite(),d.default.undefined(i)?(this._cannotHaveBody||this._noPipe)&&(a.end(),this._lockWrite()):(this._writeRequest(i,void 0,()=>{}),a.end(),this._lockWrite())),this.emit("request",e)}async _createCacheableRequest(e,r){return new Promise((s,n)=>{Object.assign(r,yc.default(e)),delete r.url;let o,i=_r.get(r.cache)(r,async a=>{a._readableState.autoDestroy=!1,o&&(await o).emit("cacheableResponse",a),s(a)});r.url=e,i.once("error",n),i.once("request",async a=>{o=a,s(o)})})}async _makeRequest(){var e,r,s,n,o;let{options:i}=this,{headers:a}=i;for(let v in a)if(d.default.undefined(a[v]))delete a[v];else if(d.default.null_(a[v]))throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${v}\` header`);if(i.decompress&&d.default.undefined(a["accept-encoding"])&&(a["accept-encoding"]=Ec?"gzip, deflate, br":"gzip, deflate"),i.cookieJar){let v=await i.cookieJar.getCookieString(i.url.toString());d.default.nonEmptyString(v)&&(i.headers.cookie=v)}for(let v of i.hooks.beforeRequest){let P=await v(i);if(!d.default.undefined(P)){i.request=()=>P;break}}i.body&&this[K]!==i.body&&(this[K]=i.body);let{agent:u,request:l,timeout:m,url:h}=i;if(i.dnsCache&&!("lookup"in i)&&(i.lookup=i.dnsCache.lookup),h.hostname==="unix"){let v=/(?.+?):(?.+)/.exec(`${h.pathname}${h.search}`);if(v!=null&&v.groups){let{socketPath:P,path:x}=v.groups;Object.assign(i,{socketPath:P,path:x,host:""})}}let y=h.protocol==="https:",p;i.http2?p=hc.auto:p=y?cc.request:qn.request;let g=(e=i.request)!==null&&e!==void 0?e:p,w=i.cache?this._createCacheableRequest:g;u&&!i.http2&&(i.agent=u[y?"https":"http"]),i[k]=g,delete i.request,delete i.timeout;let f=i;if(f.shared=(r=i.cacheOptions)===null||r===void 0?void 0:r.shared,f.cacheHeuristic=(s=i.cacheOptions)===null||s===void 0?void 0:s.cacheHeuristic,f.immutableMinTimeToLive=(n=i.cacheOptions)===null||n===void 0?void 0:n.immutableMinTimeToLive,f.ignoreCargoCult=(o=i.cacheOptions)===null||o===void 0?void 0:o.ignoreCargoCult,i.dnsLookupIpVersion!==void 0)try{f.family=Mn.dnsLookupIpVersionToFamily(i.dnsLookupIpVersion)}catch{throw new Error("Invalid `dnsLookupIpVersion` option value")}i.https&&("rejectUnauthorized"in i.https&&(f.rejectUnauthorized=i.https.rejectUnauthorized),i.https.checkServerIdentity&&(f.checkServerIdentity=i.https.checkServerIdentity),i.https.certificateAuthority&&(f.ca=i.https.certificateAuthority),i.https.certificate&&(f.cert=i.https.certificate),i.https.key&&(f.key=i.https.key),i.https.passphrase&&(f.passphrase=i.https.passphrase),i.https.pfx&&(f.pfx=i.https.pfx));try{let v=await w(h,f);d.default.undefined(v)&&(v=p(h,f)),i.request=l,i.timeout=m,i.agent=u,i.https&&("rejectUnauthorized"in i.https&&delete f.rejectUnauthorized,i.https.checkServerIdentity&&delete f.checkServerIdentity,i.https.certificateAuthority&&delete f.ca,i.https.certificate&&delete f.cert,i.https.key&&delete f.key,i.https.passphrase&&delete f.passphrase,i.https.pfx&&delete f.pfx),Pc(v)?this._onRequest(v):this.writable?(this.once("finish",()=>{this._onResponse(v)}),this._unlockWrite(),this.end(),this._lockWrite()):this._onResponse(v)}catch(v){throw v instanceof jn.CacheError?new Ye(v,this):new R(v.message,v,this)}}async _error(e){try{for(let r of this.options.hooks.beforeError)e=await r(e)}catch(r){e=new R(r.message,r,this)}this.destroy(e)}_beforeError(e){if(this[le])return;let{options:r}=this,s=this.retryCount+1;this[le]=!0,e instanceof R||(e=new R(e.message,e,this));let n=e,{response:o}=n;(async()=>{if(o&&!o.body){o.setEncoding(this._readableState.encoding);try{o.rawBody=await _c.default(o),o.body=o.rawBody.toString()}catch{}}if(this.listenerCount("retry")!==0){let i;try{let a;o&&"retry-after"in o.headers&&(a=Number(o.headers["retry-after"]),Number.isNaN(a)?(a=Date.parse(o.headers["retry-after"])-Date.now(),a<=0&&(a=1)):a*=1e3),i=await r.retry.calculateDelay({attemptCount:s,retryOptions:r.retry,error:n,retryAfter:a,computedValue:vc.default({attemptCount:s,retryOptions:r.retry,error:n,retryAfter:a,computedValue:0})})}catch(a){this._error(new R(a.message,a,this));return}if(i){let a=async()=>{try{for(let u of this.options.hooks.beforeRetry)await u(this.options,n,s)}catch(u){this._error(new R(u.message,e,this));return}this.destroyed||(this.destroy(),this.emit("retry",s,e))};this[Bn]=setTimeout(a,i);return}}this._error(n)})()}_read(){this[Je]=!0;let e=this[Ke];if(e&&!this[le]){e.readableLength&&(this[Je]=!1);let r;for(;(r=e.read())!==null;){this[ae]+=r.length,this[Nn]=!0;let s=this.downloadProgress;s.percent<1&&this.emit("downloadProgress",s),this.push(r)}}}_write(e,r,s){let n=()=>{this._writeRequest(e,r,s)};this.requestInitialized?n():this[Oe].push(n)}_writeRequest(e,r,s){this[k].destroyed||(this._progressCallbacks.push(()=>{this[ue]+=Buffer.byteLength(e,r);let n=this.uploadProgress;n.percent<1&&this.emit("uploadProgress",n)}),this[k].write(e,r,n=>{!n&&this._progressCallbacks.length>0&&this._progressCallbacks.shift()(),s(n)}))}_final(e){let r=()=>{for(;this._progressCallbacks.length!==0;)this._progressCallbacks.shift()();if(!(k in this)){e();return}if(this[k].destroyed){e();return}this[k].end(s=>{s||(this[ce]=this[ue],this.emit("uploadProgress",this.uploadProgress),this[k].emit("upload-complete")),e(s)})};this.requestInitialized?r():this[Oe].push(r)}_destroy(e,r){var s;this[le]=!0,clearTimeout(this[Bn]),k in this&&(this[gr](),!((s=this[Ke])===null||s===void 0)&&s.complete||this[k].destroy()),e!==null&&!d.default.undefined(e)&&!(e instanceof R)&&(e=new R(e.message,e,this)),r(e)}get _isAboutToError(){return this[le]}get ip(){var e;return(e=this.socket)===null||e===void 0?void 0:e.remoteAddress}get aborted(){var e,r,s;return((r=(e=this[k])===null||e===void 0?void 0:e.destroyed)!==null&&r!==void 0?r:this.destroyed)&&!(!((s=this[Fn])===null||s===void 0)&&s.complete)}get socket(){var e,r;return(r=(e=this[k])===null||e===void 0?void 0:e.socket)!==null&&r!==void 0?r:void 0}get downloadProgress(){let e;return this[oe]?e=this[ae]/this[oe]:this[oe]===this[ae]?e=1:e=0,{percent:e,transferred:this[ae],total:this[oe]}}get uploadProgress(){let e;return this[ce]?e=this[ue]/this[ce]:this[ce]===this[ue]?e=1:e=0,{percent:e,transferred:this[ue],total:this[ce]}}get timings(){var e;return(e=this[k])===null||e===void 0?void 0:e.timings}get isFromCache(){return this[Un]}pipe(e,r){if(this[Nn])throw new Error("Failed to pipe. The response has been emitted already.");return e instanceof mr.ServerResponse&&this[Ge].add(e),super.pipe(e,r)}unpipe(e){return e instanceof mr.ServerResponse&&this[Ge].delete(e),super.unpipe(e),this}};E.default=rt});var Ce=b(M=>{"use strict";var Tc=M&&M.__createBinding||(Object.create?(function(t,e,r,s){s===void 0&&(s=r),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[r]}})}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]})),xc=M&&M.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Tc(e,t,r)};Object.defineProperty(M,"__esModule",{value:!0});M.CancelError=M.ParseError=void 0;var zn=ke(),br=class extends zn.RequestError{constructor(e,r){let{options:s}=r.request;super(`${e.message} in "${s.url.toString()}"`,e,r.request),this.name="ParseError",this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_BODY_PARSE_FAILURE":this.code}};M.ParseError=br;var wr=class extends zn.RequestError{constructor(e){super("Promise was canceled",{},e),this.name="CancelError",this.code="ERR_CANCELED"}get isCanceled(){return!0}};M.CancelError=wr;xc(ke(),M)});var Wn=b(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});var $n=Ce(),Ac=(t,e,r,s)=>{let{rawBody:n}=t;try{if(e==="text")return n.toString(s);if(e==="json")return n.length===0?"":r(n.toString());if(e==="buffer")return n;throw new $n.ParseError({message:`Unknown body type '${e}'`,name:"Error"},t)}catch(o){throw new $n.ParseError(o,t)}};vr.default=Ac});var Er=b(Q=>{"use strict";var qc=Q&&Q.__createBinding||(Object.create?(function(t,e,r,s){s===void 0&&(s=r),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[r]}})}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]})),jc=Q&&Q.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&qc(e,t,r)};Object.defineProperty(Q,"__esModule",{value:!0});var Hc=require("events"),Ic=F(),Lc=Br(),st=Ce(),Vn=Wn(),Gn=ke(),Mc=nr(),Dc=dr(),Jn=hr(),Uc=["request","response","redirect","uploadProgress","downloadProgress"];function Kn(t){let e,r,s=new Hc.EventEmitter,n=new Lc((i,a,u)=>{let l=m=>{let h=new Gn.default(void 0,t);h.retryCount=m,h._noPipe=!0,u(()=>h.destroy()),u.shouldReject=!1,u(()=>a(new st.CancelError(h))),e=h,h.once("response",async g=>{var w;if(g.retryCount=m,g.request.aborted)return;let f;try{f=await Dc.default(h),g.rawBody=f}catch{return}if(h._isAboutToError)return;let v=((w=g.headers["content-encoding"])!==null&&w!==void 0?w:"").toLowerCase(),P=["gzip","deflate","br"].includes(v),{options:x}=h;if(P&&!x.decompress)g.body=f;else try{g.body=Vn.default(g,x.responseType,x.parseJson,x.encoding)}catch(U){if(g.body=f.toString(),Jn.isResponseOk(g)){h._beforeError(U);return}}try{for(let[U,ee]of x.hooks.afterResponse.entries())g=await ee(g,async pt=>{let ye=Gn.default.normalizeArguments(void 0,{...pt,retry:{calculateDelay:()=>0},throwHttpErrors:!1,resolveBodyOnly:!1},x);ye.hooks.afterResponse=ye.hooks.afterResponse.slice(0,U);for(let Ci of ye.hooks.beforeRetry)await Ci(ye);let mt=Kn(ye);return u(()=>{mt.catch(()=>{}),mt.cancel()}),mt})}catch(U){h._beforeError(new st.RequestError(U.message,U,h));return}if(r=g,!Jn.isResponseOk(g)){h._beforeError(new st.HTTPError(g));return}h.destroy(),i(h.options.resolveBodyOnly?g.body:g)});let y=g=>{if(n.isCanceled)return;let{options:w}=h;if(g instanceof st.HTTPError&&!w.throwHttpErrors){let{response:f}=g;i(h.options.resolveBodyOnly?f.body:f);return}a(g)};h.once("error",y);let p=h.options.body;h.once("retry",(g,w)=>{var f,v;if(p===((f=w.request)===null||f===void 0?void 0:f.options.body)&&Ic.default.nodeStream((v=w.request)===null||v===void 0?void 0:v.options.body)){y(w);return}l(g)}),Mc.default(h,s,Uc)};l(0)});n.on=(i,a)=>(s.on(i,a),n);let o=i=>{let a=(async()=>{await n;let{options:u}=r.request;return Vn.default(r,i,u.parseJson,u.encoding)})();return Object.defineProperties(a,Object.getOwnPropertyDescriptors(n)),a};return n.json=()=>{let{headers:i}=e.options;return!e.writableFinished&&i.accept===void 0&&(i.accept="application/json"),o("json")},n.buffer=()=>o("buffer"),n.text=()=>o("text"),n}Q.default=Kn;jc(Ce(),Q)});var Qn=b(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});var Nc=Ce();function Fc(t,...e){let r=(async()=>{if(t instanceof Nc.RequestError)try{for(let n of e)if(n)for(let o of n)t=await o(t)}catch(n){t=n}throw t})(),s=()=>r;return r.json=s,r.text=s,r.buffer=s,r.on=s,r}Sr.default=Fc});var Zn=b(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});var Xn=F();function Yn(t){for(let e of Object.values(t))(Xn.default.plainObject(e)||Xn.default.array(e))&&Yn(e);return Object.freeze(t)}Pr.default=Yn});var ti=b(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0})});var Or=b(I=>{"use strict";var Bc=I&&I.__createBinding||(Object.create?(function(t,e,r,s){s===void 0&&(s=r),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[r]}})}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]})),zc=I&&I.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Bc(e,t,r)};Object.defineProperty(I,"__esModule",{value:!0});I.defaultHandler=void 0;var ri=F(),H=Er(),$c=Qn(),it=ke(),Wc=Zn(),Vc={RequestError:H.RequestError,CacheError:H.CacheError,ReadError:H.ReadError,HTTPError:H.HTTPError,MaxRedirectsError:H.MaxRedirectsError,TimeoutError:H.TimeoutError,ParseError:H.ParseError,CancelError:H.CancelError,UnsupportedProtocolError:H.UnsupportedProtocolError,UploadError:H.UploadError},Gc=async t=>new Promise(e=>{setTimeout(e,t)}),{normalizeArguments:nt}=it.default,si=(...t)=>{let e;for(let r of t)e=nt(void 0,r,e);return e},Jc=t=>t.isStream?new it.default(void 0,t):H.default(t),Kc=t=>"defaults"in t&&"options"in t.defaults,Qc=["get","post","put","patch","head","delete"];I.defaultHandler=(t,e)=>e(t);var ni=(t,e)=>{if(t)for(let r of t)r(e)},ii=t=>{t._rawHandlers=t.handlers,t.handlers=t.handlers.map(s=>((n,o)=>{let i,a=s(n,u=>(i=o(u),i));if(a!==i&&!n.isStream&&i){let u=a,{then:l,catch:m,finally:h}=u;Object.setPrototypeOf(u,Object.getPrototypeOf(i)),Object.defineProperties(u,Object.getOwnPropertyDescriptors(i)),u.then=l,u.catch=m,u.finally=h}return a}));let e=((s,n={},o)=>{var i,a;let u=0,l=m=>t.handlers[u++](m,u===t.handlers.length?Jc:l);if(ri.default.plainObject(s)){let m={...s,...n};it.setNonEnumerableProperties([s,n],m),n=m,s=void 0}try{let m;try{ni(t.options.hooks.init,n),ni((i=n.hooks)===null||i===void 0?void 0:i.init,n)}catch(y){m=y}let h=nt(s,n,o??t.options);if(h[it.kIsNormalizedAlready]=!0,m)throw new H.RequestError(m.message,m,h);return l(h)}catch(m){if(n.isStream)throw m;return $c.default(m,t.options.hooks.beforeError,(a=n.hooks)===null||a===void 0?void 0:a.beforeError)}});e.extend=(...s)=>{let n=[t.options],o=[...t._rawHandlers],i;for(let a of s)Kc(a)?(n.push(a.defaults.options),o.push(...a.defaults._rawHandlers),i=a.defaults.mutableDefaults):(n.push(a),"handlers"in a&&o.push(...a.handlers),i=a.mutableDefaults);return o=o.filter(a=>a!==I.defaultHandler),o.length===0&&o.push(I.defaultHandler),ii({options:si(...n),handlers:o,mutableDefaults:!!i})};let r=(async function*(s,n){let o=nt(s,n,t.options);o.resolveBodyOnly=!1;let i=o.pagination;if(!ri.default.object(i))throw new TypeError("`options.pagination` must be implemented");let a=[],{countLimit:u}=i,l=0;for(;l{let o=[];for await(let i of r(s,n))o.push(i);return o}),e.paginate.each=r,e.stream=((s,n)=>e(s,{...n,isStream:!0}));for(let s of Qc)e[s]=((n,o)=>e(n,{...o,method:s})),e.stream[s]=((n,o)=>e(n,{...o,method:s,isStream:!0}));return Object.assign(e,Vc),Object.defineProperty(e,"defaults",{value:t.mutableDefaults?t:Wc.default(t),writable:t.mutableDefaults,configurable:t.mutableDefaults,enumerable:!0}),e.mergeOptions=si,e};I.default=ii;zc(ti(),I)});var ci=b((z,ot)=>{"use strict";var Xc=z&&z.__createBinding||(Object.create?(function(t,e,r,s){s===void 0&&(s=r),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[r]}})}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]})),oi=z&&z.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Xc(e,t,r)};Object.defineProperty(z,"__esModule",{value:!0});var Yc=require("url"),ai=Or(),Zc={options:{method:"GET",retry:{limit:2,methods:["GET","PUT","HEAD","DELETE","OPTIONS","TRACE"],statusCodes:[408,413,429,500,502,503,504,521,522,524],errorCodes:["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"],maxRetryAfter:void 0,calculateDelay:({computedValue:t})=>t},timeout:{},headers:{"user-agent":"got (https://github.com/sindresorhus/got)"},hooks:{init:[],beforeRequest:[],beforeRedirect:[],beforeRetry:[],beforeError:[],afterResponse:[]},cache:void 0,dnsCache:void 0,decompress:!0,throwHttpErrors:!0,followRedirect:!0,isStream:!1,responseType:"text",resolveBodyOnly:!1,maxRedirects:10,prefixUrl:"",methodRewriting:!0,ignoreInvalidCookies:!1,context:{},http2:!1,allowGetBody:!1,https:void 0,pagination:{transform:t=>t.request.options.responseType==="json"?t.body:JSON.parse(t.body),paginate:t=>{if(!Reflect.has(t.headers,"link"))return!1;let e=t.headers.link.split(","),r;for(let s of e){let n=s.split(";");if(n[1].includes("next")){r=n[0].trimStart().trim(),r=r.slice(1,-1);break}}return r?{url:new Yc.URL(r)}:!1},filter:()=>!0,shouldContinue:()=>!0,countLimit:1/0,backoff:0,requestLimit:1e4,stackAllItems:!0},parseJson:t=>JSON.parse(t),stringifyJson:t=>JSON.stringify(t),cacheOptions:{}},handlers:[ai.defaultHandler],mutableDefaults:!1},Rr=ai.default(Zc);z.default=Rr;ot.exports=Rr;ot.exports.default=Rr;ot.exports.__esModule=!0;oi(Or(),z);oi(Er(),z)});var ui=b(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.pathMap=de.ReportURL=void 0;de.ReportURL={cn:"https://mcs.zijieapi.com",sg:"https://sgali-mcs.byteoversea.com",va:"https://maliva-mcs.byteoversea.com"};de.pathMap={REPORT_PATH:"/v1/list",ABConfigPath:"/service/2/abtest_config/"}});var li=b(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.divide=void 0;function eu(t,e){return t.reduce((r,s)=>{let n=r[r.length-1];return n.length>=e&&(n=[],r.push(n)),n.push(s),r},[[]])}at.divide=eu});var hi=b(L=>{"use strict";var ct=L&&L.__awaiter||function(t,e,r,s){function n(o){return o instanceof r?o:new r(function(i){i(o)})}return new(r||(r=Promise))(function(o,i){function a(m){try{l(s.next(m))}catch(h){i(h)}}function u(m){try{l(s.throw(m))}catch(h){i(h)}}function l(m){m.done?o(m.value):n(m.value).then(a,u)}l((s=s.apply(t,e||[])).next())})},tu=L&&L.__rest||function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);nObject.assign(Object.assign({},l),{verbose:1})),timeout:o}).then(l=>{this.pluginContext.logger.trace("verify events %o result %s",e.map(m=>m.id),l.body)}).catch(l=>{let m=l==null?void 0:l.stack,h=l==null?void 0:l.message;m&&h?this.pluginContext.logger.error("network error: %s $o",h,m):this.pluginContext.logger.error("network error: %o",l)});r.push(u)}this.pluginContext.logger.trace("with channel domain %s",this.channelDomain);let a=(0,kr.default)((0,nu.join)(this.channelDomain,Cr.pathMap.REPORT_PATH),{method:"POST",retry:n,json:e.map(({event:u})=>Object.assign(Object.assign({},u),{verbose:1})),timeout:o}).then(u=>{i=!0,this.pluginContext.logger.trace("sent events %o result %s",e.map(({id:l})=>l),u.body)}).catch(u=>{let l=u==null?void 0:u.stack,m=u==null?void 0:u.message;l&&m?this.pluginContext.logger.trace("network error: %s %o",m,l):this.pluginContext.logger.trace("network error: %o",u)});r.push(a)}yield Promise.all(r).finally(()=>{var a,u;for(let{event:l}of e)this.emit("end",{event:l,hasSucceed:i}),(u=(a=this.options).onEnd)===null||u===void 0||u.call(a,l,i)})}finally{this.pending=!1}this.queue.length>0?this.flush():(this.pluginContext.logger.trace("queue drained, last sent %d",e.length),this.emit("drain",{lastEvents:e,hasSucceed:i}))})}install(e){this.pluginContext=e}onSendEvent({event:e,id:r}){let{events:s}=e,n=tu(e,["events"]),o=(0,iu.divide)(s,50).map(i=>({id:r,event:Object.assign(Object.assign({},n),{events:i})}));this.queue.push(...o),this.flush()}getVar(e,r){var s,n,o,i;return ct(this,void 0,void 0,function*(){let{header:a,user:u}=this.pluginContext.metaInfo,l=Object.assign(Object.assign(Object.assign(Object.assign({aid:a.app_id},a),u),r==null?void 0:r.extraProperties),{custom:Object.assign(Object.assign({},di(a.custom)),r==null?void 0:r.extraProperties.custom)});this.pluginContext.logger.trace("abRequest config: %o",l);let m=yield this.abRequest(l,{timeout:r==null?void 0:r.timeout});if(!((s=m[e])===null||s===void 0)&&s.vid){let{user_unique_id:h,uuid:y}=(n=r==null?void 0:r.extraProperties)!==null&&n!==void 0?n:{};this.pluginContext.logger.trace("abtest_exposure name: %s, vid: %s, val: %o",e,m[e].vid,m[e].val),this.pluginContext.collect([{extra:{ab_sdk_version:String(m[e].vid)},name:"abtest_exposure",params:{}}],{user:{user_unique_id:h||y},header:{ab_sdk_version:String(m[e].vid)}})}return(i=(o=m[e])===null||o===void 0?void 0:o.val)!==null&&i!==void 0?i:r==null?void 0:r.defaultValue})}getAllVars(e){return ct(this,void 0,void 0,function*(){let{header:r,user:s}=this.pluginContext.metaInfo,n=Object.assign(Object.assign(Object.assign(Object.assign({aid:r.app_id},r),s),e==null?void 0:e.extraProperties),{custom:Object.assign(Object.assign({},di(r.custom)),e==null?void 0:e.extraProperties.custom)});return this.pluginContext.logger.trace("abRequest config: %o",n),this.abRequest(n,{timeout:e==null?void 0:e.timeout})})}abRequest(e,r){return ct(this,void 0,void 0,function*(){let s;try{let i=new URL(this.options.abServiceOrigin);i.pathname=Cr.pathMap.ABConfigPath,s=i.toJSON(),this.pluginContext.logger.trace("request abtest config with url %s",s)}catch(i){this.pluginContext.logger.error("invalid service origin %O",i)}return s?(yield(0,kr.default)(s,{method:"POST",json:{header:e},responseType:"json",timeout:r.timeout}).then(i=>{var a;return this.pluginContext.logger.trace("abRequest response %O",i.body),(a=i.body)===null||a===void 0?void 0:a.data}).catch(i=>{this.pluginContext.logger.error("unexpected_error_when_request_ab_ata"),this.pluginContext.logger.error(i)}))||{}:{}})}};L.HttpController=ut;function ou(t){let e=t.channel_domain||t.channel&&Cr.ReportURL[t.channel];if(!e)throw new Error("plugin 'http': channel or channel_domain can't be both undefined");return new ut(t,e)}L.httpPlugin=ou});var gi=b((Xl,yi)=>{var fi=require("fs"),Tr=require("path"),{TeaSDK:au}=Mr(),{httpPlugin:cu}=hi(),uu=611930,lu="generate-mini-app";function pi(t){return Tr.join(t,".pai","skill-update","update.json")}function du(t){try{let e=Tr.resolve(t||process.cwd()),r=Tr.dirname(e),s=[pi(e)];r!==e&&s.push(pi(r));for(let n of s)if(fi.existsSync(n))try{return JSON.parse(fi.readFileSync(n,"utf-8"))[lu]||{}}catch{return{}}return{}}catch{return{}}}function mi(t={}){let e=t.cwd||process.cwd(),r=du(e);return{skill_builtin_version:r.skill_builtin_version||"",skill_local_version:r.skill_local_version||""}}var lt=class{constructor(){this._sdk=null,this._initialized=!1,this._commonParams={}}init(e={}){if(this._initialized){console.log("[TeaTracker] Already initialized, skip");return}try{let{userId:r,tenantId:s,iss:n}=e,o=mi({cwd:e.cwd});this._commonParams={product:"pai_skill",tenant_id:s||"",iss:n||"",skill_builtin_version:o.skill_builtin_version,skill_local_version:o.skill_local_version,platform:process.platform,node_version:process.version},this._sdk=new au({app_id:uu,logLevel:"error"}),this._sdk.use(cu({channel:"cn"})),this._sdk.config({user:{user_unique_id:r||""},custom:this._commonParams}),this._initialized=!0}catch(r){console.error("[TeaTracker] Init failed:",r.message)}}collect(e,r={}){if(!this._initialized||!this._sdk){console.warn("[TeaTracker] Not initialized, skip event:",e);return}try{this._sdk.collect(e,{...this._commonParams,...r})}catch(s){console.error("[TeaTracker] Collect failed:",e,s.message)}}flush(){return new Promise(e=>setTimeout(e,500))}},hu=new lt;yi.exports={teaTracker:hu,TeaTracker:lt,getSkillVersionContext:mi}});var Oi=b((Yl,xr)=>{var C=require("fs"),q=require("path"),fu=require("https"),pu="https://pai.mobile.volcapp.com",he="generate-mini-app",_i=10800*1e3;function bi(t){return q.join(t,".pai","skill-update",he)}function mu(t){return q.join(t,".pai","skill-update","."+he+".new")}function yu(t){return q.join(t,".pai","skill-update","."+he+".old")}function wi(t){return q.join(t,".pai","skill-update","update.json")}function ht(t){let e=q.join(t,"SKILL.md");if(!C.existsSync(e))return null;let s=C.readFileSync(e,"utf-8").match(/^version:\s*(.+)$/m);return s?s[1].trim():null}function gu(t){let e=wi(t);if(!C.existsSync(e))return{lastCheck:0};try{return JSON.parse(C.readFileSync(e,"utf-8"))[he]||{lastCheck:0}}catch{return{lastCheck:0}}}function Te(t,e){try{let s=wi(t);vi(q.dirname(s));var r={};if(C.existsSync(s))try{r=JSON.parse(C.readFileSync(s,"utf-8"))||{}}catch{r={}}return r[he]=e,C.writeFileSync(s,JSON.stringify(r,null,2)),!0}catch{return!1}}function dt(t,e,r,s){var n=Date.now(),o={lastCheck:n,checkedAt:new Date(n).toISOString(),status:t,reason:e||t,skill_builtin_version:r&&r.builtinVersion||"",skill_local_version:r&&r.localVersion||"",updatedAt:r&&r.updatedAt||""};return s&&Object.keys(s).forEach(function(i){o[i]=s[i]}),o}function vi(t){C.existsSync(t)||C.mkdirSync(t,{recursive:!0})}function D(t){C.existsSync(t)&&C.rmSync(t,{recursive:!0,force:!0})}function _u(t){return new Promise((e,r)=>{fu.get(t,s=>{let{statusCode:n}=s;if(n<200||n>=300){s.resume(),r(new Error("HTTP "+n));return}let o="";s.setEncoding("utf8"),s.on("data",i=>{o+=i}),s.on("end",()=>{try{e(JSON.parse(o))}catch(i){r(i)}})}).on("error",r)})}function bu(t,e,r){let s=e.replace(/^\/+/,""),n=q.resolve(t,s);n.startsWith(t)&&(vi(q.dirname(n)),C.writeFileSync(n,r))}var Ei=["system-prompt.md","ui-ux-design-principles.md"],Si=["init-template.js","preview-server.js"];function ft(t,e){return e.every(function(r){return C.existsSync(q.join(t,r))})}function wu(t){return!!ht(t)&&ft(q.join(t,"prompts"),Ei)&&ft(q.join(t,"scripts"),Si)}function vu(t){return!!ht(t)&&ft(q.join(t,"prompts"),Ei)&&ft(q.join(t,"scripts"),Si)}function Eu(t,e){let r=t.split(".").map(Number),s=e.split(".").map(Number);for(let n=0;ni)return 1;if(o0&&(r&&console.log("[update-skill] Builtin version "+u+" > local version "+h+", removing outdated local assets"),D(m),h=null,l={lastCheck:0}),D(o),D(i),Date.now()-l.lastCheck<_i)return r&&console.log("[update-skill] Skipping check, last check was "+Math.round((Date.now()-l.lastCheck)/6e4)+" minutes ago"),Te(n,{lastCheck:l.lastCheck,checkedAt:new Date().toISOString(),status:"skipped",reason:"skipped",skill_builtin_version:u||"",skill_local_version:h||"",updatedAt:l.updatedAt||"",nextCheckAt:new Date(l.lastCheck+_i).toISOString()}),{updated:!1,reason:"skipped"};var y=pu+"/api/update-skill?skill_id="+encodeURIComponent(he)+"&builtin_version="+encodeURIComponent(u)+"&local_version="+encodeURIComponent(h||"");return r&&console.log("[update-skill] Checking for updates (builtin="+u+", local="+(h||"none")+")"),_u(y).then(function(p){var g=p.data;if(!g||!g.needUpdate)return Te(n,dt("already_new",null,{builtinVersion:u,localVersion:h,updatedAt:l.updatedAt})),r&&console.log("[update-skill] Skill assets are up to date"),{updated:!1,reason:"already_new"};if(!Array.isArray(g.data)||g.data.length===0)throw new Error("Empty skill data from server");if(r&&console.log("[update-skill] Updating to "+g.version),D(o),g.data.forEach(function(w){w&&typeof w.path=="string"&&bu(o,w.path,w.content||"")}),!vu(o))throw new Error("Skill integrity check failed");return Su(o,m,i),Te(n,dt("updated",null,{builtinVersion:u,localVersion:g.version},{updatedAt:new Date().toISOString()})),r&&console.log("[update-skill] Updated to "+g.version),{updated:!0,version:g.version,reason:"updated"}}).catch(function(p){return D(o),D(i),Te(n,dt("request_failed",null,{builtinVersion:u,localVersion:h,updatedAt:l.updatedAt},{error:p.message})),r&&console.error("[update-skill] Update failed: "+p.message),{updated:!1,reason:"request_failed: "+p.message}})}catch(p){return D(o),D(i),Te(n,dt("request_failed",null,{builtinVersion:u,localVersion:h,updatedAt:l&&l.updatedAt},{error:p.message})),r&&console.error("[update-skill] Update failed: "+p.message),{updated:!1,reason:"request_failed: "+p.message}}}xr.exports={checkAndUpdate:Pi,getUpdateSkillDir:bi};require.main===xr&&Pi({cwd:process.cwd()})});var me=require("fs"),$=require("path"),Pu=require("https"),Ou=require("http"),{teaTracker:pe}=gi(),Ru=__dirname.includes(`.pai${$.sep}skill-update${$.sep}`),ku=process.argv.slice(2),Cu=ku.find(t=>!t.startsWith("--"))||".",Ri="miniapp/taro",Tu="https://pai.mobile.volcapp.com",xu=`${Tu}/api/get-app-template?template_id=${Ri}`,fe=$.resolve(process.cwd(),Cu);function Au(){var n,o;let t="",e="",r="",s=process.env.TRAE_JWT_TOKEN_PATH;if(s)try{let i=me.readFileSync(s,"utf-8").trim();if(i){let a=i.split(".");if(a.length>=2){let u=JSON.parse(Buffer.from(a[1],"base64").toString());t=((n=u==null?void 0:u.data)==null?void 0:n.user_id)||"",e=((o=u==null?void 0:u.data)==null?void 0:o.tenant_id)||"",r=(u==null?void 0:u.iss)||""}}}catch{}pe.init({userId:t,tenantId:e,iss:r,cwd:process.cwd()})}var ki=t=>{me.mkdirSync(t,{recursive:!0})},qu=t=>{let e=t.startsWith("https")?Pu:Ou;return new Promise((r,s)=>{e.get(t,n=>{let{statusCode:o}=n;if(o<200||o>=300){n.resume(),s(new Error(`HTTP ${o}`));return}let i="";n.setEncoding("utf8"),n.on("data",a=>{i+=a}),n.on("end",()=>{try{r(JSON.parse(i))}catch(a){s(a)}})}).on("error",s)})},ju=async(t,e=3)=>{let r;for(let s=0;s<=e;s++)try{return await t()}catch(n){r=n,ssetTimeout(o,500*Math.pow(2,s)))}throw r},Hu=(t,e,r)=>{let s=e.replace(/^\/+/,""),n=$.resolve(t,s);n.startsWith(t)&&(ki($.dirname(n)),me.writeFileSync(n,r))};function Iu(t,e){try{return me.realpathSync(t)===me.realpathSync(e)}catch{return $.resolve(t)===$.resolve(e)}}function Lu(t){console.log(` [SkillToolUpdated]: true`),console.log("[SkillToolPath]: "+t+` `)}(async()=>{if(Au(),!Ru){let{checkAndUpdate:e,getUpdateSkillDir:r}=Oi();await e({cwd:fe,log:!1,currentSkillDir:$.resolve(__dirname,"..")});let s=r(fe),n=$.join(s,"scripts","init-template.js");me.existsSync(n)&&!Iu(n,__filename)&&(Lu(n),process.exit(0))}let t=Date.now();pe.collect("pai_client_init_template",{status:"start",template_id:Ri});try{ki(fe);let e=await ju(()=>qu(xu)),r=Array.isArray(e.data)?e.data:[];r.forEach(s=>{s&&typeof s.path=="string"&&Hu(fe,s.path,s.content||"")}),pe.collect("pai_client_init_template",{status:"success",duration:Date.now()-t,total_files_count:r.length}),await pe.flush(),process.stdout.write(JSON.stringify({success:!0,target_dir:fe,total_files_count:r.length}))}catch(e){let r=e.message&&e.message.startsWith("HTTP "),s=e.code==="EACCES"||e.code==="EPERM";pe.collect("pai_client_init_template",{status:"fail",duration:Date.now()-t,error_code:r?3:s?4:2,error_msg:e.message||"fetch or parse failed"}),await pe.flush();let n,o;r?(n="http_error",o=`\u6A21\u7248\u4E0B\u8F7D\u5931\u8D25\uFF08${e.message}\uFF09\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u540E\u91CD\u8BD5\u3002`):s?(n="permission_denied",o=`\u6A21\u7248\u521D\u59CB\u5316\u5931\u8D25\uFF0C\u76EE\u5F55 "${fe}" \u65E0\u5199\u5165\u6743\u9650\u3002\u8BF7\u786E\u4FDD\u76EE\u5F55\u6709\u6743\u9650\u6216\u66F4\u6362\u5230\u5176\u4ED6\u76EE\u5F55\u3002`):(n="unknown",o=`\u6A21\u7248\u521D\u59CB\u5316\u5931\u8D25\uFF1A${e.message}`),process.stderr.write(`init template failed: ${e.message} `),process.stdout.write(JSON.stringify({success:!1,error:n,message:o})),process.exit(s?4:2)}})();