fern-api 1.3.0-rc2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +2 -2
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -2438,7 +2438,7 @@ ${c0y.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&xbf(th
|
|
|
2438
2438
|
`+_ua.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?_ua.default.cyan(g0y(t,this.opt.mask)):_ua.default.italic(_ua.default.dim("[hidden]")):this.opt.mask?g0y(t,this.opt.mask):_ua.default.italic(_ua.default.dim("[input is hidden] "))}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var cSu=Gi(Pse(),1);var gmy=Gi(g0f(),1),sSu=require("child_process"),vZa=require("fs"),oSu=Gi(require("path"),1),bmy=Gi(require("os"),1),mmy=require("crypto"),rmf=Gi(ymy(),1);var nSu=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var NKo=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var iSu=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var aSu=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function uSu(e="",t,r){let n=new nmf(e,r);n.runAsync((i,a)=>{if(i)setImmediate(t,i,void 0);else try{n.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function vmy(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function rOC(e){let t=[],r="";for(let n=0;n<e.length;n++){let i=e.charAt(n);n>0&&i===" "&&e[n-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${i}`}return r.length>0&&t.push(r),t}var nmf=class{text="";tempFile;editor;lastExitStatus=0;fileOptions={};get temp_file(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile}get last_exit_status(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus}constructor(t="",r){this.text=t,r&&(this.fileOptions=r),this.determineEditor(),this.createTemporaryFile()}run(){return this.launchEditor(),this.readTemporaryFile(),this.text}runAsync(t){try{this.launchEditorAsync(()=>{try{this.readTemporaryFile(),setImmediate(t,void 0,this.text)}catch(r){setImmediate(t,r,void 0)}})}catch(r){setImmediate(t,r,void 0)}}cleanup(){this.removeTemporaryFile()}determineEditor(){let t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:process.platform.startsWith("win")?"notepad":"vim",r=rOC(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??bmy.default.tmpdir(),r=(0,mmy.randomUUID)(),n=vmy(this.fileOptions.prefix),i=vmy(this.fileOptions.postfix),a=`${n}${r}${i}`,o=oSu.default.resolve(t,a),c=oSu.default.resolve(t)+oSu.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let f={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(f.mode=this.fileOptions.mode),(0,vZa.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new nSu(t)}}readTemporaryFile(){try{let t=(0,vZa.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,gmy.detect)(t)??"utf8";rmf.default.encodingExists(r)||(r="utf8"),this.text=rmf.default.decode(t,r)}}catch(t){throw new iSu(t)}}removeTemporaryFile(){try{(0,vZa.unlinkSync)(this.tempFile)}catch(t){throw new aSu(t)}}launchEditor(){try{let t=(0,sSu.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new NKo(t)}}launchEditorAsync(t){try{(0,sSu.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new NKo(r)}}};var Omy=Gi(xrt(),1);var xKo=class extends wse{_run(t){this.done=t,this.editorResult=new Omy.Subject;let r=Jve(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?cSu.default.dim("Received"):cSu.default.dim("Press <enter> to launch your preferred editor."),t&&(r=cSu.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),uSu(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(t,r){this.rl.resume(),t?this.editorResult.error(t):this.editorResult.next(r)}onEnd(t){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=t.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(t){this.render(t.isValid)}};var Emy=require("stream");var wmy=Gi(require("readline"),1),jmy=Gi(Pmy(),1),gua=class{constructor(t){this.rl||=wmy.default.createInterface(iOC(t)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&typeof this.activePrompt.close=="function"&&this.activePrompt.close(),this.rl.output.end(),this.rl.pause(),this.rl.close()}};function iOC(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new jmy.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var FKo=class extends gua{constructor(t={}){super(t),this.log=new Emy.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return OKo(this.rl,this.bottomBar.split(`
|
|
2439
2439
|
`).length),this}updateBottomBar(t){return OKo(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=t,this.render(),this.rl.output.mute(),this}writeLog(t){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(t.toString())),this.render(),this.rl.output.mute(),this}enforceLF(t){return/[\n\r]$/.test(t)?t:t+`
|
|
2440
2440
|
`}write(t){let r=t.split(/\n/);this.height=r.length,this.rl.setPrompt(r.at(-1)),this.rl.output.rows===0&&this.rl.output.columns===0&&MEu(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var J4=Gi(xrt(),1),Cmy=Gi(UJo(),1);var lSu=Gi(xrt(),1),Smy=Gi(UJo(),1),fSu=function(e,t,r){return typeof e[t]!="function"?(0,lSu.of)(e):(0,lSu.from)((0,Smy.default)(e[t])(r).then(n=>(e[t]=n,e)))};var Dmy={set:(e,t="",r)=>{let n=e;t.split(".").forEach((i,a,o)=>{i==="__proto__"||i==="constructor"||(a===o.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(e,t="",r)=>{let n=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===e?r:i}},gZa=class extends gua{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let n;return Array.isArray(t)?n=(0,J4.from)(t):(0,J4.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,J4.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,J4.from)([t]),this.process=n.pipe((0,J4.concatMap)(this.processQuestion.bind(this)),(0,J4.publish)()),this.process.connect(),this.process.pipe((0,J4.reduce)((i,a)=>(Dmy.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,J4.defer)(()=>(0,J4.of)(t).pipe((0,J4.concatMap)(this.setDefaultType.bind(this)),(0,J4.concatMap)(this.filterIfRunnable.bind(this)),(0,J4.concatMap)(()=>fSu(t,"message",this.answers)),(0,J4.concatMap)(()=>fSu(t,"default",this.answers)),(0,J4.concatMap)(()=>fSu(t,"choices",this.answers)),(0,J4.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,J4.defer)(()=>(0,J4.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,J4.defer)(()=>(0,J4.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&Dmy.get(this.answers,t.name)!==void 0)return J4.EMPTY;if(t.when===!1)return J4.EMPTY;if(typeof t.when!="function")return(0,J4.of)(t);let{answers:r}=this;return(0,J4.defer)(()=>(0,J4.from)((0,Cmy.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,J4.filter)(n=>n!=null)))}};function Imy(e){let t=function(r,n){let i;try{i=new gZa(t.prompts,e)}catch(o){return Promise.reject(o)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",PKo),this.registerPrompt("input",pua),this.registerPrompt("number",wKo),this.registerPrompt("confirm",jKo),this.registerPrompt("rawlist",EKo),this.registerPrompt("expand",SKo),this.registerPrompt("checkbox",DKo),this.registerPrompt("password",CKo),this.registerPrompt("editor",xKo)},t.restoreDefaultPrompts(),t}var amf=Imy();function oOC(e,t){amf.registerPrompt(e,t)}function sOC(){amf.restoreDefaultPrompts()}var uOC={prompt:amf,ui:{BottomBar:FKo,Prompt:gZa},createPromptModule:Imy,registerPrompt:oOC,restoreDefaultPrompts:sOC,Separator:sFe},dSu=uOC;var MZa=require("path"),cAy=require("fs"),lAy=require("readline"),qOy="posthog-node";function RPC(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"]}={}){return a=>{if(!(i==="*"||i.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[BSu.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",u=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=u;let s=a.exception?.values||[],l=s.map(O=>({...O,stacktrace:O.stacktrace?{...O.stacktrace,type:"raw",frames:(O.stacktrace.frames||[]).map(P=>({...P,platform:"node:javascript"}))}:void 0})),m={$exception_message:s[0]?.value||a.message,$exception_type:s[0]?.type,$exception_personURL:u,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:s[0]?.value||a.message,$sentry_exception_type:s[0]?.type,$sentry_tags:a.tags};return t&&r&&(m.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:m}),a}}var BSu=class{constructor(t,r,n,i){this.name=qOy,this.name=qOy,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(RPC(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};BSu.POSTHOG_ID_TAG="posthog_distinct_id";var SSu="0123456789abcdef",TSu=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=SSu.charAt(this.bytes[r]>>>4),t+=SSu.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=SSu.charAt(this.bytes[r]>>>4),t+=SSu.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},Vmf=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??NPC()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return TSu.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,TSu.ofInner(t)}},NPC=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),ROy,Wmf=()=>xPC().toString(),xPC=()=>(ROy||(ROy=new Vmf)).generate();function FPC(e,t){let r=!1;return Object.assign(n=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function zPC(e,t){global.process.on("uncaughtException",FPC(e,t))}function QPC(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var DSu,NOy,CSu;function LPC(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return CSu&&r.length===NOy||(NOy=r.length,CSu=r.reduce((n,i)=>{DSu||(DSu={});let a=DSu[i];if(a)n[a[0]]=a[1];else{let o=e(i);for(let c=o.length-1;c>=0;c--){let u=o[c]?.filename,s=t[i];if(u&&s){n[u]=s,DSu[i]=[u,s];break}}}return n},{})),CSu}function UPC(e){return typeof Event<"u"&&fAy(e,Event)}function VPC(e){return dAy(e,"Object")}function Zmf(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return fAy(e,Error)}}function fAy(e,t){try{return e instanceof t}catch{return!1}}function WPC(e){return dAy(e,"ErrorEvent")}function dAy(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function GPC(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},o=pAy(a,r,n);return{$exception_list:await Promise.all(o.map(async u=>{let s=await ZPC(e,t,u);return s.value=s.value||"",s.type=s.type||"Error",s.mechanism=a,s}))}}function pAy(e,t,r){let n=HPC(e,t,r);return n.cause?[n,...pAy(e,n.cause,r)]:[n]}function HPC(e,t,r){if(Zmf(t))return t;if(e.synthetic=!0,VPC(t)){let i=JPC(t);if(i)return i;let a=KPC(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let n=r?.syntheticException||new Error(t);return n.message=`${t}`,n}function JPC(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(Zmf(r))return r}}function KPC(e){if("name"in e&&typeof e.name=="string"){let n=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(n+=` with message '${e.message}'`),n}else if("message"in e&&typeof e.message=="string")return e.message;let t=YPC(e);if(WPC(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=$PC(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function $PC(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function YPC(e,t=40){let r=Object.keys(XPC(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return xOy(n,t);for(let i=r.length;i>0;i--){let a=r.slice(0,i).join(", ");if(!(a.length>t))return i===r.length?a:xOy(a,t)}return""}function xOy(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function XPC(e){return Zmf(e)?{message:e.message,name:e.name,stack:e.stack,...FOy(e)}:UPC(e)?{type:e.type,target:zOy(e.target),currentTarget:zOy(e.currentTarget),...FOy(e)}:e}function FOy(e){if(typeof e=="object"&&e!==null){let t={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}else return{}}function zOy(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function ZPC(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=kPC(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function kPC(e,t){return ewC(e(t.stack||"",1),e)}function ewC(e,t){let r=LPC(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var twC=2e3,DZa=class e{static async captureException(t,r,n,i,a){let o={...a};i||(o.$process_person_profile=!1);let c=await GPC(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||Wmf(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(zPC(this.onException.bind(this),this.onFatalError.bind(this)),QPC(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(twC)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function rwC(e=process.argv[1]?(0,MZa.dirname)(process.argv[1]):process.cwd(),t=MZa.sep==="\\"){let r=t?QOy(e):e;return n=>{if(!n)return;let i=t?QOy(n):n,{dir:a,base:o,ext:c}=MZa.posix.parse(i);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let u=a.lastIndexOf("/node_modules");if(u>-1)return`${a.slice(u+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let s=a.slice(r.length+1).replace(/\//g,".");return s?`${s}:${f}`:f}return f}}function QOy(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var qSu=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}},MSu=new qSu(25),_Ay=new qSu(20),kmf=7,nwC=1e3,iwC=1e4;async function awC(e){let t={};for(let i=e.length-1;i>=0;i--){let a=e[i],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||cwC(o)||lwC(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(_Ay.get(i))continue;let a=t[i];if(!a)continue;a.sort((f,u)=>f-u);let o=dwC(a);if(o.every(f=>fwC(i,f)))continue;let c=pwC(MSu,i,{});n.push(owC(i,o,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&swC(e,MSu),MSu.reduce(),e}function owC(e,t,r){return new Promise(n=>{let i=(0,cAy.createReadStream)(e),a=(0,lAy.createInterface)({input:i});function o(){i.destroy(),n()}let c=0,f=0,u=t[f];if(u===void 0){o();return}let s=u[0],l=u[1];function m(){_Ay.set(e,1),a.close(),a.removeAllListeners(),o()}i.on("error",m),a.on("error",m),a.on("close",o),a.on("line",O=>{if(c++,!(c<s)&&(r[c]=_wC(O,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let P=t[f];if(P===void 0){a.close(),a.removeAllListeners();return}s=P[0],l=P[1]}})})}function swC(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;uwC(r.lineno,r,n)}}function uwC(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=hAy(e);i<e;i++){let a=r[i];if(a===void 0){LOy(t);return}t.pre_context.push(a)}if(r[e]===void 0){LOy(t);return}t.context_line=r[e];let n=yAy(e);t.post_context=[];for(let i=e+1;i<=n;i++){let a=r[i];if(a===void 0)break;t.post_context.push(a)}}function LOy(e){delete e.pre_context,delete e.context_line,delete e.post_context}function cwC(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function lwC(e){return e.lineno!==void 0&&e.lineno>iwC||e.colno!==void 0&&e.colno>nwC}function fwC(e,t){let r=MSu.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function dwC(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=UOy(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let a=e[t+1];if(typeof a!="number")break;a<=n[1]?n[1]=a+kmf:(i.push(n),n=UOy(a)),t++}return i}function UOy(e){return[hAy(e),yAy(e)]}function hAy(e){return Math.max(1,e-kmf)}function yAy(e){return e+kmf}function pwC(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function _wC(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,n);return a>n-5&&(a=n),a===n&&(i=Math.max(a-140,0)),r=r.slice(i,a),i>0&&(r=`...${r}`),a<n&&(r+="..."),r}var hwC="4.18.0",dFe;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.DecideEndpointWasHit="decide_endpoint_was_hit",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config"})(dFe||(dFe={}));var VOy;(function(e){e.Left="left",e.Right="right",e.Center="center"})(VOy||(VOy={}));var WOy;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(WOy||(WOy={}));var GOy;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(GOy||(GOy={}));var HOy;(function(e){e.Html="html",e.Text="text"})(HOy||(HOy={}));var JOy;(function(e){e.Number="number",e.Emoji="emoji"})(JOy||(JOy={}));var KOy;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(KOy||(KOy={}));var $Oy;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})($Oy||($Oy={}));var YOy;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(YOy||(YOy={}));var XOy;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(XOy||(XOy={}));var ywC=e=>{if("flags"in e){let t=gwC(e.flags),r=bwC(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,vAy(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,vwC(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function vwC(e,t,r){return{key:e,enabled:typeof t=="string"?!0:t,variant:typeof t=="string"?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var gwC=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,eOf(r)]).filter(([,t])=>t!==void 0)),bwC=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let n=t[r];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(r=>{let n=t[r].metadata?.payload;return[r,n?vAy(n):void 0]}))},eOf=e=>e===void 0?void 0:e.variant??e.enabled,vAy=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},mwC=1,OwC=new Set(["61be3dd8","96f6df5f","8cfdba9b","bf027177","e59430a8","7fa5500b","569798e9","04809ff7","0ebc61a5","32de7f98","3beeb69a","12d34ad9","733853ec","0645bb64","5dcbee21","b1f95fa3","2189e408","82b460c2","3a8cc979","29ef8843","2cdbf767","38084b54","50f9f8de","41d0df91","5c236689","c11aedd3","ada46672","f4331ee1","42fed62a","c957462c","d62f705a","e0162666","01b3e5cf","441cef7f","bb9cafee","8f348eb0","b2553f3a","97469d7d","39f21a76","03706dcc","27d50569","307584a7","6433e92e","150c7fbb","49f57f22","3772f65b","01eb8256","3c9e9234","f853c7f7","c0ac4b67","cd609d40","10ca9b1a","8a87f11b","8e8e5216","1f6b63b3","db7943dd","79b7164c","07f78e33","2d21b6fd","952db5ee","a7d3b43f","1924dd9c","84e1b8f6","dff631b6","c5aa8a79","fa133a95","498a4508","24748755","98f3d658","21bbda67","7dbfed69","be3ec24c","fc80b8e2","75cc0998"]),AwC="utf8";function PwC(e,t){if(!e||typeof e!="string"||wwC(e))throw new Error(t)}function wwC(e){return e.trim().length===0}function jwC(e){return e?.replace(/\/+$/,"")}async function EwC(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function ZOy(){return new Date().getTime()}function Lmf(){return new Date().toISOString()}function RSu(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function SwC(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function DwC(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16).padStart(8,"0")}function CwC(e,t=0,r){let n=DwC(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function kOy(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var KKo=String.fromCharCode,eAy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ISu={};function IwC(e,t){if(!ISu[e]){ISu[e]={};for(let r=0;r<e.length;r++)ISu[e][e.charAt(r)]=r}return ISu[e][t]}var EZa={compressToBase64:function(e){if(e==null)return"";let t=EZa._compress(e,6,function(r){return eAy.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:EZa._decompress(e.length,32,function(t){return IwC(eAy,e.charAt(t))})},compress:function(e){return EZa._compress(e,16,function(t){return KKo(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],o,c,f="",u="",s="",l=2,m=3,O=2,P=0,C=0,I;for(I=0;I<e.length;I+=1)if(f=e.charAt(I),Object.prototype.hasOwnProperty.call(n,f)||(n[f]=m++,i[f]=!0),u=s+f,Object.prototype.hasOwnProperty.call(n,u))s=u;else{if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<O;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=s.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<O;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=s.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[s]}else for(c=n[s],o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[u]=m++,s=String(f)}if(s!==""){if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<O;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=s.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<O;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=s.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[s]}else for(c=n[s],o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(c=2,o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;for(;;)if(P=P<<1,C==t-1){a.push(r(P));break}else C++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:EZa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},o=4,c=4,f=3,u="",s,l,m,O,P,C,I;for(s=0;s<3;s+=1)n[s]=s;for(m=0,P=Math.pow(2,2),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;switch(m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;I=KKo(m);break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;I=KKo(m);break;case 2:return""}for(n[3]=I,l=I,i.push(I);;){if(a.index>e)return"";for(m=0,P=Math.pow(2,f),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;switch(I=m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;n[c++]=KKo(m),I=c-1,o--;break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;n[c++]=KKo(m),I=c-1,o--;break;case 2:return i.join("")}if(o==0&&(o=Math.pow(2,f),f++),n[I])u=n[I];else if(I===c)u=l+l.charAt(0);else return null;i.push(u),n[c++]=l+u.charAt(0),o--,l=u,o==0&&(o=Math.pow(2,f),f++)}}},Gmf=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}},CZa=class extends Error{constructor(t,r){super("HTTP error while fetching PostHog: status="+t.status+", reqByteLength="+r),this.response=t,this.reqByteLength=r,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},$Ko=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function tAy(e){if(e instanceof CZa){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function Umf(e){return typeof e=="object"&&(e instanceof CZa||e instanceof $Ko)}function rAy(e){return typeof e=="object"&&e instanceof CZa&&e.status===413}var Hmf;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(Hmf||(Hmf={}));var Jmf=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new Gmf,this._isInitialized=!1,PwC(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=jwC(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.preloadFeatureFlags=r?.preloadFeatureFlags??!0,this.defaultOptIn=r?.defaultOptIn??!0,this.disableSurveys=r?.disableSurveys??!1,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Umf},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r?.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(dFe.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(dFe.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(dFe.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Wmf();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}async identifyStatelessImmediate(t,r,n){let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",i,n)}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}async captureStatelessImmediate(t,r,n,i){let a=this.buildPayload({distinct_id:t,event:r,properties:n});await this.sendImmediate("capture",a,i)}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}async aliasStatelessImmediate(t,r,n,i){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,i)}groupIdentifyStateless(t,r,n,i,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...o||{}}});this.enqueue("capture",c,i)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(i=>i.json()).catch(i=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",i)),this._events.emit("error",i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let c=CwC(this.apiKey,mwC,OwC)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(u=>u.json()).then(u=>ywC(u)).catch(u=>{this._events.emit("error",u)})}async getFeatureFlagStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,n,i,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=eOf(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,n,i,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,n,i,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)).payloads}async getFeatureFlagsStateless(t,r={},n={},i={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,n,i,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let f=await this.getDecide(t,r,n,i,c);if(f!==void 0)return f.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),f.quotaLimited?.includes(Hmf.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:f?.requestId}):f}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},i=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return i&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(i))),i??[]}get props(){return this._props||(this._props=this.getPersistedProperty(dFe.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(dFe.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(dFe.Props,this.props)})}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i=this.prepareMessage(t,r,n),a=this.getPersistedProperty(dFe.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:i}),this.setPersistedProperty(dFe.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=RSu(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,n){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={api_key:this.apiKey,batch:[this.prepareMessage(t,r,n)],sent_at:Lmf()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${ZOy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,c=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(EZa.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(f){this._events.emit("error",f)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:Lmf(),uuid:n?.uuid?n.uuid:Wmf()};return(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId),i}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await tAy(t)})}async flush(){let t=kOy([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),kOy([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(dFe.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),a=i.map(m=>m.message),o=()=>{let O=(this.getPersistedProperty(dFe.Queue)||[]).slice(i.length);this.setPersistedProperty(dFe.Queue,O),t=O},c={api_key:this.apiKey,batch:a,sent_at:Lmf()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${ZOy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,s=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(EZa.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:m=>rAy(m)?!1:Umf(m)};try{await this.fetchWithRetry(u,s,l)}catch(m){if(rAy(m)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this.logMsgIfDebug(()=>console.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`));continue}throw m instanceof $Ko||o(),this._events.emit("error",m),m}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){var a;(a=AbortSignal).timeout??(a.timeout=function(u){let s=new AbortController;return setTimeout(()=>s.abort(),u),s.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,AwC)}catch{c=new TextEncoder().encode(o).length}return await EwC(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(s){throw new $Ko(s)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new CZa(f,c);return f},{...this._retryOptions,...n})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let n=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(dFe.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!Umf(i))throw i;await tAy(i)}};return Promise.race([new Promise((i,a)=>{RSu(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),n()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},Kmf=SwC();if(!Kmf){let e=TOy();Kmf=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var gAy=Kmf,NSu=class{constructor(t){this.factory=t}async getValue(){return this.value!==void 0?this.value:(this.initializationPromise===void 0&&(this.initializationPromise=(async()=>{try{let t=await this.factory();return this.value=t,t}finally{this.initializationPromise=void 0}})()),this.initializationPromise)}isInitialized(){return this.value!==void 0}async waitForInitialization(){this.isInitialized()||await this.getValue()}},bAy=new NSu(async()=>{try{return await import("crypto")}catch{return}});async function MwC(){return await bAy.getValue()}var BwC=new NSu(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await bAy.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function TwC(){return await BwC.getValue()}async function qwC(e){let t=await MwC();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await TwC();if(r){let n=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var RwC=60*1e3,NwC=1152921504606847e3,xwC=["is_not"],SZa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},jse=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},$mf=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=c.fetch||gAy,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let f of this.featureFlags)if(t===f.key){c=f;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof jse?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return o}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let u=await this.computeFlagLocally(f,t,r,n,i);a[f.key]=u;let s=await this.computeFeatureFlagPayloadLocally(f.key,u);s&&(o[f.key]=s)}catch(u){u instanceof jse||u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${u}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new jse("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let f=this.groupTypeMapping[String(c)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new jse("Flag has unknown group type index");if(!(f in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let u=a[f];return await this.matchFeatureFlagProperties(t,n[f],u)}else return await this.matchFeatureFlagProperties(t,r,i)}async matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],o=!1,c,f=[...a].sort((u,s)=>{let l=!!u.variant,m=!!s.variant;return l&&m?0:l?-1:m?1:0});for(let u of f)try{if(await this.isConditionMatch(t,r,u,n)){let s=u.variant,l=i.multivariate?.variants||[];s&&l.some(m=>m.key===s)?c=s:c=await this.getMatchingVariant(t,r)||!0;break}}catch(s){if(s instanceof jse)o=!0;else throw s}if(c!==void 0)return c;if(o)throw new jse("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i){let a=n.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((n.properties||[]).length>0){for(let c of n.properties){let f=c.type,u=!1;if(f==="cohort"?u=OAy(c,i,this.cohorts,this.debugMode):u=mAy(c,i,o),!u)return!1}if(a==null)return!0}return!(a!=null&&await nAy(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await nAy(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{i=n+c.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:c.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(RwC,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.getPollingInterval());try{let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new SZa(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new SZa(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new SZa(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof SZa&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=RSu(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,n=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;i=RSu(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function nAy(e,t,r=""){let n=await qwC(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/NwC}function mAy(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new jse("Operator is_not_set is not supported")}else throw new jse(`Property ${n} not found in propertyValues`);let o=t[n];if(o==null&&!xwC.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function c(u,s){return Array.isArray(u)?u.map(l=>String(l).toLowerCase()).includes(String(s).toLowerCase()):String(u).toLowerCase()===String(s).toLowerCase()}function f(u,s,l){if(l==="gt")return u>s;if(l==="gte")return u>=s;if(l==="lt")return u<s;if(l==="lte")return u<=s;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(i,o);case"is_not":return!c(i,o);case"is_set":return n in t;case"icontains":return String(o).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(i).toLowerCase());case"regex":return iAy(String(i))&&String(o).match(String(i))!==null;case"not_regex":return iAy(String(i))&&String(o).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let u=typeof i=="number"?i:null;if(typeof i=="string")try{u=parseFloat(i)}catch{}return u!=null&&o!=null?typeof o=="string"?f(o,String(i),a):f(o,u,a):f(String(o),String(i),a)}case"is_date_after":case"is_date_before":{let u=FwC(String(i));if(u==null&&(u=aAy(i)),u==null)throw new jse(`Invalid date: ${i}`);let s=aAy(o);return["is_date_before"].includes(a)?s<u:s>u}default:throw new jse(`Unknown operator: ${a}`)}}function OAy(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new jse("can't match cohort without a given cohort property value");let a=r[i];return AAy(a,t,r,n)}function AAy(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let f=AAy(c,t,r,n);if(i==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof jse)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new jse("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=OAy(c,t,r,n):f=mAy(c,t);let u=c.negation||!1;if(i==="AND"){if(!f&&!u||f&&u)return!1}else if(f&&!u||!f&&u)return!0}catch(f){if(f instanceof jse)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new jse("can't match cohort without a given cohort property value");return i==="AND"}}function iAy(e){try{return new RegExp(e),!0}catch{return!1}}function aAy(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new jse(`${e} is in an invalid date format`)}else throw new jse(`The date provided ${e} must be a string, number, or date object`)}function FwC(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var Ymf=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},zwC=100,oAy=30*1e3,QwC=50*1e3,Xmf=class extends Jmf{constructor(t,r={}){if(super(t,r),this._memoryStorage=new Ymf,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,zwC):oAy,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');this.featureFlagsPoller=new $mf({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new DZa(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||QwC}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):gAy(t,r)}getLibraryVersion(){return hwC}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:u}=t,s=O=>{super.captureStateless(r,n,O,{timestamp:c,disableGeoip:f,uuid:u})},l=async(O,P,C)=>(await super.getFeatureFlagsStateless(O,P,void 0,void 0,C)).flags,m=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let O={};for(let[P,C]of Object.entries(a||{}))O[P]=String(C);return await this.getAllFlags(r,{groups:O,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(O=>{let P={};if(O)for(let[I,T]of Object.entries(O))P[`$feature/${I}`]=T;let C=Object.keys(O||{}).filter(I=>O?.[I]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(O=>{s({...O,...i,$groups:a})});this.addPendingPromise(m)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:u}=t,s=O=>super.captureStatelessImmediate(r,n,O,{timestamp:c,disableGeoip:f,uuid:u}),l=async(O,P,C)=>(await super.getFeatureFlagsStateless(O,P,void 0,void 0,C)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let O={};for(let[P,C]of Object.entries(a||{}))O[P]=String(C);return await this.getAllFlags(r,{groups:O,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(O=>{let P={};if(O)for(let[I,T]of Object.entries(O))P[`$feature/${I}`]=T;let C=Object.keys(O||{}).filter(I=>O?.[I]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(O=>{s({...O,...i,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:i},{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=oAy){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(n),i(),r(a>0)})})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:u}=n||{},s=this.addLocalPersonAndGroupProperties(r,i,f,u);f=s.allPersonProperties,u=s.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,f,u),m=l!==void 0,O,P;if(!m&&!o){let I=await super.getFeatureFlagDetailStateless(t,r,i,f,u,a);if(I===void 0)return;P=I.response,l=eOf(P),O=I?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:P?.metadata?.id,$feature_flag_version:P?.metadata?.version,$feature_flag_reason:P?.reason?.description??P?.reason?.code,locally_evaluated:m,[`$feature/${t}`]:l,$feature_flag_request_id:O},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:o}=i||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:u,groupProperties:s}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,u,s);u=l.allPersonProperties,s=l.allGroupProperties;let m;return this.featureFlagsPoller!==void 0&&(n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(m!==void 0)&&!c&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,u,s,o)),m}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,n,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let u=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,o,c),s={},l={},m=!0;if(u&&(s=u.response,l=u.payloads,m=u.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,n,o,c,i);s={...s,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:s,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...i?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,n){let i=new Error("PostHog syntheticException");DZa.captureException(this,t,{syntheticException:i},r,n)}},sAy=/\(error: (.*)\)/,PAy=50,wAy="?";function LwC(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return n=>{let i=n.match(r);if(i){let a,o,c,f,u;if(i[1]){c=i[1];let m=c.lastIndexOf(".");if(c[m-1]==="."&&m--,m>0){a=c.slice(0,m),o=c.slice(m+1);let O=a.indexOf(".Module");O>0&&(c=c.slice(O+1),a=a.slice(0,O))}f=void 0}o&&(f=a,u=o),o==="<anonymous>"&&(u=void 0,c=void 0),c===void 0&&(u=u||wAy,c=f?`${f}.${u}`:u);let s=i[2]?.startsWith("file://")?i[2].slice(7):i[2],l=i[5]==="native";return s?.match(/\/[A-Z]:/)&&(s=s.slice(1)),!s&&i[5]&&!l&&(s=i[5]),{filename:s?decodeURI(s):void 0,module:e?e(s):void 0,function:c,lineno:uAy(i[3]),colno:uAy(i[4]),in_app:UwC(s||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function UwC(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.match(/^[A-Z]:/)&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes("node_modules/")}function uAy(e){return parseInt(e||"",10)||void 0}function VwC(e){return[90,LwC(e)]}function WwC(e){let r=[VwC(e)].sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0)=>{let a=[],o=n.split(`
|
|
2441
|
-
`);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=sAy.test(f)?f.replace(sAy,"$1"):f;if(!u.match(/\S*Error: /)){for(let s of r){let l=s(u);if(l){a.push(l);break}}if(a.length>=PAy)break}}return GwC(a)}}function GwC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,PAy).map(r=>({...r,filename:r.filename||HwC(t).filename,function:r.function||wAy}))}function HwC(e){return e[e.length-1]||{}}DZa.stackParser=WwC(rwC());DZa.frameModifiers=[awC];var IZa=class extends Xmf{getLibraryId(){return"posthog-node"}};var xSu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new IZa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"1.3.0-rc2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var YKo=class{async sendEvent(){}async identify(){}async flush(){}};var BZa=require("fs/promises"),DAy=require("os"),CAy=require("path");var jAy=Gi(require("crypto")),zSu=new Uint8Array(256),FSu=zSu.length;function tOf(){return FSu>zSu.length-16&&(jAy.default.randomFillSync(zSu),FSu=0),zSu.slice(FSu,FSu+=16)}var $ve=[];for(let e=0;e<256;++e)$ve.push((e+256).toString(16).slice(1));function EAy(e,t=0){return $ve[e[t+0]]+$ve[e[t+1]]+$ve[e[t+2]]+$ve[e[t+3]]+"-"+$ve[e[t+4]]+$ve[e[t+5]]+"-"+$ve[e[t+6]]+$ve[e[t+7]]+"-"+$ve[e[t+8]]+$ve[e[t+9]]+"-"+$ve[e[t+10]]+$ve[e[t+11]]+$ve[e[t+12]]+$ve[e[t+13]]+$ve[e[t+14]]+$ve[e[t+15]]}var SAy=Gi(require("crypto")),rOf={randomUUID:SAy.default.randomUUID};function JwC(e,t,r){if(rOf.randomUUID&&!t&&!e)return rOf.randomUUID();e=e||{};let n=e.random||(e.rng||tOf)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return EAy(n)}var zrt=JwC;var KwC="id",$wC=".fern",XKo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new IZa(r),this.userId=t==null?void 0:P_f(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"1.3.0-rc2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Sl(M_.of((0,DAy.homedir)()),Xs.of($wC),Xs.of(KwC));await Vv(t)||(await(0,BZa.mkdir)((0,CAy.dirname)(t),{recursive:!0}),await(0,BZa.writeFile)(t,zrt())),this.persistedDistinctId=(await(0,BZa.readFile)(t)).toString()}return this.persistedDistinctId}};var nOf;async function TZa(){return nOf==null&&(nOf=await YwC()),nOf}async function YwC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new YKo;let r=await rAu();return r!=null?new XKo({token:r,posthogApiKey:e}):await NYa()!=null?new xSu({posthogApiKey:e}):new XKo({token:void 0,posthogApiKey:e})}catch{return new YKo}}function ZKo(e,t){return function(){return e.apply(t,arguments)}}var{toString:XwC}=Object.prototype,{getPrototypeOf:aOf}=Object,{iterator:LSu,toStringTag:MAy}=Symbol,USu=(e=>t=>{let r=XwC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),kTr=e=>(e=e.toLowerCase(),t=>USu(t)===e),VSu=e=>t=>typeof t===e,{isArray:RZa}=Array,qZa=VSu("undefined");function kKo(e){return e!==null&&!qZa(e)&&e.constructor!==null&&!qZa(e.constructor)&&pFe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var BAy=kTr("ArrayBuffer");function ZwC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&BAy(e.buffer),t}var kwC=VSu("string"),pFe=VSu("function"),TAy=VSu("number"),e$o=e=>e!==null&&typeof e=="object",ejC=e=>e===!0||e===!1,QSu=e=>{if(USu(e)!=="object")return!1;let t=aOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(MAy in e)&&!(LSu in e)},tjC=e=>{if(!e$o(e)||kKo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rjC=kTr("Date"),njC=kTr("File"),ijC=kTr("Blob"),ajC=kTr("FileList"),ojC=e=>e$o(e)&&pFe(e.pipe),sjC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||pFe(e.append)&&((t=USu(e))==="formdata"||t==="object"&&pFe(e.toString)&&e.toString()==="[object FormData]"))},ujC=kTr("URLSearchParams"),[cjC,ljC,fjC,djC]=["ReadableStream","Request","Response","Headers"].map(kTr),pjC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function t$o(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),RZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(kKo(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function qAy(e,t){if(kKo(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var wua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,RAy=e=>!qZa(e)&&e!==wua;function iOf(){let{caseless:e,skipUndefined:t}=RAy(this)&&this||{},r={},n=(i,a)=>{let o=e&&qAy(r,a)||a;QSu(r[o])&&QSu(i)?r[o]=iOf(r[o],i):QSu(i)?r[o]=iOf({},i):RZa(i)?r[o]=i.slice():(!t||!qZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&t$o(arguments[i],n);return r}var _jC=(e,t,r,{allOwnKeys:n}={})=>(t$o(t,(i,a)=>{r&&pFe(i)?e[a]=ZKo(i,r):e[a]=i},{allOwnKeys:n}),e),hjC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),yjC=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},vjC=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&aOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},gjC=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},bjC=e=>{if(!e)return null;if(RZa(e))return e;let t=e.length;if(!TAy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},mjC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&aOf(Uint8Array)),OjC=(e,t)=>{let n=(e&&e[LSu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},AjC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},PjC=kTr("HTMLFormElement"),wjC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),IAy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),jjC=kTr("RegExp"),NAy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};t$o(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},EjC=e=>{NAy(e,(t,r)=>{if(pFe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(pFe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},SjC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return RZa(e)?n(e):n(String(e).split(t)),r},DjC=()=>{},CjC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function IjC(e){return!!(e&&pFe(e.append)&&e[MAy]==="FormData"&&e[LSu])}var MjC=e=>{let t=new Array(10),r=(n,i)=>{if(e$o(n)){if(t.indexOf(n)>=0)return;if(kKo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=RZa(n)?[]:{};return t$o(n,(o,c)=>{let f=r(o,i+1);!qZa(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},BjC=kTr("AsyncFunction"),TjC=e=>e&&(e$o(e)||pFe(e))&&pFe(e.then)&&pFe(e.catch),xAy=((e,t)=>e?setImmediate:t?((r,n)=>(wua.addEventListener("message",({source:i,data:a})=>{i===wua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),wua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pFe(wua.postMessage)),qjC=typeof queueMicrotask<"u"?queueMicrotask.bind(wua):typeof process<"u"&&process.nextTick||xAy,RjC=e=>e!=null&&pFe(e[LSu]),Zf={isArray:RZa,isArrayBuffer:BAy,isBuffer:kKo,isFormData:sjC,isArrayBufferView:ZwC,isString:kwC,isNumber:TAy,isBoolean:ejC,isObject:e$o,isPlainObject:QSu,isEmptyObject:tjC,isReadableStream:cjC,isRequest:ljC,isResponse:fjC,isHeaders:djC,isUndefined:qZa,isDate:rjC,isFile:njC,isBlob:ijC,isRegExp:jjC,isFunction:pFe,isStream:ojC,isURLSearchParams:ujC,isTypedArray:mjC,isFileList:ajC,forEach:t$o,merge:iOf,extend:_jC,trim:pjC,stripBOM:hjC,inherits:yjC,toFlatObject:vjC,kindOf:USu,kindOfTest:kTr,endsWith:gjC,toArray:bjC,forEachEntry:OjC,matchAll:AjC,isHTMLForm:PjC,hasOwnProperty:IAy,hasOwnProp:IAy,reduceDescriptors:NAy,freezeMethods:EjC,toObjectSet:SjC,toCamelCase:wjC,noop:DjC,toFiniteNumber:CjC,findKey:qAy,global:wua,isContextDefined:RAy,isSpecCompliantForm:IjC,toJSONObject:MjC,isAsyncFn:BjC,isThenable:TjC,setImmediate:xAy,asap:qjC,isIterable:RjC};function NZa(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Zf.inherits(NZa,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Zf.toJSONObject(this.config),code:this.code,status:this.status}}});var FAy=NZa.prototype,zAy={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{zAy[e]={value:e}});Object.defineProperties(NZa,zAy);Object.defineProperty(FAy,"isAxiosError",{value:!0});NZa.from=(e,t,r,n,i,a)=>{let o=Object.create(FAy);Zf.toFlatObject(e,o,function(s){return s!==Error.prototype},u=>u!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return NZa.call(o,c,f,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var zm=NZa;var QAy=Gi(csa(),1),WSu=QAy.default;function oOf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function UAy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function LAy(e,t,r){return e?e.concat(t).map(function(i,a){return i=UAy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function NjC(e){return Zf.isArray(e)&&!e.some(oOf)}var xjC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function FjC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(WSu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Zf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new zm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&NjC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=UAy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?LAy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return oOf(P)?!0:(t.append(LAy(I,C,a),u(P)),!1)}let l=[],m=Object.assign(xjC,{defaultVisitor:s,convertValue:u,isVisitable:oOf});function O(P,C){if(!Zf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Zf.forEach(P,function(T,z){(!(Zf.isUndefined(T)||T===null)&&i.call(t,T,Zf.isString(z)?z.trim():z,C,m))===!0&&O(T,C?C.concat(z):[z])}),l.pop()}}if(!Zf.isObject(e))throw new TypeError("data must be an object");return O(e),t}var g4i=FjC;function VAy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function WAy(e,t){this._pairs=[],e&&g4i(e,this,t)}var GAy=WAy.prototype;GAy.append=function(t,r){this._pairs.push([t,r])};GAy.toString=function(t){let r=t?function(n){return t.call(this,n,VAy)}:VAy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var HAy=WAy;function zjC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function jua(e,t,r){if(!t)return e;let n=r&&r.encode||zjC;Zf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Zf.isURLSearchParams(t)?t.toString():new HAy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var sOf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zf.forEach(this.handlers,function(n){n!==null&&t(n)})}},uOf=sOf;var xZa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var YAy=Gi(require("crypto"),1);var JAy=Gi(require("url"),1),KAy=JAy.default.URLSearchParams;var cOf="abcdefghijklmnopqrstuvwxyz",$Ay="0123456789",XAy={DIGIT:$Ay,ALPHA:cOf,ALPHA_DIGIT:cOf+cOf.toUpperCase()+$Ay},QjC=(e=16,t=XAy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);YAy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},ZAy={isNode:!0,classes:{URLSearchParams:KAy,FormData:WSu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:XAy,generateString:QjC,protocols:["http","https","file","data"]};var dOf={};yf(dOf,{hasBrowserEnv:()=>fOf,hasStandardBrowserEnv:()=>LjC,hasStandardBrowserWebWorkerEnv:()=>UjC,navigator:()=>lOf,origin:()=>VjC});var fOf=typeof window<"u"&&typeof document<"u",lOf=typeof navigator=="object"&&navigator||void 0,LjC=fOf&&(!lOf||["ReactNative","NativeScript","NS"].indexOf(lOf.product)<0),UjC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",VjC=fOf&&window.location.href||"http://localhost";var J8={...dOf,...ZAy};function pOf(e,t){return g4i(e,new J8.classes.URLSearchParams,{visitor:function(r,n,i,a){return J8.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function WjC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function GjC(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function HjC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&Zf.isArray(i)?i.length:o,f?(Zf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Zf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Zf.isArray(i[o])&&(i[o]=GjC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(WjC(n),i,r,0)}),r}return null}var GSu=HjC;function JjC(e,t,r){if(Zf.isString(e))try{return(t||JSON.parse)(e),Zf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var _Of={transitional:xZa,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Zf.isObject(t);if(a&&Zf.isHTMLForm(t)&&(t=new FormData(t)),Zf.isFormData(t))return i?JSON.stringify(GSu(t)):t;if(Zf.isArrayBuffer(t)||Zf.isBuffer(t)||Zf.isStream(t)||Zf.isFile(t)||Zf.isBlob(t)||Zf.isReadableStream(t))return t;if(Zf.isArrayBufferView(t))return t.buffer;if(Zf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return pOf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return g4i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),JjC(t)):t}],transformResponse:[function(t){let r=this.transitional||_Of.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Zf.isResponse(t)||Zf.isReadableStream(t))return t;if(t&&Zf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?zm.from(c,zm.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:J8.classes.FormData,Blob:J8.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zf.forEach(["delete","get","head","post","put","patch"],e=>{_Of.headers[e]={}});var FZa=_Of;var KjC=Zf.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),kAy=e=>{let t={},r,n,i;return e&&e.split(`
|
|
2441
|
+
`);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=sAy.test(f)?f.replace(sAy,"$1"):f;if(!u.match(/\S*Error: /)){for(let s of r){let l=s(u);if(l){a.push(l);break}}if(a.length>=PAy)break}}return GwC(a)}}function GwC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,PAy).map(r=>({...r,filename:r.filename||HwC(t).filename,function:r.function||wAy}))}function HwC(e){return e[e.length-1]||{}}DZa.stackParser=WwC(rwC());DZa.frameModifiers=[awC];var IZa=class extends Xmf{getLibraryId(){return"posthog-node"}};var xSu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new IZa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"1.3.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var YKo=class{async sendEvent(){}async identify(){}async flush(){}};var BZa=require("fs/promises"),DAy=require("os"),CAy=require("path");var jAy=Gi(require("crypto")),zSu=new Uint8Array(256),FSu=zSu.length;function tOf(){return FSu>zSu.length-16&&(jAy.default.randomFillSync(zSu),FSu=0),zSu.slice(FSu,FSu+=16)}var $ve=[];for(let e=0;e<256;++e)$ve.push((e+256).toString(16).slice(1));function EAy(e,t=0){return $ve[e[t+0]]+$ve[e[t+1]]+$ve[e[t+2]]+$ve[e[t+3]]+"-"+$ve[e[t+4]]+$ve[e[t+5]]+"-"+$ve[e[t+6]]+$ve[e[t+7]]+"-"+$ve[e[t+8]]+$ve[e[t+9]]+"-"+$ve[e[t+10]]+$ve[e[t+11]]+$ve[e[t+12]]+$ve[e[t+13]]+$ve[e[t+14]]+$ve[e[t+15]]}var SAy=Gi(require("crypto")),rOf={randomUUID:SAy.default.randomUUID};function JwC(e,t,r){if(rOf.randomUUID&&!t&&!e)return rOf.randomUUID();e=e||{};let n=e.random||(e.rng||tOf)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return EAy(n)}var zrt=JwC;var KwC="id",$wC=".fern",XKo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new IZa(r),this.userId=t==null?void 0:P_f(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"1.3.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Sl(M_.of((0,DAy.homedir)()),Xs.of($wC),Xs.of(KwC));await Vv(t)||(await(0,BZa.mkdir)((0,CAy.dirname)(t),{recursive:!0}),await(0,BZa.writeFile)(t,zrt())),this.persistedDistinctId=(await(0,BZa.readFile)(t)).toString()}return this.persistedDistinctId}};var nOf;async function TZa(){return nOf==null&&(nOf=await YwC()),nOf}async function YwC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new YKo;let r=await rAu();return r!=null?new XKo({token:r,posthogApiKey:e}):await NYa()!=null?new xSu({posthogApiKey:e}):new XKo({token:void 0,posthogApiKey:e})}catch{return new YKo}}function ZKo(e,t){return function(){return e.apply(t,arguments)}}var{toString:XwC}=Object.prototype,{getPrototypeOf:aOf}=Object,{iterator:LSu,toStringTag:MAy}=Symbol,USu=(e=>t=>{let r=XwC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),kTr=e=>(e=e.toLowerCase(),t=>USu(t)===e),VSu=e=>t=>typeof t===e,{isArray:RZa}=Array,qZa=VSu("undefined");function kKo(e){return e!==null&&!qZa(e)&&e.constructor!==null&&!qZa(e.constructor)&&pFe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var BAy=kTr("ArrayBuffer");function ZwC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&BAy(e.buffer),t}var kwC=VSu("string"),pFe=VSu("function"),TAy=VSu("number"),e$o=e=>e!==null&&typeof e=="object",ejC=e=>e===!0||e===!1,QSu=e=>{if(USu(e)!=="object")return!1;let t=aOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(MAy in e)&&!(LSu in e)},tjC=e=>{if(!e$o(e)||kKo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rjC=kTr("Date"),njC=kTr("File"),ijC=kTr("Blob"),ajC=kTr("FileList"),ojC=e=>e$o(e)&&pFe(e.pipe),sjC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||pFe(e.append)&&((t=USu(e))==="formdata"||t==="object"&&pFe(e.toString)&&e.toString()==="[object FormData]"))},ujC=kTr("URLSearchParams"),[cjC,ljC,fjC,djC]=["ReadableStream","Request","Response","Headers"].map(kTr),pjC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function t$o(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),RZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(kKo(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function qAy(e,t){if(kKo(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var wua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,RAy=e=>!qZa(e)&&e!==wua;function iOf(){let{caseless:e,skipUndefined:t}=RAy(this)&&this||{},r={},n=(i,a)=>{let o=e&&qAy(r,a)||a;QSu(r[o])&&QSu(i)?r[o]=iOf(r[o],i):QSu(i)?r[o]=iOf({},i):RZa(i)?r[o]=i.slice():(!t||!qZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&t$o(arguments[i],n);return r}var _jC=(e,t,r,{allOwnKeys:n}={})=>(t$o(t,(i,a)=>{r&&pFe(i)?e[a]=ZKo(i,r):e[a]=i},{allOwnKeys:n}),e),hjC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),yjC=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},vjC=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&aOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},gjC=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},bjC=e=>{if(!e)return null;if(RZa(e))return e;let t=e.length;if(!TAy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},mjC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&aOf(Uint8Array)),OjC=(e,t)=>{let n=(e&&e[LSu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},AjC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},PjC=kTr("HTMLFormElement"),wjC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),IAy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),jjC=kTr("RegExp"),NAy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};t$o(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},EjC=e=>{NAy(e,(t,r)=>{if(pFe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(pFe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},SjC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return RZa(e)?n(e):n(String(e).split(t)),r},DjC=()=>{},CjC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function IjC(e){return!!(e&&pFe(e.append)&&e[MAy]==="FormData"&&e[LSu])}var MjC=e=>{let t=new Array(10),r=(n,i)=>{if(e$o(n)){if(t.indexOf(n)>=0)return;if(kKo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=RZa(n)?[]:{};return t$o(n,(o,c)=>{let f=r(o,i+1);!qZa(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},BjC=kTr("AsyncFunction"),TjC=e=>e&&(e$o(e)||pFe(e))&&pFe(e.then)&&pFe(e.catch),xAy=((e,t)=>e?setImmediate:t?((r,n)=>(wua.addEventListener("message",({source:i,data:a})=>{i===wua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),wua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pFe(wua.postMessage)),qjC=typeof queueMicrotask<"u"?queueMicrotask.bind(wua):typeof process<"u"&&process.nextTick||xAy,RjC=e=>e!=null&&pFe(e[LSu]),Zf={isArray:RZa,isArrayBuffer:BAy,isBuffer:kKo,isFormData:sjC,isArrayBufferView:ZwC,isString:kwC,isNumber:TAy,isBoolean:ejC,isObject:e$o,isPlainObject:QSu,isEmptyObject:tjC,isReadableStream:cjC,isRequest:ljC,isResponse:fjC,isHeaders:djC,isUndefined:qZa,isDate:rjC,isFile:njC,isBlob:ijC,isRegExp:jjC,isFunction:pFe,isStream:ojC,isURLSearchParams:ujC,isTypedArray:mjC,isFileList:ajC,forEach:t$o,merge:iOf,extend:_jC,trim:pjC,stripBOM:hjC,inherits:yjC,toFlatObject:vjC,kindOf:USu,kindOfTest:kTr,endsWith:gjC,toArray:bjC,forEachEntry:OjC,matchAll:AjC,isHTMLForm:PjC,hasOwnProperty:IAy,hasOwnProp:IAy,reduceDescriptors:NAy,freezeMethods:EjC,toObjectSet:SjC,toCamelCase:wjC,noop:DjC,toFiniteNumber:CjC,findKey:qAy,global:wua,isContextDefined:RAy,isSpecCompliantForm:IjC,toJSONObject:MjC,isAsyncFn:BjC,isThenable:TjC,setImmediate:xAy,asap:qjC,isIterable:RjC};function NZa(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Zf.inherits(NZa,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Zf.toJSONObject(this.config),code:this.code,status:this.status}}});var FAy=NZa.prototype,zAy={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{zAy[e]={value:e}});Object.defineProperties(NZa,zAy);Object.defineProperty(FAy,"isAxiosError",{value:!0});NZa.from=(e,t,r,n,i,a)=>{let o=Object.create(FAy);Zf.toFlatObject(e,o,function(s){return s!==Error.prototype},u=>u!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return NZa.call(o,c,f,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var zm=NZa;var QAy=Gi(csa(),1),WSu=QAy.default;function oOf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function UAy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function LAy(e,t,r){return e?e.concat(t).map(function(i,a){return i=UAy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function NjC(e){return Zf.isArray(e)&&!e.some(oOf)}var xjC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function FjC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(WSu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Zf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new zm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&NjC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=UAy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?LAy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return oOf(P)?!0:(t.append(LAy(I,C,a),u(P)),!1)}let l=[],m=Object.assign(xjC,{defaultVisitor:s,convertValue:u,isVisitable:oOf});function O(P,C){if(!Zf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Zf.forEach(P,function(T,z){(!(Zf.isUndefined(T)||T===null)&&i.call(t,T,Zf.isString(z)?z.trim():z,C,m))===!0&&O(T,C?C.concat(z):[z])}),l.pop()}}if(!Zf.isObject(e))throw new TypeError("data must be an object");return O(e),t}var g4i=FjC;function VAy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function WAy(e,t){this._pairs=[],e&&g4i(e,this,t)}var GAy=WAy.prototype;GAy.append=function(t,r){this._pairs.push([t,r])};GAy.toString=function(t){let r=t?function(n){return t.call(this,n,VAy)}:VAy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var HAy=WAy;function zjC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function jua(e,t,r){if(!t)return e;let n=r&&r.encode||zjC;Zf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Zf.isURLSearchParams(t)?t.toString():new HAy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var sOf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zf.forEach(this.handlers,function(n){n!==null&&t(n)})}},uOf=sOf;var xZa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var YAy=Gi(require("crypto"),1);var JAy=Gi(require("url"),1),KAy=JAy.default.URLSearchParams;var cOf="abcdefghijklmnopqrstuvwxyz",$Ay="0123456789",XAy={DIGIT:$Ay,ALPHA:cOf,ALPHA_DIGIT:cOf+cOf.toUpperCase()+$Ay},QjC=(e=16,t=XAy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);YAy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},ZAy={isNode:!0,classes:{URLSearchParams:KAy,FormData:WSu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:XAy,generateString:QjC,protocols:["http","https","file","data"]};var dOf={};yf(dOf,{hasBrowserEnv:()=>fOf,hasStandardBrowserEnv:()=>LjC,hasStandardBrowserWebWorkerEnv:()=>UjC,navigator:()=>lOf,origin:()=>VjC});var fOf=typeof window<"u"&&typeof document<"u",lOf=typeof navigator=="object"&&navigator||void 0,LjC=fOf&&(!lOf||["ReactNative","NativeScript","NS"].indexOf(lOf.product)<0),UjC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",VjC=fOf&&window.location.href||"http://localhost";var J8={...dOf,...ZAy};function pOf(e,t){return g4i(e,new J8.classes.URLSearchParams,{visitor:function(r,n,i,a){return J8.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function WjC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function GjC(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function HjC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&Zf.isArray(i)?i.length:o,f?(Zf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Zf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Zf.isArray(i[o])&&(i[o]=GjC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(WjC(n),i,r,0)}),r}return null}var GSu=HjC;function JjC(e,t,r){if(Zf.isString(e))try{return(t||JSON.parse)(e),Zf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var _Of={transitional:xZa,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Zf.isObject(t);if(a&&Zf.isHTMLForm(t)&&(t=new FormData(t)),Zf.isFormData(t))return i?JSON.stringify(GSu(t)):t;if(Zf.isArrayBuffer(t)||Zf.isBuffer(t)||Zf.isStream(t)||Zf.isFile(t)||Zf.isBlob(t)||Zf.isReadableStream(t))return t;if(Zf.isArrayBufferView(t))return t.buffer;if(Zf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return pOf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return g4i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),JjC(t)):t}],transformResponse:[function(t){let r=this.transitional||_Of.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Zf.isResponse(t)||Zf.isReadableStream(t))return t;if(t&&Zf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?zm.from(c,zm.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:J8.classes.FormData,Blob:J8.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zf.forEach(["delete","get","head","post","put","patch"],e=>{_Of.headers[e]={}});var FZa=_Of;var KjC=Zf.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),kAy=e=>{let t={},r,n,i;return e&&e.split(`
|
|
2442
2442
|
`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&KjC[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var ePy=Symbol("internals");function r$o(e){return e&&String(e).trim().toLowerCase()}function HSu(e){return e===!1||e==null?e:Zf.isArray(e)?e.map(HSu):String(e)}function $jC(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var YjC=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function hOf(e,t,r,n,i){if(Zf.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Zf.isString(t)){if(Zf.isString(n))return t.indexOf(n)!==-1;if(Zf.isRegExp(n))return n.test(t)}}function XjC(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function ZjC(e,t){let r=Zf.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,o){return this[n].call(this,t,i,a,o)},configurable:!0})})}var zZa=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,f,u){let s=r$o(f);if(!s)throw new Error("header name must be a non-empty string");let l=Zf.findKey(i,s);(!l||i[l]===void 0||u===!0||u===void 0&&i[l]!==!1)&&(i[l||f]=HSu(c))}let o=(c,f)=>Zf.forEach(c,(u,s)=>a(u,s,f));if(Zf.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(Zf.isString(t)&&(t=t.trim())&&!YjC(t))o(kAy(t),r);else if(Zf.isObject(t)&&Zf.isIterable(t)){let c={},f,u;for(let s of t){if(!Zf.isArray(s))throw TypeError("Object iterator must return a key-value pair");c[u=s[0]]=(f=c[u])?Zf.isArray(f)?[...f,s[1]]:[f,s[1]]:s[1]}o(c,r)}else t!=null&&a(r,t,n);return this}get(t,r){if(t=r$o(t),t){let n=Zf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return $jC(i);if(Zf.isFunction(r))return r.call(this,i,n);if(Zf.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=r$o(t),t){let n=Zf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||hOf(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(o){if(o=r$o(o),o){let c=Zf.findKey(n,o);c&&(!r||hOf(n,n[c],c,r))&&(delete n[c],i=!0)}}return Zf.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||hOf(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Zf.forEach(this,(i,a)=>{let o=Zf.findKey(n,a);if(o){r[o]=HSu(i),delete r[a];return}let c=t?XjC(a):String(a).trim();c!==a&&delete r[a],r[c]=HSu(i),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Zf.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Zf.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
2443
2443
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[ePy]=this[ePy]={accessors:{}}).accessors,i=this.prototype;function a(o){let c=r$o(o);n[c]||(ZjC(i,o),n[c]=!0)}return Zf.isArray(t)?t.forEach(a):a(t),this}};zZa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Zf.reduceDescriptors(zZa.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Zf.freezeMethods(zZa);var b$=zZa;function n$o(e,t){let r=this||FZa,n=t||r,i=b$.from(n.headers),a=n.data;return Zf.forEach(e,function(c){a=c.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function i$o(e){return!!(e&&e.__CANCEL__)}function tPy(e,t,r){zm.call(this,e??"canceled",zm.ERR_CANCELED,t,r),this.name="CanceledError"}Zf.inherits(tPy,zm,{__CANCEL__:!0});var Qrt=tPy;function SUr(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new zm("Request failed with status code "+r.status,[zm.ERR_BAD_REQUEST,zm.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function yOf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function vOf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Eua(e,t,r){let n=!yOf(t);return e&&(n||r==!1)?vOf(e,t):t}var vPy=Gi(pSu(),1),gPy=Gi(require("http"),1),bPy=Gi(require("https"),1),mPy=Gi(require("util"),1),OPy=Gi(gmf(),1),MAi=Gi(require("zlib"),1);var Sua="1.12.2";function a$o(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var kjC=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function gOf(e,t,r){let n=r&&r.Blob||J8.classes.Blob,i=a$o(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=kjC.exec(e);if(!a)throw new zm("Invalid URL",zm.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],u=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!n)throw new zm("Blob is not supported",zm.ERR_NOT_SUPPORT);return new n([u],{type:o})}return u}throw new zm("Unsupported protocol "+i,zm.ERR_NOT_SUPPORT)}var Cua=Gi(require("stream"),1);var rPy=Gi(require("stream"),1);var bOf=Symbol("internals"),mOf=class extends rPy.default.Transform{constructor(t){t=Zf.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Zf.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[bOf]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[bOf];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[bOf],a=i.maxRate,o=this.readableHighWaterMark,c=i.timeWindow,f=1e3/c,u=a/f,s=i.minChunkSize!==!1?Math.max(i.minChunkSize,u*.01):0,l=(O,P)=>{let C=Buffer.byteLength(O);i.bytesSeen+=C,i.bytes+=C,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(O)?process.nextTick(P):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(P)}},m=(O,P)=>{let C=Buffer.byteLength(O),I=null,T=o,z,U=0;if(a){let q=Date.now();(!i.ts||(U=q-i.ts)>=c)&&(i.ts=q,z=u-i.bytes,i.bytes=z<0?-z:0,U=0),z=u-i.bytes}if(a){if(z<=0)return setTimeout(()=>{P(null,O)},c-U);z<T&&(T=z)}T&&C>T&&C-T>s&&(I=O.subarray(T),O=O.subarray(0,T)),l(O,I?()=>{process.nextTick(P,null,I)}:P)};m(t,function O(P,C){if(P)return n(P);C?m(C,O):n(null)})}},OOf=mOf;var APy=require("events");var iPy=Gi(require("util"),1),aPy=require("stream");var{asyncIterator:nPy}=Symbol,e1C=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[nPy]?yield*e[nPy]():yield e},JSu=e1C;var t1C=J8.ALPHABET.ALPHA_DIGIT+"-_",o$o=typeof TextEncoder=="function"?new TextEncoder:new iPy.default.TextEncoder,Dua=`\r
|
|
2444
2444
|
`,r1C=o$o.encode(Dua),n1C=2,AOf=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Zf.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${Dua}`;i?r=o$o.encode(String(r).replace(/\r?\n|\r\n?/g,Dua)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Dua}`,this.headers=o$o.encode(a+Dua),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+n1C,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Zf.isTypedArray(t)?yield t:yield*JSu(t),yield r1C}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},i1C=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+J8.generateString(i,t1C)}=r||{};if(!Zf.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=o$o.encode("--"+a+Dua),c=o$o.encode("--"+a+"--"+Dua),f=c.byteLength,u=Array.from(e.entries()).map(([l,m])=>{let O=new AOf(l,m);return f+=O.size,O});f+=o.byteLength*u.length,f=Zf.toFiniteNumber(f);let s={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(s["Content-Length"]=f),t&&t(s),aPy.Readable.from((async function*(){for(let l of u)yield o,yield*l.encode();yield c})())},oPy=i1C;var sPy=Gi(require("stream"),1),POf=class extends sPy.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},uPy=POf;var a1C=(e,t)=>Zf.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,cPy=a1C;function o1C(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let u=Date.now(),s=n[a];o||(o=u),r[i]=f,n[i]=u;let l=a,m=0;for(;l!==i;)m+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),u-o<t)return;let O=s&&u-s;return O?Math.round(m*1e3/O):void 0}}var lPy=o1C;function s1C(e,t){let r=0,n=1e3/t,i,a,o=(u,s=Date.now())=>{r=s,i=null,a&&(clearTimeout(a),a=null),e(...u)};return[(...u)=>{let s=Date.now(),l=s-r;l>=n?o(u,s):(i=u,a||(a=setTimeout(()=>{a=null,o(i)},n-l)))},()=>i&&o(i)]}var fPy=s1C;var IAi=(e,t,r=3)=>{let n=0,i=lPy(50,250);return fPy(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-n,u=i(f),s=o<=c;n=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:u||void 0,estimated:u&&c&&s?(c-o)/u:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},QZa=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},LZa=e=>(...t)=>Zf.asap(()=>e(...t));function wOf(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let a=n.length,o=n.length;for(let m=0;m<o;m++)if(n.charCodeAt(m)===37&&m+2<o){let O=n.charCodeAt(m+1),P=n.charCodeAt(m+2);(O>=48&&O<=57||O>=65&&O<=70||O>=97&&O<=102)&&(P>=48&&P<=57||P>=65&&P<=70||P>=97&&P<=102)&&(a-=2,m+=2)}let c=0,f=o-1,u=m=>m>=2&&n.charCodeAt(m-2)===37&&n.charCodeAt(m-1)===51&&(n.charCodeAt(m)===68||n.charCodeAt(m)===100);f>=0&&(n.charCodeAt(f)===61?(c++,f--):u(f)&&(c++,f-=3)),c===1&&f>=0&&(n.charCodeAt(f)===61||u(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(n,"utf8")}var dPy={flush:MAi.default.constants.Z_SYNC_FLUSH,finishFlush:MAi.default.constants.Z_SYNC_FLUSH},u1C={flush:MAi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:MAi.default.constants.BROTLI_OPERATION_FLUSH},pPy=Zf.isFunction(MAi.default.createBrotliDecompress),{http:c1C,https:l1C}=OPy.default,f1C=/https:?/,_Py=J8.protocols.map(e=>e+":"),hPy=(e,[t,r])=>(e.on("end",r).on("error",r),t);function d1C(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function PPy(e,t,r){let n=t;if(!n&&n!==!1){let i=vPy.default.getProxyForUrl(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){PPy(a,t,a.href)}}var p1C=typeof process<"u"&&Zf.kindOf(process)==="process",_1C=e=>new Promise((t,r)=>{let n,i,a=(f,u)=>{i||(i=!0,n&&n(f,u))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>n=f).catch(c)}),h1C=({address:e,family:t})=>{if(!Zf.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},yPy=(e,t)=>h1C(Zf.isObject(e)?e:{address:e,family:t}),wPy=p1C&&function(t){return _1C(async function(n,i,a){let{data:o,lookup:c,family:f}=t,{responseType:u,responseEncoding:s}=t,l=t.method.toUpperCase(),m,O=!1,P;if(c){let Ae=cPy(c,mt=>Zf.isArray(mt)?mt:[mt]);c=(mt,Ot,ze)=>{Ae(mt,Ot,(Be,er,pt)=>{if(Be)return ze(Be);let Or=Zf.isArray(er)?er.map(Zt=>yPy(Zt)):[yPy(er,pt)];Ot.all?ze(Be,Or):ze(Be,Or[0].address,Or[0].family)})}}let C=new APy.EventEmitter,I=()=>{t.cancelToken&&t.cancelToken.unsubscribe(T),t.signal&&t.signal.removeEventListener("abort",T),C.removeAllListeners()};a((Ae,mt)=>{m=!0,mt&&(O=!0,I())});function T(Ae){C.emit("abort",!Ae||Ae.type?new Qrt(null,t,P):Ae)}C.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(T),t.signal&&(t.signal.aborted?T():t.signal.addEventListener("abort",T)));let z=Eua(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(z,J8.hasBrowserEnv?J8.origin:void 0),q=U.protocol||_Py[0];if(q==="data:"){if(t.maxContentLength>-1){let mt=String(t.url||z||"");if(wOf(mt)>t.maxContentLength)return i(new zm("maxContentLength size of "+t.maxContentLength+" exceeded",zm.ERR_BAD_RESPONSE,t))}let Ae;if(l!=="GET")return SUr(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Ae=gOf(t.url,u==="blob",{Blob:t.env&&t.env.Blob})}catch(mt){throw zm.from(mt,zm.ERR_BAD_REQUEST,t)}return u==="text"?(Ae=Ae.toString(s),(!s||s==="utf8")&&(Ae=Zf.stripBOM(Ae))):u==="stream"&&(Ae=Cua.default.Readable.from(Ae)),SUr(n,i,{data:Ae,status:200,statusText:"OK",headers:new b$,config:t})}if(_Py.indexOf(q)===-1)return i(new zm("Unsupported protocol "+q,zm.ERR_BAD_REQUEST,t));let V=b$.from(t.headers).normalize();V.set("User-Agent","axios/"+Sua,!1);let{onUploadProgress:$,onDownloadProgress:re}=t,Y=t.maxRate,k,ne;if(Zf.isSpecCompliantForm(o)){let Ae=V.getContentType(/boundary=([-_\w\d]{10,70})/i);o=oPy(o,mt=>{V.set(mt)},{tag:`axios-${Sua}-boundary`,boundary:Ae&&Ae[1]||void 0})}else if(Zf.isFormData(o)&&Zf.isFunction(o.getHeaders)){if(V.set(o.getHeaders()),!V.hasContentLength())try{let Ae=await mPy.default.promisify(o.getLength).call(o);Number.isFinite(Ae)&&Ae>=0&&V.setContentLength(Ae)}catch{}}else if(Zf.isBlob(o)||Zf.isFile(o))o.size&&V.setContentType(o.type||"application/octet-stream"),V.setContentLength(o.size||0),o=Cua.default.Readable.from(JSu(o));else if(o&&!Zf.isStream(o)){if(!Buffer.isBuffer(o))if(Zf.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(Zf.isString(o))o=Buffer.from(o,"utf-8");else return i(new zm("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",zm.ERR_BAD_REQUEST,t));if(V.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return i(new zm("Request body larger than maxBodyLength limit",zm.ERR_BAD_REQUEST,t))}let Oe=Zf.toFiniteNumber(V.getContentLength());Zf.isArray(Y)?(k=Y[0],ne=Y[1]):k=ne=Y,o&&($||k)&&(Zf.isStream(o)||(o=Cua.default.Readable.from(o,{objectMode:!1})),o=Cua.default.pipeline([o,new OOf({maxRate:Zf.toFiniteNumber(k)})],Zf.noop),$&&o.on("progress",hPy(o,QZa(Oe,IAi(LZa($),!1,3)))));let pe;if(t.auth){let Ae=t.auth.username||"",mt=t.auth.password||"";pe=Ae+":"+mt}if(!pe&&U.username){let Ae=U.username,mt=U.password;pe=Ae+":"+mt}pe&&V.delete("authorization");let ge;try{ge=jua(U.pathname+U.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Ae){let mt=new Error(Ae.message);return mt.config=t,mt.url=t.url,mt.exists=!0,i(mt)}V.set("Accept-Encoding","gzip, compress, deflate"+(pPy?", br":""),!1);let _e={path:ge,method:l,headers:V.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:pe,protocol:q,family:f,beforeRedirect:d1C,beforeRedirects:{}};!Zf.isUndefined(c)&&(_e.lookup=c),t.socketPath?_e.socketPath=t.socketPath:(_e.hostname=U.hostname.startsWith("[")?U.hostname.slice(1,-1):U.hostname,_e.port=U.port,PPy(_e,t.proxy,q+"//"+U.hostname+(U.port?":"+U.port:"")+_e.path));let Ce,Se=f1C.test(_e.protocol);if(_e.agent=Se?t.httpsAgent:t.httpAgent,t.transport?Ce=t.transport:t.maxRedirects===0?Ce=Se?bPy.default:gPy.default:(t.maxRedirects&&(_e.maxRedirects=t.maxRedirects),t.beforeRedirect&&(_e.beforeRedirects.config=t.beforeRedirect),Ce=Se?l1C:c1C),t.maxBodyLength>-1?_e.maxBodyLength=t.maxBodyLength:_e.maxBodyLength=1/0,t.insecureHTTPParser&&(_e.insecureHTTPParser=t.insecureHTTPParser),P=Ce.request(_e,function(mt){if(P.destroyed)return;let Ot=[mt],ze=+mt.headers["content-length"];if(re||ne){let Zt=new OOf({maxRate:Zf.toFiniteNumber(ne)});re&&Zt.on("progress",hPy(Zt,QZa(ze,IAi(LZa(re),!0,3)))),Ot.push(Zt)}let Be=mt,er=mt.req||P;if(t.decompress!==!1&&mt.headers["content-encoding"])switch((l==="HEAD"||mt.statusCode===204)&&delete mt.headers["content-encoding"],(mt.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Ot.push(MAi.default.createUnzip(dPy)),delete mt.headers["content-encoding"];break;case"deflate":Ot.push(new uPy),Ot.push(MAi.default.createUnzip(dPy)),delete mt.headers["content-encoding"];break;case"br":pPy&&(Ot.push(MAi.default.createBrotliDecompress(u1C)),delete mt.headers["content-encoding"])}Be=Ot.length>1?Cua.default.pipeline(Ot,Zf.noop):Ot[0];let pt=Cua.default.finished(Be,()=>{pt(),I()}),Or={status:mt.statusCode,statusText:mt.statusMessage,headers:new b$(mt.headers),config:t,request:er};if(u==="stream")Or.data=Be,SUr(n,i,Or);else{let Zt=[],rt=0;Be.on("data",function(Ht){Zt.push(Ht),rt+=Ht.length,t.maxContentLength>-1&&rt>t.maxContentLength&&(O=!0,Be.destroy(),i(new zm("maxContentLength size of "+t.maxContentLength+" exceeded",zm.ERR_BAD_RESPONSE,t,er)))}),Be.on("aborted",function(){if(O)return;let Ht=new zm("stream has been aborted",zm.ERR_BAD_RESPONSE,t,er);Be.destroy(Ht),i(Ht)}),Be.on("error",function(Ht){P.destroyed||i(zm.from(Ht,null,t,er))}),Be.on("end",function(){try{let Ht=Zt.length===1?Zt[0]:Buffer.concat(Zt);u!=="arraybuffer"&&(Ht=Ht.toString(s),(!s||s==="utf8")&&(Ht=Zf.stripBOM(Ht))),Or.data=Ht}catch(Ht){return i(zm.from(Ht,null,t,Or.request,Or))}SUr(n,i,Or)})}C.once("abort",Zt=>{Be.destroyed||(Be.emit("error",Zt),Be.destroy())})}),C.once("abort",Ae=>{i(Ae),P.destroy(Ae)}),P.on("error",function(mt){i(zm.from(mt,null,t,P))}),P.on("socket",function(mt){mt.setKeepAlive(!0,1e3*60)}),t.timeout){let Ae=parseInt(t.timeout,10);if(Number.isNaN(Ae)){i(new zm("error trying to parse `config.timeout` to int",zm.ERR_BAD_OPTION_VALUE,t,P));return}P.setTimeout(Ae,function(){if(m)return;let Ot=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",ze=t.transitional||xZa;t.timeoutErrorMessage&&(Ot=t.timeoutErrorMessage),i(new zm(Ot,ze.clarifyTimeoutError?zm.ETIMEDOUT:zm.ECONNABORTED,t,P)),T()})}if(Zf.isStream(o)){let Ae=!1,mt=!1;o.on("end",()=>{Ae=!0}),o.once("error",Ot=>{mt=!0,P.destroy(Ot)}),o.on("close",()=>{!Ae&&!mt&&T(new Qrt("Request stream has been aborted",t,P))}),o.pipe(P)}else P.end(o)})};var jPy=J8.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,J8.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(J8.origin),J8.navigator&&/(msie|trident)/i.test(J8.navigator.userAgent)):()=>!0;var EPy=J8.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let o=[e+"="+encodeURIComponent(t)];Zf.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Zf.isString(n)&&o.push("path="+n),Zf.isString(i)&&o.push("domain="+i),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var SPy=e=>e instanceof b$?{...e}:e;function eqr(e,t){t=t||{};let r={};function n(u,s,l,m){return Zf.isPlainObject(u)&&Zf.isPlainObject(s)?Zf.merge.call({caseless:m},u,s):Zf.isPlainObject(s)?Zf.merge({},s):Zf.isArray(s)?s.slice():s}function i(u,s,l,m){if(Zf.isUndefined(s)){if(!Zf.isUndefined(u))return n(void 0,u,l,m)}else return n(u,s,l,m)}function a(u,s){if(!Zf.isUndefined(s))return n(void 0,s)}function o(u,s){if(Zf.isUndefined(s)){if(!Zf.isUndefined(u))return n(void 0,u)}else return n(void 0,s)}function c(u,s,l){if(l in t)return n(u,s);if(l in e)return n(void 0,u)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(u,s,l)=>i(SPy(u),SPy(s),l,!0)};return Zf.forEach(Object.keys({...e,...t}),function(s){let l=f[s]||i,m=l(e[s],t[s],s);Zf.isUndefined(m)&&l!==c||(r[s]=m)}),r}var KSu=e=>{let t=eqr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=b$.from(o),t.url=jua(Eua(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Zf.isFormData(r)){if(J8.hasStandardBrowserEnv||J8.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Zf.isFunction(r.getHeaders)){let f=r.getHeaders(),u=["content-type","content-length"];Object.entries(f).forEach(([s,l])=>{u.includes(s.toLowerCase())&&o.set(s,l)})}}if(J8.hasStandardBrowserEnv&&(n&&Zf.isFunction(n)&&(n=n(t)),n||n!==!1&&jPy(t.url))){let f=i&&a&&EPy.read(a);f&&o.set(i,f)}return t};var y1C=typeof XMLHttpRequest<"u",DPy=y1C&&function(e){return new Promise(function(r,n){let i=KSu(e),a=i.data,o=b$.from(i.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:u}=i,s,l,m,O,P;function C(){O&&O(),P&&P(),i.cancelToken&&i.cancelToken.unsubscribe(s),i.signal&&i.signal.removeEventListener("abort",s)}let I=new XMLHttpRequest;I.open(i.method.toUpperCase(),i.url,!0),I.timeout=i.timeout;function T(){if(!I)return;let U=b$.from("getAllResponseHeaders"in I&&I.getAllResponseHeaders()),V={data:!c||c==="text"||c==="json"?I.responseText:I.response,status:I.status,statusText:I.statusText,headers:U,config:e,request:I};SUr(function(re){r(re),C()},function(re){n(re),C()},V),I=null}"onloadend"in I?I.onloadend=T:I.onreadystatechange=function(){!I||I.readyState!==4||I.status===0&&!(I.responseURL&&I.responseURL.indexOf("file:")===0)||setTimeout(T)},I.onabort=function(){I&&(n(new zm("Request aborted",zm.ECONNABORTED,e,I)),I=null)},I.onerror=function(q){let V=q&&q.message?q.message:"Network Error",$=new zm(V,zm.ERR_NETWORK,e,I);$.event=q||null,n($),I=null},I.ontimeout=function(){let q=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",V=i.transitional||xZa;i.timeoutErrorMessage&&(q=i.timeoutErrorMessage),n(new zm(q,V.clarifyTimeoutError?zm.ETIMEDOUT:zm.ECONNABORTED,e,I)),I=null},a===void 0&&o.setContentType(null),"setRequestHeader"in I&&Zf.forEach(o.toJSON(),function(q,V){I.setRequestHeader(V,q)}),Zf.isUndefined(i.withCredentials)||(I.withCredentials=!!i.withCredentials),c&&c!=="json"&&(I.responseType=i.responseType),u&&([m,P]=IAi(u,!0),I.addEventListener("progress",m)),f&&I.upload&&([l,O]=IAi(f),I.upload.addEventListener("progress",l),I.upload.addEventListener("loadend",O)),(i.cancelToken||i.signal)&&(s=U=>{I&&(n(!U||U.type?new Qrt(null,e,I):U),I.abort(),I=null)},i.cancelToken&&i.cancelToken.subscribe(s),i.signal&&(i.signal.aborted?s():i.signal.addEventListener("abort",s)));let z=a$o(i.url);if(z&&J8.protocols.indexOf(z)===-1){n(new zm("Unsupported protocol "+z+":",zm.ERR_BAD_REQUEST,e));return}I.send(a||null)})};var v1C=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(u){if(!i){i=!0,c();let s=u instanceof Error?u:this.reason;n.abort(s instanceof zm?s:new Qrt(s instanceof Error?s.message:s))}},o=t&&setTimeout(()=>{o=null,a(new zm(`timeout ${t} of ms exceeded`,zm.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(a):u.removeEventListener("abort",a)}),e=null)};e.forEach(u=>u.addEventListener("abort",a));let{signal:f}=n;return f.unsubscribe=()=>Zf.asap(c),f}},CPy=v1C;var g1C=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},b1C=async function*(e,t){for await(let r of m1C(e))yield*g1C(r,t)},m1C=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},jOf=(e,t,r,n)=>{let i=b1C(e,t),a=0,o,c=f=>{o||(o=!0,n&&n(f))};return new ReadableStream({async pull(f){try{let{done:u,value:s}=await i.next();if(u){c(),f.close();return}let l=s.byteLength;if(r){let m=a+=l;r(m)}f.enqueue(new Uint8Array(s))}catch(u){throw c(u),u}},cancel(f){return c(f),i.return()}},{highWaterMark:2})};var IPy=64*1024,{isFunction:$Su}=Zf,O1C=(({Request:e,Response:t})=>({Request:e,Response:t}))(Zf.global),{ReadableStream:MPy,TextEncoder:BPy}=Zf.global,TPy=(e,...t)=>{try{return!!e(...t)}catch{return!1}},A1C=e=>{e=Zf.merge.call({skipUndefined:!0},O1C,e);let{fetch:t,Request:r,Response:n}=e,i=t?$Su(t):typeof fetch=="function",a=$Su(r),o=$Su(n);if(!i)return!1;let c=i&&$Su(MPy),f=i&&(typeof BPy=="function"?(P=>C=>P.encode(C))(new BPy):async P=>new Uint8Array(await new r(P).arrayBuffer())),u=a&&c&&TPy(()=>{let P=!1,C=new r(J8.origin,{body:new MPy,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!C}),s=o&&c&&TPy(()=>Zf.isReadableStream(new n("").body)),l={stream:s&&(P=>P.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!l[P]&&(l[P]=(C,I)=>{let T=C&&C[P];if(T)return T.call(C);throw new zm(`Response type '${P}' is not supported`,zm.ERR_NOT_SUPPORT,I)})});let m=async P=>{if(P==null)return 0;if(Zf.isBlob(P))return P.size;if(Zf.isSpecCompliantForm(P))return(await new r(J8.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(Zf.isArrayBufferView(P)||Zf.isArrayBuffer(P))return P.byteLength;if(Zf.isURLSearchParams(P)&&(P=P+""),Zf.isString(P))return(await f(P)).byteLength},O=async(P,C)=>{let I=Zf.toFiniteNumber(P.getContentLength());return I??m(C)};return async P=>{let{url:C,method:I,data:T,signal:z,cancelToken:U,timeout:q,onDownloadProgress:V,onUploadProgress:$,responseType:re,headers:Y,withCredentials:k="same-origin",fetchOptions:ne}=KSu(P),Oe=t||fetch;re=re?(re+"").toLowerCase():"text";let pe=CPy([z,U&&U.toAbortSignal()],q),ge=null,_e=pe&&pe.unsubscribe&&(()=>{pe.unsubscribe()}),Ce;try{if($&&u&&I!=="get"&&I!=="head"&&(Ce=await O(Y,T))!==0){let Be=new r(C,{method:"POST",body:T,duplex:"half"}),er;if(Zf.isFormData(T)&&(er=Be.headers.get("content-type"))&&Y.setContentType(er),Be.body){let[pt,Or]=QZa(Ce,IAi(LZa($)));T=jOf(Be.body,IPy,pt,Or)}}Zf.isString(k)||(k=k?"include":"omit");let Se=a&&"credentials"in r.prototype,Ae={...ne,signal:pe,method:I.toUpperCase(),headers:Y.normalize().toJSON(),body:T,duplex:"half",credentials:Se?k:void 0};ge=a&&new r(C,Ae);let mt=await(a?Oe(ge,ne):Oe(C,Ae)),Ot=s&&(re==="stream"||re==="response");if(s&&(V||Ot&&_e)){let Be={};["status","statusText","headers"].forEach(Zt=>{Be[Zt]=mt[Zt]});let er=Zf.toFiniteNumber(mt.headers.get("content-length")),[pt,Or]=V&&QZa(er,IAi(LZa(V),!0))||[];mt=new n(jOf(mt.body,IPy,pt,()=>{Or&&Or(),_e&&_e()}),Be)}re=re||"text";let ze=await l[Zf.findKey(l,re)||"text"](mt,P);return!Ot&&_e&&_e(),await new Promise((Be,er)=>{SUr(Be,er,{data:ze,headers:b$.from(mt.headers),status:mt.status,statusText:mt.statusText,config:P,request:ge})})}catch(Se){throw _e&&_e(),Se&&Se.name==="TypeError"&&/Load failed|fetch/i.test(Se.message)?Object.assign(new zm("Network Error",zm.ERR_NETWORK,P,ge),{cause:Se.cause||Se}):zm.from(Se,Se&&Se.code,P,ge)}}},P1C=new Map,EOf=e=>{let t=e?e.env:{},{fetch:r,Request:n,Response:i}=t,a=[n,i,r],o=a.length,c=o,f,u,s=P1C;for(;c--;)f=a[c],u=s.get(f),u===void 0&&s.set(f,u=c?new Map:A1C(t)),s=u;return u},ZaU=EOf();var SOf={http:wPy,xhr:DPy,fetch:{get:EOf}};Zf.forEach(SOf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var qPy=e=>`- ${e}`,j1C=e=>Zf.isFunction(e)||e===null||e===!1,YSu={getAdapter:(e,t)=>{e=Zf.isArray(e)?e:[e];let{length:r}=e,n,i,a={};for(let o=0;o<r;o++){n=e[o];let c;if(i=n,!j1C(n)&&(i=SOf[(c=String(n)).toLowerCase()],i===void 0))throw new zm(`Unknown adapter '${c}'`);if(i&&(Zf.isFunction(i)||(i=i.get(t))))break;a[c||"#"+o]=i}if(!i){let o=Object.entries(a).map(([f,u])=>`adapter ${f} `+(u===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
|
|
@@ -2679,7 +2679,7 @@ ${q}${z}${V}${mro}`});function _xu({message:e,error:t,logger:r,logLevel:n=p1.Err
|
|
|
2679
2679
|
Run ${vf.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
|
|
2680
2680
|
Run ${vf.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),VZa(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function TRf({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!JUy(e))return;let i=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,f)=>c.generatorName.localeCompare(f.generatorName)||c.currentVersion.localeCompare(f.currentVersion));for(let c of o)i+=`
|
|
2681
2681
|
${await VaI(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+vf.dim(c.currentVersion)+vf.reset(" \u2192 ")+vf.green(c.latestVersion);return i+=`
|
|
2682
|
-
`,n?VZa(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function VaI(e){let r=await new HUy.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function WaI({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await $Uy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=r3i(s.name,l),O=await ATr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:l});O!=null&&(c.versions[u][s.name]={previousVersion:s.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await $Uy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,u,s)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=r3i(u.name,s),m=await ATr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:s});m!=null&&(o.versions[c][f][u.name]={previousVersion:u.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function $Uy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await TTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(i!=null&&f.groupName!==i))for(let u of f.generators)n!=null&&u.name!==n||await r(a.workspaceName,f.groupName,u,o)}})}))}function YUy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let f=CFe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function gxu({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await WaI({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,u]of Object.entries(c.versions))o.push(...YUy(u,f,t.logger));else o.push(...YUy(c.versions,void 0,t.logger))}return o}var GZo=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var wro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var qRf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),XUy=typeof globalThis.AbortController=="function",ZUy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",kUy=typeof globalThis.ReadableStream=="function",eVy=typeof globalThis.FormData=="function",bxu=["get","post","put","patch","head","delete"],GaI=()=>{};GaI();var tVy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},mxu=2147483647,rVy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Oxu=Symbol("stop"),nVy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},iVy={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var HaI=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=rVy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},aVy=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},oVy=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(aVy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},sVy=(e,t,r)=>{if(!e.body)return e;let n=HaI(r??e.body);return new Request(e,{duplex:"half",body:aVy(e.body,n,t)})};var jro=e=>e!==null&&typeof e=="object";var HZo=(...e)=>{for(let t of e)if((!jro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return xRf({},...e)},RRf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function Axu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:xRf(e[r]??[],t[r]??[])}var NRf=(e={},t={})=>({beforeRequest:Axu(e,t,"beforeRequest"),beforeRetry:Axu(e,t,"beforeRetry"),afterResponse:Axu(e,t,"afterResponse"),beforeError:Axu(e,t,"beforeError")}),xRf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(jro(i)){for(let[a,o]of Object.entries(i))jro(o)&&a in t&&(o=xRf(t[a],o)),t={...t,[a]:o};jro(i.hooks)&&(n=NRf(n,i.hooks),t.hooks=n),jro(i.headers)&&(r=RRf(r,i.headers),t.headers=r)}return t};var cVy=e=>bxu.includes(e)?e.toUpperCase():e,JaI=["get","put","head","delete","options","trace"],KaI=[408,413,429,500,502,503,504],$aI=[413,429,503],uVy={limit:2,methods:JaI,statusCodes:KaI,afterStatusCodes:$aI,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},lVy=(e={})=>{if(typeof e=="number")return{...uVy,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...uVy,...e}};async function FRf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new wro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function zRf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var fVy=(e,t)=>{let r={};for(let n in t)!(n in iVy)&&!(n in nVy)&&!(n in e)&&(r[n]=t[n]);return r},dVy=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var JZo=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>mxu)throw new RangeError(`The \`timeout\` option cannot be greater than ${mxu}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let u=await f(n.request,n._options,n._decorateResponse(c.clone()));u instanceof globalThis.Response&&(c=u)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new GZo(c,n.request,n._options);for(let u of n._options.hooks.beforeError)f=await u(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!kUy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return oVy(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),n.request.bodyUsed||f.push(n.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(tVy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let u=await o;if(c==="json"){if(u.status===204)return"";let s=await u.text();return s===""?"":r.parseJson?r.parseJson(s):JSON.parse(s)}return u[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:RRf(this._input.headers,r.headers),hooks:NRf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:cVy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:lVy(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(XUy&&ZUy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(qRf&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),dVy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(eVy&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!qRf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=sVy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof wro)throw t;if(t instanceof GZo){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),mxu);if(this._retryCount<1)throw r;await zRf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Oxu)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=fVy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):FRf(this._originalRequest,t,this.abortController,this._options)}};var QRf=e=>{let t=(r,n)=>JZo.create(r,HZo(e,n));for(let r of bxu)t[r]=(n,i)=>JZo.create(n,HZo(e,i,{method:r}));return t.create=r=>QRf(HZo(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),QRf(HZo(e,r))),t.stop=Oxu,t},YaI=QRf(),pVy=YaI;var NVy=Gi(RVy(),1);function GRf(e){let t=(0,NVy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var IWy=Gi(CWy(),1),MWy=Gi(DTu(),1),iNf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},aNf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function oNf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??GRf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,IWy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let u;try{u=await pVy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new iNf(e):l}if(t.allVersions)return u;let s=new aNf(e,r);if(u["dist-tags"][r]){let{time:l}=u;u=u.versions[u["dist-tags"][r]],u.time=l}else if(r){let l=!!u.versions[r];if(n&&!l)for(let[O,P]of Object.entries(u.versions))P.deprecated&&delete u.versions[O];if(!l){let O=Object.keys(u.versions);if(r=MWy.default.maxSatisfying(O,r),!r)throw s}let{time:m}=u;if(u=u.versions[r],u.time=m,!u)throw s}return u}async function kZo(e,t){let{version:r}=await oNf(e.toLowerCase(),t);return r}async function L7i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:kZo(e.packageName,{version:t?"prerelease":"latest"})}var BWy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],qxu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=p1.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new vxu(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"1.3.0-rc2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${vf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new jne}failWithoutThrowing(t,r){this.didSucceed=!1,_xu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await TZa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await KUy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2682
|
+
`,n?VZa(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function VaI(e){let r=await new HUy.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function WaI({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await $Uy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=r3i(s.name,l),O=await ATr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:l});O!=null&&(c.versions[u][s.name]={previousVersion:s.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await $Uy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,u,s)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=r3i(u.name,s),m=await ATr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:s});m!=null&&(o.versions[c][f][u.name]={previousVersion:u.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function $Uy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await TTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(i!=null&&f.groupName!==i))for(let u of f.generators)n!=null&&u.name!==n||await r(a.workspaceName,f.groupName,u,o)}})}))}function YUy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let f=CFe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function gxu({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await WaI({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,u]of Object.entries(c.versions))o.push(...YUy(u,f,t.logger));else o.push(...YUy(c.versions,void 0,t.logger))}return o}var GZo=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var wro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var qRf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),XUy=typeof globalThis.AbortController=="function",ZUy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",kUy=typeof globalThis.ReadableStream=="function",eVy=typeof globalThis.FormData=="function",bxu=["get","post","put","patch","head","delete"],GaI=()=>{};GaI();var tVy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},mxu=2147483647,rVy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Oxu=Symbol("stop"),nVy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},iVy={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var HaI=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=rVy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},aVy=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},oVy=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(aVy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},sVy=(e,t,r)=>{if(!e.body)return e;let n=HaI(r??e.body);return new Request(e,{duplex:"half",body:aVy(e.body,n,t)})};var jro=e=>e!==null&&typeof e=="object";var HZo=(...e)=>{for(let t of e)if((!jro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return xRf({},...e)},RRf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function Axu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:xRf(e[r]??[],t[r]??[])}var NRf=(e={},t={})=>({beforeRequest:Axu(e,t,"beforeRequest"),beforeRetry:Axu(e,t,"beforeRetry"),afterResponse:Axu(e,t,"afterResponse"),beforeError:Axu(e,t,"beforeError")}),xRf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(jro(i)){for(let[a,o]of Object.entries(i))jro(o)&&a in t&&(o=xRf(t[a],o)),t={...t,[a]:o};jro(i.hooks)&&(n=NRf(n,i.hooks),t.hooks=n),jro(i.headers)&&(r=RRf(r,i.headers),t.headers=r)}return t};var cVy=e=>bxu.includes(e)?e.toUpperCase():e,JaI=["get","put","head","delete","options","trace"],KaI=[408,413,429,500,502,503,504],$aI=[413,429,503],uVy={limit:2,methods:JaI,statusCodes:KaI,afterStatusCodes:$aI,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},lVy=(e={})=>{if(typeof e=="number")return{...uVy,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...uVy,...e}};async function FRf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new wro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function zRf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var fVy=(e,t)=>{let r={};for(let n in t)!(n in iVy)&&!(n in nVy)&&!(n in e)&&(r[n]=t[n]);return r},dVy=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var JZo=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>mxu)throw new RangeError(`The \`timeout\` option cannot be greater than ${mxu}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let u=await f(n.request,n._options,n._decorateResponse(c.clone()));u instanceof globalThis.Response&&(c=u)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new GZo(c,n.request,n._options);for(let u of n._options.hooks.beforeError)f=await u(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!kUy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return oVy(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),n.request.bodyUsed||f.push(n.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(tVy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let u=await o;if(c==="json"){if(u.status===204)return"";let s=await u.text();return s===""?"":r.parseJson?r.parseJson(s):JSON.parse(s)}return u[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:RRf(this._input.headers,r.headers),hooks:NRf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:cVy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:lVy(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(XUy&&ZUy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(qRf&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),dVy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(eVy&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!qRf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=sVy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof wro)throw t;if(t instanceof GZo){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),mxu);if(this._retryCount<1)throw r;await zRf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Oxu)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=fVy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):FRf(this._originalRequest,t,this.abortController,this._options)}};var QRf=e=>{let t=(r,n)=>JZo.create(r,HZo(e,n));for(let r of bxu)t[r]=(n,i)=>JZo.create(n,HZo(e,i,{method:r}));return t.create=r=>QRf(HZo(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),QRf(HZo(e,r))),t.stop=Oxu,t},YaI=QRf(),pVy=YaI;var NVy=Gi(RVy(),1);function GRf(e){let t=(0,NVy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var IWy=Gi(CWy(),1),MWy=Gi(DTu(),1),iNf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},aNf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function oNf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??GRf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,IWy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let u;try{u=await pVy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new iNf(e):l}if(t.allVersions)return u;let s=new aNf(e,r);if(u["dist-tags"][r]){let{time:l}=u;u=u.versions[u["dist-tags"][r]],u.time=l}else if(r){let l=!!u.versions[r];if(n&&!l)for(let[O,P]of Object.entries(u.versions))P.deprecated&&delete u.versions[O];if(!l){let O=Object.keys(u.versions);if(r=MWy.default.maxSatisfying(O,r),!r)throw s}let{time:m}=u;if(u=u.versions[r],u.time=m,!u)throw s}return u}async function kZo(e,t){let{version:r}=await oNf(e.toLowerCase(),t);return r}async function L7i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:kZo(e.packageName,{version:t?"prerelease":"latest"})}var BWy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],qxu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=p1.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new vxu(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"1.3.0"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${vf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new jne}failWithoutThrowing(t,r){this.didSucceed=!1,_xu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await TZa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await KUy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2683
2683
|
`)||(r+=`
|
|
2684
2684
|
`),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=TJl(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new zZo(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw a.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,a),new jne}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await TZa()).sendEvent(t)}logger=K6r((t,...r)=>this.log(t,...r));stderr=K6r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=TWy(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?TWy(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=BWy[this.numTasks++%BWy.length],o=vf.hex(a)(i);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===mV.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let n=t.filter(i=>PFi.indexOf(i.level)>=PFi.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===p1.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await L7i({cliEnvironment:this.environment,includePreReleases:t}),n=CFe(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await gxu({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await ARf({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:vf.yellow("?"),style:{answer:i=>vf.cyan(i),message:i=>vf.bold(i),highlight:i=>vf.cyan(i)}}})}catch(n){throw n?.name==="ExitPromptError"?(this.logger.info(`
|
|
2685
2685
|
Cancelled by user.`),new jne):n}}async getInput(t){return await gRf({message:t.message,default:t.default})}};function TWy(e){return`[${e}]:`}var Pqr=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};function Rxu(e,t,r,n){if(typeof r!="function")throw new Error("method for before hook must be a function");return n||(n={}),Array.isArray(t)?t.reverse().reduce((i,a)=>Rxu.bind(null,e,a,i,n),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((i,a)=>a.hook.bind(null,i,n),r)():r(n))}function qWy(e,t,r,n){let i=n;e.registry[r]||(e.registry[r]=[]),t==="before"&&(n=(a,o)=>Promise.resolve().then(i.bind(null,o)).then(a.bind(null,o))),t==="after"&&(n=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(f=>(c=f,i(c,o))).then(()=>c)}),t==="error"&&(n=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>i(c,o))),e.registry[r].push({hook:n,orig:i})}function RWy(e,t,r){if(!e.registry[t])return;let n=e.registry[t].map(i=>i.orig).indexOf(r);n!==-1&&e.registry[t].splice(n,1)}var NWy=Function.bind,xWy=NWy.bind(NWy);function FWy(e,t,r){let n=xWy(RWy,null).apply(null,r?[t,r]:[t]);e.api={remove:n},e.remove=n,["before","error","after","wrap"].forEach(i=>{let a=r?[t,i,r]:[t,i];e[i]=e.api[i]=xWy(qWy,null).apply(null,a)})}function rsI(){let e=Symbol("Singular"),t={registry:{}},r=Rxu.bind(null,t,e);return FWy(r,t,e),r}function nsI(){let e={registry:{}},t=Rxu.bind(null,e);return FWy(t,e),t}var zWy={Singular:rsI,Collection:nsI};var isI="0.0.0-development",asI=`octokit-endpoint.js/${isI} ${xfe()}`,osI={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":asI},mediaType:{format:""}};function ssI(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function usI(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function UWy(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(n=>{usI(t[n])?n in e?r[n]=UWy(e[n],t[n]):Object.assign(r,{[n]:t[n]}):Object.assign(r,{[n]:t[n]})}),r}function QWy(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function uNf(e,t,r){if(typeof t=="string"){let[i,a]=t.split(" ");r=Object.assign(a?{method:i,url:a}:{url:i},r)}else r=Object.assign({},t);r.headers=ssI(r.headers),QWy(r),QWy(r.headers);let n=UWy(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(n.mediaType.previews=e.mediaType.previews.filter(i=>!n.mediaType.previews.includes(i)).concat(n.mediaType.previews)),n.mediaType.previews=(n.mediaType.previews||[]).map(i=>i.replace(/-preview/,""))),n}function csI(e,t){let r=/\?/.test(e)?"&":"?",n=Object.keys(t);return n.length===0?e:e+r+n.map(i=>i==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${i}=${encodeURIComponent(t[i])}`).join("&")}var lsI=/\{[^{}}]+\}/g;function fsI(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function dsI(e){let t=e.match(lsI);return t?t.map(fsI).reduce((r,n)=>r.concat(n),[]):[]}function LWy(e,t){let r={__proto__:null};for(let n of Object.keys(e))t.indexOf(n)===-1&&(r[n]=e[n]);return r}function VWy(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function Tro(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function eko(e,t,r){return t=e==="+"||e==="#"?VWy(t):Tro(t),r?Tro(r)+"="+t:t}function Bro(e){return e!=null}function sNf(e){return e===";"||e==="&"||e==="?"}function psI(e,t,r,n){var i=e[r],a=[];if(Bro(i)&&i!=="")if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")i=i.toString(),n&&n!=="*"&&(i=i.substring(0,parseInt(n,10))),a.push(eko(t,i,sNf(t)?r:""));else if(n==="*")Array.isArray(i)?i.filter(Bro).forEach(function(o){a.push(eko(t,o,sNf(t)?r:""))}):Object.keys(i).forEach(function(o){Bro(i[o])&&a.push(eko(t,i[o],o))});else{let o=[];Array.isArray(i)?i.filter(Bro).forEach(function(c){o.push(eko(t,c))}):Object.keys(i).forEach(function(c){Bro(i[c])&&(o.push(Tro(c)),o.push(eko(t,i[c].toString())))}),sNf(t)?a.push(Tro(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?Bro(i)&&a.push(Tro(r)):i===""&&(t==="&"||t==="?")?a.push(Tro(r)+"="):i===""&&a.push("");return a}function _sI(e){return{expand:hsI.bind(null,e)}}function hsI(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(n,i,a){if(i){let c="",f=[];if(r.indexOf(i.charAt(0))!==-1&&(c=i.charAt(0),i=i.substr(1)),i.split(/,/g).forEach(function(u){var s=/([^:\*]*)(?::(\d+)|(\*))?/.exec(u);f.push(psI(t,c,s[1],s[2]||s[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(f.length!==0?c:"")+f.join(o)}else return f.join(",")}else return VWy(a)}),e==="/"?e:e.replace(/\/$/,"")}function WWy(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),n=Object.assign({},e.headers),i,a=LWy(e,["method","baseUrl","url","headers","request","mediaType"]),o=dsI(r);r=_sI(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(s=>o.includes(s)).concat("baseUrl"),f=LWy(a,c);if(!/application\/octet-stream/i.test(n.accept)&&(e.mediaType.format&&(n.accept=n.accept.split(/,/).map(s=>s.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let s=n.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];n.accept=s.concat(e.mediaType.previews).map(l=>{let m=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${m}`}).join(",")}return["GET","HEAD"].includes(t)?r=csI(r,f):"data"in f?i=f.data:Object.keys(f).length&&(i=f),!n["content-type"]&&typeof i<"u"&&(n["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof i>"u"&&(i=""),Object.assign({method:t,url:r,headers:n},typeof i<"u"?{body:i}:null,e.request?{request:e.request}:null)}function ysI(e,t,r){return WWy(uNf(e,t,r))}function GWy(e,t){let r=uNf(e,t),n=ysI.bind(null,r);return Object.assign(n,{DEFAULTS:r,defaults:GWy.bind(null,r),merge:uNf.bind(null,r),parse:WWy})}var HWy=GWy(null,osI);var ZWy=Gi(YWy(),1);var wqr=class extends Error{name;status;request;response;constructor(t,r,n){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in n&&(this.response=n.response);let i=Object.assign({},n.request);n.request.headers.authorization&&(i.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),i.url=i.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=i}};var vsI="10.0.6",gsI={headers:{"user-agent":`octokit-request.js/${vsI} ${xfe()}`}};function bsI(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function XWy(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,n=e.request?.parseSuccessResponseBody!==!1,i=bsI(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,m])=>[l,String(m)])),o;try{o=await t(e.url,{method:e.method,body:i,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let m="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;m=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?m=l.cause.message:typeof l.cause=="string"&&(m=l.cause))}let O=new wqr(m,500,{request:e});throw O.cause=l,O}let c=o.status,f=o.url,u={};for(let[l,m]of o.headers)u[l]=m;let s={url:f,status:c,headers:u,data:""};if("deprecation"in u){let l=u.link&&u.link.match(/<([^<>]+)>; rel="deprecation"/),m=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${u.sunset}${m?`. See ${m}`:""}`)}if(c===204||c===205)return s;if(e.method==="HEAD"){if(c<400)return s;throw new wqr(o.statusText,c,{response:s,request:e})}if(c===304)throw s.data=await cNf(o),new wqr("Not modified",c,{response:s,request:e});if(c>=400)throw s.data=await cNf(o),new wqr(OsI(s.data),c,{response:s,request:e});return s.data=n?await cNf(o):o.body,s}async function cNf(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,ZWy.safeParse)(t);if(msI(r)){let n="";try{return n=await e.text(),JSON.parse(n)}catch{return n}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function msI(e){return e.type==="application/json"||e.type==="application/scim+json"}function OsI(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function lNf(e,t){let r=e.defaults(t);return Object.assign(function(i,a){let o=r.merge(i,a);if(!o.request||!o.request.hook)return XWy(r.parse(o));let c=(f,u)=>XWy(r.parse(r.merge(f,u)));return Object.assign(c,{endpoint:r,defaults:lNf.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:lNf.bind(null,r)})}var H7=lNf(HWy,gsI);var AsI="0.0.0-development";function PsI(e){return`Request failed due to following response errors:
|