fern-api 0.64.24 → 0.64.25
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
|
@@ -1711,7 +1711,7 @@ ${oqp.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&PQs(th
|
|
|
1711
1711
|
`+MHi.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?MHi.default.cyan(hqp(t,this.opt.mask)):MHi.default.italic(MHi.default.dim("[hidden]")):this.opt.mask?hqp(t,this.opt.mask):MHi.default.italic(MHi.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 UFo=ai(z2(),1),LTp=ai(_Js(),1),UTp=ai(VEe(),1);var XDa=class extends x2{_run(t){this.done=t,this.editorResult=new UTp.Subject;let r=jW(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?UFo.default.dim("Received"):UFo.default.dim("Press <enter> to launch your preferred editor."),t&&(r=UFo.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,LTp.editAsync)(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 GTp=require("stream");var HTp=ai(require("readline"),1),$Tp=ai(WTp(),1),xHi=class{constructor(t){this.rl||=HTp.default.createInterface(S_D(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 S_D(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new $Tp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var ZDa=class extends xHi{constructor(t={}){super(t),this.log=new GTp.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return BDa(this.rl,this.bottomBar.split(`
|
|
1712
1712
|
`).length),this}updateBottomBar(t){return BDa(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+`
|
|
1713
1713
|
`}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&&hFo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var UE=ai(VEe(),1),KTp=ai(tDa(),1);var VFo=ai(VEe(),1),QTp=ai(tDa(),1),WFo=function(e,t,r){return typeof e[t]!="function"?(0,VFo.of)(e):(0,VFo.from)((0,QTp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var JTp={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,u)=>{n==="__proto__"||n==="constructor"||(a===u.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((u,l)=>u!=null?u[l]:u,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},YNn=class extends xHi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,UE.from)(t):(0,UE.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,UE.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,UE.from)([t]),this.process=i.pipe((0,UE.concatMap)(this.processQuestion.bind(this)),(0,UE.publish)()),this.process.connect(),this.process.pipe((0,UE.reduce)((n,a)=>(JTp.set(n,a.name,a.answer),n),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,UE.defer)(()=>(0,UE.of)(t).pipe((0,UE.concatMap)(this.setDefaultType.bind(this)),(0,UE.concatMap)(this.filterIfRunnable.bind(this)),(0,UE.concatMap)(()=>WFo(t,"message",this.answers)),(0,UE.concatMap)(()=>WFo(t,"default",this.answers)),(0,UE.concatMap)(()=>WFo(t,"choices",this.answers)),(0,UE.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,UE.defer)(()=>(0,UE.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,UE.defer)(()=>(0,UE.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&JTp.get(this.answers,t.name)!==void 0)return UE.EMPTY;if(t.when===!1)return UE.EMPTY;if(typeof t.when!="function")return(0,UE.of)(t);let{answers:r}=this;return(0,UE.defer)(()=>(0,UE.from)((0,KTp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,UE.filter)(i=>i!=null)))}};function YTp(e){let t=function(r,i){let n;try{n=new YNn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",zDa),this.registerPrompt("input",EHi),this.registerPrompt("number",xDa),this.registerPrompt("confirm",RDa),this.registerPrompt("rawlist",NDa),this.registerPrompt("expand",FDa),this.registerPrompt("checkbox",LDa),this.registerPrompt("password",UDa),this.registerPrompt("editor",XDa)},t.restoreDefaultPrompts(),t}var yJs=YTp();function E_D(e,t){yJs.registerPrompt(e,t)}function M_D(){yJs.restoreDefaultPrompts()}var A_D={prompt:yJs,ui:{BottomBar:ZDa,Prompt:YNn},createPromptModule:YTp,registerPrompt:E_D,restoreDefaultPrompts:M_D,Separator:sae},HFo=A_D;var sFn=require("path"),qBp=require("fs"),TBp=require("readline"),tBp="posthog-node";function lvD(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"]}={}){return a=>{if(!(n==="*"||n.includes(a.level)))return a;a.tags||(a.tags={});let l=a.tags[d3o.POSTHOG_ID_TAG];if(l===void 0)return a;let d=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${l}`,d).toString();a.tags["PostHog Person URL"]=s;let o=a.exception?.values||[],c=o.map(g=>({...g,stacktrace:g.stacktrace?{...g.stacktrace,type:"raw",frames:(g.stacktrace.frames||[]).map(O=>({...O,platform:"node:javascript"}))}:void 0})),b={$exception_message:o[0]?.value||a.message,$exception_type:o[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:c,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:o[0]?.value||a.message,$sentry_exception_type:o[0]?.type,$sentry_tags:a.tags};return t&&r&&(b.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:l,properties:b}),a}}var d3o=class{constructor(t,r,i,n){this.name=tBp,this.name=tBp,this.setupOnce=function(a,u){let l=u()?.getClient()?.getDsn()?.projectId;a(lvD(t,{organization:r,projectId:l,prefix:i,severityAllowList:n}))}}};d3o.POSTHOG_ID_TAG="posthog_distinct_id";var u3o="0123456789abcdef",p3o=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,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>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|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,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 i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=u3o.charAt(this.bytes[r]>>>4),t+=u3o.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+=u3o.charAt(this.bytes[r]>>>4),t+=u3o.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 i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},aKs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??fvD()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}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 p3o.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,p3o.ofInner(t)}},fvD=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),rBp,oKs=()=>dvD().toString(),dvD=()=>(rBp||(rBp=new aKs)).generate();function pvD(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(u=>u.name!=="domainUncaughtExceptionClear"&&u._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function _vD(e,t){global.process.on("uncaughtException",pvD(e,t))}function hvD(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var s3o,iBp,c3o;function yvD(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return c3o&&r.length===iBp||(iBp=r.length,c3o=r.reduce((i,n)=>{s3o||(s3o={});let a=s3o[n];if(a)i[a[0]]=a[1];else{let u=e(n);for(let l=u.length-1;l>=0;l--){let s=u[l]?.filename,o=t[n];if(s&&o){i[s]=o,s3o[n]=[s,o];break}}}return i},{})),c3o}function vvD(e){return typeof Event<"u"&&CBp(e,Event)}function bvD(e){return BBp(e,"Object")}function _Ks(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return CBp(e,Error)}}function CBp(e,t){try{return e instanceof t}catch{return!1}}function gvD(e){return BBp(e,"ErrorEvent")}function BBp(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function OvD(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},u=IBp(a,r,i);return{$exception_list:await Promise.all(u.map(async s=>{let o=await EvD(e,t,s);return o.value=o.value||"",o.type=o.type||"Error",o.mechanism=a,o}))}}function IBp(e,t,r){let i=mvD(e,t,r);return i.cause?[i,...IBp(e,i.cause,r)]:[i]}function mvD(e,t,r){if(_Ks(t))return t;if(e.synthetic=!0,bvD(t)){let n=PvD(t);if(n)return n;let a=jvD(t),u=r?.syntheticException||new Error(a);return u.message=a,u}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function PvD(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(_Ks(r))return r}}function jvD(e){if("name"in e&&typeof e.name=="string"){let i=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(i+=` with message '${e.message}'`),i}else if("message"in e&&typeof e.message=="string")return e.message;let t=SvD(e);if(gvD(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=wvD(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function wvD(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function SvD(e,t=40){let r=Object.keys(DvD(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return nBp(i,t);for(let n=r.length;n>0;n--){let a=r.slice(0,n).join(", ");if(!(a.length>t))return n===r.length?a:nBp(a,t)}return""}function nBp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function DvD(e){return _Ks(e)?{message:e.message,name:e.name,stack:e.stack,...aBp(e)}:vvD(e)?{type:e.type,target:oBp(e.target),currentTarget:oBp(e.currentTarget),...aBp(e)}:e}function aBp(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 oBp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function EvD(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=MvD(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function MvD(e,t){return AvD(e(t.stack||"",1),e)}function AvD(e,t){let r=yvD(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var qvD=2e3,aFn=class e{static async captureException(t,r,i,n,a){let u={...a};n||(u.$process_person_profile=!1);let l=await OvD(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||oKs(),properties:{...l,...u}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(_vD(this.onException.bind(this),this.onFatalError.bind(this)),hvD(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(qvD)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function TvD(e=process.argv[1]?(0,sFn.dirname)(process.argv[1]):process.cwd(),t=sFn.sep==="\\"){let r=t?uBp(e):e;return i=>{if(!i)return;let n=t?uBp(i):i,{dir:a,base:u,ext:l}=sFn.posix.parse(n);(l===".js"||l===".mjs"||l===".cjs")&&(u=u.slice(0,l.length*-1));let d=decodeURIComponent(u);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${d}`;if(a.startsWith(r)){let o=a.slice(r.length+1).replace(/\//g,".");return o?`${o}:${d}`:d}return d}}function uBp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var _3o=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)}}},f3o=new _3o(25),zBp=new _3o(20),hKs=7,CvD=1e3,BvD=1e4;async function IvD(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],u=a?.filename;if(!a||typeof u!="string"||typeof a.lineno!="number"||NvD(u)||FvD(a))continue;t[u]||(t[u]=[]),t[u].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(zBp.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let u=UvD(a);if(u.every(d=>LvD(n,d)))continue;let l=VvD(f3o,n,{});i.push(zvD(n,u,l))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&xvD(e,f3o),f3o.reduce(),e}function zvD(e,t,r){return new Promise(i=>{let n=(0,qBp.createReadStream)(e),a=(0,TBp.createInterface)({input:n});function u(){n.destroy(),i()}let l=0,d=0,s=t[d];if(s===void 0){u();return}let o=s[0],c=s[1];function b(){zBp.set(e,1),a.close(),a.removeAllListeners(),u()}n.on("error",b),a.on("error",b),a.on("close",u),a.on("line",g=>{if(l++,!(l<o)&&(r[l]=WvD(g,0),l>=c)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let O=t[d];if(O===void 0){a.close(),a.removeAllListeners();return}o=O[0],c=O[1]}})})}function xvD(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;RvD(r.lineno,r,i)}}function RvD(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=xBp(e);n<e;n++){let a=r[n];if(a===void 0){sBp(t);return}t.pre_context.push(a)}if(r[e]===void 0){sBp(t);return}t.context_line=r[e];let i=RBp(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function sBp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function NvD(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function FvD(e){return e.lineno!==void 0&&e.lineno>BvD||e.colno!==void 0&&e.colno>CvD}function LvD(e,t){let r=f3o.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function UvD(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=cBp(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+hKs:(n.push(i),i=cBp(a)),t++}return n}function cBp(e){return[xBp(e),RBp(e)]}function xBp(e){return Math.max(1,e-hKs)}function RBp(e){return e+hKs}function VvD(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function WvD(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}var HvD="4.18.0",_ae;(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"})(_ae||(_ae={}));var lBp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(lBp||(lBp={}));var fBp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(fBp||(fBp={}));var dBp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(dBp||(dBp={}));var pBp;(function(e){e.Html="html",e.Text="text"})(pBp||(pBp={}));var _Bp;(function(e){e.Number="number",e.Emoji="emoji"})(_Bp||(_Bp={}));var hBp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(hBp||(hBp={}));var yBp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(yBp||(yBp={}));var vBp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(vBp||(vBp={}));var bBp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(bBp||(bBp={}));var $vD=e=>{if("flags"in e){let t=QvD(e.flags),r=JvD(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,NBp(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,GvD(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function GvD(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 QvD=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,yKs(r)]).filter(([,t])=>t!==void 0)),JvD=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?NBp(i):void 0]}))},yKs=e=>e===void 0?void 0:e.variant??e.enabled,NBp=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},KvD=1,YvD=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"]),XvD="utf8";function ZvD(e,t){if(!e||typeof e!="string"||kvD(e))throw new Error(t)}function kvD(e){return e.trim().length===0}function ebD(e){return e?.replace(/\/+$/,"")}async function tbD(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function gBp(){return new Date().getTime()}function iKs(){return new Date().toISOString()}function h3o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function rbD(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function ibD(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 nbD(e,t=0,r){let i=ibD(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function OBp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var sEa=String.fromCharCode,mBp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l3o={};function abD(e,t){if(!l3o[e]){l3o[e]={};for(let r=0;r<e.length;r++)l3o[e][e.charAt(r)]=r}return l3o[e][t]}var iFn={compressToBase64:function(e){if(e==null)return"";let t=iFn._compress(e,6,function(r){return mBp.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:iFn._decompress(e.length,32,function(t){return abD(mBp,e.charAt(t))})},compress:function(e){return iFn._compress(e,16,function(t){return sEa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(d=e.charAt(w),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:iFn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=sEa(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=sEa(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=sEa(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=sEa(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},uKs=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(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}},oFn=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()}},cEa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function PBp(e){if(e instanceof oFn){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 nKs(e){return typeof e=="object"&&(e instanceof oFn||e instanceof cEa)}function jBp(e){return typeof e=="object"&&e instanceof oFn&&e.status===413}var sKs;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(sKs||(sKs={}));var cKs=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new uKs,this._isInitialized=!1,ZvD(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=ebD(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:nKs},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(_ae.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(_ae.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(_ae.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));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=oKs();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}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`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",n)),this._events.emit("error",n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let l=nbD(this.apiKey,KvD,YvD)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,d={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",l)),this.fetchWithRetry(l,d,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>$vD(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagDetailStateless(t,r,i,n,a,u);if(l===void 0)return{response:void 0,requestId:void 0};let d=yKs(l.response);return d===void 0&&(d=!1),{response:d,requestId:l.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagDetailsStateless(r,i,n,a,u,[t]);return l===void 0?void 0:{response:l.flags[t],requestId:l.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u,[t]);if(!l)return;let d=l[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,u){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,u)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,u){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,u)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,u){await this._initPromise;let l=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,u);return l?{flags:l.featureFlags,payloads:l.featureFlagPayloads,requestId:l.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},i={},n={},a,u){await this._initPromise;let l={};(a??this.disableGeoip)&&(l.geoip_disable=!0),u&&(l.flag_keys_to_evaluate=u);let d=await this.getDecide(t,r,i,n,l);if(d!==void 0)return d.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"),d.quotaLimited?.includes(sKs.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:d?.requestId}):d}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"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let u=`Surveys API could not be loaded: ${a.status}`,l=new Error(u);this.logMsgIfDebug(()=>console.error(l)),this._events.emit("error",new Error(u));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(_ae.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(_ae.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(_ae.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(_ae.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(_ae.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=h3o(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){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 n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:iKs()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${gBp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,l=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(iFn.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(u,l)}catch(d){this._events.emit("error",d)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:iKs(),uuid:i?.uuid?i.uuid:oKs()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await PBp(t)})}async flush(){let t=OBp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),OBp([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(_ae.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(b=>b.message),u=()=>{let g=(this.getPersistedProperty(_ae.Queue)||[]).slice(n.length);this.setPersistedProperty(_ae.Queue,g),t=g},l={api_key:this.apiKey,batch:a,sent_at:iKs()};this.historicalMigration&&(l.historical_migration=!0);let d=JSON.stringify(l),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${gBp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,o=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(iFn.compressToBase64(d))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:d},c={retryCheck:b=>jBp(b)?!1:nKs(b)};try{await this.fetchWithRetry(s,o,c)}catch(b){if(jBp(b)&&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 b instanceof cEa||u(),this._events.emit("error",b),b}u(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let o=new AbortController;return setTimeout(()=>o.abort(),s),o.signal});let u=r.body?r.body:"",l=-1;try{l=Buffer.byteLength(u,XvD)}catch{l=new TextEncoder().encode(u).length}return await tbD(async()=>{let d=null;try{d=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(o){throw new cEa(o)}if(!(r.mode==="no-cors")&&(d.status<200||d.status>=400))throw new oFn(d,l);return d},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(_ae.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!nKs(n))throw n;await PBp(n)}};return Promise.race([new Promise((n,a)=>{h3o(()=>{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)}),i()])}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}},lKs=rbD();if(!lKs){let e=eBp();lKs=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var FBp=lKs,y3o=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()}},LBp=new y3o(async()=>{try{return await import("crypto")}catch{return}});async function obD(){return await LBp.getValue()}var ubD=new y3o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await LBp.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function sbD(){return await ubD.getValue()}async function cbD(e){let t=await obD();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await sbD();if(r){let i=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(i)).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 lbD=60*1e3,fbD=1152921504606847e3,dbD=["is_not"],nFn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},R2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},fKs=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){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=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||FBp,this.onError=l.onError,this.customHeaders=u,this.onLoad=l.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){l=d;break}if(l!==void 0)try{u=await this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof R2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async d=>{try{let s=await this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof R2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}})),{response:a,payloads:u,fallbackToDecide:l}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new R2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new R2("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return await this.matchFeatureFlagProperties(t,i[d],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(await this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=await this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof R2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new R2("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let d=l.type,s=!1;if(d==="cohort"?s=VBp(l,n,this.cohorts,this.debugMode):s=UBp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&await wBp(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await wBp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),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(lbD,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 nFn(`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 nFn(`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 nFn(`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((i,n)=>(i[n.key]=n,i),{}),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 nFn&&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(),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=h3o(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,i=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;n=h3o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function wBp(e,t,r=""){let i=await cbD(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/fbD}function UBp(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new R2("Operator is_not_set is not supported")}else throw new R2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!dbD.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return SBp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return SBp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=pbD(String(n));if(s==null&&(s=DBp(n)),s==null)throw new R2(`Invalid date: ${n}`);let o=DBp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new R2(`Unknown operator: ${a}`)}}function VBp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new R2("can't match cohort without a given cohort property value");let a=r[n];return WBp(a,t,r,i)}function WBp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=WBp(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof R2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new R2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=VBp(l,t,r,i):d=UBp(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof R2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new R2("can't match cohort without a given cohort property value");return n==="AND"}}function SBp(e){try{return new RegExp(e),!0}catch{return!1}}function DBp(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 R2(`${e} is in an invalid date format`)}else throw new R2(`The date provided ${e} must be a string, number, or date object`)}function pbD(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var dKs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},_bD=100,EBp=30*1e3,hbD=50*1e3,pKs=class extends cKs{constructor(t,r={}){if(super(t,r),this._memoryStorage=new dKs,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,_bD):EBp,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 fKs({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new aFn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||hbD}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):FBp(t,r)}getLibraryVersion(){return HvD}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:i,properties:n,groups:a,sendFeatureFlags:u,timestamp:l,disableGeoip:d,uuid:s}=t,o=g=>{super.captureStateless(r,i,g,{timestamp:l,disableGeoip:d,uuid:s})},c=async(g,O,m)=>(await super.getFeatureFlagsStateless(g,O,void 0,void 0,m)).flags,b=Promise.resolve().then(async()=>{if(u)return await c(r,a,d);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let g={};for(let[O,m]of Object.entries(a||{}))g[O]=String(m);return await this.getAllFlags(r,{groups:g,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(g=>{let O={};if(g)for(let[w,E]of Object.entries(g))O[`$feature/${w}`]=E;let m=Object.keys(g||{}).filter(w=>g?.[w]!==!1).sort();return m.length>0&&(O.$active_feature_flags=m),O}).catch(()=>({})).then(g=>{o({...g,...n,$groups:a})});this.addPendingPromise(b)}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:i,properties:n,groups:a,sendFeatureFlags:u,timestamp:l,disableGeoip:d,uuid:s}=t,o=g=>super.captureStatelessImmediate(r,i,g,{timestamp:l,disableGeoip:d,uuid:s}),c=async(g,O,m)=>(await super.getFeatureFlagsStateless(g,O,void 0,void 0,m)).flags;await Promise.resolve().then(async()=>{if(u)return await c(r,a,d);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let g={};for(let[O,m]of Object.entries(a||{}))g[O]=String(m);return await this.getAllFlags(r,{groups:g,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(g=>{let O={};if(g)for(let[w,E]of Object.entries(g))O[`$feature/${w}`]=E;let m=Object.keys(g||{}).filter(w=>g?.[w]!==!1).sort();return m.length>0&&(O.$active_feature_flags=m),O}).catch(()=>({})).then(g=>{o({...g,...n,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:n},{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:n},{disableGeoip:i})}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=EBp){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0,g,O;if(!b&&!u){let w=await super.getFeatureFlagDetailStateless(t,r,n,d,s,a);if(w===void 0)return;O=w.response,c=yKs(O),g=w?.requestId}let m=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(m))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(m):this.distinctIdHasSentFlagCalls[r]=[m],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,$feature_flag_id:O?.metadata?.id,$feature_flag_version:O?.metadata?.version,$feature_flag_reason:O?.reason?.description??O?.reason?.code,locally_evaluated:b,[`$feature/${t}`]:c,$feature_flag_request_id:g},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),l==null&&(l=!1),d==null&&(d=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}captureException(t,r,i){let n=new Error("PostHog syntheticException");aFn.captureException(this,t,{syntheticException:n},r,i)}},MBp=/\(error: (.*)\)/,HBp=50,$Bp="?";function ybD(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,u,l,d,s;if(n[1]){l=n[1];let b=l.lastIndexOf(".");if(l[b-1]==="."&&b--,b>0){a=l.slice(0,b),u=l.slice(b+1);let g=a.indexOf(".Module");g>0&&(l=l.slice(g+1),a=a.slice(0,g))}d=void 0}u&&(d=a,s=u),u==="<anonymous>"&&(s=void 0,l=void 0),l===void 0&&(s=s||$Bp,l=d?`${d}.${s}`:s);let o=n[2]?.startsWith("file://")?n[2].slice(7):n[2],c=n[5]==="native";return o?.match(/\/[A-Z]:/)&&(o=o.slice(1)),!o&&n[5]&&!c&&(o=n[5]),{filename:o?decodeURI(o):void 0,module:e?e(o):void 0,function:l,lineno:ABp(n[3]),colno:ABp(n[4]),in_app:vbD(o||"",c),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function vbD(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 ABp(e){return parseInt(e||"",10)||void 0}function bbD(e){return[90,ybD(e)]}function gbD(e){let r=[bbD(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],u=i.split(`
|
|
1714
|
-
`);for(let l=n;l<u.length;l++){let d=u[l];if(d.length>1024)continue;let s=MBp.test(d)?d.replace(MBp,"$1"):d;if(!s.match(/\S*Error: /)){for(let o of r){let c=o(s);if(c){a.push(c);break}}if(a.length>=HBp)break}}return ObD(a)}}function ObD(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,HBp).map(r=>({...r,filename:r.filename||mbD(t).filename,function:r.function||$Bp}))}function mbD(e){return e[e.length-1]||{}}aFn.stackParser=gbD(TvD());aFn.frameModifiers=[IvD];var uFn=class extends pKs{getLibraryId(){return"posthog-node"}};var v3o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new uFn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.64.24",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var lEa=class{async sendEvent(){}async identify(){}async flush(){}};var cFn=require("fs/promises"),KBp=require("os"),YBp=require("path");var GBp=ai(require("crypto")),g3o=new Uint8Array(256),b3o=g3o.length;function vKs(){return b3o>g3o.length-16&&(GBp.default.randomFillSync(g3o),b3o=0),g3o.slice(b3o,b3o+=16)}var DW=[];for(let e=0;e<256;++e)DW.push((e+256).toString(16).slice(1));function QBp(e,t=0){return DW[e[t+0]]+DW[e[t+1]]+DW[e[t+2]]+DW[e[t+3]]+"-"+DW[e[t+4]]+DW[e[t+5]]+"-"+DW[e[t+6]]+DW[e[t+7]]+"-"+DW[e[t+8]]+DW[e[t+9]]+"-"+DW[e[t+10]]+DW[e[t+11]]+DW[e[t+12]]+DW[e[t+13]]+DW[e[t+14]]+DW[e[t+15]]}var JBp=ai(require("crypto")),bKs={randomUUID:JBp.default.randomUUID};function PbD(e,t,r){if(bKs.randomUUID&&!t&&!e)return bKs.randomUUID();e=e||{};let i=e.random||(e.rng||vKs)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return QBp(i)}var hae=PbD;var jbD="id",wbD=".fern",fEa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new uFn(r),this.userId=t==null?void 0:sVs(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:"0.64.24",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Lu(hl.of((0,KBp.homedir)()),Ua.of(wbD),Ua.of(jbD));await mf(t)||(await(0,cFn.mkdir)((0,YBp.dirname)(t),{recursive:!0}),await(0,cFn.writeFile)(t,hae())),this.persistedDistinctId=(await(0,cFn.readFile)(t)).toString()}return this.persistedDistinctId}};var gKs;async function lFn(){return gKs==null&&(gKs=await SbD()),gKs}async function SbD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new lEa;let r=await NBo();return r!=null?new fEa({token:r,posthogApiKey:e}):await cRn()!=null?new v3o({posthogApiKey:e}):new fEa({token:void 0,posthogApiKey:e})}catch{return new lEa}}function dEa(e,t){return function(){return e.apply(t,arguments)}}var{toString:DbD}=Object.prototype,{getPrototypeOf:mKs}=Object,{iterator:m3o,toStringTag:ZBp}=Symbol,P3o=(e=>t=>{let r=DbD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),lWt=e=>(e=e.toLowerCase(),t=>P3o(t)===e),j3o=e=>t=>typeof t===e,{isArray:fFn}=Array,pEa=j3o("undefined");function EbD(e){return e!==null&&!pEa(e)&&e.constructor!==null&&!pEa(e.constructor)&&yae(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var kBp=lWt("ArrayBuffer");function MbD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&kBp(e.buffer),t}var AbD=j3o("string"),yae=j3o("function"),eIp=j3o("number"),w3o=e=>e!==null&&typeof e=="object",qbD=e=>e===!0||e===!1,O3o=e=>{if(P3o(e)!=="object")return!1;let t=mKs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ZBp in e)&&!(m3o in e)},TbD=lWt("Date"),CbD=lWt("File"),BbD=lWt("Blob"),IbD=lWt("FileList"),zbD=e=>w3o(e)&&yae(e.pipe),xbD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||yae(e.append)&&((t=P3o(e))==="formdata"||t==="object"&&yae(e.toString)&&e.toString()==="[object FormData]"))},RbD=lWt("URLSearchParams"),[NbD,FbD,LbD,UbD]=["ReadableStream","Request","Response","Headers"].map(lWt),VbD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _Ea(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),fFn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function tIp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var VHi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rIp=e=>!pEa(e)&&e!==VHi;function OKs(){let{caseless:e}=rIp(this)&&this||{},t={},r=(i,n)=>{let a=e&&tIp(t,n)||n;O3o(t[a])&&O3o(i)?t[a]=OKs(t[a],i):O3o(i)?t[a]=OKs({},i):fFn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&_Ea(arguments[i],r);return t}var WbD=(e,t,r,{allOwnKeys:i}={})=>(_Ea(t,(n,a)=>{r&&yae(n)?e[a]=dEa(n,r):e[a]=n},{allOwnKeys:i}),e),HbD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$bD=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},GbD=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&mKs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},QbD=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},JbD=e=>{if(!e)return null;if(fFn(e))return e;let t=e.length;if(!eIp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},KbD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&mKs(Uint8Array)),YbD=(e,t)=>{let i=(e&&e[m3o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},XbD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},ZbD=lWt("HTMLFormElement"),kbD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),XBp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),e0D=lWt("RegExp"),iIp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};_Ea(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},t0D=e=>{iIp(e,(t,r)=>{if(yae(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(yae(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},r0D=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return fFn(e)?i(e):i(String(e).split(t)),r},i0D=()=>{},n0D=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function a0D(e){return!!(e&&yae(e.append)&&e[ZBp]==="FormData"&&e[m3o])}var o0D=e=>{let t=new Array(10),r=(i,n)=>{if(w3o(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=fFn(i)?[]:{};return _Ea(i,(u,l)=>{let d=r(u,n+1);!pEa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},u0D=lWt("AsyncFunction"),s0D=e=>e&&(w3o(e)||yae(e))&&yae(e.then)&&yae(e.catch),nIp=((e,t)=>e?setImmediate:t?((r,i)=>(VHi.addEventListener("message",({source:n,data:a})=>{n===VHi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),VHi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",yae(VHi.postMessage)),c0D=typeof queueMicrotask<"u"?queueMicrotask.bind(VHi):typeof process<"u"&&process.nextTick||nIp,l0D=e=>e!=null&&yae(e[m3o]),us={isArray:fFn,isArrayBuffer:kBp,isBuffer:EbD,isFormData:xbD,isArrayBufferView:MbD,isString:AbD,isNumber:eIp,isBoolean:qbD,isObject:w3o,isPlainObject:O3o,isReadableStream:NbD,isRequest:FbD,isResponse:LbD,isHeaders:UbD,isUndefined:pEa,isDate:TbD,isFile:CbD,isBlob:BbD,isRegExp:e0D,isFunction:yae,isStream:zbD,isURLSearchParams:RbD,isTypedArray:KbD,isFileList:IbD,forEach:_Ea,merge:OKs,extend:WbD,trim:VbD,stripBOM:HbD,inherits:$bD,toFlatObject:GbD,kindOf:P3o,kindOfTest:lWt,endsWith:QbD,toArray:JbD,forEachEntry:YbD,matchAll:XbD,isHTMLForm:ZbD,hasOwnProperty:XBp,hasOwnProp:XBp,reduceDescriptors:iIp,freezeMethods:t0D,toObjectSet:r0D,toCamelCase:kbD,noop:i0D,toFiniteNumber:n0D,findKey:tIp,global:VHi,isContextDefined:rIp,isSpecCompliantForm:a0D,toJSONObject:o0D,isAsyncFn:u0D,isThenable:s0D,setImmediate:nIp,asap:c0D,isIterable:l0D};function dFn(e,t,r,i,n){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),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}us.inherits(dFn,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:us.toJSONObject(this.config),code:this.code,status:this.status}}});var aIp=dFn.prototype,oIp={};["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=>{oIp[e]={value:e}});Object.defineProperties(dFn,oIp);Object.defineProperty(aIp,"isAxiosError",{value:!0});dFn.from=(e,t,r,i,n,a)=>{let u=Object.create(aIp);return us.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),dFn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Np=dFn;var uIp=ai($Fo(),1),S3o=uIp.default;function PKs(e){return us.isPlainObject(e)||us.isArray(e)}function cIp(e){return us.endsWith(e,"[]")?e.slice(0,-2):e}function sIp(e,t,r){return e?e.concat(t).map(function(n,a){return n=cIp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function f0D(e){return us.isArray(e)&&!e.some(PKs)}var d0D=us.toFlatObject(us,{},null,function(t){return/^is[A-Z]/.test(t)});function p0D(e,t,r){if(!us.isObject(e))throw new TypeError("target must be an object");t=t||new(S3o||FormData),r=us.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!us.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&us.isSpecCompliantForm(t);if(!us.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(us.isDate(O))return O.toISOString();if(us.isBoolean(O))return O.toString();if(!d&&us.isBlob(O))throw new Np("Blob is not supported. Use a Buffer instead.");return us.isArrayBuffer(O)||us.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(us.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(us.isArray(O)&&f0D(O)||(us.isFileList(O)||us.endsWith(m,"[]"))&&(E=us.toArray(O)))return m=cIp(m),E.forEach(function(A,D){!(us.isUndefined(A)||A===null)&&t.append(u===!0?sIp([m],D,a):u===null?m:m+"[]",s(A))}),!1}return PKs(O)?!0:(t.append(sIp(w,m,a),s(O)),!1)}let c=[],b=Object.assign(d0D,{defaultVisitor:o,convertValue:s,isVisitable:PKs});function g(O,m){if(!us.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),us.forEach(O,function(E,q){(!(us.isUndefined(E)||E===null)&&n.call(t,E,us.isString(q)?q.trim():q,m,b))===!0&&g(E,m?m.concat(q):[q])}),c.pop()}}if(!us.isObject(e))throw new TypeError("data must be an object");return g(e),t}var JSi=p0D;function lIp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function fIp(e,t){this._pairs=[],e&&JSi(e,this,t)}var dIp=fIp.prototype;dIp.append=function(t,r){this._pairs.push([t,r])};dIp.toString=function(t){let r=t?function(i){return t.call(this,i,lIp)}:lIp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var pIp=fIp;function _0D(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function WHi(e,t,r){if(!t)return e;let i=r&&r.encode||_0D;us.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=us.isURLSearchParams(t)?t.toString():new pIp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var jKs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){us.forEach(this.handlers,function(i){i!==null&&t(i)})}},wKs=jKs;var pFn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var vIp=ai(require("crypto"),1);var _Ip=ai(require("url"),1),hIp=_Ip.default.URLSearchParams;var SKs="abcdefghijklmnopqrstuvwxyz",yIp="0123456789",bIp={DIGIT:yIp,ALPHA:SKs,ALPHA_DIGIT:SKs+SKs.toUpperCase()+yIp},h0D=(e=16,t=bIp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);vIp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},gIp={isNode:!0,classes:{URLSearchParams:hIp,FormData:S3o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:bIp,generateString:h0D,protocols:["http","https","file","data"]};var MKs={};Dn(MKs,{hasBrowserEnv:()=>EKs,hasStandardBrowserEnv:()=>y0D,hasStandardBrowserWebWorkerEnv:()=>v0D,navigator:()=>DKs,origin:()=>b0D});var EKs=typeof window<"u"&&typeof document<"u",DKs=typeof navigator=="object"&&navigator||void 0,y0D=EKs&&(!DKs||["ReactNative","NativeScript","NS"].indexOf(DKs.product)<0),v0D=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",b0D=EKs&&window.location.href||"http://localhost";var aA={...MKs,...gIp};function AKs(e,t){return JSi(e,new aA.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return aA.isNode&&us.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function g0D(e){return us.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function O0D(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function m0D(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&us.isArray(n)?n.length:u,d?(us.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!us.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&us.isArray(n[u])&&(n[u]=O0D(n[u])),!l)}if(us.isFormData(e)&&us.isFunction(e.entries)){let r={};return us.forEachEntry(e,(i,n)=>{t(g0D(i),n,r,0)}),r}return null}var D3o=m0D;function P0D(e,t,r){if(us.isString(e))try{return(t||JSON.parse)(e),us.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var qKs={transitional:pFn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=us.isObject(t);if(a&&us.isHTMLForm(t)&&(t=new FormData(t)),us.isFormData(t))return n?JSON.stringify(D3o(t)):t;if(us.isArrayBuffer(t)||us.isBuffer(t)||us.isStream(t)||us.isFile(t)||us.isBlob(t)||us.isReadableStream(t))return t;if(us.isArrayBufferView(t))return t.buffer;if(us.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return AKs(t,this.formSerializer).toString();if((l=us.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return JSi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),P0D(t)):t}],transformResponse:[function(t){let r=this.transitional||qKs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(us.isResponse(t)||us.isReadableStream(t))return t;if(t&&us.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?Np.from(l,Np.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:aA.classes.FormData,Blob:aA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};us.forEach(["delete","get","head","post","put","patch"],e=>{qKs.headers[e]={}});var _Fn=qKs;var j0D=us.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"]),OIp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1714
|
+
`);for(let l=n;l<u.length;l++){let d=u[l];if(d.length>1024)continue;let s=MBp.test(d)?d.replace(MBp,"$1"):d;if(!s.match(/\S*Error: /)){for(let o of r){let c=o(s);if(c){a.push(c);break}}if(a.length>=HBp)break}}return ObD(a)}}function ObD(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,HBp).map(r=>({...r,filename:r.filename||mbD(t).filename,function:r.function||$Bp}))}function mbD(e){return e[e.length-1]||{}}aFn.stackParser=gbD(TvD());aFn.frameModifiers=[IvD];var uFn=class extends pKs{getLibraryId(){return"posthog-node"}};var v3o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new uFn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.64.25",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var lEa=class{async sendEvent(){}async identify(){}async flush(){}};var cFn=require("fs/promises"),KBp=require("os"),YBp=require("path");var GBp=ai(require("crypto")),g3o=new Uint8Array(256),b3o=g3o.length;function vKs(){return b3o>g3o.length-16&&(GBp.default.randomFillSync(g3o),b3o=0),g3o.slice(b3o,b3o+=16)}var DW=[];for(let e=0;e<256;++e)DW.push((e+256).toString(16).slice(1));function QBp(e,t=0){return DW[e[t+0]]+DW[e[t+1]]+DW[e[t+2]]+DW[e[t+3]]+"-"+DW[e[t+4]]+DW[e[t+5]]+"-"+DW[e[t+6]]+DW[e[t+7]]+"-"+DW[e[t+8]]+DW[e[t+9]]+"-"+DW[e[t+10]]+DW[e[t+11]]+DW[e[t+12]]+DW[e[t+13]]+DW[e[t+14]]+DW[e[t+15]]}var JBp=ai(require("crypto")),bKs={randomUUID:JBp.default.randomUUID};function PbD(e,t,r){if(bKs.randomUUID&&!t&&!e)return bKs.randomUUID();e=e||{};let i=e.random||(e.rng||vKs)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return QBp(i)}var hae=PbD;var jbD="id",wbD=".fern",fEa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new uFn(r),this.userId=t==null?void 0:sVs(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:"0.64.25",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Lu(hl.of((0,KBp.homedir)()),Ua.of(wbD),Ua.of(jbD));await mf(t)||(await(0,cFn.mkdir)((0,YBp.dirname)(t),{recursive:!0}),await(0,cFn.writeFile)(t,hae())),this.persistedDistinctId=(await(0,cFn.readFile)(t)).toString()}return this.persistedDistinctId}};var gKs;async function lFn(){return gKs==null&&(gKs=await SbD()),gKs}async function SbD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new lEa;let r=await NBo();return r!=null?new fEa({token:r,posthogApiKey:e}):await cRn()!=null?new v3o({posthogApiKey:e}):new fEa({token:void 0,posthogApiKey:e})}catch{return new lEa}}function dEa(e,t){return function(){return e.apply(t,arguments)}}var{toString:DbD}=Object.prototype,{getPrototypeOf:mKs}=Object,{iterator:m3o,toStringTag:ZBp}=Symbol,P3o=(e=>t=>{let r=DbD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),lWt=e=>(e=e.toLowerCase(),t=>P3o(t)===e),j3o=e=>t=>typeof t===e,{isArray:fFn}=Array,pEa=j3o("undefined");function EbD(e){return e!==null&&!pEa(e)&&e.constructor!==null&&!pEa(e.constructor)&&yae(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var kBp=lWt("ArrayBuffer");function MbD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&kBp(e.buffer),t}var AbD=j3o("string"),yae=j3o("function"),eIp=j3o("number"),w3o=e=>e!==null&&typeof e=="object",qbD=e=>e===!0||e===!1,O3o=e=>{if(P3o(e)!=="object")return!1;let t=mKs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ZBp in e)&&!(m3o in e)},TbD=lWt("Date"),CbD=lWt("File"),BbD=lWt("Blob"),IbD=lWt("FileList"),zbD=e=>w3o(e)&&yae(e.pipe),xbD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||yae(e.append)&&((t=P3o(e))==="formdata"||t==="object"&&yae(e.toString)&&e.toString()==="[object FormData]"))},RbD=lWt("URLSearchParams"),[NbD,FbD,LbD,UbD]=["ReadableStream","Request","Response","Headers"].map(lWt),VbD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _Ea(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),fFn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function tIp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var VHi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rIp=e=>!pEa(e)&&e!==VHi;function OKs(){let{caseless:e}=rIp(this)&&this||{},t={},r=(i,n)=>{let a=e&&tIp(t,n)||n;O3o(t[a])&&O3o(i)?t[a]=OKs(t[a],i):O3o(i)?t[a]=OKs({},i):fFn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&_Ea(arguments[i],r);return t}var WbD=(e,t,r,{allOwnKeys:i}={})=>(_Ea(t,(n,a)=>{r&&yae(n)?e[a]=dEa(n,r):e[a]=n},{allOwnKeys:i}),e),HbD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$bD=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},GbD=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&mKs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},QbD=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},JbD=e=>{if(!e)return null;if(fFn(e))return e;let t=e.length;if(!eIp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},KbD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&mKs(Uint8Array)),YbD=(e,t)=>{let i=(e&&e[m3o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},XbD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},ZbD=lWt("HTMLFormElement"),kbD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),XBp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),e0D=lWt("RegExp"),iIp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};_Ea(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},t0D=e=>{iIp(e,(t,r)=>{if(yae(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(yae(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},r0D=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return fFn(e)?i(e):i(String(e).split(t)),r},i0D=()=>{},n0D=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function a0D(e){return!!(e&&yae(e.append)&&e[ZBp]==="FormData"&&e[m3o])}var o0D=e=>{let t=new Array(10),r=(i,n)=>{if(w3o(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=fFn(i)?[]:{};return _Ea(i,(u,l)=>{let d=r(u,n+1);!pEa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},u0D=lWt("AsyncFunction"),s0D=e=>e&&(w3o(e)||yae(e))&&yae(e.then)&&yae(e.catch),nIp=((e,t)=>e?setImmediate:t?((r,i)=>(VHi.addEventListener("message",({source:n,data:a})=>{n===VHi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),VHi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",yae(VHi.postMessage)),c0D=typeof queueMicrotask<"u"?queueMicrotask.bind(VHi):typeof process<"u"&&process.nextTick||nIp,l0D=e=>e!=null&&yae(e[m3o]),us={isArray:fFn,isArrayBuffer:kBp,isBuffer:EbD,isFormData:xbD,isArrayBufferView:MbD,isString:AbD,isNumber:eIp,isBoolean:qbD,isObject:w3o,isPlainObject:O3o,isReadableStream:NbD,isRequest:FbD,isResponse:LbD,isHeaders:UbD,isUndefined:pEa,isDate:TbD,isFile:CbD,isBlob:BbD,isRegExp:e0D,isFunction:yae,isStream:zbD,isURLSearchParams:RbD,isTypedArray:KbD,isFileList:IbD,forEach:_Ea,merge:OKs,extend:WbD,trim:VbD,stripBOM:HbD,inherits:$bD,toFlatObject:GbD,kindOf:P3o,kindOfTest:lWt,endsWith:QbD,toArray:JbD,forEachEntry:YbD,matchAll:XbD,isHTMLForm:ZbD,hasOwnProperty:XBp,hasOwnProp:XBp,reduceDescriptors:iIp,freezeMethods:t0D,toObjectSet:r0D,toCamelCase:kbD,noop:i0D,toFiniteNumber:n0D,findKey:tIp,global:VHi,isContextDefined:rIp,isSpecCompliantForm:a0D,toJSONObject:o0D,isAsyncFn:u0D,isThenable:s0D,setImmediate:nIp,asap:c0D,isIterable:l0D};function dFn(e,t,r,i,n){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),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}us.inherits(dFn,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:us.toJSONObject(this.config),code:this.code,status:this.status}}});var aIp=dFn.prototype,oIp={};["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=>{oIp[e]={value:e}});Object.defineProperties(dFn,oIp);Object.defineProperty(aIp,"isAxiosError",{value:!0});dFn.from=(e,t,r,i,n,a)=>{let u=Object.create(aIp);return us.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),dFn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Np=dFn;var uIp=ai($Fo(),1),S3o=uIp.default;function PKs(e){return us.isPlainObject(e)||us.isArray(e)}function cIp(e){return us.endsWith(e,"[]")?e.slice(0,-2):e}function sIp(e,t,r){return e?e.concat(t).map(function(n,a){return n=cIp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function f0D(e){return us.isArray(e)&&!e.some(PKs)}var d0D=us.toFlatObject(us,{},null,function(t){return/^is[A-Z]/.test(t)});function p0D(e,t,r){if(!us.isObject(e))throw new TypeError("target must be an object");t=t||new(S3o||FormData),r=us.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!us.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&us.isSpecCompliantForm(t);if(!us.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(us.isDate(O))return O.toISOString();if(us.isBoolean(O))return O.toString();if(!d&&us.isBlob(O))throw new Np("Blob is not supported. Use a Buffer instead.");return us.isArrayBuffer(O)||us.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(us.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(us.isArray(O)&&f0D(O)||(us.isFileList(O)||us.endsWith(m,"[]"))&&(E=us.toArray(O)))return m=cIp(m),E.forEach(function(A,D){!(us.isUndefined(A)||A===null)&&t.append(u===!0?sIp([m],D,a):u===null?m:m+"[]",s(A))}),!1}return PKs(O)?!0:(t.append(sIp(w,m,a),s(O)),!1)}let c=[],b=Object.assign(d0D,{defaultVisitor:o,convertValue:s,isVisitable:PKs});function g(O,m){if(!us.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),us.forEach(O,function(E,q){(!(us.isUndefined(E)||E===null)&&n.call(t,E,us.isString(q)?q.trim():q,m,b))===!0&&g(E,m?m.concat(q):[q])}),c.pop()}}if(!us.isObject(e))throw new TypeError("data must be an object");return g(e),t}var JSi=p0D;function lIp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function fIp(e,t){this._pairs=[],e&&JSi(e,this,t)}var dIp=fIp.prototype;dIp.append=function(t,r){this._pairs.push([t,r])};dIp.toString=function(t){let r=t?function(i){return t.call(this,i,lIp)}:lIp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var pIp=fIp;function _0D(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function WHi(e,t,r){if(!t)return e;let i=r&&r.encode||_0D;us.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=us.isURLSearchParams(t)?t.toString():new pIp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var jKs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){us.forEach(this.handlers,function(i){i!==null&&t(i)})}},wKs=jKs;var pFn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var vIp=ai(require("crypto"),1);var _Ip=ai(require("url"),1),hIp=_Ip.default.URLSearchParams;var SKs="abcdefghijklmnopqrstuvwxyz",yIp="0123456789",bIp={DIGIT:yIp,ALPHA:SKs,ALPHA_DIGIT:SKs+SKs.toUpperCase()+yIp},h0D=(e=16,t=bIp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);vIp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},gIp={isNode:!0,classes:{URLSearchParams:hIp,FormData:S3o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:bIp,generateString:h0D,protocols:["http","https","file","data"]};var MKs={};Dn(MKs,{hasBrowserEnv:()=>EKs,hasStandardBrowserEnv:()=>y0D,hasStandardBrowserWebWorkerEnv:()=>v0D,navigator:()=>DKs,origin:()=>b0D});var EKs=typeof window<"u"&&typeof document<"u",DKs=typeof navigator=="object"&&navigator||void 0,y0D=EKs&&(!DKs||["ReactNative","NativeScript","NS"].indexOf(DKs.product)<0),v0D=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",b0D=EKs&&window.location.href||"http://localhost";var aA={...MKs,...gIp};function AKs(e,t){return JSi(e,new aA.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return aA.isNode&&us.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function g0D(e){return us.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function O0D(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function m0D(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&us.isArray(n)?n.length:u,d?(us.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!us.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&us.isArray(n[u])&&(n[u]=O0D(n[u])),!l)}if(us.isFormData(e)&&us.isFunction(e.entries)){let r={};return us.forEachEntry(e,(i,n)=>{t(g0D(i),n,r,0)}),r}return null}var D3o=m0D;function P0D(e,t,r){if(us.isString(e))try{return(t||JSON.parse)(e),us.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var qKs={transitional:pFn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=us.isObject(t);if(a&&us.isHTMLForm(t)&&(t=new FormData(t)),us.isFormData(t))return n?JSON.stringify(D3o(t)):t;if(us.isArrayBuffer(t)||us.isBuffer(t)||us.isStream(t)||us.isFile(t)||us.isBlob(t)||us.isReadableStream(t))return t;if(us.isArrayBufferView(t))return t.buffer;if(us.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return AKs(t,this.formSerializer).toString();if((l=us.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return JSi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),P0D(t)):t}],transformResponse:[function(t){let r=this.transitional||qKs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(us.isResponse(t)||us.isReadableStream(t))return t;if(t&&us.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?Np.from(l,Np.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:aA.classes.FormData,Blob:aA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};us.forEach(["delete","get","head","post","put","patch"],e=>{qKs.headers[e]={}});var _Fn=qKs;var j0D=us.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"]),OIp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1715
1715
|
`).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&j0D[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var mIp=Symbol("internals");function hEa(e){return e&&String(e).trim().toLowerCase()}function E3o(e){return e===!1||e==null?e:us.isArray(e)?e.map(E3o):String(e)}function w0D(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var S0D=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function TKs(e,t,r,i,n){if(us.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!us.isString(t)){if(us.isString(i))return t.indexOf(i)!==-1;if(us.isRegExp(i))return i.test(t)}}function D0D(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function E0D(e,t){let r=us.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var hFn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,d,s){let o=hEa(d);if(!o)throw new Error("header name must be a non-empty string");let c=us.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||d]=E3o(l))}let u=(l,d)=>us.forEach(l,(s,o)=>a(s,o,d));if(us.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(us.isString(t)&&(t=t.trim())&&!S0D(t))u(OIp(t),r);else if(us.isObject(t)&&us.isIterable(t)){let l={},d,s;for(let o of t){if(!us.isArray(o))throw TypeError("Object iterator must return a key-value pair");l[s=o[0]]=(d=l[s])?us.isArray(d)?[...d,o[1]]:[d,o[1]]:o[1]}u(l,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=hEa(t),t){let i=us.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return w0D(n);if(us.isFunction(r))return r.call(this,n,i);if(us.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=hEa(t),t){let i=us.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||TKs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=hEa(u),u){let l=us.findKey(i,u);l&&(!r||TKs(i,i[l],l,r))&&(delete i[l],n=!0)}}return us.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||TKs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return us.forEach(this,(n,a)=>{let u=us.findKey(i,a);if(u){r[u]=E3o(n),delete r[a];return}let l=t?D0D(a):String(a).trim();l!==a&&delete r[a],r[l]=E3o(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return us.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&us.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
1716
1716
|
`)}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 i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[mIp]=this[mIp]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=hEa(u);i[l]||(E0D(n,u),i[l]=!0)}return us.isArray(t)?t.forEach(a):a(t),this}};hFn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);us.reduceDescriptors(hFn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});us.freezeMethods(hFn);var rR=hFn;function yEa(e,t){let r=this||_Fn,i=t||r,n=rR.from(i.headers),a=i.data;return us.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function vEa(e){return!!(e&&e.__CANCEL__)}function PIp(e,t,r){Np.call(this,e??"canceled",Np.ERR_CANCELED,t,r),this.name="CanceledError"}us.inherits(PIp,Np,{__CANCEL__:!0});var HEe=PIp;function Qtr(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new Np("Request failed with status code "+r.status,[Np.ERR_BAD_REQUEST,Np.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function CKs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function BKs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function HHi(e,t,r){let i=!CKs(t);return e&&(i||r==!1)?BKs(e,t):t}var NIp=ai(kDa(),1),FIp=ai(require("http"),1),LIp=ai(require("https"),1),UIp=ai(require("util"),1),VIp=ai(BJs(),1),lfi=ai(require("zlib"),1);var $Hi="1.10.0";function bEa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var M0D=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function IKs(e,t,r){let i=r&&r.Blob||aA.classes.Blob,n=bEa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=M0D.exec(e);if(!a)throw new Np("Invalid URL",Np.ERR_INVALID_URL);let u=a[1],l=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),l?"base64":"utf8");if(t){if(!i)throw new Np("Blob is not supported",Np.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new Np("Unsupported protocol "+n,Np.ERR_NOT_SUPPORT)}var QHi=ai(require("stream"),1);var jIp=ai(require("stream"),1);var zKs=Symbol("internals"),xKs=class extends jIp.default.Transform{constructor(t){t=us.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!us.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[zKs]={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",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[zKs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[zKs],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,d=1e3/l,s=a/d,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,c=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),w=null,E=u,q,A=0;if(a){let D=Date.now();(!n.ts||(A=D-n.ts)>=l)&&(n.ts=D,q=s-n.bytes,n.bytes=q<0?-q:0,A=0),q=s-n.bytes}if(a){if(q<=0)return setTimeout(()=>{O(null,g)},l-A);q<E&&(E=q)}E&&m>E&&m-E>o&&(w=g.subarray(E),g=g.subarray(0,E)),c(g,w?()=>{process.nextTick(O,null,w)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},RKs=xKs;var WIp=require("events");var SIp=ai(require("util"),1),DIp=require("stream");var{asyncIterator:wIp}=Symbol,A0D=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[wIp]?yield*e[wIp]():yield e},M3o=A0D;var q0D=aA.ALPHABET.ALPHA_DIGIT+"-_",gEa=typeof TextEncoder=="function"?new TextEncoder:new SIp.default.TextEncoder,GHi=`\r
|
|
1717
1717
|
`,T0D=gEa.encode(GHi),C0D=2,NKs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=us.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${GHi}`;n?r=gEa.encode(String(r).replace(/\r?\n|\r\n?/g,GHi)):a+=`Content-Type: ${r.type||"application/octet-stream"}${GHi}`,this.headers=gEa.encode(a+GHi),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+C0D,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;us.isTypedArray(t)?yield t:yield*M3o(t),yield T0D}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},B0D=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+aA.generateString(n,q0D)}=r||{};if(!us.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=gEa.encode("--"+a+GHi),l=gEa.encode("--"+a+"--"+GHi),d=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new NKs(c,b);return d+=g.size,g});d+=u.byteLength*s.length,d=us.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),DIp.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},EIp=B0D;var MIp=ai(require("stream"),1),FKs=class extends MIp.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},AIp=FKs;var I0D=(e,t)=>us.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,qIp=I0D;function z0D(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),o=i[a];u||(u=s),r[n]=d,i[n]=s;let c=a,b=0;for(;c!==n;)b+=r[c++],c=c%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var TIp=z0D;function x0D(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),c=o-r;c>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-c)))},()=>n&&u(n)]}var CIp=x0D;var cfi=(e,t,r=3)=>{let i=0,n=TIp(50,250);return CIp(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,d=u-i,s=n(d),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:d,rate:s||void 0,estimated:s&&l&&o?(l-u)/s:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(c)},r)},yFn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},vFn=e=>(...t)=>us.asap(()=>e(...t));var BIp={flush:lfi.default.constants.Z_SYNC_FLUSH,finishFlush:lfi.default.constants.Z_SYNC_FLUSH},R0D={flush:lfi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:lfi.default.constants.BROTLI_OPERATION_FLUSH},IIp=us.isFunction(lfi.default.createBrotliDecompress),{http:N0D,https:F0D}=VIp.default,L0D=/https:?/,zIp=aA.protocols.map(e=>e+":"),xIp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function U0D(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function HIp(e,t,r){let i=t;if(!i&&i!==!1){let n=NIp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){HIp(a,t,a.href)}}var V0D=typeof process<"u"&&us.kindOf(process)==="process",W0D=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},u=d=>{a(d),t(d)},l=d=>{a(d,!0),r(d)};e(u,l,d=>i=d).catch(l)}),H0D=({address:e,family:t})=>{if(!us.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},RIp=(e,t)=>H0D(us.isObject(e)?e:{address:e,family:t}),$Ip=V0D&&function(t){return W0D(async function(i,n,a){let{data:u,lookup:l,family:d}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let Oe=qIp(l,Ue=>us.isArray(Ue)?Ue:[Ue]);l=(Ue,wt,De)=>{Oe(Ue,wt,(Te,xt,Pe)=>{if(Te)return De(Te);let ot=us.isArray(xt)?xt.map(at=>RIp(at)):[RIp(xt,Pe)];wt.all?De(Te,ot):De(Te,ot[0].address,ot[0].family)})}}let m=new WIp.EventEmitter,w=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((Oe,Ue)=>{b=!0,Ue&&(g=!0,w())});function E(Oe){m.emit("abort",!Oe||Oe.type?new HEe(null,t,O):Oe)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(E),t.signal&&(t.signal.aborted?E():t.signal.addEventListener("abort",E)));let q=HHi(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(q,aA.hasBrowserEnv?aA.origin:void 0),D=A.protocol||zIp[0];if(D==="data:"){let Oe;if(c!=="GET")return Qtr(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{Oe=IKs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Ue){throw Np.from(Ue,Np.ERR_BAD_REQUEST,t)}return s==="text"?(Oe=Oe.toString(o),(!o||o==="utf8")&&(Oe=us.stripBOM(Oe))):s==="stream"&&(Oe=QHi.default.Readable.from(Oe)),Qtr(i,n,{data:Oe,status:200,statusText:"OK",headers:new rR,config:t})}if(zIp.indexOf(D)===-1)return n(new Np("Unsupported protocol "+D,Np.ERR_BAD_REQUEST,t));let C=rR.from(t.headers).normalize();C.set("User-Agent","axios/"+$Hi,!1);let{onUploadProgress:x,onDownloadProgress:$}=t,I=t.maxRate,L,V;if(us.isSpecCompliantForm(u)){let Oe=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=EIp(u,Ue=>{C.set(Ue)},{tag:`axios-${$Hi}-boundary`,boundary:Oe&&Oe[1]||void 0})}else if(us.isFormData(u)&&us.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let Oe=await UIp.default.promisify(u.getLength).call(u);Number.isFinite(Oe)&&Oe>=0&&C.setContentLength(Oe)}catch{}}else if(us.isBlob(u)||us.isFile(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=QHi.default.Readable.from(M3o(u));else if(u&&!us.isStream(u)){if(!Buffer.isBuffer(u))if(us.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(us.isString(u))u=Buffer.from(u,"utf-8");else return n(new Np("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Np.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new Np("Request body larger than maxBodyLength limit",Np.ERR_BAD_REQUEST,t))}let K=us.toFiniteNumber(C.getContentLength());us.isArray(I)?(L=I[0],V=I[1]):L=V=I,u&&(x||L)&&(us.isStream(u)||(u=QHi.default.Readable.from(u,{objectMode:!1})),u=QHi.default.pipeline([u,new RKs({maxRate:us.toFiniteNumber(L)})],us.noop),x&&u.on("progress",xIp(u,yFn(K,cfi(vFn(x),!1,3)))));let Y;if(t.auth){let Oe=t.auth.username||"",Ue=t.auth.password||"";Y=Oe+":"+Ue}if(!Y&&A.username){let Oe=A.username,Ue=A.password;Y=Oe+":"+Ue}Y&&C.delete("authorization");let Z;try{Z=WHi(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Oe){let Ue=new Error(Oe.message);return Ue.config=t,Ue.url=t.url,Ue.exists=!0,n(Ue)}C.set("Accept-Encoding","gzip, compress, deflate"+(IIp?", br":""),!1);let oe={path:Z,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:Y,protocol:D,family:d,beforeRedirect:U0D,beforeRedirects:{}};!us.isUndefined(l)&&(oe.lookup=l),t.socketPath?oe.socketPath=t.socketPath:(oe.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,oe.port=A.port,HIp(oe,t.proxy,D+"//"+A.hostname+(A.port?":"+A.port:"")+oe.path));let _e,de=L0D.test(oe.protocol);if(oe.agent=de?t.httpsAgent:t.httpAgent,t.transport?_e=t.transport:t.maxRedirects===0?_e=de?LIp.default:FIp.default:(t.maxRedirects&&(oe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(oe.beforeRedirects.config=t.beforeRedirect),_e=de?F0D:N0D),t.maxBodyLength>-1?oe.maxBodyLength=t.maxBodyLength:oe.maxBodyLength=1/0,t.insecureHTTPParser&&(oe.insecureHTTPParser=t.insecureHTTPParser),O=_e.request(oe,function(Ue){if(O.destroyed)return;let wt=[Ue],De=+Ue.headers["content-length"];if($||V){let at=new RKs({maxRate:us.toFiniteNumber(V)});$&&at.on("progress",xIp(at,yFn(De,cfi(vFn($),!0,3)))),wt.push(at)}let Te=Ue,xt=Ue.req||O;if(t.decompress!==!1&&Ue.headers["content-encoding"])switch((c==="HEAD"||Ue.statusCode===204)&&delete Ue.headers["content-encoding"],(Ue.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":wt.push(lfi.default.createUnzip(BIp)),delete Ue.headers["content-encoding"];break;case"deflate":wt.push(new AIp),wt.push(lfi.default.createUnzip(BIp)),delete Ue.headers["content-encoding"];break;case"br":IIp&&(wt.push(lfi.default.createBrotliDecompress(R0D)),delete Ue.headers["content-encoding"])}Te=wt.length>1?QHi.default.pipeline(wt,us.noop):wt[0];let Pe=QHi.default.finished(Te,()=>{Pe(),w()}),ot={status:Ue.statusCode,statusText:Ue.statusMessage,headers:new rR(Ue.headers),config:t,request:xt};if(s==="stream")ot.data=Te,Qtr(i,n,ot);else{let at=[],me=0;Te.on("data",function(jt){at.push(jt),me+=jt.length,t.maxContentLength>-1&&me>t.maxContentLength&&(g=!0,Te.destroy(),n(new Np("maxContentLength size of "+t.maxContentLength+" exceeded",Np.ERR_BAD_RESPONSE,t,xt)))}),Te.on("aborted",function(){if(g)return;let jt=new Np("stream has been aborted",Np.ERR_BAD_RESPONSE,t,xt);Te.destroy(jt),n(jt)}),Te.on("error",function(jt){O.destroyed||n(Np.from(jt,null,t,xt))}),Te.on("end",function(){try{let jt=at.length===1?at[0]:Buffer.concat(at);s!=="arraybuffer"&&(jt=jt.toString(o),(!o||o==="utf8")&&(jt=us.stripBOM(jt))),ot.data=jt}catch(jt){return n(Np.from(jt,null,t,ot.request,ot))}Qtr(i,n,ot)})}m.once("abort",at=>{Te.destroyed||(Te.emit("error",at),Te.destroy())})}),m.once("abort",Oe=>{n(Oe),O.destroy(Oe)}),O.on("error",function(Ue){n(Np.from(Ue,null,t,O))}),O.on("socket",function(Ue){Ue.setKeepAlive(!0,1e3*60)}),t.timeout){let Oe=parseInt(t.timeout,10);if(Number.isNaN(Oe)){n(new Np("error trying to parse `config.timeout` to int",Np.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(Oe,function(){if(b)return;let wt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",De=t.transitional||pFn;t.timeoutErrorMessage&&(wt=t.timeoutErrorMessage),n(new Np(wt,De.clarifyTimeoutError?Np.ETIMEDOUT:Np.ECONNABORTED,t,O)),E()})}if(us.isStream(u)){let Oe=!1,Ue=!1;u.on("end",()=>{Oe=!0}),u.once("error",wt=>{Ue=!0,O.destroy(wt)}),u.on("close",()=>{!Oe&&!Ue&&E(new HEe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var GIp=aA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,aA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(aA.origin),aA.navigator&&/(msie|trident)/i.test(aA.navigator.userAgent)):()=>!0;var QIp=aA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];us.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),us.isString(i)&&u.push("path="+i),us.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.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 JIp=e=>e instanceof rR?{...e}:e;function fWt(e,t){t=t||{};let r={};function i(s,o,c,b){return us.isPlainObject(s)&&us.isPlainObject(o)?us.merge.call({caseless:b},s,o):us.isPlainObject(o)?us.merge({},o):us.isArray(o)?o.slice():o}function n(s,o,c,b){if(us.isUndefined(o)){if(!us.isUndefined(s))return i(void 0,s,c,b)}else return i(s,o,c,b)}function a(s,o){if(!us.isUndefined(o))return i(void 0,o)}function u(s,o){if(us.isUndefined(o)){if(!us.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l,headers:(s,o,c)=>n(JIp(s),JIp(o),c,!0)};return us.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=d[o]||n,b=c(e[o],t[o],o);us.isUndefined(b)&&c!==l||(r[o]=b)}),r}var A3o=e=>{let t=fWt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=rR.from(u),t.url=WHi(HHi(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(us.isFormData(r)){if(aA.hasStandardBrowserEnv||aA.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[s,...o]=d?d.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(aA.hasStandardBrowserEnv&&(i&&us.isFunction(i)&&(i=i(t)),i||i!==!1&&GIp(t.url))){let s=n&&a&&QIp.read(a);s&&u.set(n,s)}return t};var $0D=typeof XMLHttpRequest<"u",KIp=$0D&&function(e){return new Promise(function(r,i){let n=A3o(e),a=n.data,u=rR.from(n.headers).normalize(),{responseType:l,onUploadProgress:d,onDownloadProgress:s}=n,o,c,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let w=new XMLHttpRequest;w.open(n.method.toUpperCase(),n.url,!0),w.timeout=n.timeout;function E(){if(!w)return;let A=rR.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:A,config:e,request:w};Qtr(function($){r($),m()},function($){i($),m()},C),w=null}"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(E)},w.onabort=function(){w&&(i(new Np("Request aborted",Np.ECONNABORTED,e,w)),w=null)},w.onerror=function(){i(new Np("Network Error",Np.ERR_NETWORK,e,w)),w=null},w.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||pFn;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new Np(D,C.clarifyTimeoutError?Np.ETIMEDOUT:Np.ECONNABORTED,e,w)),w=null},a===void 0&&u.setContentType(null),"setRequestHeader"in w&&us.forEach(u.toJSON(),function(D,C){w.setRequestHeader(C,D)}),us.isUndefined(n.withCredentials)||(w.withCredentials=!!n.withCredentials),l&&l!=="json"&&(w.responseType=n.responseType),s&&([b,O]=cfi(s,!0),w.addEventListener("progress",b)),d&&w.upload&&([c,g]=cfi(d),w.upload.addEventListener("progress",c),w.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=A=>{w&&(i(!A||A.type?new HEe(null,e,w):A),w.abort(),w=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let q=bEa(n.url);if(q&&aA.protocols.indexOf(q)===-1){i(new Np("Unsupported protocol "+q+":",Np.ERR_BAD_REQUEST,e));return}w.send(a||null)})};var G0D=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,l();let o=s instanceof Error?s:this.reason;i.abort(o instanceof Np?o:new HEe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new Np(`timeout ${t} of ms exceeded`,Np.ETIMEDOUT))},t),l=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=i;return d.unsubscribe=()=>us.asap(l),d}},YIp=G0D;var Q0D=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},J0D=async function*(e,t){for await(let r of K0D(e))yield*Q0D(r,t)},K0D=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},LKs=(e,t,r,i)=>{let n=J0D(e,t),a=0,u,l=d=>{u||(u=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:o}=await n.next();if(s){l(),d.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}d.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(d){return l(d),n.return()}},{highWaterMark:2})};var T3o=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ZIp=T3o&&typeof ReadableStream=="function",Y0D=T3o&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),kIp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},X0D=ZIp&&kIp(()=>{let e=!1,t=new Request(aA.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),XIp=64*1024,UKs=ZIp&&kIp(()=>us.isReadableStream(new Response("").body)),q3o={stream:UKs&&(e=>e.body)};T3o&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!q3o[t]&&(q3o[t]=us.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new Np(`Response type '${t}' is not supported`,Np.ERR_NOT_SUPPORT,i)})})})(new Response);var Z0D=async e=>{if(e==null)return 0;if(us.isBlob(e))return e.size;if(us.isSpecCompliantForm(e))return(await new Request(aA.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(us.isArrayBufferView(e)||us.isArrayBuffer(e))return e.byteLength;if(us.isURLSearchParams(e)&&(e=e+""),us.isString(e))return(await Y0D(e)).byteLength},k0D=async(e,t)=>{let r=us.toFiniteNumber(e.getContentLength());return r??Z0D(t)},ezp=T3o&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:d,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=A3o(e);s=s?(s+"").toLowerCase():"text";let g=YIp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),w;try{if(d&&X0D&&r!=="get"&&r!=="head"&&(w=await k0D(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),x;if(us.isFormData(i)&&(x=C.headers.get("content-type"))&&o.setContentType(x),C.body){let[$,I]=yFn(w,cfi(vFn(d)));i=LKs(C.body,XIp,$,I)}}us.isString(c)||(c=c?"include":"omit");let E="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:E?c:void 0});let q=await fetch(O,b),A=UKs&&(s==="stream"||s==="response");if(UKs&&(l||A&&m)){let C={};["status","statusText","headers"].forEach(L=>{C[L]=q[L]});let x=us.toFiniteNumber(q.headers.get("content-length")),[$,I]=l&&yFn(x,cfi(vFn(l),!0))||[];q=new Response(LKs(q.body,XIp,$,()=>{I&&I(),m&&m()}),C)}s=s||"text";let D=await q3o[us.findKey(q3o,s)||"text"](q,e);return!A&&m&&m(),await new Promise((C,x)=>{Qtr(C,x,{data:D,headers:rR.from(q.headers),status:q.status,statusText:q.statusText,config:e,request:O})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new Np("Network Error",Np.ERR_NETWORK,e,O),{cause:E.cause||E}):Np.from(E,E&&E.code,e,O)}});var VKs={http:$Ip,xhr:KIp,fetch:ezp};us.forEach(VKs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var tzp=e=>`- ${e}`,egD=e=>us.isFunction(e)||e===null||e===!1,C3o={getAdapter:e=>{e=us.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!egD(r)&&(i=VKs[(u=String(r)).toLowerCase()],i===void 0))throw new Np(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
|
|
@@ -1952,7 +1952,7 @@ ${A}${q}${D}${bKp.default.cursorHide}`});var YTa=ai(Cwi(),1);function Moc(e,t){i
|
|
|
1952
1952
|
Run ${Ds.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1953
1953
|
Run ${Ds.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),gFn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Foc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!VKp(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,d)=>l.generatorName.localeCompare(d.generatorName)||l.currentVersion.localeCompare(d.currentVersion));for(let l of u)n+=`
|
|
1954
1954
|
${await DUD(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Ds.dim(l.currentVersion)+Ds.reset(" \u2192 ")+Ds.green(l.latestVersion);return n+=`
|
|
1955
|
-
`,i?gFn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function DUD(e){let r=await new UKp.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 EUD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await HKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=Twi(o.name,c),g=await tkt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await HKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=Twi(s.name,o),b=await tkt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function HKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await RVt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function $Kp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=qae(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function RLo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await EUD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...$Kp(s,d,t.logger));else u.push(...$Kp(l.versions,void 0,t.logger))}return u}var nCa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var Z6n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Loc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)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(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),GKp=typeof globalThis.AbortController=="function",QKp=typeof globalThis.ReadableStream=="function",JKp=typeof globalThis.FormData=="function",NLo=["get","post","put","patch","head","delete"],MUD=()=>{};MUD();var KKp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},FLo=2147483647,YKp=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,LLo=Symbol("stop"),XKp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},ZKp={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 AUD=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=YKp,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.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},kKp=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(n){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:l,value:d}=await a.read();if(l){n.close();return}if(t){i+=d.byteLength;let s=r===0?0:i/r;t({percent:s,transferredBytes:i,totalBytes:r},d)}n.enqueue(d),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},eYp=(e,t)=>{let r=AUD(e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(n){let a=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function u(){let{done:l,value:d}=await a.read();if(l){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),n.close();return}i+=d.byteLength;let s=r===0?0:i/r;(r<i||s===1)&&(s=.99),t&&t({percent:Number(s.toFixed(2)),transferredBytes:i,totalBytes:r},d),n.enqueue(d),await u()}await u()}})})};var k6n=e=>e!==null&&typeof e=="object";var aCa=(...e)=>{for(let t of e)if((!k6n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Woc({},...e)},Uoc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function ULo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Woc(e[r]??[],t[r]??[])}var Voc=(e={},t={})=>({beforeRequest:ULo(e,t,"beforeRequest"),beforeRetry:ULo(e,t,"beforeRetry"),afterResponse:ULo(e,t,"afterResponse"),beforeError:ULo(e,t,"beforeError")}),Woc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(k6n(n)){for(let[a,u]of Object.entries(n))k6n(u)&&a in t&&(u=Woc(t[a],u)),t={...t,[a]:u};k6n(n.hooks)&&(i=Voc(i,n.hooks),t.hooks=i),k6n(n.headers)&&(r=Uoc(r,n.headers),t.headers=r)}return t};var rYp=e=>NLo.includes(e)?e.toUpperCase():e,qUD=["get","put","head","delete","options","trace"],TUD=[408,413,429,500,502,503,504],CUD=[413,429,503],tYp={limit:2,methods:qUD,statusCodes:TUD,afterStatusCodes:CUD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},iYp=(e={})=>{if(typeof e=="number")return{...tYp,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{...tYp,...e}};async function Hoc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Z6n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function $oc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var nYp=(e,t)=>{let r={};for(let i in t)!(i in ZKp)&&!(i in XKp)&&!(i in e)&&(r[i]=t[i]);return r};var oCa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>FLo)throw new RangeError(`The \`timeout\` option cannot be greater than ${FLo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new nCa(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!QKp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return kKp(l.clone(),i._options.onDownloadProgress)}return l},u=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[l,d]of Object.entries(KKp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await u;if(l==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Uoc(this._input.headers,r.headers),hooks:Voc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:rYp(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:iYp(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(GKp){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(Loc&&(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),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(JKp&&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(!Loc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=eYp(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Z6n)throw t;if(t instanceof nCa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=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(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n: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 i=Math.min(this._calculateRetryDelay(r),FLo);if(this._retryCount<1)throw r;await $oc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===LLo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=nYp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Hoc(r,t,this.abortController,this._options)}};var Goc=e=>{let t=(r,i)=>oCa.create(r,aCa(e,i));for(let r of NLo)t[r]=(i,n)=>oCa.create(i,aCa(e,n,{method:r}));return t.create=r=>Goc(aCa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Goc(aCa(e,r))),t.stop=LLo,t},BUD=Goc(),aYp=BUD;var MYp=ai(EYp(),1);function Xoc(e){let t=(0,MYp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var PXp=ai(mXp(),1),jXp=ai(Cwi(),1),luc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},fuc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function duc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Xoc(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,PXp.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await aYp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new luc(e):c}if(t.allVersions)return s;let o=new fuc(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=jXp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function dCa(e,t){let{version:r}=await duc(e.toLowerCase(),t);return r}async function bEi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:dCa(e.packageName,{version:t?"prerelease":"latest"})}var wXp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],kLo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=T0.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new xLo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.64.24"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Ds.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new l9}failWithoutThrowing(t,r){this.didSucceed=!1,CLo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await lFn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await WKp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1955
|
+
`,i?gFn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function DUD(e){let r=await new UKp.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 EUD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await HKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=Twi(o.name,c),g=await tkt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await HKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=Twi(s.name,o),b=await tkt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function HKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await RVt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function $Kp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=qae(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function RLo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await EUD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...$Kp(s,d,t.logger));else u.push(...$Kp(l.versions,void 0,t.logger))}return u}var nCa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var Z6n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Loc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)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(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),GKp=typeof globalThis.AbortController=="function",QKp=typeof globalThis.ReadableStream=="function",JKp=typeof globalThis.FormData=="function",NLo=["get","post","put","patch","head","delete"],MUD=()=>{};MUD();var KKp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},FLo=2147483647,YKp=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,LLo=Symbol("stop"),XKp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},ZKp={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 AUD=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=YKp,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.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},kKp=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(n){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:l,value:d}=await a.read();if(l){n.close();return}if(t){i+=d.byteLength;let s=r===0?0:i/r;t({percent:s,transferredBytes:i,totalBytes:r},d)}n.enqueue(d),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},eYp=(e,t)=>{let r=AUD(e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(n){let a=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function u(){let{done:l,value:d}=await a.read();if(l){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),n.close();return}i+=d.byteLength;let s=r===0?0:i/r;(r<i||s===1)&&(s=.99),t&&t({percent:Number(s.toFixed(2)),transferredBytes:i,totalBytes:r},d),n.enqueue(d),await u()}await u()}})})};var k6n=e=>e!==null&&typeof e=="object";var aCa=(...e)=>{for(let t of e)if((!k6n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Woc({},...e)},Uoc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function ULo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Woc(e[r]??[],t[r]??[])}var Voc=(e={},t={})=>({beforeRequest:ULo(e,t,"beforeRequest"),beforeRetry:ULo(e,t,"beforeRetry"),afterResponse:ULo(e,t,"afterResponse"),beforeError:ULo(e,t,"beforeError")}),Woc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(k6n(n)){for(let[a,u]of Object.entries(n))k6n(u)&&a in t&&(u=Woc(t[a],u)),t={...t,[a]:u};k6n(n.hooks)&&(i=Voc(i,n.hooks),t.hooks=i),k6n(n.headers)&&(r=Uoc(r,n.headers),t.headers=r)}return t};var rYp=e=>NLo.includes(e)?e.toUpperCase():e,qUD=["get","put","head","delete","options","trace"],TUD=[408,413,429,500,502,503,504],CUD=[413,429,503],tYp={limit:2,methods:qUD,statusCodes:TUD,afterStatusCodes:CUD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},iYp=(e={})=>{if(typeof e=="number")return{...tYp,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{...tYp,...e}};async function Hoc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Z6n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function $oc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var nYp=(e,t)=>{let r={};for(let i in t)!(i in ZKp)&&!(i in XKp)&&!(i in e)&&(r[i]=t[i]);return r};var oCa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>FLo)throw new RangeError(`The \`timeout\` option cannot be greater than ${FLo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new nCa(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!QKp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return kKp(l.clone(),i._options.onDownloadProgress)}return l},u=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[l,d]of Object.entries(KKp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await u;if(l==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Uoc(this._input.headers,r.headers),hooks:Voc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:rYp(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:iYp(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(GKp){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(Loc&&(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),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(JKp&&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(!Loc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=eYp(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Z6n)throw t;if(t instanceof nCa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=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(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n: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 i=Math.min(this._calculateRetryDelay(r),FLo);if(this._retryCount<1)throw r;await $oc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===LLo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=nYp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Hoc(r,t,this.abortController,this._options)}};var Goc=e=>{let t=(r,i)=>oCa.create(r,aCa(e,i));for(let r of NLo)t[r]=(i,n)=>oCa.create(i,aCa(e,n,{method:r}));return t.create=r=>Goc(aCa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Goc(aCa(e,r))),t.stop=LLo,t},BUD=Goc(),aYp=BUD;var MYp=ai(EYp(),1);function Xoc(e){let t=(0,MYp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var PXp=ai(mXp(),1),jXp=ai(Cwi(),1),luc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},fuc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function duc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Xoc(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,PXp.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await aYp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new luc(e):c}if(t.allVersions)return s;let o=new fuc(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=jXp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function dCa(e,t){let{version:r}=await duc(e.toLowerCase(),t);return r}async function bEi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:dCa(e.packageName,{version:t?"prerelease":"latest"})}var wXp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],kLo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=T0.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new xLo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.64.25"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Ds.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new l9}failWithoutThrowing(t,r){this.didSucceed=!1,CLo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await lFn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await WKp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1956
1956
|
`)||(r+=`
|
|
1957
1957
|
`),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=UBs(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.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 XTa(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 i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new l9}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await lFn()).sendEvent(t)}logger=_Xt((t,...r)=>this.log(t,...r));stderr=_Xt((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=SXp(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?SXp(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=wXp[this.numTasks++%wXp.length],u=Ds.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===MB.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 i=t.filter(n=>Vji.indexOf(n.level)>=Vji.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===T0.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 bEi({cliEnvironment:this.environment,includePreReleases:t}),i=qae(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await RLo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await joc({message:t,default:r})}async getInput(t){return await woc({message:t.message,default:t.default})}};function SXp(e){return`[${e}]:`}var lg_=require("fs/promises");function rFe({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Ds.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Ds.dim(r)),i.join(`
|
|
1958
1958
|
`)}var e__=require("fs/promises");var WWt=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var cMe=class extends WWt{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var pCa=class{context;constructor(t){this.context=t}};var eUo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let d=n!=null?gy.of(`${n}${tVt}${u}`):gy.of(u);t[d]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${tVt}${u}`:u,d=i.directories[u];r(d,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(tVt))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[gy.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var ZGi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new eUo,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return vkt(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))DXp(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(DXp(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??C_((yxe(r)+"/"+VUi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===gy.of(VF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Tgo(yxe(OBn.of(`/${t}`)),OBn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Tgo(yxe(OBn.of(`/${t}`)),OBn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===gy.of(VF))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>v2(l,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=EN(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:EN(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:EN(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===TS?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function DXp(e){return e?.header!=null}var Tae={openapi:e=>({...e,type:"openapi",_visit:function(t){return Tae._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Tae._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var o4n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return o4n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Q9={basic:e=>({...e,type:"basic",_visit:function(t){return Q9._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Q9._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Q9._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Q9._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Q9._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var OO={primitive:e=>({value:e,type:"primitive",_visit:function(t){return OO._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return OO._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return OO._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return OO._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return OO._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return OO._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return OO._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return OO._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var D_={int:e=>({value:e,type:"int",_visit:function(t){return D_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return D_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return D_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return D_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return D_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return D_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return D_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return D_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return D_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return D_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return D_._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var u4n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return u4n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return u4n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var gEi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return gEi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return gEi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var RW={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case RW.GenerallyAvailable:return t.generallyAvailable();case RW.Beta:return t.beta();case RW.Deprecated:return t.deprecated();default:return t._other()}}};var iFe={cursor:e=>({...e,type:"cursor",_visit:function(t){return iFe._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return iFe._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return iFe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var kfi={language:e=>({...e,type:"language",_visit:function(t){return kfi._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return kfi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var NW={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case NW.Curl:return t.curl();case NW.Python:return t.python();case NW.Javascript:return t.javascript();case NW.Typescript:return t.typescript();case NW.Go:return t.go();case NW.Ruby:return t.ruby();case NW.Csharp:return t.csharp();case NW.Java:return t.java();case NW.Js:return t.js();case NW.Node:return t.node();case NW.Ts:return t.ts();case NW.Nodets:return t.nodets();case NW.Golang:return t.golang();case NW.Dotnet:return t.dotnet();case NW.Jvm:return t.jvm();default:return t._other()}}};var HWt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return HWt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return HWt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var $Wt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return $Wt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return $Wt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var FW={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case FW.Get:return t.get();case FW.Post:return t.post();case FW.Put:return t.put();case FW.Patch:return t.patch();case FW.Delete:return t.delete();case FW.Head:return t.head();case FW.Options:return t.options();case FW.Trace:return t.trace();default:return t._other()}}};var OEi={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return OEi._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return OEi._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return OEi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var edi={file:e=>({...e,type:"file",_visit:function(t){return edi._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return edi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var GQ={file:e=>({...e,type:"file",_visit:function(t){return GQ._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return GQ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return GQ._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return GQ._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return GQ._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return GQ._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return GQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Hy={primitive:e=>({...e,type:"primitive",_visit:function(t){return Hy._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Hy._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Hy._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Hy._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Hy._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Hy._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Hy._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Hy._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Hy._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Hy._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Hy._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Xj={int:e=>({...e,type:"int",_visit:function(t){return Xj._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Xj._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Xj._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Xj._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Xj._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Xj._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Xj._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Xj._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Xj._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Xj._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Xj._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var fz={boolean:e=>({value:e,type:"boolean",_visit:function(t){return fz._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return fz._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var tdi={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return tdi._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return tdi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var lMe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return lMe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return lMe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return lMe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var bC={file:e=>({...e,type:"file",_visit:function(t){return bC._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return bC._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return bC._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return bC._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return bC._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return bC._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return bC._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var ql={primitive:e=>({...e,type:"primitive",_visit:function(t){return ql._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ql._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ql._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ql._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ql._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ql._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ql._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ql._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ql._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ql._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ql._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var xZ={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return xZ._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return xZ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var ep={int:e=>({...e,type:"int",_visit:function(t){return ep._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return ep._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return ep._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return ep._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return ep._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return ep._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return ep._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return ep._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return ep._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return ep._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return ep._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var Tv={};Dn(Tv,{AllOfPropertyConflict:()=>q4n,ArraySchema:()=>yVo,ArraySchemaWithExample:()=>HVo,Availability:()=>lUo,Base64WithExample:()=>FVo,BasicSecurityScheme:()=>pUo,BearerSecurityScheme:()=>_Uo,BooleanSchema:()=>lVo,BooleanWithExample:()=>LVo,BytesResponse:()=>m4n,CasingOverrides:()=>vUo,CommonProperty:()=>wVo,CommonPropertyWithExample:()=>kVo,CursorPagination:()=>QUo,CustomCodeSample:()=>$Uo,CustomCodeSampleLanguage:()=>VUo,CustomCodeSampleSdk:()=>HUo,CustomPagination:()=>KUo,DateWithExample:()=>NVo,DatetimeWithExample:()=>RVo,DiscriminatedOneOfSchema:()=>PVo,DiscriminatedOneOfSchemaWithExample:()=>XVo,DoubleSchema:()=>sVo,DoubleWithExample:()=>zVo,Encoding:()=>cUo,Endpoint:()=>YUo,EndpointExample:()=>S4n,EndpointResponseExample:()=>UUo,EndpointSdkName:()=>zrr,EndpointWithExample:()=>rZp,EnumSchema:()=>f4n,EnumSchemaWithExample:()=>VVo,EnumValue:()=>jEi,ErrorExample:()=>xUo,FernExample:()=>NUo,FileResponse:()=>g4n,FileSchema:()=>AUo,FloatWithExample:()=>IVo,FullEndpointExample:()=>GUo,FullExample:()=>Vq,FullObjectExample:()=>wUo,FullOneOfExample:()=>DUo,GlobalHeader:()=>dVo,Header:()=>SEi,HeaderExample:()=>w4n,HeaderSecurityScheme:()=>hUo,HeaderWithExample:()=>MEi,HttpEndpointServer:()=>P4n,HttpError:()=>RUo,HttpErrorWithExample:()=>AVo,HttpMethod:()=>_4n,IdempotencyHeader:()=>pVo,Int64WithExample:()=>TVo,IntSchema:()=>oVo,IntWithExample:()=>qVo,JsonRequest:()=>BUo,JsonRequestWithExample:()=>DVo,JsonResponse:()=>O4n,JsonResponseWithExample:()=>B4n,KeyValuePair:()=>SUo,LiteralExample:()=>jUo,LiteralSchema:()=>A4n,LiteralSchemaValue:()=>_Vo,LongSchema:()=>uVo,MapSchema:()=>vVo,MapSchemaWithExample:()=>$Vo,MultipartRequest:()=>b4n,MultipartRequestProperty:()=>CUo,MultipartRequestPropertyEncoding:()=>TUo,MultipartSchema:()=>qUo,NamedFullExample:()=>Rrr,Namespace:()=>bUo,NamespaceId:()=>PUo,NullableSchema:()=>gVo,NullableSchemaWithExample:()=>QVo,OauthSecurityScheme:()=>OUo,ObjectProperty:()=>mVo,ObjectPropertyConflictInfo:()=>T4n,ObjectPropertyWithExample:()=>YVo,ObjectSchema:()=>hVo,ObjectSchemaWithExample:()=>JVo,OctetStreamRequest:()=>v4n,OffsetPagination:()=>JUo,OneOfSchema:()=>OVo,OneOfSchemaWithExample:()=>KVo,OpenApiIntermediateRepresentation:()=>eZp,OpenApiSource:()=>aUo,OptionalSchema:()=>bVo,OptionalSchemaWithExample:()=>GVo,Pagination:()=>D4n,PathParameter:()=>h4n,PathParameterExample:()=>FUo,PathParameterWithExample:()=>SVo,PrimitiveExample:()=>p4n,PrimitiveSchema:()=>EEi,PrimitiveSchemaValue:()=>fVo,PrimitiveSchemaValueWithExample:()=>UVo,PrimitiveSchemaWithExample:()=>I4n,PropertyKey:()=>d4n,ProtobufEncoding:()=>sUo,ProtobufSource:()=>oUo,QueryParameter:()=>y4n,QueryParameterExample:()=>j4n,QueryParameterWithExample:()=>C4n,QuerySecurityScheme:()=>yUo,ReferencedSchema:()=>xrr,Request:()=>IUo,RequestWithExample:()=>EVo,Response:()=>zUo,ResponseWithExample:()=>MVo,Schema:()=>wm,SchemaId:()=>RZ,SchemaWithExample:()=>lA,Schemas:()=>aVo,SdkGroup:()=>gUo,SdkGroupInfo:()=>EUo,SdkGroupName:()=>wEi,SecurityScheme:()=>mUo,SecuritySchemeId:()=>dUo,Server:()=>vCa,Source:()=>uUo,StatusCode:()=>Irr,StreamingResponseExample:()=>LUo,StringSchema:()=>cVo,StringSchemaWithExample:()=>xVo,SupportedSdkLanguage:()=>WUo,Tag:()=>fUo,TagId:()=>NZ,Tags:()=>MUo,TextResponse:()=>DEi,Uint64WithExample:()=>BVo,UintWithExample:()=>CVo,UnDiscriminatedOneOfSchema:()=>jVo,UnDiscriminatedOneOfSchemaWithExample:()=>ZVo,UnknownSchemaWithExample:()=>WVo,Webhook:()=>XUo,WebhookExampleCall:()=>M4n,WebhookHttpMethod:()=>E4n,WebhookWithExample:()=>iZp,WebsocketChannel:()=>nVo,WebsocketHandshake:()=>ZUo,WebsocketHandshakeWithExample:()=>tZp,WebsocketMessageExample:()=>rVo,WebsocketMessageOrigin:()=>kUo,WebsocketMessageSchema:()=>eVo,WebsocketServer:()=>tVo,WebsocketSessionExample:()=>iVo,WithAvailability:()=>Th,WithDescription:()=>gf,WithEncoding:()=>Cae,WithInline:()=>WE,WithName:()=>z0,WithNamespace:()=>i0,WithSdkGroupName:()=>sm,WithSource:()=>Xh,WithStatusCode:()=>nFe,WithTitle:()=>um,commons:()=>vuc,example:()=>buc,finalIr:()=>guc,parseIr:()=>Ouc});var vuc={};Dn(vuc,{BasicSecurityScheme:()=>pUo,BearerSecurityScheme:()=>_Uo,Encoding:()=>cUo,HeaderSecurityScheme:()=>hUo,Namespace:()=>bUo,NamespaceId:()=>PUo,OauthSecurityScheme:()=>OUo,OpenApiSource:()=>aUo,ProtobufEncoding:()=>sUo,ProtobufSource:()=>oUo,QuerySecurityScheme:()=>yUo,SchemaId:()=>RZ,SdkGroup:()=>gUo,SdkGroupName:()=>wEi,SecurityScheme:()=>mUo,SecuritySchemeId:()=>dUo,Server:()=>vCa,Source:()=>uUo,StatusCode:()=>Irr,Tag:()=>fUo,TagId:()=>NZ,WithAvailability:()=>Th,WithDescription:()=>gf,WithEncoding:()=>Cae,WithInline:()=>WE,WithName:()=>z0,WithNamespace:()=>i0,WithSdkGroupName:()=>sm,WithSource:()=>Xh,WithStatusCode:()=>nFe,WithTitle:()=>um});var Mt={};Dn(Mt,{JsonError:()=>s4n,ParseError:()=>c4n,any:()=>UXp,bigint:()=>MXp,boolean:()=>VXp,booleanLiteral:()=>LXp,date:()=>AXp,discriminant:()=>XXp,enum_:()=>rUo,getObjectLikeUtils:()=>GWt,getObjectUtils:()=>kGi,getSchemaUtils:()=>Uq,isProperty:()=>PEi,lazy:()=>qXp,lazyObject:()=>RXp,list:()=>nUo,number:()=>WXp,object:()=>iUo,objectWithoutOptionalProperties:()=>xXp,optional:()=>puc,property:()=>CXp,record:()=>QXp,set:()=>JXp,string:()=>HXp,stringLiteral:()=>FXp,transform:()=>_uc,undiscriminatedUnion:()=>YXp,union:()=>kXp,unknown:()=>$Xp,withParsedProperties:()=>yuc});var Mj={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function cA(e,t){return`Expected ${t}. Received ${FVD(e)}.`}function FVD(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function J9(e){return{...e,json:EXp(e.json),parse:EXp(e.parse)}}function EXp(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|